function _processSave(&$controller, &$xoopsUser) { $statusArr = $this->mActionForm->get('status'); $comment_handler = xoops_gethandler('comment'); foreach (array_keys($statusArr) as $cid) { $comment =& $comment_handler->get($cid); if (is_object($comment)) { $olddata['com_status'] = $comment->get('com_status'); $newdata['com_status'] = $this->mActionForm->get('status', $cid); if (count(array_diff_assoc($olddata, $newdata)) > 0) { $comment->set('com_status', $this->mActionForm->get('status', $cid)); if (!$comment_handler->insert($comment)) { return LEGACY_FRAME_VIEW_ERROR; } $add_userpost = false; $call_approvefunc = false; $call_updatefunc = false; $notify_event = false; if (!empty($newdata['com_status']) && $newdata['com_status'] != XOOPS_COMMENT_PENDING) { if (XOOPS_COMMENT_PENDING == $olddata['com_status']) { $add_userpost = true; if (XOOPS_COMMENT_ACTIVE == $newdata['com_status']) { $call_updatefunc = true; $call_approvefunc = true; $notify_event = 'comment'; } } elseif (XOOPS_COMMENT_HIDDEN == $olddata['com_status'] && XOOPS_COMMENT_ACTIVE == $newdata['com_status']) { $call_updatefunc = true; } elseif (XOOPS_COMMENT_ACTIVE == $olddata['com_status'] && XOOPS_COMMENT_HIDDEN == $newdata['com_status']) { $call_updatefunc = true; } } $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment); if ($comment_config && $call_approvefunc != false) { $function = $comment_config['callback']['approve']; if (function_exists($function)) { call_user_func($function, $comment); } } if ($comment_config && $call_updatefunc != false) { $function = $comment_config['callback']['update']; if (function_exists($function)) { $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->getVar('com_modid'))); $criteria->add(new Criteria('com_itemid', $comment->getVar('com_itemid'))); $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); $comment_count = $comment_handler->getCount($criteria); call_user_func_array($function, array($comment->getVar('com_itemid'), $comment_count, $comment->getVar('com_id'))); } } $uid = $comment->getVar('com_uid'); if ($uid > 0 && false != $add_userpost) { $member_handler =& xoops_gethandler('member'); $poster =& $member_handler->getUser($uid); if (is_object($poster)) { $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') + 1); } } //notification // RMV-NOTIFY // trigger notification event if necessary if ($notify_event) { $not_modid = $comment->getVar('com_modid'); include_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; $not_catinfo =& notificationCommentCategoryInfo($not_modid); $not_category = $not_catinfo['name']; $not_itemid = $comment->getVar('com_itemid'); $not_event = $notify_event; $comment_tags = array(); $module_handler =& xoops_gethandler('module'); $not_module =& $module_handler->get($not_modid); $com_config =& $not_module->getInfo('comments'); $comment_url = $com_config['pageName'] . '?'; //Umm....not use com_exparams(--;;Fix Me!) //$extra_params = $comment->getVar('com_exparams'); //$comment_url .= $extra_params; $comment_url .= $com_config['itemName']; $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $comment->getVar('com_itemid') . '&com_id=' . $comment->getVar('com_id') . '&com_rootid=' . $comment->getVar('com_rootid') . '#comment' . $comment->getVar('com_id'); $notification_handler =& xoops_gethandler('notification'); $notification_handler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid); } //notify if } //count if } //object if } //foreach foreach (array_keys($statusArr) as $cid) { if ($this->mActionForm->get('delete', $cid) == 1) { $comment =& $comment_handler->get($cid); if (is_object($comment)) { if (!$comment_handler->delete($comment)) { return LEGACY_FRAME_VIEW_ERROR; } if ($comment->get('com_status') != 1 && $comment->get('com_uid') > 0) { $memberhandler =& xoops_gethandler('member'); $user =& $memberhandler->getUser($comment->get('com_uid')); if (is_object($user)) { $count = $user->get('posts'); if ($count > 0) { $memberhandler->updateUserByField($user, 'posts', $count - 1); } } } // get all comments posted later within the same thread $thread_comments =& $comment_handler->getThread($comment->getVar('com_rootid'), $cid); include_once XOOPS_ROOT_PATH . '/class/tree.php'; $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid'); $child_comments =& $xot->getFirstChild($cid); // now set new parent ID for direct child comments $new_pid = $comment->getVar('com_pid'); $errs = array(); foreach (array_keys($child_comments) as $i) { $child_comments[$i]->setVar('com_pid', $new_pid); // if the deleted comment is a root comment, need to change root id to own id if (false != $comment->isRoot()) { $new_rootid = $child_comments[$i]->getVar('com_id'); $child_comments[$i]->setVar('com_rootid', $child_comments[$i]->getVar('com_id')); if (!$comment_handler->insert($child_comments[$i])) { $errs[] = 'Could not change comment parent ID from <b>' . $cid . '</b> to <b>' . $new_pid . '</b>. (ID: ' . $new_rootid . ')'; } else { // need to change root id for all its child comments as well $c_child_comments =& $xot->getAllChild($new_rootid); $cc_count = count($c_child_comments); foreach (array_keys($c_child_comments) as $j) { $c_child_comments[$j]->setVar('com_rootid', $new_rootid); if (!$comment_handler->insert($c_child_comments[$j])) { $errs[] = 'Could not change comment root ID from <b>' . $cid . '</b> to <b>' . $new_rootid . '</b>.'; } } } } else { if (!$comment_handler->insert($child_comments[$i])) { $errs[] = 'Could not change comment parent ID from <b>' . $cid . '</b> to <b>' . $new_pid . '</b>.'; } } } if (count($errs) > 0) { return LEGACY_FRAME_VIEW_ERROR; } // // callback // $comment_config = Legacy_CommentEditAction::loadCallbackFile($comment); if ($comment_config) { $function = $comment_config['callback']['update']; if (function_exists($function)) { $criteria = new CriteriaCompo(new Criteria('com_modid', $comment->getVar('com_modid'))); $criteria->add(new Criteria('com_itemid', $comment->getVar('com_itemid'))); $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); $comment_count = $comment_handler->getCount($criteria); call_user_func_array($function, array($comment->getVar('com_itemid'), $comment_count, $comment->getVar('com_id'))); } } } //if object } //if } //foreach return LEGACY_FRAME_VIEW_SUCCESS; }
/** * Return number of products from one or several categories * * @param integer $cat_cid * @param boolean $withNested * @return integer */ function getCategoryProductsCount($cat_cid, $withNested = true) { global $h_myshop_products; $childsIDs = array(); $childsIDs[] = $cat_cid; if ($withNested) { // Search sub-categories $items = $childs = array(); include_once XOOPS_ROOT_PATH . '/class/tree.php'; $items = $this->getAllCategories(); $mytree = new XoopsObjectTree($items, 'cat_cid', 'cat_pid'); $childs = $mytree->getAllChild($cat_cid); if (count($childs) > 0) { foreach ($childs as $onechild) { $childsIDs[] = $onechild->getVar('cat_cid'); } } } return $h_myshop_products->getCategoryProductsCount($childsIDs); }
function topicsmanager() { global $xoopsModule, $xoopsModuleConfig, $xoopsDB; include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; //$uploadfolder=sprintf(_AMS_AM_UPLOAD_WARNING,XOOPS_URL . "/modules/" . $xoopsModule -> dirname().'/images/topics'); $uploadirectory = "/modules/" . $xoopsModule->dirname() . '/images/topics'; $start = isset($_GET['start']) ? intval($_GET['start']) : 0; include_once XOOPS_ROOT_PATH . "/class/tree.php"; $xt = new AmsTopic($xoopsDB->prefix("ams_topics")); $allTopics = $xt->getAllTopics(); $totaltopics = count($allTopics); if ($totaltopics > 0) { $topic_obj_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_obj_tree->getAllChild(0); } echo "<form action='index.php' method='POST'>"; echo "<div class=\"odd\">"; echo "<div style='text-align: center;'><b>" . _AMS_AM_TOPICSMNGR . ' (' . ($start + 1) . '-' . ($start + $xoopsModuleConfig['storycountadmin'] > $totaltopics ? $totaltopics : $start + $xoopsModuleConfig['storycountadmin']) . ' ' . _AMS_AM_OF . ' ' . $totaltopics . ')' . "</b><br /><br />"; echo "<table border='1' width='100%'><tr class='bg3'><td align='center'>" . _AMS_AM_TOPIC . "</td><td align='left'>" . _AMS_AM_TOPICNAME . "</td><td align='center'>" . _AMS_AM_PARENTTOPIC . "</td><td> " . _AMS_AM_WEIGHT . " </td><td align='center'>" . _AMS_AM_ACTION . "</td></tr>"; //If topic not empty if ($totaltopics > 0) { $i = 0; foreach ($topics_arr as $thisTopic) { $i++; if ($i > $start && $i - $start <= $xoopsModuleConfig['storycountadmin']) { $linkedit = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/index.php?op=topicsmanager&topic_id=' . $thisTopic->topic_id(); $linkdelete = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/admin/index.php?op=delTopic&topic_id=' . $thisTopic->topic_id(); $action = sprintf("<a href='%s'>%s</a> - <a href='%s'>%s</a>", $linkedit, _AMS_AM_EDIT, $linkdelete, _AMS_AM_DELETE); $parent = ' '; $pid = $thisTopic->topic_pid(); if ($pid > 0) { $parent = $topics_arr[$pid]->topic_title(); $thisTopic->prefix = str_replace(".", "-", $thisTopic->prefix) . ' '; } else { $thisTopic->prefix = str_replace(".", "", $thisTopic->prefix); } echo "<tr><td>" . $thisTopic->topic_id() . "</td><td align='left'>" . $thisTopic->prefix() . $thisTopic->topic_title() . "</td><td align='left'>" . $parent . "</td><td align='center'><input type='text' name='weight[" . $thisTopic->topic_id() . "]' value='" . $thisTopic->weight . "' size='10' maxlength='10' /> </td><td>" . $action . "</td></tr>"; } } echo "<tr><td colspan='3'></td><td><input type='hidden' name='op' value='reorder' />\r\n <input type='submit' name='submit' value='" . _AMS_AM_SUBMIT . "' /></td><td></td></tr>"; } echo "</table></div></div></form>"; if ($totaltopics > $xoopsModuleConfig['storycountadmin']) { $pagenav = new XoopsPageNav($totaltopics, $xoopsModuleConfig['storycountadmin'], $start, 'start', 'op=topicsmanager'); echo "<div align='right'>"; echo $pagenav->renderNav() . '</div><br />'; } $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : 0; if ($topic_id > 0) { $xtmod = $topics_arr[$topic_id]; $topic_title = $xtmod->topic_title('E'); $op = 'modTopicS'; if (trim($xtmod->topic_imgurl()) != '') { $topicimage = $xtmod->topic_imgurl(); } else { $topicimage = "blank.png"; } $btnlabel = _AMS_AM_MODIFY; $parent = $xtmod->topic_pid(); $formlabel = _AMS_AM_MODIFYTOPIC; $banner = $xtmod->banner; $banner_inherit = $xtmod->banner_inherit; $forum = $xtmod->forum_id; unset($xtmod); } else { $topic_title = ''; $op = 'addTopic'; $topicimage = 'xoops.gif'; $btnlabel = _AMS_AM_ADD; $parent = 0; $formlabel = _AMS_AM_ADD_TOPIC; $banner = ''; $banner_inherit = 0; $forum = 0; } $sform = new XoopsThemeForm($formlabel, "topicform", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php', 'post'); $sform->setExtra('enctype="multipart/form-data"'); $sform->addElement(new XoopsFormText(_AMS_AM_TOPICNAME . ' ' . _AMS_AM_MAX40CHAR, 'topic_title', 40, 50, $topic_title), true); $sform->addElement(new XoopsFormHidden('op', $op), false); $sform->addElement(new XoopsFormHidden('topic_id', $topic_id), false); if ($totaltopics > 0) { $sform->addElement(new XoopsFormLabel(_AMS_AM_PARENTTOPIC, $topic_obj_tree->makeSelBox('topic_pid', 'topic_title', '--', $parent, true))); } else { $sform->addElement(new XoopsFormHidden('topic_pid', 0)); } // ********** Picture $imgtray = new XoopsFormElementTray(_AMS_AM_TOPICIMG, '<br />'); $imgpath = sprintf(_AMS_AM_IMGNAEXLOC, "modules/" . $xoopsModule->dirname() . "/images/topics/"); $imageselect = new XoopsFormSelect($imgpath, 'topic_imgurl', $topicimage); $topics_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . "/modules/AMS/images/topics/"); foreach ($topics_array as $image) { $imageselect->addOption("{$image}", $image); } $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"topic_imgurl\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'"); $imgtray->addElement($imageselect, false); $imgtray->addElement(new XoopsFormLabel('', "<br /><img src='" . XOOPS_URL . "/" . $uploadirectory . "/" . $topicimage . "' name='image3' id='image3' alt='' />")); $uploadfolder = sprintf(_AMS_AM_UPLOAD_WARNING, XOOPS_URL . "/modules/" . $xoopsModule->dirname() . '/images/topics'); $fileseltray = new XoopsFormElementTray('', '<br />'); $fileseltray->addElement(new XoopsFormFile(_AMS_AM_TOPIC_PICTURE, 'attachedfile', $xoopsModuleConfig['maxuploadsize']), false); $fileseltray->addElement(new XoopsFormLabel($uploadfolder), false); $imgtray->addElement($fileseltray); $sform->addElement($imgtray); //Forum linking $module_handler =& xoops_gethandler('module'); $forum_module =& $module_handler->getByDirname('newbb'); if (is_object($forum_module) && $forum_module->getVar('version') >= 200) { $forum_handler =& xoops_getmodulehandler('forum', 'newbb', true); if (is_object($forum_handler)) { $forums = $forum_handler->getForums(); if (count($forums) > 0) { $forum_tree = new XoopsObjectTree($forums, 'forum_id', 'parent_forum'); $sform->addElement(new XoopsFormLabel(_AMS_AM_LINKEDFORUM, $forum_tree->makeSelBox('forum_id', 'forum_name', '--', $forum, true))); } } } //Banner $sform->addElement(new XoopsFormDhtmlTextArea(_AMS_AM_TOPICBANNER, 'banner', $banner)); $inherit_checkbox = new XoopsFormCheckBox(_AMS_AM_BANNERINHERIT, 'banner_inherit', $banner_inherit); $inherit_checkbox->addOption(1, _YES); $sform->addElement($inherit_checkbox); //Added in AMS 2.50 Final. Use News 1.62 permission style //Enhance in AMS 3.0 Beta 1. Add default permission for approval=admin, submit=admin,User. // Permissions $member_handler =& xoops_gethandler('member'); $group_list =& $member_handler->getGroupList(); $gperm_handler =& xoops_gethandler('groupperm'); $group_type_ref =& $member_handler->getGroups(null, true); $admin_list = array(); $user_list = array(); $full_list = array(); $admincount = 1; $usercount = 1; $fullcount = 1; foreach (array_keys($group_type_ref) as $i) { if ($group_type_ref[$i]->getVar('group_type') == 'Admin') { $admin_list[$i] = $group_list[$i]; $admincount++; $user_list[$i] = $group_list[$i]; $usercount++; } if ($group_type_ref[$i]->getVar('group_type') == 'User') { $user_list[$i] = $group_list[$i]; $usercount++; } $full_list[$i] = $group_list[$i]; $fullcount++; } $admin_list = array_keys($admin_list); $user_list = array_keys($user_list); $full_list = array_keys($full_list); $groups_ids = array(); if ($topic_id > 0) { // Edit mode $groups_ids = $gperm_handler->getGroupIds('ams_approve', $topic_id, $xoopsModule->getVar('mid')); $groups_ids = array_values($groups_ids); $groups_AMS_can_approve_checkbox = new XoopsFormCheckBox(_AMS_AM_APPROVEFORM, 'groups_AMS_can_approve[]', $groups_ids); } else { // Creation mode $groups_AMS_can_approve_checkbox = new XoopsFormCheckBox(_AMS_AM_APPROVEFORM, 'groups_AMS_can_approve[]', $admin_list); } $groups_AMS_can_approve_checkbox->addOptionArray($group_list); $sform->addElement($groups_AMS_can_approve_checkbox); $groups_ids = array(); if ($topic_id > 0) { // Edit mode $groups_ids = $gperm_handler->getGroupIds('ams_submit', $topic_id, $xoopsModule->getVar('mid')); $groups_ids = array_values($groups_ids); $groups_AMS_can_submit_checkbox = new XoopsFormCheckBox(_AMS_AM_SUBMITFORM, 'groups_AMS_can_submit[]', $groups_ids); } else { // Creation mode $groups_AMS_can_submit_checkbox = new XoopsFormCheckBox(_AMS_AM_SUBMITFORM, 'groups_AMS_can_submit[]', $user_list); } $groups_AMS_can_submit_checkbox->addOptionArray($group_list); $sform->addElement($groups_AMS_can_submit_checkbox); $groups_ids = array(); if ($topic_id > 0) { // Edit mode $groups_ids = $gperm_handler->getGroupIds('ams_view', $topic_id, $xoopsModule->getVar('mid')); $groups_ids = array_values($groups_ids); $groups_AMS_can_view_checkbox = new XoopsFormCheckBox(_AMS_AM_VIEWFORM, 'groups_AMS_can_view[]', $groups_ids); } else { // Creation mode $groups_AMS_can_view_checkbox = new XoopsFormCheckBox(_AMS_AM_VIEWFORM, 'groups_AMS_can_view[]', $full_list); } $groups_AMS_can_view_checkbox->addOptionArray($group_list); $sform->addElement($groups_AMS_can_view_checkbox); // Submit buttons $button_tray = new XoopsFormElementTray('', ''); $submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit'); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform->display(); }
/** * Creates all the meta datas : * - For Mozilla/Netscape and Opera the site navigation's bar * - The Dublin's Core Metadata * - The link for Firefox 2 micro summaries * - The meta keywords * - The meta description * * @package News * @author Instant Zero (http://xoops.instant-zero.com) * @copyright (c) Instant Zero */ function nw_CreateMetaDatas($story = null) { global $xoopsConfig, $xoTheme, $xoopsTpl; $content = ''; $myts =& MyTextSanitizer::getInstance(); include_once NW_MODULE_PATH . '/class/class.newstopic.php'; /** * Firefox and Opera Navigation's Bar */ if(nw_getmoduleoption('sitenavbar', NW_MODULE_DIR_NAME)) { $content .= sprintf("<link rel=\"Home\" title=\"%s\" href=\"%s/\" />\n",$xoopsConfig['sitename'],XOOPS_URL); $content .= sprintf("<link rel=\"Contents\" href=\"%s\" />\n",NW_MODULE_URL . '/index.php'); $content .= sprintf("<link rel=\"Search\" href=\"%s\" />\n",XOOPS_URL.'/search.php'); $content .= sprintf("<link rel=\"Glossary\" href=\"%s\" />\n",NW_MODULE_URL . '/archive.php'); $content .= sprintf("<link rel=\"%s\" href=\"%s\" />\n",$myts->htmlSpecialChars(_MA_NW_SUBMITNEWS), NW_MODULE_URL . '/submit.php'); $content .= sprintf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s\" href=\"%s/\" />\n",$xoopsConfig['sitename'], XOOPS_URL.'/backend.php'); // Create chapters include_once XOOPS_ROOT_PATH.'/class/tree.php'; include_once NW_MODULE_PATH . '/class/class.newstopic.php'; $xt = new nw_NewsTopic(); $allTopics = $xt->getAllTopics(nw_getmoduleoption('restrictindex', NW_MODULE_DIR_NAME)); $topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_tree->getAllChild(0); foreach ($topics_arr as $onetopic) { $content .= sprintf("<link rel=\"Chapter\" title=\"%s\" href=\"%s\" />\n",$onetopic->topic_title(),NW_MODULE_URL . '/index.php?storytopic='.$onetopic->topic_id()); } } /** * Meta Keywords and Description * If you have set this module's option to 'yes' and if the information was entered, then they are rendered in the page else they are computed */ $meta_keywords = ''; if(isset($story) && is_object($story)) { if(xoops_trim($story->keywords()) != '') { $meta_keywords = $story->keywords(); } else { $meta_keywords = nw_createmeta_keywords($story->hometext().' '.$story->bodytext()); } if(xoops_trim($story->description())!='') { $meta_description = strip_tags($story->description); } else { $meta_description = strip_tags($story->title); } if(isset($xoTheme) && is_object($xoTheme)) { $xoTheme->addMeta( 'meta', 'keywords', $meta_keywords); $xoTheme->addMeta( 'meta', 'description', $meta_description); } elseif(isset($xoopsTpl) && is_object($xoopsTpl)) { // Compatibility for old Xoops versions $xoopsTpl->assign('xoops_meta_keywords', $meta_keywords); $xoopsTpl->assign('xoops_meta_description', $meta_description); } } /** * Dublin Core's meta datas */ if(nw_getmoduleoption('dublincore', NW_MODULE_DIR_NAME) && isset($story) && is_object($story)) { $config_handler =& xoops_gethandler('config'); $xoopsConfigMetaFooter =& $config_handler->getConfigsByCat(XOOPS_CONF_METAFOOTER); $content .= '<meta name="DC.Title" content="'.nw_DublinQuotes($story->title())."\" />\n"; $content .= '<meta name="DC.Creator" content="'.nw_DublinQuotes($story->uname())."\" />\n"; $content .= '<meta name="DC.Subject" content="'.nw_DublinQuotes($meta_keywords)."\" />\n"; $content .= '<meta name="DC.Description" content="'.nw_DublinQuotes($story->title())."\" />\n"; $content .= '<meta name="DC.Publisher" content="'.nw_DublinQuotes($xoopsConfig['sitename'])."\" />\n"; $content .= '<meta name="DC.Date.created" scheme="W3CDTF" content="'.date('Y-m-d',$story->created)."\" />\n"; $content .= '<meta name="DC.Date.issued" scheme="W3CDTF" content="'.date('Y-m-d',$story->published)."\" />\n"; $content .= '<meta name="DC.Identifier" content="'.NW_MODULE_URL . '/article.php?storyid='.$story->storyid()."\" />\n"; $content .= '<meta name="DC.Source" content="'.XOOPS_URL."\" />\n"; $content .= '<meta name="DC.Language" content="'._LANGCODE."\" />\n"; $content .= '<meta name="DC.Relation.isReferencedBy" content="'.NW_MODULE_URL . '/index.php?storytopic='.$story->topicid()."\" />\n"; if(isset($xoopsConfigMetaFooter['meta_copyright'])) { $content .= '<meta name="DC.Rights" content="'.nw_DublinQuotes($xoopsConfigMetaFooter['meta_copyright'])."\" />\n"; } } /** * Firefox 2 micro summaries */ if(nw_getmoduleoption('firefox_microsummaries', NW_MODULE_DIR_NAME)) { $content .= sprintf("<link rel=\"microsummary\" href=\"%s\" />\n",NW_MODULE_URL . '/micro_summary.php'); } if(isset($xoopsTpl) && is_object($xoopsTpl)) { $xoopsTpl->assign('xoops_module_header', $content); } }
xoops_error($errs); include XOOPS_ROOT_PATH . '/footer.php'; exit; } redirect_header($redirect_page . '=' . $com_itemid . '&com_order=' . $com_order . '&com_mode=' . $com_mode, 1, _CM_COMDELETED); break; case 'delete_all': $comment_handler = xoops_gethandler('comment'); $comment =& $comment_handler->get($com_id); $com_rootid = $comment->getVar('com_rootid'); // get all comments posted later within the same thread $thread_comments =& $comment_handler->getThread($com_rootid, $com_id); // construct a comment tree include_once XOOPS_ROOT_PATH . '/class/tree.php'; $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid'); $child_comments =& $xot->getAllChild($com_id); // add itself here $child_comments[$com_id] =& $comment; $msgs = array(); $deleted_num = array(); $member_handler =& xoops_gethandler('member'); foreach (array_keys($child_comments) as $i) { if (!$comment_handler->delete($child_comments[$i])) { $msgs[] = _CM_COMDELETENG . ' (ID: ' . $child_comments[$i]->getVar('com_id') . ')'; } else { $msgs[] = _CM_COMDELETED . ' (ID: ' . $child_comments[$i]->getVar('com_id') . ')'; // store poster ID and deleted post number into array for later use $poster_id = $child_comments[$i]->getVar('com_uid'); if ($poster_id > 0) { $deleted_num[$poster_id] = !isset($deleted_num[$poster_id]) ? 1 : $deleted_num[$poster_id] + 1; }
/** * Retourne le nombre de produits d'une ou de plusieurs catégories * * @param integer $cat_cid L'identifiant de la catégorie dont on veut récupérer le nombre de produits * @param boolean $withNested Faut il inclure les sous-catégories ? * @return integer Le nombre de produits */ public function getCategoryProductsCount($cat_cid, $withNested = true) { global $h_oledrion_products; $childsIDs = array(); $childsIDs[] = $cat_cid; if ($withNested) { // Recherche des sous catégories de cette catégorie $items = $childs = array(); include_once XOOPS_ROOT_PATH . '/class/tree.php'; $items = $this->getAllCategories(new oledrion_parameters()); $mytree = new XoopsObjectTree($items, 'cat_cid', 'cat_pid'); $childs = $mytree->getAllChild($cat_cid); if (count($childs) > 0) { foreach ($childs as $onechild) { $childsIDs[] = $onechild->getVar('cat_cid'); } } } return $h_oledrion_products->getCategoryProductsCount($childsIDs); }
public function displayDelete() { $xoops = Xoops::getInstance(); $op = Request::getCmd('op', 'delete', 'POST'); $mode = Request::getString('com_mode', 'flat'); $order = Request::getString('com_order', COMMENTS_OLD1ST); $id = Request::getInt('com_id'); /* @var $comment CommentsComment */ /* @var $comment_handler CommentsCommentHandler */ $comment_handler = $this->getHandlerComment(); $comment = $comment_handler->get($id); if (!is_object($comment)) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } $module = $xoops->getModuleById($comment->getVar('modid')); if (!is_object($module)) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } if (!$xoops->isAdminSide && COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname')) || !$xoops->isUser() && !$xoops->getModuleConfig('com_anonpost', $module->getVar('dirname')) || !$xoops->isModule()) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } $modid = $module->getVar('mid'); /* @var $plugin CommentsPluginInterface */ if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'comments')) { if ($xoops->isAdminSide) { $redirect_page = $this->url('admin/main.php?com_modid=' . $modid . '&com_itemid'); } else { $redirect_page = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $plugin->pageName() . '?'); $comment_confirm_extra = array(); if (is_array($extraParams = $plugin->extraParams())) { foreach ($extraParams as $extra_param) { if (isset($_GET[$extra_param])) { $redirect_page .= $extra_param . '=' . $_GET[$extra_param] . '&'; // for the confirmation page $comment_confirm_extra[$extra_param] = $_GET[$extra_param]; } } } $redirect_page .= $plugin->itemName(); } $accesserror = false; if (!$xoops->isUser()) { $accesserror = true; } else { if (!$xoops->user->isAdmin($modid)) { $accesserror = true; } } if (false != $accesserror) { $ref = $xoops->getEnv('HTTP_REFERER'); if ($ref != '') { $xoops->redirect($ref, 2, XoopsLocale::E_NO_ACCESS_PERMISSION); } else { $xoops->redirect($redirect_page . '?' . $plugin->itemName() . '=' . (int) $id, 2, XoopsLocale::E_NO_ACCESS_PERMISSION); } } switch ($op) { case 'delete_one': if (!$comment_handler->delete($comment)) { $xoops->header(); echo $xoops->alert('error', _MD_COMMENTS_COMDELETENG . ' (ID: ' . $comment->getVar('id') . ')'); $xoops->footer(); } $itemid = $comment->getVar('itemid'); $criteria = new CriteriaCompo(new Criteria('modid', $modid)); $criteria->add(new Criteria('itemid', $itemid)); $criteria->add(new Criteria('status', COMMENTS_ACTIVE)); $comment_count = $comment_handler->getCount($criteria); $plugin->update($itemid, $comment_count); // update user posts if its not an anonymous post if ($comment->getVar('uid') != 0) { $member_handler = $xoops->getHandlerMember(); $poster = $member_handler->getUser($comment->getVar('uid')); if (is_object($poster)) { $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') - 1); } } // get all comments posted later within the same thread $thread_comments = $comment_handler->getThread($comment->getVar('rootid'), $id); $xot = new XoopsObjectTree($thread_comments, 'id', 'pid', 'rootid'); $child_comments = $xot->getFirstChild($id); // now set new parent ID for direct child comments $new_pid = $comment->getVar('pid'); $errs = array(); foreach (array_keys($child_comments) as $i) { $child_comments[$i]->setVar('pid', $new_pid); // if the deleted comment is a root comment, need to change root id to own id if (false != $comment->isRoot()) { $new_rootid = $child_comments[$i]->getVar('id'); $child_comments[$i]->setVar('rootid', $child_comments[$i]->getVar('id')); if (!$comment_handler->insert($child_comments[$i])) { $errs[] = 'Could not change comment parent ID from <strong>' . $id . '</strong> to <strong>' . $new_pid . '</strong>. (ID: ' . $new_rootid . ')'; } else { // need to change root id for all its child comments as well $c_child_comments = $xot->getAllChild($new_rootid); $cc_count = count($c_child_comments); foreach (array_keys($c_child_comments) as $j) { $c_child_comments[$j]->setVar('rootid', $new_rootid); if (!$comment_handler->insert($c_child_comments[$j])) { $errs[] = 'Could not change comment root ID from <strong>' . $id . '</strong> to <strong>' . $new_rootid . '</strong>.'; } } } } else { if (!$comment_handler->insert($child_comments[$i])) { $errs[] = 'Could not change comment parent ID from <strong>' . $id . '</strong> to <strong>' . $new_pid . '</strong>.'; } } } if (count($errs) > 0) { $xoops->header(); echo $xoops->alert('error', $errs); $xoops->footer(); exit; } $xoops->redirect($redirect_page . '=' . $itemid . '&com_order=' . $order . '&com_mode=' . $mode, 1, _MD_COMMENTS_COMDELETED); break; case 'delete_all': $rootid = $comment->getVar('rootid'); // get all comments posted later within the same thread $thread_comments = $comment_handler->getThread($rootid, $id); // construct a comment tree $xot = new XoopsObjectTree($thread_comments, 'id', 'pid', 'rootid'); $child_comments = $xot->getAllChild($id); // add itself here $child_comments[$id] = $comment; $msgs = array(); $deleted_num = array(); $member_handler = $xoops->getHandlerMember(); foreach (array_keys($child_comments) as $i) { if (!$comment_handler->delete($child_comments[$i])) { $msgs[] = _MD_COMMENTS_COMDELETENG . ' (ID: ' . $child_comments[$i]->getVar('id') . ')'; } else { $msgs[] = _MD_COMMENTS_COMDELETED . ' (ID: ' . $child_comments[$i]->getVar('id') . ')'; // store poster ID and deleted post number into array for later use $poster_id = $child_comments[$i]->getVar('uid'); if ($poster_id > 0) { $deleted_num[$poster_id] = !isset($deleted_num[$poster_id]) ? 1 : $deleted_num[$poster_id] + 1; } } } foreach ($deleted_num as $user_id => $post_num) { // update user posts $poster = $member_handler->getUser($user_id); if (is_object($poster)) { $member_handler->updateUserByField($poster, 'posts', $poster->getVar('posts') - $post_num); } } $itemid = $comment->getVar('itemid'); $criteria = new CriteriaCompo(new Criteria('modid', $modid)); $criteria->add(new Criteria('itemid', $itemid)); $criteria->add(new Criteria('status', COMMENTS_ACTIVE)); $comment_count = $comment_handler->getCount($criteria); $plugin->update($itemid, $comment_count); $xoops->header(); echo $xoops->alert('info', $msgs); echo '<br /><a href="' . $redirect_page . '=' . $itemid . '&com_order=' . $order . '&com_mode=' . $mode . '">' . XoopsLocale::GO_BACK . '</a>'; $xoops->footer(); break; case 'delete': default: $xoops->header(); $comment_confirm = array('com_id' => $id, 'com_mode' => $mode, 'com_order' => $order, 'op' => array(_MD_COMMENTS_DELETEONE => 'delete_one', _MD_COMMENTS_DELETEALL => 'delete_all')); if (!empty($comment_confirm_extra) && is_array($comment_confirm_extra)) { $comment_confirm = $comment_confirm + $comment_confirm_extra; } echo $xoops->confirm($comment_confirm, 'comment_delete.php', _MD_COMMENTS_DELETESELECT); $xoops->footer(); break; } } }
/** * News export * * You can use this function in the module's admin when you click on the tab named "News Export" * First select a range of date, possibly a range of topics and if you want, check the option "Include Topics Definitions" * to also export the topics. * News, and topics, will be exported to the XML format. */ function NewsExport() { global $xoopsDB; include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; xoops_cp_header(); adminmenu(4); echo "<br />"; $sform = new XoopsThemeForm(_AM_NEWS_EXPORT_NEWS, "exportform", XOOPS_URL . '/modules/news/admin/index.php', 'post'); $dates_tray = new XoopsFormElementTray(_AM_NEWS_EXPORT_BETWEEN); $date1 = new XoopsFormTextDateSelect('', 'date1', 15, time()); $date2 = new XoopsFormTextDateSelect(_AM_NEWS_EXPORT_AND, 'date2', 15, time()); $dates_tray->addElement($date1); $dates_tray->addElement($date2); $sform->addElement($dates_tray); $topiclist = new XoopsFormSelect(_AM_NEWS_PRUNE_TOPICS, 'export_topics', '', 5, true); $topics_arr = array(); $xt = new NewsTopic(); $allTopics = $xt->getAllTopics(false); // The webmaster can see everything $topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_tree->getAllChild(0); if (count($topics_arr)) { foreach ($topics_arr as $onetopic) { $topiclist->addOption($onetopic->topic_id(), $onetopic->topic_title()); } } $topiclist->setDescription(_AM_NEWS_EXPORT_PRUNE_DSC); $sform->addElement($topiclist, false); $sform->addElement(new XoopsFormRadioYN(_AM_NEWS_EXPORT_INCTOPICS, 'includetopics', 0), false); $sform->addElement(new XoopsFormHidden('op', 'launchexport'), false); $button_tray = new XoopsFormElementTray('', ''); $submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform->display(); }
function deleteComment($com_id) { $delete_op = isset($_POST['delete_op']) ? xoops_trim($_POST['delete_op']) : 'delete_one'; switch ($delete_op) { case 'delete_one': $comment_handler = xoops_gethandler('comment'); $comment =& $comment_handler->get($com_id); if (!$comment_handler->delete($comment)) { return xoops_error(_CM_COMDELETENG . ' (ID: ' . $comment->getVar('com_id') . ')'); exit; } $com_itemid = $comment->getVar('com_itemid'); // update user posts if its not an anonymous post if ($comment->getVar('com_uid') != 0) { $member_handler =& xoops_gethandler('member'); $com_poster =& $member_handler->getUser($comment->getVar('com_uid')); if (is_object($com_poster)) { $member_handler->updateUserByField($com_poster, 'posts', $com_poster->getVar('posts') - 1); } } // get all comments posted later within the same thread $thread_comments =& $comment_handler->getThread($comment->getVar('com_rootid'), $com_id); include_once XOOPS_ROOT_PATH . '/class/tree.php'; $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid'); $child_comments =& $xot->getFirstChild($com_id); // now set new parent ID for direct child comments $new_pid = $comment->getVar('com_pid'); // $errs = array(); $msgs = ''; foreach (array_keys($child_comments) as $i) { $child_comments[$i]->setVar('com_pid', $new_pid); // if the deleted comment is a root comment, need to change root id to own id if (false != $comment->isRoot()) { $new_rootid = $child_comments[$i]->getVar('com_id'); $child_comments[$i]->setVar('com_rootid', $child_comments[$i]->getVar('com_id')); if (!$comment_handler->insert($child_comments[$i])) { // $errs[] = 'Could not change comment parent ID from <b>'.$com_id.'</b> to <b>'.$new_pid.'</b>. (ID: '.$new_rootid.')'; $msgs .= 'Could not change comment parent ID from <b>' . $com_id . '</b> to <b>' . $new_pid . '</b>. (ID: ' . $new_rootid . ')<br />'; } else { // need to change root id for all its child comments as well $c_child_comments =& $xot->getAllChild($new_rootid); $cc_count = count($c_child_comments); foreach (array_keys($c_child_comments) as $j) { $c_child_comments[$j]->setVar('com_rootid', $new_rootid); if (!$comment_handler->insert($c_child_comments[$j])) { // $errs[] = 'Could not change comment root ID from <b>'.$com_id.'</b> to <b>'.$new_rootid.'</b>.'; $msgs .= 'Could not change comment root ID from <b>' . $com_id . '</b> to <b>' . $new_rootid . '</b>.<br />'; } } } } else { if (!$comment_handler->insert($child_comments[$i])) { // $errs[] = 'Could not change comment parent ID from <b>'.$com_id.'</b> to <b>'.$new_pid.'</b>.'; $msgs .= 'Could not change comment parent ID from <b>' . $com_id . '</b> to <b>' . $new_pid . '</b>.<br />'; } } } // if(count($errs) > 0) if ($msgs != '') { // return xoops_error($errs); return $msgs; exit; } // redirect_header($redirect_page.'='.$com_itemid.'&com_order='.$com_order.'&com_mode='.$com_mode, 1, _CM_COMDELETED); return _CM_COMDELETED; break; case 'delete_all': $comment_handler = xoops_gethandler('comment'); $comment =& $comment_handler->get($com_id); $com_rootid = $comment->getVar('com_rootid'); // get all comments posted later within the same thread $thread_comments =& $comment_handler->getThread($com_rootid, $com_id); // construct a comment tree include_once XOOPS_ROOT_PATH . '/class/tree.php'; $xot = new XoopsObjectTree($thread_comments, 'com_id', 'com_pid', 'com_rootid'); $child_comments =& $xot->getAllChild($com_id); // add itself here $child_comments[$com_id] =& $comment; // $msgs = array(); $msgs = ''; $deleted_num = array(); $member_handler =& xoops_gethandler('member'); foreach (array_keys($child_comments) as $i) { if (!$comment_handler->delete($child_comments[$i])) { // $msgs[] = _CM_COMDELETENG.' (ID: '.$child_comments[$i]->getVar('com_id').')'; $msgs .= _CM_COMDELETENG . ' (ID: ' . $child_comments[$i]->getVar('com_id') . ')<br />'; } else { // $msgs[] = _CM_COMDELETED.' (ID: '.$child_comments[$i]->getVar('com_id').')'; $msgs .= _CM_COMDELETED . ' (ID: ' . $child_comments[$i]->getVar('com_id') . ')<br />'; // store poster ID and deleted post number into array for later use $poster_id = $child_comments[$i]->getVar('com_uid'); if ($poster_id > 0) { $deleted_num[$poster_id] = !isset($deleted_num[$poster_id]) ? 1 : $deleted_num[$poster_id] + 1; } } } foreach ($deleted_num as $user_id => $post_num) { // update user posts $com_poster = $member_handler->getUser($user_id); if (is_object($com_poster)) { $member_handler->updateUserByField($com_poster, 'posts', $com_poster->getVar('posts') - $post_num); } } $com_itemid = $comment->getVar('com_itemid'); // execute updateStat callback function if set if (isset($comment_config['callback']['update']) && trim($comment_config['callback']['update']) != '') { $skip = false; if (!function_exists($comment_config['callback']['update'])) { if (isset($comment_config['callbackFile'])) { $callbackfile = trim($comment_config['callbackFile']); if ($callbackfile != '' && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) { include_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile; } if (!function_exists($comment_config['callback']['update'])) { $skip = true; } } else { $skip = true; } } if (!$skip) { $criteria = new CriteriaCompo(new Criteria('com_modid', $this->mid)); $criteria->add(new Criteria('com_itemid', $com_itemid)); $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); $comment_count = $comment_handler->getCount($criteria); $comment_config['callback']['update']($com_itemid, $comment_count); } } // return xoops_result($msgs); return $msgs; break; } }
if (!isset($_SESSION['items_count']) || $_SESSION['items_count'] == -1) { $sql = "SELECT COUNT(*) as cpt FROM " . $xoopsDB->prefix("topics") . " WHERE menu=1"; $result = $xoopsDB->query($sql); list($count) = $xoopsDB->fetchRow($result); $_SESSION['items_count'] = $count; } else { $count = $_SESSION['items_count']; } if ($count > 0) { include_once XOOPS_ROOT_PATH . '/class/tree.php'; include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; $xt = new NewsTopic(); $allTopics = $xt->getAllTopics(news_getmoduleoption('restrictindex')); $topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_tree->getAllChild(0); if ($module) { foreach ($topics_arr as $onetopic) { if ($gperm_handler->checkRight('news_view', $onetopic->topic_id(), $groups, $xoopsModule->getVar('mid')) && $onetopic->menu()) { $modversion['sub'][$i]['name'] = $onetopic->topic_title(); $modversion['sub'][$i]['url'] = "index.php?storytopic=" . $onetopic->topic_id(); } $i++; } } unset($xt); } } $modversion['sub'][$i]['name'] = _MI_NEWS_SMNAME2; $modversion['sub'][$i]['url'] = "archive.php"; if ($cansubmit) {
$xoopsTpl->assign('lang_category', _MD_MYLINKS_CATEGORY); $xoopsTpl->assign('lang_hits', _MD_MYLINKS_HITS); $xoopsTpl->assign('lang_rating', _MD_MYLINKS_RATING); $xoopsTpl->assign('lang_vote', _MD_MYLINKS_VOTE); // get main category titles $criteria = new CriteriaCompo(); $criteria->add(new Criteria('pid', 0, '=')); $catElements = array('title'); $mainCatTitleArray = $mylinksCatHandler->getAll($criteria, $catElements, false, true); $mainCatIdArray = array_keys($mainCatTitleArray); $catCount = count($mainCatIdArray); $mainCatIds = $catCount ? '(' . implode(',', $mainCatIdArray) . ')' : ''; $rankings = array(); foreach ($mainCatIdArray as $catKey) { $treeIds = array(); $thisCatTree = $myCatTree->getAllChild($catKey); if (!empty($thisCatTree)) { $treeIds = array_keys($thisCatTree); } array_push($treeIds, $catKey); $subcatIds = '(' . implode(',', $treeIds) . ')'; $sql = "SELECT lid, cid, title, hits, rating, votes FROM " . "" . $xoopsDB->prefix("mylinks_links") . "" . " WHERE status>0 AND cid IN {$subcatIds} WHERE {$sortDB}>0 ORDER BY {$sortDB} DESC LIMIT 0,10"; $result = $xoopsDB->query($sql); if ($result) { $catTitle = $myts->htmlSpecialChars($mainCatTitleArray[$catKey]['title']); $rankings[$catKey]['title'] = sprintf(_MD_MYLINKS_TOP10, $catTitle); $rank = 1; while (list($lid, $lcid, $ltitle, $hits, $rating, $votes) = $xoopsDB->fetchRow($result)) { $thisCatObj = $mylinksCatHandler->get($lcid); $homePath = "<a href='" . XOOPSMYLINKURL . "/index.php'>" . _MD_MYLINKS_MAIN . "</a> : "; $itemPath = "<a href='" . XOOPSMYLINKURL . "/viewcat.php?cid={$lcid}'>" . $thisCatObj->getVar('title') . "</a>";
/** * Creates, for Mozilla/Netscape and Opera the site navigation's bar * * @package News * @author Hervé Thouzard (www.herve-thouzard.com) * @copyright (c) The Xoops Project - www.xoops.org */ function CreateSiteNavBar() { global $xoopsConfig; $content = ''; $myts =& MyTextSanitizer::getInstance(); include_once XOOPS_ROOT_PATH . "/modules/news/class/class.newstopic.php"; $content = sprintf("<link rel=\"Home\" title=\"%s\" href=\"%s/\" />\n", $xoopsConfig['sitename'], XOOPS_URL); $content .= sprintf("<link rel=\"Contents\" href=\"%s\" />\n", XOOPS_URL . '/modules/news/index.php'); $content .= sprintf("<link rel=\"Search\" href=\"%s\" />\n", XOOPS_URL . '/search.php'); $content .= sprintf("<link rel=\"Glossary\" href=\"%s\" />\n", XOOPS_URL . '/modules/news/archive.php'); $content .= sprintf("<link rel=\"%s\" href=\"%s\" />\n", $myts->htmlSpecialChars(_NW_SUBMITNEWS), XOOPS_URL . '/modules/news/submit.php'); $content .= sprintf("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"%s\" href=\"%s/\" />\n", $xoopsConfig['sitename'], XOOPS_URL . '/backend.php'); // create chapters include_once XOOPS_ROOT_PATH . "/class/tree.php"; include_once XOOPS_ROOT_PATH . "/modules/news/class/class.newstopic.php"; $xt = new NewsTopic(); $allTopics = $xt->getAllTopics(getmoduleoption('restrictindex')); $topic_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topics_arr = $topic_tree->getAllChild(0); foreach ($topics_arr as $onetopic) { $content .= sprintf("<link rel=\"Chapter\" title=\"%s\" href=\"%s\" />\n", $onetopic->topic_title(), XOOPS_URL . '/modules/news/index.php?storytopic=' . $onetopic->topic_id()); } return $content; }
/** * Affiche le bloc des catégories en fonction de la catégorie en cours (fonctionne de paire avec les pages du module) */ function b_oledrion_category_show($options) { global $xoopsTpl; $block = array(); include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; $url = OLEDRION_URL . 'include/oledrion.css'; $xoopsTpl->assign("xoops_module_header", "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$url}\" />"); $block['nostock_msg'] = oledrion_utils::getModuleOption('nostock_msg'); if (intval($options[0]) == 0) { // Catégories selon la page en cours $block['block_option'] = 0; if (!isset($GLOBALS['current_category']) || $GLOBALS['current_category'] == -1) { return false; } $cat_cid = intval($GLOBALS['current_category']); include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; if ($cat_cid > 0) { include_once XOOPS_ROOT_PATH . '/class/tree.php'; $tbl_categories = $tblChilds = $tbl_tmp = array(); $tbl_categories = $h_oledrion_cat->getAllCategories(new oledrion_parameters()); $mytree = new XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); $tblChilds = $mytree->getAllChild($cat_cid); //$tblChilds = array_reverse($tblChilds); foreach ($tblChilds as $item) { $tbl_tmp[] = "<a href='" . $item->getLink() . "' title='" . oledrion_utils::makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . "</a>"; } $block['block_categories'] = $tbl_tmp; $category = null; if ($cat_cid > 0) { $category = $h_oledrion_cat->get($cat_cid); if (is_object($category)) { $block['block_current_category'] = $category->toArray(); } } } else { // On est à la racine, on n'affiche donc que les catégories mères $tbl_categories = array(); $criteria = new Criteria('cat_pid', 0, '='); $criteria->setSort('cat_title'); $tbl_categories = $h_oledrion_cat->getObjects($criteria, true); foreach ($tbl_categories as $item) { $tbl_tmp[] = "<a href='" . $item->getLink() . "' title='" . oledrion_utils::makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . "</a>"; } $block['block_categories'] = $tbl_tmp; } } elseif (intval($options[0]) == 1) { // Affichage classique $block['block_option'] = 1; include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; include_once OLEDRION_PATH . 'class/tree.php'; $tbl_categories = $h_oledrion_cat->getAllCategories(new oledrion_parameters()); $mytree = new Oledrion_XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); $jump = OLEDRION_URL . "category.php?cat_cid="; $additional = "onchange='location=\"" . $jump . "\"+this.options[this.selectedIndex].value'"; if (isset($GLOBALS['current_category']) && $GLOBALS['current_category'] != -1) { $cat_cid = intval($GLOBALS['current_category']); } else { $cat_cid = 0; } $htmlSelect = $mytree->makeSelBox('cat_cid', 'cat_title', '-', $cat_cid, false, 0, $additional); $block['htmlSelect'] = $htmlSelect; } else { // Affichage de toute l'arborescence, dépliée $block['block_option'] = 2; $block['liMenu'] = $h_oledrion_cat->getUlMenu('category_title'); } return $block; }
function b_myshop_category_show($options) { global $xoopsTpl; $block = array(); include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; $url = MYSHOP_URL . 'include/myshop.css'; $xoopsTpl->assign("xoops_module_header", "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$url}\" />"); $block['nostock_msg'] = myshop_utils::getModuleOption('nostock_msg'); if (intval($options[0]) == 0) { $block['block_option'] = 0; if (!isset($GLOBALS['current_category']) || $GLOBALS['current_category'] == -1) { return false; } $cat_cid = intval($GLOBALS['current_category']); include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; if ($cat_cid > 0) { include_once XOOPS_ROOT_PATH . '/class/tree.php'; $tbl_categories = $tblChilds = $tbl_tmp = array(); $tbl_categories = $h_myshop_cat->getAllCategories(); $mytree = new XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); $tblChilds = $mytree->getAllChild($cat_cid); foreach ($tblChilds as $item) { $tbl_tmp[] = "<a href='" . $item->getLink() . "' title='" . myshop_utils::makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . "</a>"; } $block['block_categories'] = $tbl_tmp; $category = null; if ($cat_cid > 0) { $category = $h_myshop_cat->get($cat_cid); if (is_object($category)) { $block['block_current_category'] = $category->toArray(); } } } else { $tbl_categories = array(); $criteria = new Criteria('cat_pid', 0, '='); $criteria->setSort('cat_title'); $tbl_categories = $h_myshop_cat->getObjects($criteria, true); foreach ($tbl_categories as $item) { $tbl_tmp[] = "<a href='" . $item->getLink() . "' title='" . myshop_utils::makeHrefTitle($item->getVar('cat_title')) . "'>" . $item->getVar('cat_title') . "</a>"; } $block['block_categories'] = $tbl_tmp; } } else { // Normal display $block['block_option'] = 1; include XOOPS_ROOT_PATH . '/modules/myshop/include/common.php'; include_once MYSHOP_PATH . 'class/tree.php'; $tbl_categories = $h_myshop_cat->getAllCategories(); $mytree = new Myshop_XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid'); $jump = MYSHOP_URL . "category.php?cat_cid="; $additional = "onchange='location=\"" . $jump . "\"+this.options[this.selectedIndex].value'"; if (isset($GLOBALS['current_category']) && $GLOBALS['current_category'] != -1) { $cat_cid = intval($GLOBALS['current_category']); } else { $cat_cid = 0; } $htmlSelect = $mytree->makeSelBox('cat_cid', 'cat_title', '-', $cat_cid, false, 0, $additional); $block['htmlSelect'] = $htmlSelect; } return $block; }