Skip to content

Instantly share code, notes, and snippets.

View splittingred's full-sized avatar
💭
🚀

Shaun McCormick splittingred

💭
🚀
View GitHub Profile
@splittingred
splittingred / gist:1435521
Created December 5, 2011 21:46
MODX 2.2 line count report, 12/5/2011
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
PHP 2218 24654 71713 180956
Javascript 223 3906 5440 49419
CSS 99 5030 1072 24588
XML 16 469 303 2903
Java 1 47 62 182
SQL 4 20 37 120
Smarty 3 5 0 58
@splittingred
splittingred / update.class.php
Created November 2, 2011 18:53
The nice and short Category update processor in MODX 2.2
<?php
class modElementCategoryUpdateProcessor extends modObjectUpdateProcessor {
public $classKey = 'modCategory';
public $languageTopics = array('category');
public $permission = 'save_category';
public $objectType = 'category';
}
return 'modElementCategoryUpdateProcessor';
<?php
require_once (dirname(dirname(__FILE__)).'/create.class.php');
/**
* Create a snippet.
*
* @param string $name The name of the element
* @param string $snippet The code of the snippet.
* @param string $description (optional) A brief description.
* @param integer $category (optional) The category to assign to. Defaults to no
* category.
@splittingred
splittingred / create.class.php
Created November 1, 2011 21:26
2.2 Chunk Create Processor
<?php
require_once (dirname(dirname(__FILE__)).'/create.class.php');
/**
* Creates a chunk.
*
* @param string $name The name of the chunk.
* @param string $description (optional) The description of the chunk.
* @param integer $category The category the chunk is assigned to.
* @param string $snippet The code of the chunk.
* @param boolean $locked Whether or not the chunk can only be accessed by
@splittingred
splittingred / updatefromgrid.class.php
Created September 29, 2011 15:40
Example of a derivative processor extending functionality
<?php
require_once (dirname(__FILE__) . '/update.class.php');
/**
* Update a setting from a grid
*
* @param string $key The key of the setting
* @param string $oldkey The old key of the setting
* @param string $value The value of the setting
* @param string $area The area for the setting
@splittingred
splittingred / getlist.php
Created September 28, 2011 22:07
Driver-specific processor in MODX 2.2. This is the databasetables/getlist processor.
<?php
/**
* Gets a list of database tables
*
* @package modx
* @subpackage processors.system.databasetable
*/
class modDatabaseTableGetListProcessor extends modDriverSpecificProcessor {
public function checkPermissions() {
return $this->modx->hasPermission('database');
@splittingred
splittingred / create.class.php (new)
Created September 28, 2011 20:59
Old vs New MODX Processors (as of 2.2)
<?php
class modActionCreateProcessor extends modProcessor {
/** @var modAction $action */
public $action;
public function checkPermissions() {
return $this->modx->hasPermission('actions');
}
public function getLanguageTopics() {
return array('action','menu','namespace');
@splittingred
splittingred / snippet.getpagetitle.php
Created September 26, 2011 18:57
Gets a pagetitle of a specified resource
<?php
$id = $modx->getOption('id',$scriptProperties,$modx->resource->get('id'));
$pageTitle = '';
$resource = $modx->getObject('modResource',$id);
if ($resource) {
$pageTitle = $resource->get('pagetitle');
}
return $pageTitle;
@splittingred
splittingred / install.sh
Created September 22, 2011 21:35
Bash script to install a new MODX Revolution 2.2+ install via CLI
Examples of above script:
# into a standard directory, where config.xml resides in the current working directory
sh install.sh /home/modx/public_html/
# with a custom config.xml file
sh install.sh /home/modx/public_html/ /opt/local/modx/config.xml
@splittingred
splittingred / activeuser.chunk.tpl
Created September 22, 2011 13:26
A MODX Snippet to show active, logged in users
<li>[[+username]]</li>