Skip to content

Instantly share code, notes, and snippets.

View avoronkin's full-sized avatar

Alexandr Voronkin avoronkin

  • Saint-Petersburg
View GitHub Profile
@avoronkin
avoronkin / clientarea
Created January 20, 2011 17:01
autoClientArea
<?php
$adminId = 1;
$polisyID = 4;
$authorityLevel = 9999;
$extendedField = 'redirect';
//resorce setings
$template = 1;
$parent = 2;
$published = 1;
<?php
$parent = 156; //parent to put the new pages under
$published = 1; //published? 0 or 1
$hidemenu = 0; //hidemenu? 0 or 1
$template = 11; // template that you like to use for page
$newsdateId = 7; //newsdate tv id
$rssfeed = 'http://www.BLABLABLA.co.uk/index.php?id=68'; //put your feed here
$doc = new DOMDocument();
$doc->load($rssfeed);
@avoronkin
avoronkin / specificTV.php
Created February 15, 2011 16:53
return all resources with a specific TV value
<?php
$c = $modx->newQuery('modResource');
$c->innerJoin('modTemplateVarResource','TemplateVarResources');
$c->innerJoin('modTemplateVar','TemplateVar','TemplateVarResources.tmplvarid = TemplateVar.id');
$c->where(array(
'TemplateVar.name' => 'access_front',
'TemplateVarResources.value' => true,
));
$ress = $modx->getCollection('modResource',$c);
@avoronkin
avoronkin / rssGrabber.snippet.php
Created February 17, 2011 09:32
Grab RSS to resources
<?php
if ($debug) {
$modx->setLogLevel(modx::LOG_LEVEL_DEBUG);
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
}
@avoronkin
avoronkin / FormIt2AddUser.php
Created February 17, 2011 09:57
FormIt custom hook
<?php
$debug = $modx->getOption('debug', $scriptProperties, false);
if ($debug) {
$modx->setLogLevel(modX::LOG_LEVEL_DEBUG);
}
//new user object
$user = $modx->newObject('modUser');
//get all form fields
$formFields = $hook->getValues();
@avoronkin
avoronkin / MultipleTV.php
Created March 22, 2011 09:30
Multiple TV searching via xPDO
<?php
//http://modxcms.com/forums/index.php?topic=58644.msg354702#msg354702
$query->where(array(
array(
'id:IN' => $children_of_this_folder,
'published' => true,
'deleted' => false,
'hidemenu' => false,
'isfolder' => false,
@avoronkin
avoronkin / phpthumbof.php
Created April 6, 2011 13:10
Multiple fltr not working.
<php?
//phpthumbof 1.1.0
//Multiple fltr not working. Works only the last filter
//[[*photo:phpthumbof=`&fltr=gray&fltr=flip|y&w=100&h=100&zc=1`]]
//I changed snippet code from this
if (!empty($opt[0])) {
$ptOptions[$opt[0]] = $opt[1];
}
@avoronkin
avoronkin / simple_tags
Created May 26, 2011 09:21
MODX Evolution simple tag list
<?php
//$landingID = 35;
$tb1 = $modx->getFullTableName("site_tmplvar_contentvalues");
$query = "SELECT value";
$query .= " FROM ".$tb1;
$query .= " WHERE tmplvarid=".$tvID;
$query .= " GROUP BY value";
$query .= " ORDER BY id DESC";
$query .= " LIMIT 50;";
@avoronkin
avoronkin / xml_import_trans
Created May 26, 2011 09:48
MODX Evolution xml import+transliteration
<?php
$parent = isset($parent) ? $parent : 0;//родительская папка
$published = isset($published) ? $published : 0;//публиковать?
$hidemenu = isset($hidemenu) ? $hidemenu : 0;//показывать в меню?
$template = isset($template) ? $template : 0;//ид нужного шаблона
//настройки транслитерации
if (!isset ($plugin_dir) ) { $plugin_dir = 'transalias'; }
if (!isset ($plugin_path) ) { $plugin_path = $modx->config['base_path'].'assets/plugins/'.$plugin_dir; }
if (!isset ($table_name)) { $table_name = 'russian'; }
@avoronkin
avoronkin / gist:9637027
Created March 19, 2014 07:30
tail recursion with throw ...
function factorial(n) {
function recur(n, result) {
if (n == 0) {
throw result;
} else {
recur(n-1, result*n);
}
}
try {
recur(n, n);