* @author The SmartFactory * @version $Id: item.php 339 2011-12-07 00:09:26Z lusopoemas@gmail.com $ */ include_once dirname(__FILE__) . '/header.php'; $itemid = SmartsectionRequest::getInt('itemid'); $item_page_id = SmartsectionRequest::getInt('page', -1); if ($itemid == 0) { redirect_header("javascript:history.go(-1)", 1, _MD_SMARTSECTION_NOITEMSELECTED); exit(); } // Creating the item object for the selected item $itemObj = $smartsection->getHandler('item')->get($itemid); // if the selected item was not found, exit if (!$itemObj) { redirect_header("javascript:history.go(-1)", 1, _MD_SMARTSECTION_NOITEMSELECTED); exit(); } $xoopsOption['template_main'] = 'smartsection_item.html'; include_once XOOPS_ROOT_PATH . '/header.php'; $xoTheme->addStylesheet(SMARTSECTION_URL . '/css/jquery.popeye.style.css'); $xoTheme->addStylesheet(XOOPS_URL . '/themes/hinduism/css/epubstyles.css'); $xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); $xoTheme->addScript(SMARTSECTION_URL . '/js/jquery.popeye-2.0.4.js'); $xoTheme->addScript(SMARTSECTION_URL . '/js/smartsection.js'); include_once SMARTSECTION_ROOT_PATH . '/footer.php'; // Creating the category object that holds the selected item $categoryObj = $smartsection->getHandler('category')->get($itemObj->categoryid()); // Check user permissions to access that category of the selected item if (!$itemObj->accessGranted()) { redirect_header("javascript:history.go(-1)", 1, _NOPERM); exit; } // Update the read counter of the selected item if (!$xoopsUser || ($xoopsUser->isAdmin($smartsection->getModule()->mid()) && $smartsection->getConfig('item_admin_hits') == 1) || ($xoopsUser && !$xoopsUser->isAdmin($smartsection->getModule()->mid()))) { $itemObj->updateCounter(); } // creating the Item objects that belong to the selected category switch ($smartsection->getConfig('format_order_by')) { case 'title' : $sort = 'title'; $order = 'ASC'; break; case 'date' : $sort = 'datesub'; $order = 'DESC'; break; default : $sort = 'weight'; $order = 'ASC'; break; } if ($smartsection->getConfig('item_other_items_type') == "previous_next") { // Retreiving the next and previous object $previous_item_link = ''; $previous_item_url = ''; $next_item_link = ''; $next_item_url = ''; $previousObj = $smartsection->getHandler('item')->getPreviousPublished($itemObj); $nextObj = $smartsection->getHandler('item')->getNextPublished($itemObj); if (is_object($previousObj)) { $previous_item_link = $previousObj->getItemLink(); $previous_item_url = $previousObj->getItemUrl(); } if (is_object($nextObj)) { $next_item_link = $nextObj->getItemLink(); $next_item_url = $nextObj->getItemUrl(); } unset($previousObj, $nextObj); $xoopsTpl->assign('previous_item_link', $previous_item_link); $xoopsTpl->assign('next_item_link', $next_item_link); $xoopsTpl->assign('previous_item_url', $previous_item_url); $xoopsTpl->assign('next_item_url', $next_item_url); } //CAREFUL!! with many items this will exhaust memory if ($smartsection->getConfig('item_other_items_type') == "all") { $itemsObj = $smartsection->getHandler('item')->getAllPublished(0, 0, $categoryObj->categoryid(), $sort, $order, '', true, true); $items = array(); foreach ($itemsObj as $theitemObj) { $theitem['titlelink'] = $theitemObj->getItemLink(); $theitem['datesub'] = $theitemObj->datesub(); $theitem['counter'] = $theitemObj->counter(); if ($theitemObj->itemid() == $itemObj->itemid()) { $theitem['titlelink'] = $theitemObj->title(); } $items[] = $theitem; unset($theitem); } unset($itemsObj); $xoopsTpl->assign('items', $items); } // Populating the smarty variables with informations related to the selected item $item = $itemObj->toArray($item_page_id); $xoopsTpl->assign('show_subtitle', $smartsection->getConfig('item_disp_subtitle')); if ($itemObj->pagescount() > 0) { if ($item_page_id == -1) { $item_page_id = 0; } include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; $pagenav = new XoopsPageNav($itemObj->pagescount(), 1, $item_page_id, 'page', 'itemid=' . $itemObj->itemid()); $xoopsTpl->assign('pagenav', $pagenav->renderNav()); } // Creating the files object associated with this item $file = array(); $files = array(); $embeded_files = array(); $filesObj = $itemObj->getFiles(); foreach ($filesObj as $fileObj) { if ($fileObj->mimetype() == 'application/x-shockwave-flash') { $file['content'] = $fileObj->displayFlash(); if (strpos($item['maintext'], '[flash-' . $fileObj->getVar('fileid') . ']')) { $item['maintext'] = str_replace('[flash-' . $fileObj->getVar('fileid') . ']', $file['content'], $item['maintext']); } else { $embeded_files[] = $file; } } else { $file['fileid'] = $fileObj->fileid(); $file['name'] = $fileObj->name(); $file['description'] = $fileObj->description(); $file['name'] = $fileObj->name(); $file['type'] = $fileObj->mimetype(); $file['datesub'] = $fileObj->datesub(); $file['hits'] = $fileObj->counter(); $files[] = $file; } } $item['files'] = $files; $item['embeded_files'] = $embeded_files; unset($file, $embeded_files, $filesObj, $fileObj); // Language constants $xoopsTpl->assign('mail_link', 'mailto:?subject=' . sprintf(_CO_SMARTSECTION_INTITEM, $xoopsConfig['sitename']) . '&body=' . sprintf(_CO_SMARTSECTION_INTITEMFOUND, $xoopsConfig['sitename']) . ': ' . $itemObj->getItemUrl()); $xoopsTpl->assign('itemid', $itemObj->itemid()); $xoopsTpl->assign('sectionname', $smartsection->getModule()->getVar('name')); $xoopsTpl->assign('modulename', $smartsection->getModule()->getVar('dirname')); $xoopsTpl->assign('module_home', smartsection_moduleHome($smartsection->getConfig('format_linked_path'))); $xoopsTpl->assign('categoryPath', $item['categoryPath'] . " > " . $item['title']); $xoopsTpl->assign('commentatarticlelevel', $smartsection->getConfig('perm_com_art_level')); $xoopsTpl->assign('com_rule', $smartsection->getConfig('com_rule')); $xoopsTpl->assign('other_items', $smartsection->getConfig('item_other_items_type')); $xoopsTpl->assign('itemfooter', $myts->displayTarea($smartsection->getConfig('item_footer'), 1)); $xoopsTpl->assign('perm_author_items', $smartsection->getConfig('perm_author_items')); // tags support if (xoops_isActiveModule('tag')) { include_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php'; $xoopsTpl->assign('tagbar', tagBar($itemid, $catid = 0)); } /** * Generating meta information for this page */ $smartsection_metagen = new SmartsectionMetagen($itemObj->getVar('title'), $itemObj->getVar('meta_keywords', 'n'), $itemObj->getVar('meta_description', 'n'), $itemObj->getCategoryPath()); $smartsection_metagen->createMetaTags(); // Include the comments if the selected ITEM supports comments if ((($itemObj->cancomment() == 1) || !$smartsection->getConfig('perm_com_art_level')) && ($smartsection->getConfig('com_rule') <> 0)) { include_once XOOPS_ROOT_PATH . "/include/comment_view.php"; // Problem with url_rewrite and posting comments : $xoopsTpl->assign(array( 'editcomment_link' => SMARTSECTION_URL . '/comment_edit.php?com_itemid=' . $com_itemid . '&com_order=' . $com_order . '&com_mode=' . $com_mode . $link_extra, 'deletecomment_link' => SMARTSECTION_URL . '/comment_delete.php?com_itemid=' . $com_itemid . '&com_order=' . $com_order . '&com_mode=' . $com_mode . $link_extra, 'replycomment_link' => SMARTSECTION_URL . '/comment_reply.php?com_itemid=' . $com_itemid . '&com_order=' . $com_order . '&com_mode=' . $com_mode . $link_extra)); $xoopsTpl->_tpl_vars['commentsnav'] = str_replace("self.location.href='", "self.location.href='" . SMARTSECTION_URL . '/', $xoopsTpl->_tpl_vars['commentsnav']); } // Include support for AJAX rating if ($smartsection->getConfig('perm_rating')) { $xoopsTpl->assign('rating_enabled', true); $item['ratingbar'] = smartsection_ratingBar($itemid); $xoTheme->addScript(SMARTSECTION_URL . '/js/behavior.js'); $xoTheme->addScript(SMARTSECTION_URL . '/js/rating.js'); } $xoopsTpl->assign('item', $item); include_once XOOPS_ROOT_PATH . '/footer.php';