Skip to content

Instantly share code, notes, and snippets.

View netProphET's full-sized avatar

Mike Schell netProphET

  • MODX, LLC
  • Bancroft, Ontario, Canada
View GitHub Profile
@netProphET
netProphET / context_directory_binding.php
Created May 16, 2011 17:17
emulate @Directory binding, but from base_path of Resource's context #MODX
<?php
/**
* emulate @DIRECTORY binding, from base_path of Resource's context
*
* usage:
* a) create context settings named 'base_path' for each context (not neccessary for web context)
* (note: you may also want assets_path and/or other settings in your contexts as well)
* b) call with @EVAL in TV's Input Options field, e.g.
* @EVAL $dir='assets/images/'; return(include '/path/to/this/file/context_directory_binding.php');
*/
@netProphET
netProphET / subdomain-context.php
Created December 13, 2010 14:43
MODx Revolution plugin bound to OnHandleRequest event
<?php
/**
* plugin to map subdomain requests to contexts
* @setting event OnHandleRequest
* @todo currently, subdomains and context names are bound together.. remove this constraint through some mapping/lookup
* @todo currently, assumes first name in host (name before first dot) is what maps to the context
*/
$context = 'web';
@netProphET
netProphET / mgrChunk.php
Created November 26, 2010 18:01
mgrChunk snippet idea
<?php
$return = '';
if(isset ($_SESSION['mgrValidated'])){
$return = $modx->getChunk($chunk);
}
return $return;
?>
regexp = /(\[\[[^\]]*)&amp;([^\[]*\]\])/g;
tests = [
"",
"no modx tags",
"[[something?&amp;foo=`bar`]]",
"[[something? &amp;foo=`[[$bar &amp;baz=`fuz`]]`]]",
"[[something? &amp;replace=`yes`]] &amp; don't replace",
"[[something? &amp;replace=`yes`]] &amp; don't replace [[something? &amp;replace=`yes`]]",
"[[line1? &amp;foo=`bar`]] &amp; don't replace\n[[line2? &amp;bar=`baz`]]"
];
<?php
require_once dirname(dirname(__FILE__)) . '/inc/sys.inc';
require_once XPDO_PATH . '/xpdo.class.php';
session_start();
$xpdo= new xPDO(XPDO_DSN,XPDO_DBUSER,XPDO_DBPW, array(
xPDO::OPT_CACHE_DB=> true,
xPDO::OPT_CACHE_DB_COLLECTIONS=> true,
xPDO::OPT_CACHE_PATH=> CACHE_PATH,
<?php
class xPDOSimpleTemplatingObject extends xPDOSimpleObject {
function __construct(& $xpdo) {
parent :: __construct($xpdo);
}
/**
* Load a collection of xPDOObject instances.
*
* @static
* @param xPDO &$xpdo A valid xPDO instance.