本文整理汇总了PHP中item::load方法的典型用法代码示例。如果您正苦于以下问题:PHP item::load方法的具体用法?PHP item::load怎么用?PHP item::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::load方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nvweb_content
function nvweb_content($vars = array())
{
global $website;
global $DB;
global $current;
global $template;
global $structure;
$out = '';
switch (@$vars['mode']) {
case 'title':
if ($current['type'] == 'structure') {
$rs = nvweb_content_items($current['object']->id, true, 1);
$texts = webdictionary::load_element_strings('item', $rs[0]->id);
$out = $texts[$current['lang']]['title'];
} else {
$texts = webdictionary::load_element_strings($current['type'], $current['object']->id);
$out = $texts[$current['lang']]['title'];
}
if (!empty($vars['function'])) {
eval('$out = ' . $vars['function'] . '("' . $out . '");');
}
break;
case 'date':
case 'date_post':
$ts = $current['object']->date_to_display;
// if no date, return nothing
if (!empty($ts)) {
$out = nvweb_content_date_format(@$vars['format'], $ts);
}
break;
case 'date_created':
$ts = $current['object']->date_created;
$out = $vars['format'];
$out = nvweb_content_date_format($out, $ts);
break;
case 'comments':
// display published comments number for the current item
$out = nvweb_content_comments_count();
break;
case 'views':
$out = $current['object']->views;
break;
case 'summary':
$length = 300;
$allowed_tags = array();
if (!empty($vars['length'])) {
$length = intval($vars['length']);
}
$texts = webdictionary::load_element_strings('item', $current['object']->id);
$text = $texts[$current['lang']]['main'];
if (!empty($vars['allowed_tags'])) {
$allowed_tags = explode(',', $vars['allowed_tags']);
}
$out = core_string_cut($text, 300, '…', $allowed_tags);
break;
case 'author':
if (!empty($current['object']->author)) {
$nu = new user();
$nu->load($current['object']->author);
$out = $nu->username;
unset($nu);
}
if (empty($out)) {
$out = $website->name;
}
break;
case 'structure':
// force loading structure data
nvweb_menu();
$structure_id = 0;
if ($current['type'] == 'item') {
$structure_id = $current['object']->category;
} else {
if ($current['type'] == 'structure') {
$structure_id = $current['object']->id;
}
}
switch ($vars['return']) {
case 'path':
$out = $structure['routes'][$structure_id];
break;
case 'title':
$out = $structure['dictionary'][$structure_id];
break;
case 'action':
$out = nvweb_menu_action($structure_id);
break;
default:
}
break;
case 'tags':
$tags = array();
$search_url = nvweb_source_url('theme', 'search');
if (!empty($search_url)) {
$search_url .= '?q=';
} else {
$search_url = NVWEB_ABSOLUTE . '/nvtags?q=';
}
$ids = array();
if (empty($vars['separator'])) {
//.........这里部分代码省略.........
示例2: array
function metaWeblog_getPost($args)
{
global $DB;
global $session;
$out = array();
list($post_id, $username, $password) = $args;
$item = new item();
$item->load(intval($post_id));
$website_id = $item->website;
$website = new website();
$website->load($website_id);
// check auth
if (metaWeblog_userAllowed($username, $password, $website_id)) {
if ($item->embedding == 1) {
$link = nvweb_source_url('structure', $item->category, $session['lang']);
} else {
$link = $item->link($session['lang']);
}
$category = new structure();
$category->load($item->category);
$content = $item->dictionary[$session['lang']]['section-main'];
$content = nvweb_template_fix_download_paths($content);
if (empty($item->date_to_display)) {
$item->date_to_display = $item->date_created;
}
$out = array("postid" => $item->id, "userid" => $item->author, "dateCreated" => new IXR_Date($item->date_to_display), "category" => $item->category, "title" => $item->dictionary[$session['lang']]['title'], "description" => $content, "url" => $link, "permalink" => $link, "mt_keywords" => $item->dictionary[$session['lang']]['tags']);
} else {
$out = new IXR_Error(401, "User not allowed.");
}
return $out;
}
示例3: nvweb_route_parse
function nvweb_route_parse($route = "")
{
global $website;
global $DB;
global $current;
global $session;
global $theme;
global $events;
global $dictionary;
// node route types
if (substr($route, 0, 5) == 'node/') {
$node = substr($route, 5);
$route = 'node';
}
switch ($route) {
case 'object':
nvweb_object();
nvweb_clean_exit();
break;
case 'nvajax':
nvweb_ajax();
nvweb_clean_exit();
break;
case 'nvtags':
case 'nvsearch':
$current['template'] = 'search';
break;
case 'nv.webuser/verify':
$hash = $_REQUEST['hash'];
$email = filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL);
if (!empty($hash) && !empty($email)) {
$ok = webuser::email_verification($email, $hash);
if ($ok) {
$session['nv.webuser/verify:email_confirmed'] = time();
}
}
nvweb_clean_exit(NVWEB_ABSOLUTE . $website->homepage());
break;
case 'node':
if ($node > 0) {
$current['id'] = $node;
$DB->query('SELECT * FROM nv_items
WHERE id = ' . protect($current['id']) . '
AND website = ' . $website->id);
$current['object'] = $DB->first();
// let's count a hit (except admin)
if ($current['navigate_session'] != 1 && !nvweb_is_bot()) {
$DB->execute(' UPDATE nv_items SET views = views + 1
WHERE id = ' . $current['id'] . '
AND website = ' . $website->id);
}
$current['type'] = 'item';
$current['template'] = $current['object']->template;
if ($current['navigate_session'] == 1 && !empty($_REQUEST['template'])) {
$current['template'] = $_REQUEST['template'];
}
}
break;
case 'sitemap.xml':
nvweb_webget_load('sitemap');
echo nvweb_sitemap(array('mode' => 'xml'));
nvweb_clean_exit();
break;
// redirect to home page of the current website
// redirect to home page of the current website
case 'nvweb.home':
case 'nv.home':
header('location: ' . NVWEB_ABSOLUTE . $website->homepage());
nvweb_clean_exit();
break;
// webservice endpoint via XML-RPC calls
// webservice endpoint via XML-RPC calls
case 'xmlrpc':
$events->trigger('nvweb', 'xmlrpc', array('route' => '/' . $route));
// if no extension processes the call, use the integrated XML-RPC parser
nvweb_xmlrpc();
nvweb_clean_exit();
break;
// empty path
// empty path
case '':
case '/':
case 'nv.empty':
if ($website->empty_path_action == 'homepage_noredirect') {
$route = $website->homepage();
if (strpos($route, '/') === 0) {
$route = substr($route, 1);
}
} else {
$route = "";
$website->wrong_path_action = $website->empty_path_action;
}
// do NOT break this case, continue processing as wrong_path action
// no special route (or already processed), look for the path on navigate routing table
// do NOT break this case, continue processing as wrong_path action
// no special route (or already processed), look for the path on navigate routing table
default:
$DB->query('SELECT * FROM nv_paths
WHERE path = ' . protect('/' . $route) . '
AND website = ' . $website->id . '
//.........这里部分代码省略.........
示例4: export_sample
public static function export_sample($a_categories, $a_items, $a_block_groups, $a_blocks, $a_comments, $folder)
{
global $website;
global $theme;
global $DB;
@set_time_limit(0);
$categories = array();
$items = array();
$blocks = array();
$block_groups = array();
$comments = array();
$properties = array();
$files = array();
$settings = array();
// structure
for ($c = 0; $c < count($a_categories); $c++) {
$tmp = new structure();
$tmp->load($a_categories[$c]);
//$properties['structure'][$tmp->id] = property::load_properties_associative('structure', $tmp->template, 'structure', $tmp->id);
$properties['structure'][$tmp->id] = property::load_properties('structure', $tmp->template, 'structure', $tmp->id);
$categories[$tmp->id] = $tmp;
// add files referenced in properties
if (is_array($properties['structure'][$tmp->id])) {
foreach ($properties['structure'][$tmp->id] as $property) {
if ($property->type == 'image' || $property->type == 'file') {
$files[] = $property->value;
}
}
}
}
// comments
for ($c = 0; $c < count($a_comments); $c++) {
$tmp = new comment();
$tmp->load($a_comments[$c]);
$comments[$tmp->id] = $tmp;
}
// items
for ($i = 0; $i < count($a_items); $i++) {
$tmp = new item();
$tmp->load($a_items[$i]);
$template_id = $tmp->template;
if ($tmp->association != "free" && $tmp->embedding == 1) {
// we have to get the template set in the category of the item
$template_id = $DB->query_single('template', 'nv_structure', ' id = ' . protect($tmp->category) . ' AND website = ' . $website->id);
}
$properties['item'][$tmp->id] = property::load_properties('item', $template_id, 'item', $tmp->id);
list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files);
// add files referenced in properties
if (is_array($properties['item'][$tmp->id])) {
foreach ($properties['item'][$tmp->id] as $property) {
if ($property->type == 'image' || $property->type == 'file') {
$files[] = $property->value;
}
}
}
// add files referenced in gallery
if (is_array($tmp->galleries[0])) {
$gallery_images = array_keys($tmp->galleries[0]);
$files = array_merge($files, $gallery_images);
}
$items[$tmp->id] = $tmp;
}
// block_groups
for ($i = 0; $i < count($a_block_groups); $i++) {
$tmp = new block_group();
$tmp->load($a_block_groups[$i]);
$block_groups[$tmp->id] = $tmp;
if (is_array($tmp->blocks)) {
foreach ($tmp->blocks as $bgb) {
if ($bgb['type'] == 'block_group_block') {
$properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties($bgb['id'], $tmp->code, 'block_group_block', $bgb['id'], $bgb['uid']);
} else {
if ($bgb['type'] == 'extension') {
$properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties(NULL, $bgb['id'], "extension_block", NULL, $bgb['uid']);
}
}
}
}
// note: maybe not all blocks in the group have been selected in the "blocks" tab
// here we only export the block group definition, the block group blocks properties and the extension blocks properties, not adding anything else to export
}
// blocks
for ($i = 0; $i < count($a_blocks); $i++) {
$tmp = new block();
$tmp->load($a_blocks[$i]);
$properties['block'][$tmp->id] = property::load_properties('block', $tmp->type, 'block', $tmp->id);
list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files);
list($tmp->trigger['trigger-content'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-content'], $files);
list($tmp->trigger['trigger-html'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-html'], $files);
if (!empty($tmp->trigger['trigger-image'])) {
$files = array_merge($files, array_values($tmp->trigger['trigger-image']));
}
if (!empty($tmp->trigger['trigger-rollover'])) {
$files = array_merge($files, array_values($tmp->trigger['trigger-rollover']));
}
if (!empty($tmp->trigger['trigger-rollover-active'])) {
$files = array_merge($files, array_values($tmp->trigger['trigger-rollover-active']));
}
if (!empty($tmp->trigger['trigger-flash'])) {
$files = array_merge($files, array_values($tmp->trigger['trigger-flash']));
//.........这里部分代码省略.........
示例5: run
function run()
{
global $layout;
global $DB;
global $website;
global $theme;
global $user;
$out = '';
$item = new item();
switch ($_REQUEST['act']) {
case 'json':
case 1:
// json data retrieval & operations
switch ($_REQUEST['oper']) {
case 'del':
// remove rows
$ids = $_REQUEST['ids'];
foreach ($ids as $id) {
$item->load($id);
$item->delete();
}
echo json_encode(true);
break;
default:
// list or search
// translation of request search & order fields
switch ($_REQUEST['searchField']) {
case 'id':
$_REQUEST['searchField'] = 'i.id';
break;
case 'title':
$_REQUEST['searchField'] = 'd.text';
break;
case 'language':
$_REQUEST['searchField'] = 'd.lang';
break;
case 'category':
$_REQUEST['searchField'] = 'i.category';
break;
case 'dates':
$_REQUEST['searchField'] = 'i.date_published';
break;
case 'permission':
$_REQUEST['searchField'] = 'i.permission';
break;
default:
}
if ($_REQUEST['sidx'] == 'dates') {
$_REQUEST['sidx'] = 'i.date_published';
}
$page = intval($_REQUEST['page']);
$max = intval($_REQUEST['rows']);
$offset = ($page - 1) * $max;
$orderby = $_REQUEST['sidx'] . ' ' . $_REQUEST['sord'];
$where = ' i.website = ' . $website->id;
if ($_REQUEST['_search'] == 'true' || isset($_REQUEST['quicksearch'])) {
if (isset($_REQUEST['quicksearch'])) {
$where .= $item->quicksearch($_REQUEST['quicksearch']);
} else {
if (isset($_REQUEST['filters'])) {
if (is_array($_REQUEST['filters'])) {
$filters = json_decode(json_encode($_REQUEST['filters']), FALSE);
} else {
$filters = json_decode($_REQUEST['filters']);
}
for ($r = 0; $r < count($filters->rules); $r++) {
switch ($filters->rules[$r]->field) {
case 'id':
$filters->rules[$r]->field = 'i.id';
break;
case 'title':
$filters->rules[$r]->field = 'd.text';
break;
case 'language':
$filters->rules[$r]->field = 'd.lang';
break;
case 'category':
$filters->rules[$r]->field = 'i.category';
break;
case 'dates':
$filters->rules[$r]->field = 'i.date_published';
break;
case 'permission':
$filters->rules[$r]->field = 'i.permission';
break;
default:
}
}
$where .= navitable::jqgridsearch(json_encode($filters));
} else {
// single search
$where .= ' AND ' . navitable::jqgridcompare($_REQUEST['searchField'], $_REQUEST['searchOper'], $_REQUEST['searchString']);
}
}
}
$sql = ' SELECT SQL_CALC_FOUND_ROWS
i.*, d.text as title, d.lang as language,
u.username as author_username,
( SELECT COUNT(*)
FROM nv_comments cm
//.........这里部分代码省略.........
示例6: nvweb_gallery
function nvweb_gallery($vars = array())
{
global $website;
global $DB;
global $current;
global $webgets;
$out = '';
$webget = 'gallery';
// the request can come from a free item or from a category, so we have to load the first element available
$item = NULL;
$border = '';
if (!empty($vars['border'])) {
$border = '&border=' . $vars['border'];
}
$items = PHP_INT_MAX;
// number of images shown, 0 => all gallery photos
if (!empty($vars['items']) && $vars['items'] != '0') {
$items = intval($vars['items']);
}
$order = 'priority';
// display images using the assigned priority
if (!empty($vars['order'])) {
$order = $vars['order'];
}
if (!empty($vars['item'])) {
if (is_object($vars['item'])) {
$item = $vars['item'];
} else {
if (is_numeric($vars['item'])) {
$item = new item();
$item->load($vars['item']);
}
}
} else {
if ($current['type'] == 'item') {
// check publishing is enabled
$enabled = nvweb_object_enabled($current['object']);
if ($enabled || $_REQUEST['preview'] == 'true' && $current['navigate_session'] == 1) {
$item = $current['object'];
}
} else {
if ($current['type'] == 'structure') {
$DB->query('
SELECT id, permission, date_published, date_unpublish
FROM nv_items
WHERE category = ' . protect($current['object']->id) . '
AND website = ' . $website->id . '
');
$rs = $DB->first();
$enabled = nvweb_object_enabled($rs);
if ($enabled || $_REQUEST['preview'] == 'true' && $current['navigate_session'] == 1) {
$item = new item();
$item->load($rs->id);
}
}
}
}
if ($item == NULL) {
return '';
}
if (empty($vars['width']) && empty($vars['height'])) {
$vars['width'] = 120;
$vars['height'] = 90;
} else {
if (empty($vars['height'])) {
$vars['height'] = '';
} else {
if (empty($vars['width'])) {
$vars['width'] = '';
}
}
}
// which gallery model?
$out = array();
switch (@$vars['mode']) {
case 'image':
if (is_array($item->galleries)) {
$gallery = $item->galleries[0];
}
if (is_string($item->galleries)) {
$gallery = mb_unserialize($item->galleries);
$gallery = $gallery[0];
}
// no images in the gallery?
if (!is_array($gallery)) {
return '';
}
$gallery = nvweb_gallery_reorder($gallery, $order);
$image_ids = array_keys($gallery);
$position = intval($vars['position']);
$image_selected = $image_ids[$position];
// no image found at the requested position
if (empty($image_selected)) {
return '';
}
list($image_title, $image_description) = nvweb_gallery_image_caption($image_selected, $gallery);
if (!empty($vars['return']) && $vars['return'] == 'url') {
$out[] = NVWEB_OBJECT . '?wid=' . $website->id . '&id=' . $image_selected . '&disposition=inline';
} else {
if (!empty($vars['return']) && $vars['return'] == 'thumbnail') {
//.........这里部分代码省略.........
示例7: blocks_form
//.........这里部分代码省略.........
$options[$lang] = language::name_by_code($lang);
}
$navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', $naviforms->buttonset('language_selector', $options, $website->languages_list[0], "navigate_items_select_language(this);")));
foreach ($website->languages_list as $lang) {
$navibars->add_tab_content('
<div class="language_fields" id="language_fields_' . $lang . '" style=" display: none; ">
');
$navibars->add_tab_content_row(array('<label>' . t(558, 'Question') . '</label>', $naviforms->textfield('title-' . $lang, @$item->dictionary[$lang]['title']), ''));
// Poll options
$table = new naviorderedtable("poll_answers_table_" . $lang);
$table->setWidth("330px");
$table->setHiddenInput("poll-answers-table-order-" . $lang);
$navibars->add_tab_content($naviforms->hidden("poll-answers-table-order-" . $lang, ""));
$table->addHeaderColumn(t(67, 'Title'), 200);
//$table->addHeaderColumn(t(237, 'Code'), 120);
$table->addHeaderColumn(t(352, 'Votes'), 80);
$table->addHeaderColumn(t(35, 'Remove'), 50);
if (!empty($item->trigger[$lang])) {
$poll_answers = $item->trigger[$lang];
foreach ($poll_answers as $pa) {
$uid = uniqid();
$table->addRow("poll-answers-table-row-" . $uid, array(array('content' => '<input type="text" name="poll-answers-table-title-' . $lang . '[' . $uid . ']" value="' . $pa['title'] . '" style="width: 200px;" />', 'align' => 'left'), array('content' => '<input type="text" name="poll-answers-table-votes-' . $lang . '[' . $uid . ']" value="' . intval($pa['votes']) . '" style="width: 80px;" />', 'align' => 'left'), array('content' => '<img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" style="cursor: pointer;" onclick="navigate_blocks_poll_answers_table_row_remove(this);" />', 'align' => 'center')));
}
}
$uid = uniqid();
$table->addRow("poll-answers-table-row-model-" . $lang, array(array('content' => '<input type="text" name="poll-answers-table-title-' . $lang . '[' . $uid . ']" value="" style="width: 200px;" />', 'align' => 'left'), array('content' => '<input type="text" name="poll-answers-table-votes-' . $lang . '[' . $uid . ']" value="0" style="width: 80px;" />', 'align' => 'left'), array('content' => '<img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" style="cursor: pointer;" onclick="navigate_blocks_poll_answers_table_row_remove(this);" />', 'align' => 'center')));
$navibars->add_tab_content_row(array('<label>' . t(559, "Answers") . '</label>', '<div id="poll-answers-' . $lang . '">' . $table->generate() . '</div>', '<label> </label>', '<button id="poll-answers-table-add-' . $lang . '" data-lang="' . $lang . '"><img src="img/icons/silk/add.png" align="absmiddle" style="cursor:pointer;" /> ' . t(472, 'Add') . '</button>'));
$navibars->add_tab_content('
</div>
');
}
foreach ($website->languages_list as $alang) {
$layout->add_script('
$(window).on("load", function()
{
poll_answers_table_row_models["' . $alang . '"] = $("#poll-answers-table-row-model-' . $alang . '").html();
if($("#poll_answers_table_' . $alang . '").find("tr").not(".nodrag").length > 1)
$("#poll-answers-table-row-model-' . $alang . '").hide();
navigate_naviorderedtable_poll_answers_table_' . $alang . '_reorder();
});
');
}
$layout->add_script('
var active_languages = ["' . implode('", "', array_keys($options)) . '"];
navigate_items_select_language("' . $website->languages_list[0] . '");
');
break;
case 'block':
case 'theme':
default:
$options = array();
foreach ($website->languages_list as $lang) {
$options[$lang] = language::name_by_code($lang);
}
$navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', $naviforms->buttonset('language_selector', $options, $website->languages_list[0], "navigate_items_select_language(this);")));
foreach ($website->languages_list as $lang) {
$navibars->add_tab_content('<div class="language_fields" id="language_fields_' . $lang . '" style=" display: none; ">');
$navibars->add_tab_content_row(array('<label>' . t(67, 'Title') . '</label>', $naviforms->textfield('title-' . $lang, @$item->dictionary[$lang]['title']), ''));
$block_trigger_types = array('' => t(181, 'Hidden'), 'title' => t(67, 'Title'), 'content' => t(9, 'Content'), 'image' => t(157, 'Image'), 'rollover' => t(182, 'Rollover'), 'video' => t(272, 'Video'), 'html' => 'HTML', 'links' => t(549, 'Links'), 'flash' => 'Flash');
// check block trigger restrictions in theme definition
if (is_array($theme->blocks)) {
foreach ($theme->blocks as $tb) {
if ($tb->code == $item->type && isset($tb->trigger)) {
if (!is_array($tb->trigger)) {
$tb->trigger = array($tb->trigger);
}
示例8: nvweb_list
//.........这里部分代码省略.........
$total = $DB->foundRows();
} else {
if ($vars['source'] == 'block') {
list($rs, $total) = nvweb_blocks(array('type' => $vars['type'], 'number' => $vars['items'], 'mode' => $order == 'random' ? 'random' : 'ordered', 'zone' => 'object'));
} else {
if ($vars['source'] == 'block_link') {
// only useful if this nvlist is inside another nv list of source="block"
$block_links = $vars['nvlist_parent_item']->trigger['trigger-links'][$current['lang']];
$rs = array();
if (!is_array($block_links)) {
$block_links = array();
}
foreach ($block_links as $b_key => $b_data) {
if (!is_array($b_data)) {
$b_data = array();
}
$b_i = 0;
foreach ($b_data as $b_ref => $b_value) {
if (!isset($rs[$b_i])) {
$rs[$b_i] = new stdClass();
}
if (!isset($rs[$b_i]->id)) {
$rs[$b_i]->id = $b_ref;
}
$rs[$b_i]->{$b_key} = $b_value;
$b_i++;
}
}
$total = count($rs);
} else {
if ($vars['source'] == 'block_group') {
$bg = new block_group();
if (!empty($vars['type'])) {
$bg->load_by_code($vars['type']);
}
if (!empty($bg) && !empty($bg->blocks)) {
$rs = array();
foreach ($bg->blocks as $bgb) {
unset($bgbo);
switch ($bgb['type']) {
case 'block':
$bgbo = new block();
$bgbo->load($bgb['id']);
if (empty($bgbo) || empty($bgbo->type)) {
continue;
}
// check if we can display this block
if (nvweb_object_enabled($bgbo)) {
// check categories / exclusions
if (!empty($bgbo->categories)) {
$bgbo_cat_found = false;
foreach ($categories as $list_cat) {
if (in_array($list_cat, $bgbo->categories)) {
$bgbo_cat_found = true;
}
}
if (!$bgbo_cat_found) {
// block categories don't match the current list categories, skip this block
continue;
}
}
if (!empty($bgbo->exclusions)) {
foreach ($categories as $list_cat) {
if (in_array($list_cat, $bgbo->exclusions)) {
continue;
}
示例9: nvweb_search
//.........这里部分代码省略.........
SELECT SQL_CALC_FOUND_ROWS rs.id
FROM (
SELECT i.id as id, i.permission, i.date_published, i.date_unpublish,
i.date_to_display, COALESCE(NULLIF(i.date_to_display, 0), i.date_created) as pdate,
i.position as position, wd.text as title
FROM nv_items i, nv_webdictionary d
LEFT JOIN nv_webdictionary wd
ON wd.node_id = d.node_id
AND wd.lang = ' . protect($current['lang']) . '
AND wd.node_type = "item"
AND wd.website = ' . protect($website->id) . '
WHERE i.website = ' . $website->id . '
AND i.permission <= ' . $permission . '
AND (i.date_published = 0 OR i.date_published < ' . core_time() . ')
AND (i.date_unpublish = 0 OR i.date_unpublish > ' . core_time() . ')
AND (i.access = 0 OR i.access = ' . $access . ')
AND d.website = ' . protect($website->id) . '
AND d.node_id = i.id
AND d.lang = ' . protect($current['lang']) . '
AND (d.node_type = "item" OR d.node_type = "tags")
AND (
' . implode(' AND ', $likes) . '
)
' . (empty($categories) ? '' : 'AND category IN(' . implode(",", $categories) . ')') . '
' . $orderby . '
) rs
GROUP BY rs.id
LIMIT ' . $vars['items'] . '
OFFSET ' . $offset);
$rs = $DB->result();
$total = $DB->foundRows();
for ($i = 0; $i < count($rs); $i++) {
if (empty($rs[$i]->id)) {
break;
}
$item = new item();
$item->load($rs[$i]->id);
// get the nv list template
$item_html = $vars['template'];
// now, parse the nvlist_conditional tags (with html source code inside (and other nvlist tags))
unset($nested_condition_fragments);
list($item_html, $nested_conditional_fragments) = nvweb_list_isolate_conditionals($item_html);
$conditional_placeholder_tags = nvweb_tags_extract($item_html, 'nvlist_conditional_placeholder', true, true, 'UTF-8');
// selfclosing = true
while (!empty($conditional_placeholder_tags)) {
$tag = $conditional_placeholder_tags[0];
$conditional = $nested_conditional_fragments[$tag["attributes"]["id"]];
$conditional_html_output = nvweb_list_parse_conditional($conditional, $item, $conditional['nvlist_conditional_template'], $i, count($rs));
$item_html = str_replace($tag["full_tag"], $conditional_html_output, $item_html);
$conditional_placeholder_tags = nvweb_tags_extract($item_html, 'nvlist_conditional_placeholder', true, true, 'UTF-8');
// selfclosing = true
}
// now parse the (remaining) common nvlist tags
$template_tags = nvweb_tags_extract($item_html, 'nvlist', true, true, 'UTF-8');
// selfclosing = true
if (empty($item_html)) {
$item_html = array();
$item_html[] = '<div class="search-result-item">';
$item_html[] = ' <div class="search-result-title"><a href="' . $website->absolute_path() . $item->paths[$current['lang']] . '">' . $item->dictionary[$current['lang']]['title'] . '</a></div>';
$item_html[] = ' <div class="search-result-summary">' . core_string_cut($item->dictionary[$current['lang']]['section-main'], 300, '…') . '</div>';
$item_html[] = '</div>';
$item_html = implode("\n", $item_html);
$out[] = $item_html;
} else {
// parse special template tags
foreach ($template_tags as $tag) {
$content = nvweb_list_parse_tag($tag, $item, $vars['source'], $i, $i + $offset, $total);
$item_html = str_replace($tag['full_tag'], $content, $item_html);
}
$out[] = $item_html;
}
}
if ($total == 0) {
$search_results_empty_text = $theme->t("no_results_found");
if (isset($vars['no_results_found'])) {
$search_results_empty_text = $theme->t($vars["no_results_found"]);
}
if (empty($search_results_empty_text) || $search_results_empty_text == 'no_results_found') {
$search_results_empty_text = t(645, "No results found");
}
// display the error message only if
// 1) it's not empty
// 2) the template is preventing the display of any error message in the search ( no_results_found="" )
if (!empty($search_results_empty_text) && (!isset($vars['no_results_found']) || isset($vars['no_results_found']) && !empty($vars['no_results_found']))) {
$out[] = '<div class="search-results-empty">';
$out[] = $search_results_empty_text;
$out[] = '</div>';
}
}
$archive = $_REQUEST['archive'];
if (!empty($archive)) {
$archive = 'archive=' . $archive . '&';
}
if (isset($vars['paginator']) && $vars['paginator'] != 'false') {
$search_url = '?' . $archive . $vars['request'] . '=' . $_REQUEST[$vars['request']] . '&page=';
$out[] = nvweb_list_paginator($vars['paginator'], $_GET['page'], $total, $vars['items'], $vars, $search_url);
}
}
return implode("\n", $out);
}
示例10: nvweb_properties_render
//.........这里部分代码省略.........
break;
case 'image':
$add = '';
$extra = '';
if (@$property->multilanguage == 'true' || $property->multilanguage == '1') {
$image_id = $property->value[$session['lang']];
} else {
$image_id = $property->value;
}
if (isset($vars['width'])) {
$add .= ' width="' . $vars['width'] . '" ';
$extra .= '&width=' . $vars['width'];
}
if (isset($vars['height'])) {
$add .= ' height="' . $vars['height'] . '" ';
$extra .= '&height=' . $vars['height'];
}
if (isset($vars['border'])) {
$extra .= '&border=' . $vars['border'];
}
if (isset($vars['quality'])) {
$extra .= '&quality=' . $vars['quality'];
}
$img_url = NVWEB_OBJECT . '?type=image&id=' . $image_id . $extra;
if (empty($image_id)) {
$out = '';
} else {
if ($vars['return'] == 'url') {
$out = $img_url;
} else {
// retrieve additional info (title/alt), if available
if (is_numeric($image_id)) {
$f = new file();
$f->load($image_id);
$ftitle = $f->title[$current['lang']];
$falt = $f->description[$current['lang']];
if (!empty($ftitle)) {
$add .= ' title="' . $ftitle . '" ';
}
if (!empty($falt)) {
$add .= ' alt="' . $falt . '" ';
}
}
$out = '<img class="' . $vars['class'] . '" src="' . $img_url . '" ' . $add . ' />';
}
}
break;
case 'file':
if (!empty($property->value)) {
$file = $DB->query_single('name', 'nv_files', ' id = ' . protect($property->value) . ' AND website = ' . $website->id);
if ($vars['return'] == 'url' || $vars['return'] == 'url-download') {
$out = NVWEB_OBJECT . '?type=file&id=' . $property->value . '&disposition=attachment';
} else {
if ($vars['return'] == 'url-inline') {
$out = NVWEB_OBJECT . '?type=file&id=' . $property->value . '&disposition=inline';
} else {
$out = '<a href="' . NVWEB_OBJECT . '?type=file&id=' . $property->value . '&disposition=attachment">' . $file . '</a>';
}
}
}
break;
case 'comment':
$out = $property->value;
break;
case 'coordinates':
$coordinates = explode('#', $property->value);
示例11: item
// include some utils functions
include_once get_module_path('CLLP') . '/lib/utils.lib.php';
require_once get_module_path('CLLP') . '/lib/item.class.php';
if ($totalGrade > 0) {
$scoreRaw = $totalResult / $totalGrade * 100;
$scoreMin = 0;
$scoreMax = 100;
} else {
$scoreRaw = $scoreMin = $scoreMax = 0;
$completionStatus = 'incomplete';
}
$completionStatus = 'incomplete';
if (isset($_SESSION['thisItemId'])) {
$itemId = (int) $_SESSION['thisItemId'];
$item = new item();
if ($item->load($itemId)) {
if ($scoreRaw >= (int) $item->getCompletionThreshold()) {
$completionStatus = 'completed';
}
}
}
$sessionTime = unixToScormTime($timeToCompleteExe);
$jsForLP = '' . 'doSetValue("cmi.score.raw","' . $scoreRaw . '");' . "\n" . 'doSetValue("cmi.score.min","' . $scoreMin . '");' . "\n" . 'doSetValue("cmi.score.max","' . $scoreMax . '");' . "\n" . 'doSetValue("cmi.session_time","' . $sessionTime . '");' . "\n" . 'doSetValue("cmi.completion_status","' . $completionStatus . '");' . "\n" . 'doTerminate();' . "\n";
}
// old learning path tool
if (isset($_SESSION['inPathMode']) && $_SESSION['inPathMode']) {
set_learning_path_progression($totalResult, $totalGrade, $timeToCompleteExe, claro_get_current_user_id());
}
}
} elseif (!$exerciseIsAvailable) {
$showResult = false;
示例12: 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);
}
示例13: comments_form
function comments_form($item)
{
global $DB;
global $website;
global $layout;
global $events;
global $theme;
$navibars = new navibars();
$naviforms = new naviforms();
if (empty($item->id)) {
$navibars->title(t(250, 'Comments') . ' / ' . t(38, 'Create'));
} else {
$navibars->title(t(250, 'Comments') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
}
if (empty($item->id)) {
$navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
} else {
$navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>'));
$delete_html = array();
$delete_html[] = '<div id="navigate-delete-dialog" class="hidden">' . t(57, 'Do you really want to delete this item?') . '</div>';
$delete_html[] = '<script language="javascript" type="text/javascript">';
$delete_html[] = 'function navigate_delete_dialog()';
$delete_html[] = '{';
$delete_html[] = '$("#navigate-delete-dialog").removeClass("hidden");';
$delete_html[] = '$("#navigate-delete-dialog").dialog({
resizable: true,
height: 150,
width: 300,
modal: true,
title: "' . t(59, 'Confirmation') . '",
buttons: {
"' . t(35, 'Delete') . '": function() {
$(this).dialog("close");
window.location.href = "?fid=' . $_REQUEST['fid'] . '&act=remove&id=' . $item->id . '";
},
"' . t(58, 'Cancel') . '": function() {
$(this).dialog("close");
}
}
});';
$delete_html[] = '}';
$delete_html[] = '</script>';
$navibars->add_content(implode("\n", $delete_html));
}
$navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=comments&act=edit"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=comments&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
$navibars->form();
$navibars->add_tab(t(43, "Main"));
$navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
$navibars->add_tab_content($naviforms->hidden('id', $item->id));
$navibars->add_tab_content_row(array('<label>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
$navibars->add_tab_content($naviforms->hidden('comment-item', $item->item));
if ($item->item > 0) {
$content = new item();
$content->load($item->item);
$title = $content->dictionary[$website->languages_list[0]]['title'];
}
$navibars->add_tab_content_row(array('<label>' . t(180, 'Item') . '</label>', $naviforms->textfield('comment-item-text', $title)));
$layout->add_script('
$("#comment-item-text").autocomplete(
{
source: function(request, response)
{
var toFind = {
"title": request.term,
"lang": "' . $website->languages[0] . '",
nd: new Date().getTime()
};
$.ajax(
{
url: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=' . $_REQUEST['fid'] . '&act=91",
dataType: "json",
method: "GET",
data: toFind,
success: function( data )
{
response( data );
}
});
},
minLength: 1,
select: function(event, ui)
{
$("#comment-item").val(ui.item.id);
}
});
');
$webuser_id = '';
if (!empty($item->user)) {
$webuser_username = $DB->query_single('username', 'nv_webusers', ' id = ' . $item->user);
if (!empty($webuser_username)) {
$webuser_username = array($webuser_username);
$webuser_id = array($item->user);
}
}
$navibars->add_tab_content_row(array('<label>' . t(1, 'User') . '</label>', $naviforms->selectfield('comment-user', $webuser_id, $webuser_username, $item->user, null, false, null, null, false), '<span style="display: none;" id="comment-user-helper">' . t(535, "Find user by name") . '</span>'));
$layout->add_script('
$("#comment-user").select2(
{
placeholder: $("#comment-user-helper").text(),
//.........这里部分代码省略.........
示例14: nvweb_conditional
function nvweb_conditional($vars = array())
{
global $website;
global $DB;
global $current;
global $cache;
global $structure;
global $webgets;
global $webuser;
$out = array();
$webget = 'conditional';
$categories = array();
$item = new item();
if ($current['type'] == 'item') {
$item->load($current['object']->id);
$item_type = 'element';
} else {
$item_type = 'structure';
if (isset($vars['scope']) && $vars['scope'] == 'element') {
// the current path belongs to a structure category, but the template is asking for an element value,
// so we try to find the first element assigned to the current category
$categories = array();
if (!empty($current['object']->id)) {
$categories = array($current['object']->id);
}
if (isset($vars['categories'])) {
$categories = explode(',', $vars['categories']);
$categories = array_filter($categories);
// remove empty elements
}
$permission = !empty($_SESSION['APP_USER#' . APP_UNIQUE]) ? 1 : 0;
// public access / webuser based / webuser groups based
$access = 2;
$access_extra = '';
if (!empty($current['webuser'])) {
$access = 1;
if (!empty($webuser->groups)) {
$access_groups = array();
foreach ($webuser->groups as $wg) {
if (empty($wg)) {
continue;
}
$access_groups[] = 's.groups LIKE "%g' . $wg . '%"';
}
if (!empty($access_groups)) {
$access_extra = ' OR (s.access = 3 AND (' . implode(' OR ', $access_groups) . '))';
}
}
}
// get order type: PARAMETER > NV TAG PROPERTY > DEFAULT (priority given in CMS)
$order = @$_REQUEST['order'];
if (empty($order)) {
$order = @$vars['order'];
}
if (empty($order)) {
// default order: latest
$order = 'latest';
}
$orderby = nvweb_list_get_orderby($order);
$rs = NULL;
$access_extra_items = str_replace('s.', 'i.', $access_extra);
if (empty($categories)) {
// force executing the query; search in all categories
$categories = nvweb_menu_get_children(array(0));
}
// default source for retrieving items
$DB->query('
SELECT SQL_CALC_FOUND_ROWS i.id, i.permission, i.date_published, i.date_unpublish,
i.date_to_display, COALESCE(NULLIF(i.date_to_display, 0), i.date_created) as pdate,
d.text as title, i.position as position
FROM nv_items i, nv_structure s, nv_webdictionary d
WHERE i.category IN(' . implode(",", $categories) . ')
AND i.website = ' . $website->id . '
AND i.permission <= ' . $permission . '
AND (i.date_published = 0 OR i.date_published < ' . core_time() . ')
AND (i.date_unpublish = 0 OR i.date_unpublish > ' . core_time() . ')
AND s.id = i.category
AND (s.date_published = 0 OR s.date_published < ' . core_time() . ')
AND (s.date_unpublish = 0 OR s.date_unpublish > ' . core_time() . ')
AND s.permission <= ' . $permission . '
AND (s.access = 0 OR s.access = ' . $access . $access_extra . ')
AND (i.access = 0 OR i.access = ' . $access . $access_extra_items . ')
AND d.website = i.website
AND d.node_type = "item"
AND d.subtype = "title"
AND d.node_id = i.id
AND d.lang = ' . protect($current['lang']) . '
' . $orderby . '
LIMIT 1
OFFSET 0');
$rs = $DB->result();
// now we have the element against which the condition will be checked
$i = 0;
$item->load($rs[$i]->id);
$item_type = 'element';
} else {
if (!isset($vars['scope']) || $vars['scope'] == 'structure') {
$item = $current['object'];
$item_type = 'structure';
}
//.........这里部分代码省略.........