本文整理汇总了PHP中Sections::list_selected方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::list_selected方法的具体用法?PHP Sections::list_selected怎么用?PHP Sections::list_selected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::list_selected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AND
/**
* search for some keywords in sub-sections
*
* This function also searches in sub-sections, with up to three levels of depth.
*
* @see search.php
*
* Modification dates are taken into account to prefer freshest information.
*
* @link http://www.artfulcode.net/articles/full-text-searching-mysql/
*
* @param int the id of the section to look in
* @param string the search string
* @param float maximum score to look at
* @param int the number of items to display
* @param mixed the layout, if any
* @return NULL on error, else an ordered array of array($score, $summary)
*/
public static function &search_in_section($section_id, $pattern, $offset = 1.0, $count = 10, $layout = 'search')
{
global $context;
// sanity check
if (!($pattern = trim($pattern))) {
$output = NULL;
return $output;
}
// limit the scope of the request
$where = Sections::get_sql_where();
// search is restricted to one section
$sections_where = '';
if ($section_id) {
// look within this branch of the content tree
$anchors = Sections::get_branch_at_anchor('section:' . $section_id);
// the full set of sections searched
$where .= " AND (sections.id IN (" . str_replace('section:', '', join(", ", $anchors)) . "))";
}
// only consider live sections
$where .= " AND ((sections.expiry_date is NULL) " . "OR (sections.expiry_date <= '" . NULL_DATE . "') OR (sections.expiry_date > '" . $context['now'] . "'))";
// how to compute the score for sections
$score = "(MATCH(title, introduction, description)" . " AGAINST('" . SQL::escape($pattern) . "' IN BOOLEAN MODE)" . "/SQRT(GREATEST(1.1, DATEDIFF(NOW(), edit_date))))";
// the list of articles
$query = "SELECT sections.*," . " " . $score . " AS score" . " FROM " . SQL::table_name('sections') . " AS sections" . " WHERE (" . $score . " < " . $offset . ") AND (" . $score . " > 0)" . " AND (" . $where . ")" . " ORDER BY score DESC" . " LIMIT " . $count;
$output =& Sections::list_selected(SQL::query($query), $layout);
return $output;
}
示例2: AND
/**
* list alphabetically the sections related to any anchor
*
* Actually list sections by rank, then by title, then by date.
* If you select to not use the ranking system, sections will be ordered by title only.
* Else sections with a low ranking mark will appear first,
* and sections with a high ranking mark will be put at the end of the list.
*
* Only sections matching following criteria are returned:
* - section is visible (active='Y')
* - section is restricted (active='R'), but surfer is a logged user
* - section is restricted (active='N'), but surfer is an associate
* - an expiry date has not been defined, or is not yet passed
*
* @param the target anchor
* @param int the offset from the start of the list; usually, 0 or 1
* @param int the number of items to display
* @param string the list variant, if any
* @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
*
* @see sections/select.php
*/
public static function &list_sections_by_title_for_anchor($anchor, $offset = 0, $count = 10, $variant = 'compact')
{
global $context;
// display active and restricted items
$where = "sections.active='Y'";
if (Surfer::is_logged()) {
$where .= " OR sections.active='R'";
}
if (Surfer::is_empowered('S')) {
$where .= " OR sections.active='N'";
}
$where = '(' . $where . ')';
// only consider live sections
$where .= " AND ((sections.expiry_date is NULL)" . "OR (sections.expiry_date <= '" . NULL_DATE . "') OR (sections.expiry_date > '" . $context['now'] . "'))";
// the list of sections
$query = "SELECT sections.*" . "\tFROM (" . SQL::table_name('members') . " AS members" . ", " . SQL::table_name('sections') . " AS sections)" . " WHERE (members.anchor LIKE '" . SQL::escape($anchor) . "')" . "\tAND (members.member_type = 'section')" . "\tAND (members.member_id = sections.id)" . "\tAND (" . $where . ")" . " ORDER BY sections.title, sections.edit_date DESC LIMIT " . $offset . ',' . $count;
// use existing listing facility
$output =& Sections::list_selected(SQL::query($query), $variant);
return $output;
}