Skip to content

Instantly share code, notes, and snippets.

View hansek's full-sized avatar

Jan Tezner hansek

  • Prague, Czech Republic
View GitHub Profile
@hansek
hansek / modx_cache_disabler.sql
Created September 17, 2014 12:49
SQL to disable caching in MODX Revolution for Development purpose
-- disable all cache options
UPDATE `modx_system_settings` SET value = 0
WHERE `area` = 'caching' AND `xtype` = 'combo-boolean';
-- reactivate cache_disabled :)
UPDATE `modx_system_settings` SET value = 1
WHERE `key` = 'cache_disabled';
-- disable compress JS and CSS
UPDATE `modx_system_settings` SET value = 0
@hansek
hansek / rsync.sh
Created September 25, 2014 09:26
Script to easily manage Rsync settings to sync project media
#!/bin/bash
# check if config file exists
if [ ! -f $(dirname "$0")/rsync_config.sh ]; then
echo -e "\e[41mERROR:\e[0m Config file not found!"
exit 1
fi
# include config file
source $(dirname "$0")/rsync_config.sh
@hansek
hansek / atLeastOneOf
Last active August 29, 2015 14:22
atLeastOneOf - MODX FormIt Hook : at least one of validated field have to be correct
<?php
/**
* atLeastOneOf
*
* Custom MODX FormIt hook to check if at least one of defined field is correctly filled
*
* !!! To proper work have to be set on last validate field (phone in example)
*
* Usage example:
* &customValidators=`atLeastOneOf`
@hansek
hansek / gist:2228776
Created March 28, 2012 18:00
MODX Revolution Snippet for bulk assignment of all Resources into defined Resource Group
<?php
$docArray = $modx->getCollection('modResource');
foreach($docArray as $doc) {
$doc->joinGroup('GroupName');
}
@hansek
hansek / gist:3951452
Created October 25, 2012 08:37
Basic call of jQuery Cycle for Adapt
// banner slideshow
if ($('#js-banner-wrapper').children().length > 1) {
$('#js-banner-wrapper').cycle({
fx: 'fade',
activePagerClass: 'active',
timeout: 0,
next: '#js-banner-next',
prev: '#js-banner-prev',
width: '100%',
@hansek
hansek / rbak.php
Created November 2, 2012 09:41
MODX Revolution Backup script
<?php
/**
* MODX Revolution Backup script
*
* Useful for fast moving MODX Revolution from FTP (w/o SSH access) to local computer
*/
$starttime = microtime(true);
// ini_set('max_execution_time', 300);
@hansek
hansek / gist:4268455
Created December 12, 2012 15:03
jQuery UI confirm dialog for link, reflects target="_blank"
THIRD_PARTY_LINK_TITLE = 'Dialog title';
THIRD_PARTY_LINK_TEXT = 'Dialog text ...';
// JS 3rd party link confirm dialog
$('.3rd-party-link').on('click', function() {
var anchor = this;
$('<div></div>')
.appendTo('body')
@hansek
hansek / MODX Combo browser - media source of selected file
Created February 6, 2013 09:52
Definition of browser field in my panel.js, but it returns only one argument (data about selected image), but there is no info in which Media Source was file selected.
{
name: 'annex',
fieldLabel: _('workshops.annex'),
xtype: 'modx-combo-browser',
id: this.ident +'-annex',
maxLength: 250,
hideFiles: true,
listeners: {
'select': {
fn: function(data) {
@hansek
hansek / workshops.mysql.schema.xml
Created February 8, 2013 13:30
XML schema of xPDO model for Workshops CMP
<?xml version="1.0" encoding="UTF-8"?>
<model package="workshops" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="Workshop" table="workshop" extends="xPDOSimpleObject">
<field key="title" dbtype="varchar" precision="250" phptype="string" null="false" />
<field key="date" dbtype="int" precision="20" phptype="integer" null="false" default="0" />
<field key="time_start" dbtype="time" phptype="string" null="true" />
<field key="time_end" dbtype="time" phptype="string" null="true" />
<field key="capacity" dbtype="int" precision="11" phptype="integer" null="false" />
<field key="description" dbtype="text" phptype="string" null="false" />
<field key="status" dbtype="int" precision="11" phptype="integer" null="false" />
@hansek
hansek / workshops.structure.sql
Created February 8, 2013 13:40
Structure of MySQL tables for Workshops CMP
CREATE TABLE IF NOT EXISTS `cx_workshop` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(250) NOT NULL,
`date` int(20) NOT NULL DEFAULT '0',
`time_start` time DEFAULT NULL,
`time_end` time DEFAULT NULL,
`capacity` int(11) NOT NULL,
`description` text NOT NULL,
`status` int(11) NOT NULL,
`annex` varchar(250) NOT NULL,