/** * Получение строки из языкового пакета * * @param string $name имя записи в языковом пакете * @param string $def Строка по умолчанию, если запись в языковом пакете не будет обнаружена * @return string строка в соответствии с текущими языковыми настройками */ public function getMsg($name, $def = '') { $out = \APIhelpers::getkey($this->_lang, $name, $def); if (class_exists('evoBabel', false) && isset($this->modx->snippetCache['lang'])) { $msg = $this->modx->runSnippet('lang', array('a' => $name)); if (!empty($msg)) { $out = $msg; } } return $out; }
* DocLister wrapper for SimpleGallery table * * @category snippet * @version 1.0.0 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) * @internal @properties * @internal @modx_category Content * @author Pathologic (m@xim.name) */ include_once MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php'; $_prepare = explode(",", $prepare); $prepare = array(); $prepare[] = \APIhelpers::getkey($modx->event->params, 'BeforePrepare', ''); $prepare = array_merge($prepare, $_prepare); $prepare[] = 'DLsgLister::prepare'; $prepare[] = \APIhelpers::getkey($modx->event->params, 'AfterPrepare', ''); $modx->event->params['prepare'] = trim(implode(",", $prepare), ','); $params = array_merge(array("controller" => "onetable", "config" => "sgLister:assets/snippets/simplegallery/config/"), $modx->event->params, array('depth' => '0', 'showParent' => '-1')); if (!class_exists("DLsgLister", false)) { class DLsgLister { public static function prepare(array $data = array(), DocumentParser $modx, $_DL, prepare_DL_Extender $_extDocLister) { $imageField = $_DL->getCfgDef('imageField'); $thumbOptions = $_DL->getCfgDef('thumbOptions'); $thumbSnippet = $_DL->getCfgDef('thumbSnippet'); if (!empty($thumbOptions) && !empty($thumbSnippet)) { $_thumbOptions = json_decode($thumbOptions, true); if (is_array($_thumbOptions)) { foreach ($_thumbOptions as $key => $value) { $postfix = $key == 'default' ? '.' : '_' . $key . '.';
if (!defined('MODX_BASE_PATH')) { die('HACK???'); } include_once MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php'; $p =& $modx->event->params; if (!is_array($p)) { $p = array(); } $titleField = APIhelpers::getkey($p, 'titleField', 'pagetitle'); $valueField = APIhelpers::getkey($p, 'valueField', 'id'); $p = array_merge(array('idType' => 'parents', 'valueField' => $valueField, 'titleField' => $titleField, 'api' => implode(",", array($titleField, $valueField)), 'controller' => 'site_content', 'debug' => '0'), $p); $json = $modx->runSnippet("DocLister", $p); $json = jsonHelper::jsonDecode($json, array('assoc' => true)); $out = array(); $nopTitle = APIhelpers::getkey($p, 'addNopTitle'); if ($nopTitle) { $nopValue = APIhelpers::getkey($p, 'addNopValue'); $out[] = $nopTitle . '==' . $nopValue; } foreach ($json as $el) { $out[] = APIhelpers::getkey($el, $titleField) . '==' . APIhelpers::getkey($el, $valueField); } if (APIhelpers::getkey($p, 'debug')) { $key = APIhelpers::getkey($p, 'sysKey', 'dl') . '.debug'; $debugStack = $modx->getPlaceholder($key); if (!empty($debugStack)) { $modx->logEvent(0, 1, $debugStack, 'DocLister [DLValueList]'); } } return implode("||", $out);
<a href="[+url+]" title="[+e.title+]">[+title+]</a> [+dl.submenu+] </li>'); /** * TplDepthN Шаблон пункта меню вложенности N * TplNoChildrenDepthN Шаблон пункта меню вложенности N без дочерних элементов * noChildrenRowTPL Общий шаблон пункта меню без дочерних элементов */ $currentTpl = \APIhelpers::getkey($p, 'TplDepth' . $currentDepth, $currentTpl); $currentNoChildrenTpl = \APIhelpers::getkey($p, 'TplNoChildrenDepth' . $currentDepth); if (empty($currentNoChildrenTpl)) { $currentNoChildrenTpl = \APIhelpers::getkey($p, 'noChildrenRowTPL', $currentTpl); } /** Условия выборки документов для всех уровней */ $p['addWhereList'] = $currentWhere = \APIhelpers::getkey($p, 'addWhereList', 'c.hidemenu = 0'); /** addWhereListN Условия выборки документов N уровня */ $currentWhere = \APIhelpers::getkey($p, 'addWhereList' . $currentDepth, $currentWhere); $p['orderBy'] = $currentOrderBy = \APIhelpers::getkey($p, 'orderBy', 'menuindex ASC, id ASC'); /** orderByN Условия сортировки документов N уровня */ $currentOrderBy = \APIhelpers::getkey($p, 'orderBy' . $currentDepth, $currentOrderBy); /** * Получение prepare сниппетов из параметров BeforePrepare и AfterPrepare * для совмещения с обязательным вызовом DLFixedPrepare::buildMenu метода */ $prepare = \APIhelpers::getkey($p, 'BeforePrepare', ''); $prepare = explode(",", $prepare); $prepare[] = 'DLFixedPrepare::buildMenu'; $prepare[] = \APIhelpers::getkey($p, 'AfterPrepare', ''); $p['prepare'] = trim(implode(",", $prepare), ','); return $modx->runSnippet('DocLister', array_merge(array('idType' => 'parents', 'parents' => \APIhelpers::getkey($p, 'parents', 0)), $p, array('params' => $p, 'tpl' => $currentTpl, 'ownerTPL' => $currentOwnerTpl, 'mainRowTpl' => $currentTpl, 'noChildrenRowTPL' => $currentNoChildrenTpl, 'noneWrapOuter' => '0', 'addWhereList' => $currentWhere, 'orderBy' => $currentOrderBy)));
/** * Группировка документов по первой букве * * [[DLFirstChar? * &documents=`2,4,23,3` * &idType=`documents` * &tpl=`@CODE:[+CharSeparator+][+OnNewChar+]<span class="brand_name"><a href="[+url+]">[+pagetitle+]</a></span><br />` * &tplOnNewChar=`@CODE:<div class="block"><strong class="bukva">[+char+]</strong> ([+total+])</div>` * &tplCharSeparator=`@CODE:</div>` * &orderBy=`BINARY pagetitle ASC` * ]] */ if (!defined('MODX_BASE_PATH')) { die('HACK???'); } include_once MODX_BASE_PATH . 'assets/lib/APIHelpers.class.php'; include_once MODX_BASE_PATH . 'assets/snippets/DocLister/lib/DLFixedPrepare.class.php'; $p =& $modx->event->params; if (!is_array($p)) { $p = array(); } /** * Получение prepare сниппетов из параметров BeforePrepare и AfterPrepare * для совмещения с обязательным вызовом DLFixedPrepare::firstChar метода */ $prepare = \APIhelpers::getkey($p, 'BeforePrepare', ''); $prepare = explode(",", $prepare); $prepare[] = 'DLFixedPrepare::firstChar'; $prepare[] = \APIhelpers::getkey($p, 'AfterPrepare', ''); $p['prepare'] = trim(implode(",", $prepare), ','); return $modx->runSnippet('DocLister', $p);
public function getPlaceholder($placeholder) { return \APIhelpers::getkey($this->placeholders, $placeholder); }
public function getCFGDef($name, $def = null) { return \APIhelpers::getkey($this->_cfg, $name, $def); }
public function getCFGDef($param, $default = null) { return \APIhelpers::getkey($this->config, $param, $default); }