本文整理汇总了PHP中EntryManager::fetchSectionIDFromHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP EntryManager::fetchSectionIDFromHandle方法的具体用法?PHP EntryManager::fetchSectionIDFromHandle怎么用?PHP EntryManager::fetchSectionIDFromHandle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntryManager
的用法示例。
在下文中一共展示了EntryManager::fetchSectionIDFromHandle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grab
function grab($param = array())
{
extract($this->_env, EXTR_PREFIX_ALL, 'env');
include_once TOOLKIT . '/class.entrymanager.php';
$entryManager = new EntryManager($this->_parent);
$section_id = $entryManager->fetchSectionIDFromHandle($this->__resolveDefine("dsFilterPARENTSECTION"));
$schema = $entryManager->fetchEntryFieldSchema($section_id, NULL, $this->_dsFilterCUSTOMFIELD);
$schema = $schema[0];
##Check the cache
$hash_id = md5(get_class($this));
if ($param['caching'] && ($cache = $this->check_cache($hash_id))) {
return $cache;
exit;
}
##------------------------------
##Create the XML container
$xml = new XMLElement("categories-list");
$xml->setAttribute("section", "customfield");
##Populate the XML
if (empty($schema) || !is_array($schema)) {
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
} else {
$ops = preg_split('/,/', $schema['values'], -1, PREG_SPLIT_NO_EMPTY);
$ops = array_map("trim", $ops);
$xml->addChild(new XMLElement("name", $schema['name']));
$xml->setAttribute("handle", $schema['handle']);
$options = new XMLElement("options");
foreach ($ops as $o) {
if ($schema['type'] == 'multiselect') {
$table = 'tbl_entries2customfields_list';
} else {
$table = 'tbl_entries2customfields';
}
$count = $this->_db->fetchVar('count', 0, "SELECT count(id) AS `count` FROM `{$table}` WHERE `field_id` = '" . $schema['id'] . "' AND value_raw = '{$o}' ");
$xO = new XMLElement("option", $o);
$xO->setAttribute('entry-count', $count);
$xO->setAttribute('handle', Lang::createHandle($o, $this->_parent->getConfigVar('handle_length', 'admin')));
$options->addChild($xO);
}
$xml->addChild($options);
}
##------------------------------
##Write To Cache
if ($param['caching']) {
$result = $xml->generate($param['indent'], $param['indent-depth']);
$this->write_to_cache($hash_id, $result, $this->_cache_sections);
return $result;
}
return $xml;
}
示例2: grab
function grab($param = array())
{
## Decide if we return an emtpy set or not
if ($this->__forceEmptySet()) {
##Create the XML container
$xml = new XMLElement("archive-overview");
$xml->setAttribute("section", $this->getType());
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
}
$obDate = $this->_parent->getDateObj();
extract($this->_env, EXTR_PREFIX_ALL, 'env');
$where = $sort = $joins = NULL;
include_once TOOLKIT . '/class.entrymanager.php';
$entryManager = new EntryManager($this->_parent);
$section_id = $entryManager->fetchSectionIDFromHandle($this->getType());
##Prepare the Query
if ($handle = $this->__resolveDefine("dsFilterHANDLE")) {
$entries = $entryManager->fetchEntryIDFromPrimaryFieldHandle($section_id, $handle);
$where .= " AND t1.`id`" . ($this->__isDefineNotClause("dsFilterHANDLE") ? ' NOT' : '') . " IN ('" . @implode("', '", $entries) . "') ";
}
if ($date = $this->__resolveDefine("dsFilterDAY")) {
$where .= " AND DATE_FORMAT(t1.publish_date, '%d') " . ($this->__isDefineNotClause("dsFilterDAY") ? '!' : '') . "= '" . $date . "' ";
}
if ($month = $this->__resolveDefine("dsFilterMONTH")) {
$where .= " AND DATE_FORMAT(t1.publish_date, '%m') " . ($this->__isDefineNotClause("dsFilterMONTH") ? '!' : '') . "= '" . $month . "' ";
}
if ($year = $this->__resolveDefine("dsFilterYEAR")) {
$where .= " AND DATE_FORMAT(t1.publish_date, '%Y') " . ($this->__isDefineNotClause("dsFilterYEAR") ? '!' : '') . "= '" . $year . "' ";
}
if ($this->_dsFilterINCLUDEPOSTDATED != 'yes') {
$where .= " AND UNIX_TIMESTAMP(t1.publish_date_gmt) <= '" . $obDate->get(false, false) . "' ";
}
if (is_array($this->_dsFilterCUSTOM) && !empty($this->_dsFilterCUSTOM)) {
$table_id = 15;
foreach ($this->_dsFilterCUSTOM as $handle => $value) {
$field = $this->_db->fetchRow(0, "SELECT `id`, `type`, `foreign_select_multiple` FROM `tbl_customfields` WHERE `parent_section` = '{$section_id}' AND `handle` = '{$handle}' LIMIT 1");
$value_handle = Lang::createHandle($value, $this->_parent->getConfigVar('handle_length', 'admin'));
if ($field['type'] == 'multiselect' || $field['type'] == 'foreign' && $field['foreign_select_multiple'] == 'yes') {
$joins .= " LEFT JOIN `tbl_entries2customfields_list` AS t{$table_id} ON t1.`id` = t{$table_id}.`entry_id` AND t{$table_id}.field_id = " . $field['id'] . " ";
$where .= " AND (t{$table_id}.value_raw = '{$value}' OR t{$table_id}.handle = '{$value_handle}') ";
} else {
$joins .= " LEFT JOIN `tbl_entries2customfields` AS t{$table_id} ON t1.`id` = t{$table_id}.`entry_id` AND t{$table_id}.field_id = " . $field['id'] . " ";
$where .= " AND (t{$table_id}.value_raw = '{$value}' OR t{$table_id}.handle = '{$value_handle}') ";
}
$table_id++;
}
}
if ($this->_dsFilterSORT != '') {
$sort = strtoupper($this->_dsFilterSORT);
}
$sql = "SELECT t1.id, t1.publish_date_gmt " . "FROM `tbl_entries` AS t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` " . "AND t2.`class` = 'entry' " . "LEFT JOIN `tbl_authors` AS t4 ON t1.`author_id` = t4.`id` " . $joins . "LEFT JOIN `tbl_entries2sections` AS t8 ON t1.id = t8.entry_id " . "WHERE t8.section_id = '{$section_id}' " . $where . "GROUP BY t1.`id` " . "ORDER BY t1.`publish_date_gmt` " . $sort;
##Check the cache
$hash_id = md5(get_class($this) . serialize($env_url));
if ($param['caching'] && ($cache = $this->check_cache($hash_id))) {
return $cache;
exit;
}
##------------------------------
##Create the XML container
$xml = new XMLElement("archive-overview");
$xml->setAttribute("section", $this->getType());
##Grab the records
$entries = $this->_db->fetch($sql);
$current_month = date("m", $obDate->get(true, false));
$current_year = date("Y", $obDate->get(true, false));
##Populate the XML
if (empty($entries) || !is_array($entries)) {
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
} else {
$bin = array();
foreach ($entries as $e) {
list($dYear, $dMonth, $dDay) = explode("-", date("Y-m-d", $obDate->get(true, false, strtotime($e['publish_date_gmt']))));
$bin[$dYear][intval($dMonth)]++;
}
$years = @array_keys($bin);
if ($sort && $sort == 'DESC') {
$end_year = $current_year;
$bin_years = array_keys($bin);
rsort($bin_years);
for ($ii = $bin_years[0] + 1; $ii <= $current_year; $ii++) {
$bin[$ii] = array();
}
$bin = array_reverse($bin, true);
} else {
$start_year = $years[0];
}
foreach ($bin as $year => $months) {
$xYear = new XMLElement("year");
$xYear->setAttribute("value", $year);
#foreach($months as $month => $count){
if ($sort && $sort == 'DESC') {
for ($month = 12; $month > 0; $month--) {
if ($current_year > $year || $current_year == $year && $current_month >= $month) {
$xMonth = new XMLElement("month");
$xMonth->setAttribute("value", $month < 10 ? "0{$month}" : $month);
$xMonth->setAttribute("entry-count", "" . max(0, intval($months[$month])) . "");
$xYear->addChild($xMonth);
}
//.........这里部分代码省略.........
示例3: grab
function grab($param = array())
{
## Decide if we return an emtpy set or not
if ($this->__forceEmptySet()) {
##Create the XML container
$xml = new XMLElement("archive-entry-list");
$xml->setAttribute("section", $this->getType());
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
}
$obDate = $this->_parent->getDateObj();
extract($this->_env, EXTR_PREFIX_ALL, 'env');
$where = $sort = $joins = NULL;
include_once TOOLKIT . '/class.entrymanager.php';
$entryManager = new EntryManager($this->_parent);
$section_id = $entryManager->fetchSectionIDFromHandle($this->getType());
##Prepare the Query
if ($handle = $this->__resolveDefine("dsFilterHANDLE")) {
$entries = $entryManager->fetchEntryIDFromPrimaryFieldHandle($section_id, $handle);
$where .= " AND t1.`id`" . ($this->__isDefineNotClause("dsFilterHANDLE") ? ' NOT' : '') . " IN ('" . @implode("', '", $entries) . "') ";
}
if ($date = $this->__resolveDefine("dsFilterDAY")) {
$where .= " AND DATE_FORMAT(t1.publish_date, '%d') " . ($this->__isDefineNotClause("dsFilterDAY") ? '!' : '') . "= '" . $date . "' ";
}
if ($month = $this->__resolveDefine("dsFilterMONTH")) {
$where .= " AND DATE_FORMAT(t1.publish_date, '%m') " . ($this->__isDefineNotClause("dsFilterMONTH") ? '!' : '') . "= '" . $month . "' ";
}
if ($year = $this->__resolveDefine("dsFilterYEAR")) {
$where .= " AND DATE_FORMAT(t1.publish_date, '%Y') " . ($this->__isDefineNotClause("dsFilterYEAR") ? '!' : '') . "= '" . $year . "' ";
}
if ($this->_dsFilterINCLUDEPOSTDATED != 'yes') {
$where .= " AND UNIX_TIMESTAMP(t1.publish_date_gmt) <= '" . $obDate->get(false, false) . "' ";
}
if (is_array($this->_dsFilterCUSTOM) && !empty($this->_dsFilterCUSTOM)) {
$table_id = 15;
foreach ($this->_dsFilterCUSTOM as $handle => $value) {
$field = $this->_db->fetchRow(0, "SELECT `id`, `type`, `foreign_select_multiple` FROM `tbl_customfields` WHERE `parent_section` = '{$section_id}' AND `handle` = '{$handle}' LIMIT 1");
$value_handle = Lang::createHandle($value, $this->_parent->getConfigVar('handle_length', 'admin'));
if ($field['type'] == 'multiselect' || $field['type'] == 'foreign' && $field['foreign_select_multiple'] == 'yes') {
$joins .= " LEFT JOIN `tbl_entries2customfields_list` AS t{$table_id} ON t1.`id` = t{$table_id}.`entry_id` AND t{$table_id}.field_id = " . $field['id'] . " ";
$where .= " AND (t{$table_id}.value_raw = '{$value}' OR t{$table_id}.handle = '{$value_handle}') ";
} else {
$joins .= " LEFT JOIN `tbl_entries2customfields` AS t{$table_id} ON t1.`id` = t{$table_id}.`entry_id` AND t{$table_id}.field_id = " . $field['id'] . " ";
$where .= " AND (t{$table_id}.value_raw = '{$value}' OR t{$table_id}.handle = '{$value_handle}') ";
}
$table_id++;
}
}
if ($this->_dsFilterSORT != '') {
$sort = strtoupper($this->_dsFilterSORT);
}
if ($max_months = $this->__resolveDefine("dsFilterLIMIT_MONTHS")) {
$sql = "SELECT UNIX_TIMESTAMP(t1.publish_date) AS publish_timestamp " . "FROM `tbl_entries` AS t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` " . "AND t2.`class` = 'entry' " . "LEFT JOIN `tbl_authors` AS t4 ON t1.`author_id` = t4.`id` " . $joins . "LEFT JOIN `tbl_entries2sections` AS t8 ON t1.id = t8.entry_id " . "WHERE t8.section_id = '{$section_id}' " . $where . "GROUP BY t1.`id` " . "ORDER BY t1.`publish_date` {$sort} " . "LIMIT 1";
$relative_start = $this->_db->fetchVar('publish_timestamp', 0, $sql);
switch ($sort) {
case "DESC":
$end = mktime(0, 0, 0, date('m', $relative_start) - $max_months + 1, 1, date('Y', $relative_start));
$where .= " AND (UNIX_TIMESTAMP(t1.publish_date) <= '{$relative_start}' AND UNIX_TIMESTAMP(t1.publish_date) >= '{$end}')";
break;
case "ASC":
## Since this is assending, we need to start from 0. The DS editor will give us 1+
$max_months--;
$last_day = date('d', mktime(0, 0, 0, date('m', $relative_start) + 1, 0, date('Y', $relative_start)));
$end = mktime(23, 59, 59, date('m', $relative_start) + $max_months, $last_day, date('Y', $relative_start));
$where .= " AND (UNIX_TIMESTAMP(t1.publish_date) >= '{$relative_start}' AND UNIX_TIMESTAMP(t1.publish_date) <= '{$end}')";
break;
}
} else {
##We are trying to preview
if (isset($param['limit'])) {
$limit = " LIMIT 0, " . $param['limit'];
} elseif ($this->_dsFilterLIMIT != '') {
$limit = " LIMIT 0, " . $this->_dsFilterLIMIT;
} elseif ($where == NULL) {
$limit = " LIMIT 0, 50";
}
}
$sql = "SELECT t1.id " . "FROM `tbl_entries` AS t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` " . "AND t2.`class` = 'entry' " . "LEFT JOIN `tbl_authors` AS t4 ON t1.`author_id` = t4.`id` " . $joins . "LEFT JOIN `tbl_entries2sections` AS t8 ON t1.id = t8.entry_id " . "WHERE t8.section_id = '{$section_id}' " . $where . "GROUP BY t1.`id` " . "ORDER BY t1.`publish_date_gmt` " . $sort . $limit;
##Check the cache
$hash_id = md5(get_class($this) . serialize($env_url));
if ($param['caching'] && ($cache = $this->check_cache($hash_id))) {
return $cache;
exit;
}
##------------------------------
##Create the XML container
$xml = new XMLElement("archive-entry-list");
$xml->setAttribute("section", $this->getType());
$xml->setAttribute("section-id", $section_id);
##Grab the records
$entries = $this->_db->fetchCol("id", $sql);
##Populate the XML
if (empty($entries) || !is_array($entries)) {
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
} else {
$bin = array();
foreach ($entries as $id) {
$row = $entryManager->fetchEntriesByID($id, false, true);
list($dYear, $dMonth, $dDay) = explode("-", date("Y-m-d", $obDate->get(true, false, strtotime($row['publish_date_gmt']))));
//.........这里部分代码省略.........
示例4: grab
function grab($param = array())
{
## Decide if we return an emtpy set or not
if ($this->__forceEmptySet()) {
##Create the XML container
$xml = new XMLElement("comments");
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
}
$obDate = $this->_parent->getDateObj();
extract($this->_env, EXTR_PREFIX_ALL, 'env');
$where = NULL;
include_once TOOLKIT . "/class.entrymanager.php";
$entryManager = new EntryManager($this->_parent);
##Prepare the Query
if ($section_id = $entryManager->fetchSectionIDFromHandle($this->_dsFilterSECTION)) {
$comment_where .= " AND t4.`section_id` = '{$section_id}' ";
if ($entries = $this->__resolveDefine("dsFilterHANDLE", true)) {
$entry_ids = $entryManager->fetchEntryIDFromPrimaryFieldHandle($section_id, $entries);
$comment_where .= " AND t3.`id`" . ($this->__isDefineNotClause("dsFilterHANDLE") ? ' NOT' : '') . " IN ('" . @implode("', '", $entry_ids) . "') ";
}
}
if ($date = $this->__resolveDefine("dsFilterDAY")) {
$comment_where .= " AND DATE_FORMAT(t2.creation_date, '%d') " . ($this->__isDefineNotClause("dsFilterDAY") ? '!' : '') . "= '" . $date . "' ";
}
if ($month = $this->__resolveDefine("dsFilterMONTH")) {
$comment_where .= " AND DATE_FORMAT(t2.creation_date, '%m') " . ($this->__isDefineNotClause("dsFilterMONTH") ? '!' : '') . "= '" . $month . "' ";
}
if ($year = $this->__resolveDefine("dsFilterYEAR")) {
$comment_where .= " AND DATE_FORMAT(t2.creation_date, '%Y') " . ($this->__isDefineNotClause("dsFilterYEAR") ? '!' : '') . "= '" . $year . "' ";
}
$sort = "DESC";
if ($this->_dsFilterSORT != '') {
$sort = strtoupper($this->_dsFilterSORT);
}
if (!isset($this->_dsFilterSHOWSPAM) || $this->_dsFilterSHOWSPAM != 'yes') {
$comment_where .= " AND `t1`.`spam` = 'no' ";
}
if ($max_months = $this->__resolveDefine("dsFilterLIMIT_MONTHS")) {
$sql = "SELECT UNIX_TIMESTAMP(t2.creation_date_gmt) as `creation_timestamp_gmt` " . "FROM `tbl_comments` as t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` AND t2.`class` = 'comment' " . "INNER JOIN `tbl_entries` as t3 ON t1.`entry_id` = t3.`id` " . "LEFT JOIN `tbl_entries2sections` AS t4 ON t3.`id` = t4.`entry_id` " . "WHERE 1 " . $comment_where . "GROUP BY t1.`id` " . "ORDER BY `creation_timestamp_gmt` {$sort} " . "LIMIT 1";
$relative_start = $this->_db->fetchVar('creation_timestamp_gmt', 0, $sql);
switch ($sort) {
case "DESC":
$end = mktime(0, 0, 0, date('m', $relative_start) - $max_months + 1, 1, date('Y', $relative_start));
$comment_where .= " AND (UNIX_TIMESTAMP(t2.creation_date_gmt) <= '{$relative_start}' AND UNIX_TIMESTAMP(t2.creation_date_gmt) >= '{$end}')";
break;
case "ASC":
## Since this is assending, we need to start from 0. The DS editor will give us 1+
$max_months--;
$last_day = date('d', mktime(0, 0, 0, date('m', $relative_start) + 1, 0, date('Y', $relative_start)));
$end = mktime(23, 59, 59, date('m', $relative_start) + $max_months, $last_day, date('Y', $relative_start));
$comment_where .= " AND (UNIX_TIMESTAMP(t2.creation_date_gmt) >= '{$relative_start}' AND UNIX_TIMESTAMP(t2.creation_date_gmt) <= '{$end}')";
break;
}
} else {
##We are trying to preview
if (isset($param['limit'])) {
$limit = $param['limit'];
} elseif ($this->_dsFilterLIMIT != '') {
$limit = intval($this->_dsFilterLIMIT);
##Prevent things from getting too big
} else {
$limit = 50;
}
}
$start = 0;
$sql = "SELECT count(t1.id) AS `total-comments` " . "FROM `tbl_comments` AS t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` AND t2.`class` = 'comment' " . "INNER JOIN `tbl_entries` as t3 ON t1.`entry_id` = t3.`id` " . "LEFT JOIN `tbl_entries2sections` AS t4 ON t3.`id` = t4.`entry_id` " . "WHERE 1 " . $comment_where;
$kTotalCommentCount = $this->_db->fetchVar('total-comments', 0, $sql);
if (isset($this->_dsFilterPAGENUMBER)) {
$pagenumber = $this->__resolveDefine("dsFilterPAGENUMBER");
$kPageNumber = max(1, intval($pagenumber));
if (!$limit) {
$limit = 50;
}
$kTotalPages = ceil($kTotalCommentCount * (1 / $limit));
$start = $limit * ($kPageNumber - 1);
}
$sql = "SELECT t1.*, UNIX_TIMESTAMP(t2.creation_date_gmt) as `creation_timestamp_gmt` " . "FROM `tbl_comments` as t1 " . "LEFT JOIN `tbl_metadata` AS t2 ON t1.`id` = t2.`relation_id` AND t2.`class` = 'comment' " . "INNER JOIN `tbl_entries` as t3 ON t1.`entry_id` = t3.`id` " . "LEFT JOIN `tbl_entries2sections` AS t4 ON t3.`id` = t4.`entry_id` " . "WHERE 1 " . $comment_where . "GROUP BY t1.`id` " . "ORDER BY `creation_timestamp_gmt` {$sort} " . ($limit ? " LIMIT {$start}, {$limit}" : '');
##Check Cache
$hash_id = md5(get_class($this) . $sql);
if ($param['caching'] && ($cache = $this->check_cache($hash_id))) {
return $cache;
exit;
}
##------------------------------
##Create the XML container
$xml = new XMLElement("comments");
##Grab the records
$comments = $this->_db->fetch($sql);
##Populate the XML
if (empty($comments) || !is_array($comments)) {
$xml->addChild(new XMLElement("error", "No Records Found."));
return $xml;
} else {
$entries = array();
foreach ($comments as $c) {
$entries[$c['entry_id']]['commenting'] = $c['commenting'];
$entries[$c['entry_id']]['comments'][] = $c;
}
if (in_array("pagination-info", $this->_dsFilterXMLFIELDS)) {
//.........这里部分代码省略.........