Skip to content

Instantly share code, notes, and snippets.

View andronex's full-sized avatar

Andrey andronex

View GitHub Profile
@andronex
andronex / introRTE
Created October 1, 2016 21:54 — forked from christianseel/introRTE
RTE for introtext #modx
<?php
// Add RTE for introtext if richtext option is enabled for the resource
// check "OnDocFormRender" event
$modx->regClientStartupHTMLBlock('<script>Ext.onReady(function() {
if(MODx.loadRTE) MODx.loadRTE("modx-resource-introtext");
});</script>');
@andronex
andronex / cloneResource.php
Created January 8, 2019 20:58 — forked from sepiariver/cloneResource.php
A Snippet to clone a Resource into multiple, user-defined parent containers in arbitrary contexts
<?php
// get user-defined source document and target parents
$source = intval($modx->getOption('sourceId', $scriptProperties, ''));
$targets = array_map('trim', explode(',', $modx->getOption('targetIds', $scriptProperties, '')));
// to prevent accidents...
$_allowedUsers = explode(',', 'username1,username2');
// check stuff, and if passed then get the source document object
if ( !in_array($modx->user->get('username'), $_allowedUsers) || empty($source) || $source == 0 || !is_array($targets) || empty($targets) ) return;
$sourceDoc = $modx->getObject('modResource', $source);
@andronex
andronex / checkApiKey.php
Created March 6, 2019 16:31 — forked from webnitros/checkApiKey.php
Проверка сайта на доступ для приложения
<?php
/**
* Created by Andrey Stepanenko.
* User: webnitros
* Date: 24.01.2019
* Time: 1:00
*/
ini_set('display_errors', 1);
ini_set("max_execution_time", 50);
define('MODX_API_MODE', true);
@andronex
andronex / autoTemplate.php
Created October 20, 2019 21:30 — forked from Realetive/autoTemplate.php
Plugin for setup template by parent resource
<?php
if ( $modx->event->name == 'OnDocFormRender' && $mode == modSystemEvent::MODE_NEW ) {
$template = $modx->runSnippet( 'pdoField', array(
"id" => $_REQUEST['parent']
, "field" => "template"
, "top" => 0
) );
switch ( $template ) {
case 1:
$template = 2;
@andronex
andronex / ean_check.php
Created June 28, 2020 16:29 — forked from DaveChild/ean_check.php
PHP Function to Validate EANs
<?php
/*
0346745008178
Should fail - checksum should be 9
5060096384137
Should pass
5020650002112
@andronex
andronex / createdBy.plugin.php
Created February 1, 2022 23:35 — forked from matdave/createdBy.plugin.php
MODX change author plugin
<?php
/**
* Plugin to add a "created by" field on a resource form and moves "published on" to document tab
*
* @var modX $modx
* @var array $scriptProperties
*
* @event OnDocFormPrerender
*/
$dateFormat = $modx->getOption('manager_date_format',null,'d.m.Y');
@andronex
andronex / parse-resource.php
Created October 14, 2024 17:10 — forked from joeke/parse-resource.php
MODX Revo: Parse full contents of resource
<?php
/**
* Get full parsed HTML from resource
* (you already need to have the resource object available in $this->resource)
*
* @access public
* @return string $html The parsed html of the resource
*/
public function parseResource() {