Skip to content

Instantly share code, notes, and snippets.

@sergant210
sergant210 / factory.php
Created Sep 26, 2020
Скрипт создания ресурсов
View factory.php
<?php
// Пути для корня сайта
require_once __DIR__ . '/config.core.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError', '', '');
// Вариант 1.
/*$doc = $modx->newObject('modDocument', [
@sergant210
sergant210 / Worker.php
Created May 9, 2019 — forked from etheriqa/Worker.php
Parallel processing on PHP using stream_select()
View Worker.php
<?php
interface Worker
{
public function getCommand();
public function done($stdout, $stderr);
public function fail($stdout, $stderr, $status);
}
View search_getoption_use.php
<?php
/**
* Файл поиска использования метода getOption.
* Должен находится в корне сайта.
*/
define('MODX_API_MODE', true);
require 'index.php';
$modx->lexicon->load('resource','context','element','system_events','access','default','setting');
//echo $modx->lexicon('setting_cache_context_settings'); exit;
$count = 0;
View plugin.onebooking.php
<?php
/** @var array $scriptProperties
* @var msOrder $msOrder
*/
switch ($modx->event->name) {
case 'msOnBeforeAddToCart':
if (!empty($_SESSION['oneBooking']['price'])) {
$product->set('price', $_SESSION['oneBooking']['price']);
}
break;
@sergant210
sergant210 / StorageTrait.php
Last active Oct 10, 2017
Fenom Storage trait
View StorageTrait.php
<?php
namespace Fenom;
trait StorageTrait
{
/**
* @var array storage
*/
View pdotoolsplus.class.php
<?php
require_once 'pdotools.class.php';
class pdoToolsPlus extends pdoTools
{
/**
* Loads template engine
*
* @return bool|Fenom
*/
View _fenomplus.php
<?php
require_once '_fenom.php';
class FenomPlus extends FenomX
{
/**
* @inheritdoc
*/
protected function _addDefaultModifiers()
{
View obExtras
<?php
$oneBooking = $modx->getService('onebooking','oneBooking',$modx->getOption('core_path').'components/onebooking/model/onebooking/', $scriptProperties);
if (!($oneBooking instanceof oneBooking)) return '';
$included = array();
if (!empty($scriptProperties['fields'])) {
$included = explode(',',$scriptProperties['fields']);
array_walk($included,'trim');
}
$fields = false;
@sergant210
sergant210 / gist:4a5e631a7005bea680da
Created Sep 19, 2015
Скрипт переноса данных из HitsPage в siteStatistics
View gist:4a5e631a7005bea680da
<?php
$tstart = microtime(true);
$hits = array();
$q = $modx->newQuery('modResource');
$q->select('id,properties');
$q->sortby('id');
// Для поэтапной обработки указываем limit и offset
//$q->limit(100,0);
if ($q->prepare() && $q->stmt->execute()) {
while($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
@sergant210
sergant210 / showErrors.php
Last active Aug 29, 2015
Show errors from the system error log in a new window
View showErrors.php
<?php
switch ($modx->event->name) {
case 'OnManagerPageBeforeRender':
// Определяем названия // Define titles on your language
$lang['no'] = 'Нет'; //No
$lang['yes'] = 'Есть'; //Yes
$lang['errors'] = 'Ошибки'; //Errors
$lang['errors_title'] = 'Открыть журнал ошибок в новом окне'; //Open the error log in a new window
//
$response = $modx->runProcessor('system/errorlog/get');
You can’t perform that action at this time.