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; }
public static function firstChar(array $data = array(), DocumentParser $modx, $_DocLister, prepare_DL_Extender $_extDocLister) { $char = mb_substr($data['pagetitle'], 0, 1, 'UTF-8'); $oldChar = $_extDocLister->getStore('char'); if ($oldChar !== $char) { $sanitarInIDs = $_DocLister->sanitarIn($_DocLister->getIDs()); $where = sqlHelper::trimLogicalOp($_DocLister->getCFGDef('addWhereList', '')); $where = sqlHelper::trimLogicalOp(($where ? $where . ' AND ' : '') . $_DocLister->filtersWhere()); $where = sqlHelper::trimLogicalOp(($where ? $where . ' AND ' : '') . "SUBSTRING(c.pagetitle,1,1) = '" . $modx->db->escape($char) . "'"); if ($_DocLister->getCFGDef('idType', 'parents') == 'parents') { if ($where != '') { $where .= " AND "; } $where = "WHERE {$where} c.parent IN (" . $sanitarInIDs . ")"; if (!$_DocLister->getCFGDef('showNoPublish', 0)) { $where .= " AND c.deleted=0 AND c.published=1"; } } else { if ($sanitarInIDs != "''") { $where .= ($where ? " AND " : "") . "c.id IN ({$sanitarInIDs}) AND"; } $where = sqlHelper::trimLogicalOp($where); if ($_DocLister->getCFGDef('showNoPublish', 0)) { if ($where != '') { $where = "WHERE {$where}"; } } else { if ($where != '') { $where = "WHERE {$where} AND "; } else { $where = "WHERE {$where} "; } $where .= "c.deleted=0 AND c.published=1"; } } $q = $_DocLister->dbQuery("SELECT count(c.id) as total FROM " . $_DocLister->getTable('site_content', 'c') . " " . $where); $total = $modx->db->getValue($q); $data['OnNewChar'] = $_DocLister->parseChunk($_DocLister->getCFGDef('tplOnNewChar'), compact("char", "total")); $_extDocLister->setStore('char', $char); if ($oldChar !== null) { $data['CharSeparator'] = $_DocLister->parseChunk($_DocLister->getCFGDef('tplCharSeparator'), compact("char", "total")); } } return $data; }