public function __construct($modx, $tv) { $this->modx = $modx; $this->tv = $tv; $this->DLTemplate = \DLTemplate::getInstance($this->modx); $this->fs = \Helpers\FS::getInstance(); }
/** * gets the instance via lazy initialization (created on first usage) * * @return self */ public static function getInstance(DocumentParser $modx) { if (null === self::$instance) { self::$instance = new self($modx); } return self::$instance; }
/** * @param $modx * @param string $lang_attribute * @param bool $debug */ public function __construct($modx, $lang_attribute = 'en', $debug = false) { $this->modx = $modx; $this->_table = $modx->getFullTableName($this->table); $this->lang_attribute = $lang_attribute; $this->params = $modx->event->params; if ($this->checkTemplate && !isset($this->params['template']) && $modx->event->name != 'OnEmptyTrash') { $this->params['template'] = array_pop($modx->getDocument($this->params['id'], 'template', 'all', 'all')); } //overload plugin and class properties $_params = $modx->parseProperties('&template=;;' . $this->params['template'] . ' &id=;;' . $this->params['id'], $modx->event->activePlugin, 'plugin'); foreach ($_params as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } $this->params = array_merge($this->params, $_params); $modx->event->_output = ""; $this->DLTemplate = \DLTemplate::getInstance($this->modx); $this->fs = \Helpers\FS::getInstance(); }
$params = is_array($modx->Event->params) ? $modx->Event->params : array(); $params = array_merge($params, array('api' => 1, 'debug' => '0')); $json = $modx->runSnippet("DocLister", $params); $children = jsonHelper::jsonDecode($json, array('assoc' => true)); $children = is_array($children) ? $children : array(); $self = $prev = $next = null; foreach ($children as $key => $data) { if (!empty($self)) { $next = $key; break; } if ($key == $ID) { $self = $key; if (empty($prev)) { $prev = end($children); $prev = $prev['id']; } } else { $prev = $key; } } if (empty($next)) { reset($children); $next = current($children); $next = $next['id']; } if ($next == $prev) { $next = ''; } $TPL = DLTemplate::getInstance($modx); return $prev == $ID ? '' : $TPL->parseChunk($prevnextTPL, array('prev' => empty($prev) ? '' : $TPL->parseChunk($prevTPL, $children[$prev]), 'next' => empty($next) ? '' : $TPL->parseChunk($nextTPL, $children[$next])));
<?php include_once MODX_MANAGER_PATH . "/composer/vendor/autoload.php"; $modx->doc = new modResource($modx); $modx->tpl = DLTemplate::getInstance($modx); $modx->fs = \Helpers\FS::getInstance(); switch (true) { case function_exists('apc_cache_info'): $modx->cache = new \Doctrine\Common\Cache\ApcCache(); break; case class_exists('Memcache'): $modx->cache = new \Doctrine\Common\Cache\MemcacheCache(); $memcache = new Memcache(); $memcache->connect('localhost', 11211); $modx->cache->setMemcache($memcache); break; case class_exists('Memcached'): $modx->cache = new \Doctrine\Common\Cache\MemcachedCache(); $memcached = new Memcached(); $memcached->connect('localhost', 11211); $modx->cache->setMemcache($memcached); break; case class_exists('SQLite3'): $modx->cache = new \Doctrine\Common\Cache\SQLite3Cache(new SQLite3(MODX_BASE_PATH . 'assets/cache/sqlite.db'), 'cache'); break; default: $modx->cache = new Doctrine\Common\Cache\FilesystemCache(MODX_BASE_PATH . 'assets/cache/template/'); } $modx->cache->setNamespace($modx->getConfig('site_name')); $moduleDebug = false; if (!is_ajax() && ($modx->isFrontend() && $modx->getLoginUserID('mgr')) || $modx->isBackend() && isset($_GET['a']) && $_GET['a'] == 112 && $moduleDebug) {
/** * Редирект */ public function moveTo($params) { $out = ''; $id = (int) \APIHelpers::getkey($params, 'id', 0); $uri = \APIHelpers::getkey($params, 'url', ''); if (empty($uri) && !empty($id) || !is_string($uri)) { $uri = $this->makeUrl($id); } $code = (int) \APIHelpers::getkey($params, 'code', 0); $addUrl = \APIHelpers::getkey($params, 'addUrl', ''); if (is_scalar($addUrl) && $addUrl != '') { $uri .= "?" . $addUrl; } if (\APIHelpers::getkey($params, 'validate', false)) { if (isset($this->modx->snippetCache['getPageID'])) { $out = $this->modx->runSnippet('getPageID', compact('uri')); if (empty($out)) { $uri = ''; } } else { $uri = \DLTemplate::getInstance($this->modx)->sanitarTag($uri); } } else { //$modx->sendRedirect($url, 0, 'REDIRECT_HEADER', 'HTTP/1.1 307 Temporary Redirect'); header("Location: " . $uri, true, $code > 0 ? $code : 307); } return $uri; }
/** * refactor $modx->parseChunk(); * * @param string $name Template: chunk name || @CODE: template || @FILE: file with template * @param array $data paceholder * @param bool $parseDocumentSource render html template via DocumentParser::parseDocumentSource() * @return string html template with data without placeholders */ public function parseChunk($name, $data, $parseDocumentSource = false) { $this->debug->debug(array("parseChunk" => $name, "With data" => print_r($data, 1)), "parseChunk", 2, array('html', null)); $out = DLTemplate::getInstance($this->getMODX())->parseChunk($name, $data, $parseDocumentSource); if (empty($out)) { $this->debug->debug("Empty chunk: " . $this->debug->dumpData($name), '', 2); } $this->debug->debugEnd("parseChunk"); return $out; }
<?php if (!defined('MODX_BASE_PATH')) { die('HACK???'); } require_once MODX_BASE_PATH . "assets/snippets/DocLister/lib/DLTemplate.class.php"; $tpl = ''; if (isset($modx->Event->params['tpl'])) { $tpl = $modx->Event->params['tpl']; unset($modx->Event->params['tpl']); } return empty($tpl) ? '' : DLTemplate::getInstance($modx)->parseChunk($tpl, $modx->Event->params);
public function parseChunk($name, $data, $parseDocumentSource = false) { $out = null; $out = \DLTemplate::getInstance($this->modx)->parseChunk($name, $data, $parseDocumentSource); if ($this->lexicon->isReady()) { $out = $this->lexicon->parseLang($out); } return $out; }
/** * refactor $modx->parseChunk(); * * @param string $name Template: chunk name || @CODE: template || @FILE: file with template * @param array $data paceholder * @param bool $parseDocumentSource render html template via DocumentParser::parseDocumentSource() * @return string html template with data without placeholders */ public function parseChunk($name, $data, $parseDocumentSource = false) { $out = null; $this->debug->debug("parseChunk: " . $this->debug->dumpData($name) . "\r\nWith data: " . $this->debug->dumpData($data), "parseChunk", 2); $out = DLTemplate::getInstance($this->getMODX())->parseChunk($name, $data, $parseDocumentSource); if (empty($out)) { $this->debug->debug("Empty chunk: " . $this->debug->dumpData($name), '', 2); } $this->debug->debugEnd("parseChunk"); return $out; }