Skip to content

Instantly share code, notes, and snippets.

View splittingred's full-sized avatar
💭
🚀

Shaun McCormick splittingred

💭
🚀
View GitHub Profile
<?php
/**
* @var modX $modx
* @var modTemplateVar $this
* @var array $params
*
* @package modx
* @subpackage processors.element.tv.renders.mgr.input
*/
$modx->lexicon->load('tv_widget');
@splittingred
splittingred / prehook.profile.php
Created August 26, 2011 17:48
PreHook for FormIt to load User data into form
<?php
if (!$modx->user->hasSessionContext($modx->context->get('key')) return '';
$userArray = $modx->user->toArray();
$profile = $modx->user->getOne('Profile');
if ($profile) {
$userArray = array_merge($profile->toArray(),$userArray);
$extended = $profile->get('extended');
if (!empty($extended) && is_array($extended)) {
@splittingred
splittingred / gist:1151579
Created August 17, 2011 14:00
Example resolver
<?php
if ($object->xpdo) {
$modx =& $object->xpdo;
switch ($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_INSTALL:
break;
case xPDOTransport::ACTION_UPGRADE:
break;
case xPDOTransport::ACTION_UNINSTALL:
break;
@splittingred
splittingred / gist:1129536
Created August 6, 2011 17:20
merging arrays to send to modx->getChunk
<?php
$properties = array_merge($customObj->toArray(),$profile->toArray(),$user->toArray());
$output = $modx->getChunk('MyChunk',$properties);
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
@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
/**
* 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 / 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]]" />
@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 / 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.