Skip to content

Instantly share code, notes, and snippets.

View Fi1osof's full-sized avatar

Nikolay Lanets Fi1osof

View GitHub Profile
@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: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;
<?
$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 */
<?php
$modx->setLogTarget('HTML');
print '<pre>';
$topic = $modx->modblog->getTopic(289);
$blogs = $modx->modblog->getBlogs(); // Получаем все блоги
$blogtopics = array();
foreach($blogs as $blog){
// Создаем объект Топик-Блог (еще не сохраняем)
@Fi1osof
Fi1osof / gist:4495700
Created January 9, 2013 18:45
load modBlog
<?php
$path = $this->getOption('modsociety.core_path', null);
if(!$path){
$path = MODX_CORE_PATH .'components/modsociety/';
}
$path .= 'model/modSociety/';
if(!$this->loadClass('modSociety', $path, false, true)){
@Fi1osof
Fi1osof / gist:4493453
Last active December 10, 2015 21:09
$modx->runProcessor()
<?php
MODx{
function runProcessor($action = '',$scriptProperties = array(),$options = array()){
if($class = $this->loadProcessorClass($action, $options){
$processor = new $class($scriptProperties,$options);
return $processor->process();
}
return ;
<?php
$path = $this->getOption('modsociety.core_path', null);
if(!$path){
$path = MODX_CORE_PATH .'components/modsociety/';
}
$path .= 'model/modSociety/';
if(!$this->loadClass('modSociety', $path, false, true)){
@Fi1osof
Fi1osof / gist:4479563
Created January 7, 2013 23:24
CustomUser
<?php
class SocietyUser extends modUser {
static function load(xPDO &$xpdo, $className, $criteria, $cacheFlag = true) {
$instance= null;
$fromCache= false;
if ($className= $xpdo->loadClass($className)) {
if (!is_object($criteria)) {
$criteria= $xpdo->getCriteria($className, $criteria, $cacheFlag);
}
@Fi1osof
Fi1osof / gist:4461649
Last active December 10, 2015 16:29
modX::addExtensionPackage(
<?php
public function addExtensionPackage($name,$path,array $options = array()) {
// What is it for?
// $extPackages
// It`s not using
$extPackages = $this->getOption('extension_packages');
$extPackages = !empty($extPackages) ? $extPackages : array();
$extPackages = is_array($extPackages) ? $extPackages : $this->fromJSON($extPackages);
$extPackages[$name] = $options;
$extPackages['path'] = $path;
@Fi1osof
Fi1osof / gist:4449671
Created January 4, 2013 03:27
Manifest
<?php
/**
* Discuss
*
* Copyright 2010-11 by Shaun McCormick <shaun@modx.com>
*
* This file is part of Discuss, a native forum for MODx Revolution.
*
* Discuss is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software