Skip to content

Instantly share code, notes, and snippets.

@alanpich
alanpich / slim1.php
Created November 2, 2012 17:15
SlimPHP optional path params
/*@var $controllers Array of String */
/**
* Set up Slim listeners for each controller
*/
foreach($controllers as $C){
// Map GET
$slim->get("/$C/:id/:relation",function($id,$relation){
print_r(array(
@alanpich
alanpich / slimcontrollers.php
Created November 2, 2012 17:30
filesystem controller w/ Slim
<?php
header('Content-Type: text/plain');
define('ROOT',dirname(dirname(__FILE__)).'/');
define('CONTROLLER_PATH',ROOT.'controllers/');
/**
* Initialize some Slim action
*/
require ROOT.'lib/Slim/Slim/Slim.php';
@alanpich
alanpich / modMigrate.php
Created November 28, 2012 10:11
modMigrate ideas
<?php
abstract class modMigrateObject {
/* @var object Object Properties */
private $data;
/* @var string MODx Class Name */
private $classKey;
@alanpich
alanpich / pmsPackageInterface.php
Created November 28, 2012 20:41
pmsPackage Interface
<?php
/**
* Interface definition for pms packages
*
* @package pms
* @author Alan Pich <alan@alanpich.com>
* @copyright (c) 2013, Alan Pich
* @date 28-Nov-2012
*/
<?php
namespace OS\ConMan;
use \Slim\Extras\Views\Twig;
class ConMan {
protected $slim;
protected $view;
@alanpich
alanpich / ModxWrapper.php
Created March 4, 2013 14:06
Wrapper class for loading a MODx instance from a specific path on disk and interacting with it
<?php
namespace AlanPich\Tools;
class ModxWrapper
{
/** @var \modX */
protected $modx;
/** @var string */
@alanpich
alanpich / jquery.temporaryCss.js
Created March 7, 2013 20:17
jQuery plugin to that allows styles to be set temporarily to an element, and will revert to their previous state after an allotted time or when a specified event is triggered on the element
/**
* jQuery plugin that allows styles to be set temporarily
* to an element, and will revert to their previous state
* after an allotted time or when a specified event is triggered
*
* @author Alan Pich <alan.pich@gmail.com>
*
* @param {Object} styles
* @param {String|Number} timeOrEvent
*/
@alanpich
alanpich / Usage.modx.html
Last active December 15, 2015 04:39
Include a MODX static resource as a script tag in a document
<html>
<head>
...
[[~123:javascript]]
[[~321:stylesheet]]
</head>
</html>
@alanpich
alanpich / getchildlist.class.php
Last active December 18, 2015 00:49
Amending ModxCampaignMonitor extra to allow MCM.combo.resource to only show resources that are direct children on a parent resource
<?php
/** core/components/mcm/processors/mgr/resource/getchildlist.class.php */
/**
* Create this file to allow filtering of resources by a parent ID
*
* @param int $parentId
* @return array Array of modResource child elements
*
*/
if(!class_exists('modObjectGetListProcessor')){
@alanpich
alanpich / modx.package-install.php
Last active December 1, 2016 15:48
Rough outline of installing transport packages via the CLI
<?php
$path_to_modx = '/var/www/modx';
define('MODX_API_MODE',true);
require $path_to_modx."/index.php";
/** @var \modX $modx */
// Download Details
/** @var string $package_url - URL from the orange 'Download' button on the MODx Extras website */
$package_url = 'http://modx.com/extras/download/?id=512403a2f245547611000025'
$package_signature = 'getresources-1.6.0-pl'