Skip to content

Instantly share code, notes, and snippets.

View splittingred's full-sized avatar
💭
🚀

Shaun McCormick splittingred

💭
🚀
View GitHub Profile
@splittingred
splittingred / gist:1018976
Created June 10, 2011 14:47
base Resource manager controller class
<?php
abstract class ResourceManagerController extends modManagerController {
public static function getInstance(modX &$modx,$className,array $config = array()) {
if (!empty($_REQUEST['class_key'])) {
$resourceClass = str_replace(array('../','..','/','\\'),'',$_REQUEST['class_key']);
$delegateView = $modx->call($resourceClass,'getControllerPath',array(&$modx));
$action = strtolower(str_replace(array('Resource','ManagerController'),'',$className));
$className = str_replace('mod','',$resourceClass).ucfirst($action).'ManagerController';
$controllerFile = $delegateView.$action.'.class.php';
@splittingred
splittingred / home.class.php
Created June 13, 2011 15:30
Revo 2.2 New Manager Controllers Interface
<?php
/* this goes in core/components/batcher/controllers/home.class.php - note the class name: "Home" matches the file name */
class BatcherHomeManagerController extends BatcherManagerController {
/* Do any controller logic here. Can also return an array of placeholders to set, or use $this->setPlaceholder($k,$v); */
public function process(array $scriptProperties = array()) {
}
/* set the page title */
<?php
abstract class BatcherManagerController extends modManagerController {
public function initialize() {
$this->batcher = new Batcher($this->modx);
$this->addCss($this->batcher->config['cssUrl'].'mgr.css');
$this->addJavascript($this->batcher->config['jsUrl'].'batcher.js');
$this->addHtml('<script type="text/javascript">
Ext.onReady(function() {
Batcher.config = '.$this->modx->toJSON($this->batcher->config).';
@splittingred
splittingred / modresource.class.php
Created July 13, 2011 20:32
modResource docblock
/**
* Represents a web resource managed by the MODX framework.
*
* @property int $id The ID of the Resource
* @property string $type The type of the resource; document/reference
* @property string $contentType The content type string of the Resource, such as text/html
* @property string $pagetitle The page title of the Resource
* @property string $longtitle The long title of the Resource
* @property string $description The description of the Resource
* @property string $alias The FURL alias of the resource
@splittingred
splittingred / modusergrouprole.class.php
Created July 14, 2011 14:02
modUserGroupRole docblock
<?php
/**
* @package modx
*/
/**
* Represents a Role that a User can have within a specific User Group. Roles are sorted into authority levels, where
* lower authority numbers will automatically inherit Permissions owned by higher authority numbers.
*
* For example, an Administrator with authority of 1 will automatically inherit any Permissions assigned to a Member
* role with authority 9999, since 1 is less than 9999. However, the reverse will not be true.
@splittingred
splittingred / snippet.formit.after.php
Created July 18, 2011 13:41
Before/After FormIt refactoring
<?php
require_once $modx->getOption('formit.core_path',null,$modx->getOption('core_path',null,MODX_CORE_PATH).'components/formit/').'model/formit/formit.class.php';
$fi = new FormIt($modx,$scriptProperties);
$fi->initialize($modx->context->get('key'));
$fi->loadRequest();
$fields = $fi->request->prepare();
return $fi->request->handle($fields);
@splittingred
splittingred / gist:1090454
Created July 18, 2011 19:45
File-based Hooks coming in FormIt 2.0
[[!FormIt?
&submitVar=`submit`
&preHooks=`[[++assets_path]]hooks/myhook.php`
&validate=`name:required`
]]
<form action="[[~[[*id]]]]" method="post">
<label>Name: [[!+fi.error.name]]
<input type="text" name="name" value="[[!+fi.name]]" />
<?php
/**
* MODX Revolution
*
* Copyright 2006-2011 by MODX, LLC.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
@splittingred
splittingred / snippet.include.php
Created August 3, 2011 21:20
include snippet for MODX Revolution
if (empty($file)) return '';
$o = '';
$modx->parser->processElementTags('',$file,true,true);
$file = str_replace(array(
'{core_path}',
'{base_path}',
'{assets_path}',
),array(
$modx->getOption('core_path'),
PHP Catchable fatal error: Argument 1 passed to DocBlox_Transformer_Behaviour_Inherit_Node_Abstract::copyShortDescription() must be an instance of DOMElement, boolean given, called in /www/docblox/src/DocBlox/Transformer/Behaviour/Inherit/Node/Abstract.php on line 259 and defined in /www/docblox/src/DocBlox/Transformer/Behaviour/Inherit/Node/Abstract.php on line 122
PHP Stack trace:
PHP 1. {main}() /www/docblox/bin/docblox.php:0
PHP 2. DocBlox_Core_Application->main() /www/docblox/bin/docblox.php:40
PHP 3. DocBlox_Task_Project_Run->execute() /www/docblox/src/DocBlox/Core/Application.php:47
PHP 4. DocBlox_Task_Project_Transform->execute() /www/docblox/src/DocBlox/Task/Project/Run.php:133
PHP 5. DocBlox_Transformer->execute() /www/docblox/src/DocBlox/Task/Project/Transform.php:173
PHP 6. DocBlox_Transformer_Behaviour_Collection->process() /www/docblox/src/DocBlox/Transformer.php:379
PHP 7. DocBlox_Transformer_Behaviour_Inherit->process() /www/docblox/src/DocBlox/Transformer/Behaviour/Collection.p