本文整理汇总了PHP中comment::load_from_resultset方法的典型用法代码示例。如果您正苦于以下问题:PHP comment::load_from_resultset方法的具体用法?PHP comment::load_from_resultset怎么用?PHP comment::load_from_resultset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comment
的用法示例。
在下文中一共展示了comment::load_from_resultset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nvweb_list_parse_tag
//.........这里部分代码省略.........
$out = '#';
}
break;
case 'message':
if (!empty($tag['attributes']['length'])) {
$out = core_string_cut($item->message, $tag['attributes']['length'], '…');
} else {
$out = nl2br($item->message);
}
break;
case 'date':
// Navigate CMS 1.6.6 compatibility
if (empty($tag['attributes']['format']) && !empty($tag['attributes']['date_format'])) {
$tag['attributes']['format'] = $tag['attributes']['date_format'];
}
if (!empty($tag['attributes']['format'])) {
// custom date format
$out = nvweb_content_date_format($tag['attributes']['format'], $item->date_created);
} else {
$out = date($website->date_format . ' H:i', $item->date_created);
}
break;
case 'item_url':
$out = nvweb_source_url('item', $item->item, $current['lang']);
break;
case 'item_title':
$out = $item->item_title;
break;
case 'reply_to':
$out = $item->reply_to;
break;
case 'depth':
$c = new comment();
$c->load_from_resultset(array($item));
$out = $c->depth();
break;
case 'property':
$c = new comment();
$c->load_from_resultset(array($item));
// pass all nvlist tag parameters to properties nvweb, but some attribute/values take preference
$nvweb_properties_parameters = array_replace($tag['attributes'], array('mode' => 'comment', 'id' => $c->id, 'template' => $c->element_template(), 'property' => !empty($tag['attributes']['property']) ? $tag['attributes']['property'] : $tag['attributes']['name']));
$out = nvweb_properties($nvweb_properties_parameters);
break;
}
break;
case 'block':
switch ($tag['attributes']['value']) {
case 'id':
$out = $item->id;
break;
// only for blocks in a block group!
// only for blocks in a block group!
case 'uid':
$out = $item->uid;
break;
case 'block':
// generate the full block code
if ($item->type == "extension") {
if (function_exists('nvweb_' . $item->extension . '_' . $item->id)) {
// load extension block property values
$item->properties = property::load_properties(NULL, $item->id, "extension_block", NULL, $item->uid);
$out = call_user_func('nvweb_' . $item->extension . '_' . $item->id, $item);
}
} else {
$out = nvweb_blocks_render($item->type, $item->trigger, $item->action, NULL, NULL, $tag['attributes']);
}
示例2: get_replies
public function get_replies($recursive = true)
{
global $DB;
$out = array();
// replies are always ordered by ascending date creation
$DB->query('
SELECT nvc.*, nvwu.username, nvwu.avatar
FROM nv_comments nvc
LEFT OUTER JOIN nv_webusers nvwu
ON nvwu.id = nvc.user
WHERE nvc.reply_to = ' . $this->id . ' AND
nvc.website = ' . $this->website . ' AND
nvc.status = 0
ORDER BY nvc.date_created ASC');
$rs = $DB->result();
if ($recursive) {
for ($r = 0; $r < count($rs); $r++) {
$c = new comment();
$c->load_from_resultset(array($rs[$r]));
$replies = $c->get_replies();
$out[] = $rs[$r];
if (!empty($replies)) {
foreach ($replies as $reply) {
$out[] = $reply;
}
}
}
} else {
$out = $rs;
}
return $out;
}
示例3: nvweb_comments_list
function nvweb_comments_list($offset = 0, $limit = NULL, $permission = NULL, $order = 'oldest')
{
global $DB;
global $website;
global $current;
$limit = value_or_default($limit, 2147483647);
if ($order == 'newest' || $order == 'hierarchy_newest') {
$orderby = "nvc.date_created DESC";
} else {
$orderby = "nvc.date_created ASC";
}
$element = $current['object'];
if ($current['type'] == 'structure') {
if (empty($current['structure_elements'])) {
$current['structure_elements'] = $element->elements();
}
$element = $current['structure_elements'][0];
} else {
if ($current['type'] == 'item') {
$element = new item();
$element->load($current['id']);
}
}
if (strpos($order, 'hierarchy') !== false) {
// list comments keeping hierarchy
// MySQL (still) does not have recursive queries, meanwhile we apply the following procedure:
// find all comments of 0-depth (root level) and calculate if they have any reply
// then, in PHP, parse the results and load (recursively) all replies and subreplies
// in the result array, INSERT the additional results in the position where they must be respecting the order requested (oldest/newest)
// note 1: this procedure allows optimization, for now we've made it work
// note 2: the only drawback is that offset/limit it's only taken into account for the root level comments, so the
// number of results is variable on each request; we found that an acceptable drawback
$DB->query('
SELECT SQL_CALC_FOUND_ROWS nvc.*, nvwu.username, nvwu.avatar,
(SELECT COUNT(nvcr.id)
FROM nv_comments nvcr
WHERE nvcr.reply_to = nvc.id
AND nvcr.status = 0
) AS replies
FROM nv_comments nvc
LEFT OUTER JOIN nv_webusers nvwu
ON nvwu.id = nvc.user
WHERE nvc.website = ' . protect($website->id) . '
AND nvc.item = ' . protect($element->id) . '
AND nvc.status = 0
AND nvc.reply_to = 0
ORDER BY ' . $orderby . '
LIMIT ' . $limit . '
OFFSET ' . $offset);
$rs = $DB->result();
$out = array();
for ($r = 0; $r < count($rs); $r++) {
$rows_to_add = array();
if ($rs[$r]->replies > 0) {
$c = new comment();
$c->load_from_resultset(array($rs[$r]));
$rows_to_add = $c->get_replies();
}
$out[] = $rs[$r];
if (!empty($rows_to_add)) {
foreach ($rows_to_add as $rta) {
$out[] = $rta;
}
}
}
$rs = $out;
$total = count($rs);
} else {
$DB->query('
SELECT SQL_CALC_FOUND_ROWS nvc.*, nvwu.username, nvwu.avatar
FROM nv_comments nvc
LEFT OUTER JOIN nv_webusers nvwu
ON nvwu.id = nvc.user
WHERE nvc.website = ' . protect($website->id) . '
AND nvc.item = ' . protect($element->id) . '
AND nvc.status = 0
ORDER BY ' . $orderby . '
LIMIT ' . $limit . '
OFFSET ' . $offset);
$rs = $DB->result();
$total = $DB->foundRows();
}
return array($rs, $total);
}