Ejemplo n.º 1
0
 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 . '.';
                 $data['thumb' . $postfix . $imageField] = $modx->runSnippet($thumbSnippet, array('input' => $data[$imageField], 'options' => $value));
                 $info = getimagesize(MODX_BASE_PATH . $data['thumb' . $postfix . $imageField]);
                 $data['thumb' . $postfix . 'width.' . $imageField] = $info[0];
                 $data['thumb' . $postfix . 'height.' . $imageField] = $info[1];
             }
         } else {
             $data['thumb.' . $imageField] = $modx->runSnippet($thumbSnippet, array('input' => $data[$imageField], 'options' => $thumbOptions));
         }
         $info = getimagesize(MODX_BASE_PATH . $data['thumb.' . $imageField]);
         $data['thumb.width.' . $imageField] = $info[0];
         $data['thumb.height.' . $imageField] = $info[1];
     }
     $properties = json_decode($data['sg_properties'], true);
     foreach ($properties as $key => $value) {
         $data['properties.' . $key] = $value;
     }
     return $data;
 }
Ejemplo n.º 2
0
 public static function prepare(array $data = array(), DocumentParser $modx, $_DocLister, prepare_DL_Extender $_extDocLister)
 {
     if (isset($data['images'])) {
         $wrapper = '';
         $imageField = $_DocLister->getCfgDef('imageField', 'sg_image');
         $thumbOptions = $_DocLister->getCfgDef('thumbOptions');
         $thumbSnippet = $_DocLister->getCfgDef('thumbSnippet');
         foreach ($data['images'] as $image) {
             $ph = $image;
             if (!empty($thumbOptions) && !empty($thumbSnippet)) {
                 $ph['thumb.' . $imageField] = $modx->runSnippet($thumbSnippet, array('input' => $image[$imageField], 'options' => $thumbOptions));
                 $info = getimagesize(MODX_BASE_PATH . $ph['thumb.' . $imageField]);
                 $ph['thumb.width.' . $imageField] = $info[0];
                 $ph['thumb.height.' . $imageField] = $info[1];
             }
             //сделали превьюшку
             $ph['e.sg_title'] = htmlentities($image['sg_title'], ENT_COMPAT, 'UTF-8', false);
             $ph['e.sg_description'] = htmlentities($image['sg_description'], ENT_COMPAT, 'UTF-8', false);
             //добавили поля e.sg_title и e.sg_description
             $properties = json_decode($image['sg_properties'], true);
             foreach ($properties as $key => $value) {
                 $ph['properties.' . $key] = $value;
             }
             $wrapper .= $_DocLister->parseChunk($_DocLister->getCfgDef('sgRowTpl'), $ph);
             //обработали чанк sgRowTpl - для каждой картинки
         }
         $data['images'] = $_DocLister->parseChunk($_DocLister->getCfgDef('sgOuterTpl'), array('wrapper' => $wrapper));
         //обработали чанк sgOuterTpl
     }
     return $data;
 }
Ejemplo n.º 3
0
 public static function prepare(array $data = array(), \DocumentParser $modx, $_DL, \prepare_DL_Extender $_extDocLister)
 {
     if (($data['parentName'] = $_extDocLister->getStore('parentName' . $data['parent'])) === null) {
         $q = $modx->db->query("SELECT pagetitle FROM " . $modx->getFullTableName('site_content') . " WHERE id = '" . $data['parent'] . "'");
         $data['parentName'] = $modx->db->getValue($q);
         $_extDocLister->setStore('parentName' . $data['parent'], $data['parentName']);
     }
     if (($docCrumbs = $_extDocLister->getStore('currentParents' . $data['parent'])) === null) {
         $modx->documentObject['id'] = $data['id'];
         $docCrumbs = rtrim($modx->runSnippet('DLcrumbs', array('ownerTPL' => '@CODE:[+crumbs.wrap+]', 'tpl' => '@CODE: [+title+] /', 'tplCurrent' => '@CODE: [+title+] /', 'hideMain' => '1')), ' /');
         $_extDocLister->setStore('currentParents' . $data['parent'], $docCrumbs);
     }
     $html = preg_replace("/(" . preg_quote($_DL->getCFGDef('search'), "/") . ")/iu", "<b>\$0</b>", $data['pagetitle']);
     $data['text'] = "{$data['id']}. {$data['pagetitle']}";
     $data['html'] = "<div><small>{$docCrumbs}</small><br>{$data['id']}. {$html}</div>";
     return $data;
 }
Ejemplo n.º 4
0
 public static function buildMenu(array $data = array(), DocumentParser $modx, $_DL, prepare_DL_Extender $_eDL)
 {
     $params = $_DL->getCFGDef('params', array());
     if ($_DL->getCfgDef('currentDepth', 1) < $_DL->getCFGDef('maxDepth', 5)) {
         $params['currentDepth'] = $_DL->getCfgDef('currentDepth', 1) + 1;
         $params['parents'] = $data['id'];
         $params['idType'] = 'parents';
         $params['documents'] = '';
         $data['dl.submenu'] = $modx->runSnippet('DLBuildMenu', $params);
     } else {
         $data['dl.submenu'] = '';
     }
     $data['dl.currentDepth'] = $_DL->getCfgDef('currentDepth', 1);
     if (($parentIDs = $_eDL->getStore('parentIDs')) === null) {
         $parentIDs = array_values($modx->getParentIds($modx->documentObject['id']));
         $_eDL->setStore('parentIDs', $parentIDs);
     }
     $isActive = is_array($parentIDs) && in_array($data['id'], $parentIDs) || $data['id'] == $modx->documentObject['id'];
     $activeClass = $_DL->getCfgDef('activeClass', 'active');
     if ($isActive) {
         $data['dl.class'] .= ' ' . $activeClass;
     }
     if (strpos($data['dl.class'], 'current') !== false && strpos($data['dl.class'], ' ' . $activeClass) === false) {
         $data['dl.class'] = str_replace('current', 'current ' . $activeClass, $data['dl.class']);
     }
     $tpl = empty($data['dl.submenu']) ? 'noChildrenRowTPL' : 'mainRowTpl';
     $_DL->renderTPL = $_DL->getCfgDef($tpl);
     if (strpos($data['dl.class'], 'current') !== false) {
         $_DL->renderTPL = $_DL->getCfgDef('TplCurrent', $_DL->renderTPL);
         $_DL->renderTPL = $_DL->getCfgDef('TplCurrent' . $data['dl.currentDepth'], $_DL->renderTPL);
         if (empty($data['dl.submenu'])) {
             $_DL->renderTPL = $_DL->getCfgDef('TplCurrentNoChildren' . $data['dl.currentDepth'], $_DL->renderTPL);
         }
     }
     return $data;
 }