Skip to content

Instantly share code, notes, and snippets.

View Fi1osof's full-sized avatar

Nikolay Lanets Fi1osof

View GitHub Profile
<?php
$modx->setLogTarget('HTML');
print '<pre>';
$topic = $modx->modblog->getTopic(289);
$blogs = $modx->modblog->getBlogs(); // Получаем все блоги
$blogtopics = array();
foreach($blogs as $blog){
// Создаем объект Топик-Блог (еще не сохраняем)
<?
$rt = false; /* $rt will be an array if the event fires */
if ($mgrEvents) {
$rt = $modx->invokeEvent("OnBeforeManagerLogin", $onBeforeLoginParams);
} else {
$rt = $modx->invokeEvent("OnBeforeWebLogin", $onBeforeLoginParams);
}
/* If the event fired, loop through the event array and fail if there's an error message */
if (is_array($rt)) {
foreach ($rt as $key => $value) { /* php4 compatible */
@Fi1osof
Fi1osof / gist:4583503
Created January 21, 2013 03:58
Свич процессоров в процессоре
<?php
class YleyCompaniesUsersGetListProcessor extends modProcessor{
public static function getInstance(modX &$modx,$className,$properties = array()) {
switch($properties['type']){
case 'company__':
$className = require_once dirname(__FILE__).'/users/getlist.class.php';
break;
@Fi1osof
Fi1osof / gist:4986826
Last active December 13, 2015 22:49
MODX Revolution. Плагин, позволяющий определять, какие дочерние документы показывать или нет. Просто создайте плагин на событие OnManagerPageInit и пропишите в нем свои правила resourcesRules
<?php
switch($modx->event->name){
case 'OnManagerPageInit':
$JS = <<<JS
<script type="text/javascript">
Ext.onReady(function(){
// Получаем дерево
var tree = Ext.getCmp('modx-resource-tree');
@Fi1osof
Fi1osof / gist:5062419
Created March 1, 2013 04:11
OnWebPageComplete stats plugin
<?php
$memory = round(memory_get_usage()/1024/1024, 4).' Mb';
print "<div>Memory: {$memory}</div>";
$totalTime= ($modx->getMicroTime() - $modx->startTime);
$queryTime= $modx->queryTime;
$queryTime= sprintf("%2.4f s", $queryTime);
$queries= isset ($modx->executedQueries) ? $modx->executedQueries : 0;
$totalTime= sprintf("%2.4f s", $totalTime);
@Fi1osof
Fi1osof / gist:5070120
Created March 2, 2013 08:00
ShopmodxObjectGetListProcessor
<?php
abstract class ShopmodxObjectGetListProcessor extends modObjectGetListProcessor{
function prepareQueryBeforeCount(xPDOQuery $c) {
$this->addDerivativeCriteria($c);
return parent::prepareQueryBeforeCount($c);
}
protected function addDerivativeCriteria(xPDOQuery $c){
$this->modx->addDerivativeCriteria($this->classKey, $c);
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
function smarty_function_processor($params, & $smarty)
@Fi1osof
Fi1osof / gist:6023918
Last active December 19, 2015 21:59
Дефолтовый контроллер
<?php
$properties = $modx->resource->getOne('Template')->getProperties();
if(!empty($properties['tpl'])){
$tpl = $properties['tpl'];
}
else{
$tpl = 'index.tpl';
}
@Fi1osof
Fi1osof / gist:6907324
Created October 9, 2013 19:58
Создаем таблицы и основные записи для пакета Billing
<?php
$manager = $modx->getManager();
// Создаем таблицы
$objects = array(
'Order',
'OrderProduct',
'OrderStatus',
<?php
$q = $modx->newQuery('modResource');
$q->innerJoin('ShopmodxProduct', 'Product');
$q->leftJoin('modTemplateVarResource', 'tv', 'tv.contentid=modResource.id and tv.tmplvarid=29');
$q->where(array(
"tv.id" => null,
));
print $modx->getCount('modResource', $q);