Skip to content

Instantly share code, notes, and snippets.

View chucktrukk's full-sized avatar

Charlie Madison chucktrukk

View GitHub Profile
@chucktrukk
chucktrukk / revosnippet.class.php
Created September 26, 2011 20:00
Revo Snippet
<?php
if( !defined('VENDOR_PATH')) {
define('VENDOR_PATH', MODX_BASE_PATH.'/vendors');
}
class RevoSnippet
{
public function __construct()
{
var toggleFullScreen = false;
jQuery(document).ready(function($) {
$('#toggleButton').click(function() {
toggleFullScreen = true;
flowplayer.pause();
toggleFullScreen = false;
Array
(
[0] => __construct
[1] => listGroups
[2] => getTemplateVarCollection
[3] => refreshURIs
[4] => process
[5] => getContent
[6] => setContent
[7] => getCacheKey
<?php
function variable_name( &$var, $scope=false, $prefix='UNIQUE', $suffix='VARIABLE' ){
if($scope) {
$vals = $scope;
} else {
$vals = $GLOBALS;
}
$old = $var;
$var = $new = $prefix.rand().$suffix;
@chucktrukk
chucktrukk / gist:1100267
Created July 22, 2011 19:48
revo updates

Allow multiple templates to have the same name

  1. Remove index on template name via: ALTER TABLE modx3_site_templates DROP INDEX templatename
  2. comment out 25-30 in /core/model/modx/processors/element/template/create.php
  3. comment out 40-46 in /core/model/modx/processors/element/template/update.php
<?php
class Template
{
public $context = array();
private $template;
public function __construct($template)
$('label').autoWidth({limitWidth: 350});
jQuery.fn.autoWidth = function(options)
{
var settings = {
limitWidth : false
}
if(options) {
jQuery.extend(settings, options);
@chucktrukk
chucktrukk / find_script_folder.js
Created June 23, 2011 19:35
find the URL for this script's absolute path and set as the resourceFolderName.
var resourcesFolderName = "my/folder/here";
var documentName = "name-of-doc";
var documentLoaderFilename = "this-script-name.js";
// find the URL for this script's absolute path and set as the resourceFolderName
try {
var scripts = document.getElementsByTagName('script');
for(var i = 0; i < scripts.length; i++) {
var scriptSrc = scripts[i].src;
if(scriptSrc != null && scriptSrc.indexOf(documentLoaderFilename) != -1) {
<?php
function trim_text($input, $length, $ellipses = true, $strip_html = true, $output_entities = true){
// Strip tags, if desired
if($strip_html) {
$input = strip_tags($input);
}
// No need to trim, already shorter than trim length
if(strlen($input) <= $length) {
<?php
function detect_mobile()
{
$_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : '';
$mobile_browser = '0';
if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', strtolower($_SERVER['HTTP_USER_AGENT'])))
$mobile_browser++;