예제 #1
0
function smartsection_latest_files_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    /**
     * $options[0] : Sort order - datesub | counter
     * $options[1] : Number of files to display
     * $oprions[2] : bool TRUE to link to the file download, FALSE to link to the article
     */
    $block = array();
    $sort = $options[0];
    $order = smartsection_getOrderBy($sort);
    $limit = $options[1];
    $directDownload = $options[2];
    $smartsection_file_handler =& smartsection_gethandler('file', 'smartsection');
    // creating the files objects
    $filesObj = $smartsection_file_handler->getAllFiles(0, _SSECTION_STATUS_FILE_ACTIVE, $limit, 0, $sort, $order);
    foreach ($filesObj as $fileObj) {
        $aFile = array();
        $aFile['link'] = $directDownload ? $fileObj->getFileLink() : $fileObj->getItemLink();
        if ($sort == "datesub") {
            $aFile['new'] = $fileObj->datesub();
        } elseif ($sort == "counter") {
            $aFile['new'] = $fileObj->counter();
        } elseif ($sort == "weight") {
            $aFile['new'] = $fileObj->weight();
        }
        $block['files'][] = $aFile;
    }
    return $block;
}
예제 #2
0
 /**
  * constructor
  */
 function SmartsectionItem($id = null)
 {
     $this->db =& Database::getInstance();
     $this->initVar("itemid", XOBJ_DTYPE_INT, -1, false);
     $this->initVar("categoryid", XOBJ_DTYPE_INT, 0, false);
     $this->initVar("title", XOBJ_DTYPE_TXTBOX, null, true, 255);
     $this->initVar("summary", XOBJ_DTYPE_TXTAREA, null, false);
     $this->initVar("display_summary", XOBJ_DTYPE_INT, 1, false);
     $this->initVar("body", XOBJ_DTYPE_TXTAREA, null, false);
     $this->initVar("uid", XOBJ_DTYPE_INT, 0, false);
     $this->initVar("datesub", XOBJ_DTYPE_INT, null, false);
     $this->initVar("status", XOBJ_DTYPE_INT, -1, false);
     $this->initVar("image", XOBJ_DTYPE_TXTBOX, 'blank.png', false, 255);
     $this->initVar("counter", XOBJ_DTYPE_INT, 0, false);
     $this->initVar("weight", XOBJ_DTYPE_INT, 0, false);
     $this->initVar("partial_view", XOBJ_DTYPE_TXTBOX, null, false);
     $this->initVar("dohtml", XOBJ_DTYPE_INT, 1, true);
     $this->initVar("dosmiley", XOBJ_DTYPE_INT, 1, true);
     $this->initVar("doimage", XOBJ_DTYPE_INT, 1, true);
     $this->initVar("dobr", XOBJ_DTYPE_INT, 1, false);
     $this->initVar("doxcode", XOBJ_DTYPE_INT, 1, true);
     $this->initVar("cancomment", XOBJ_DTYPE_INT, 1, true);
     $this->initVar("comments", XOBJ_DTYPE_INT, 0, false);
     $this->initVar("notifypub", XOBJ_DTYPE_INT, 1, false);
     $this->initVar("meta_keywords", XOBJ_DTYPE_TXTAREA, null, false);
     $this->initVar("meta_description", XOBJ_DTYPE_TXTAREA, null, false);
     $this->initVar("short_url", XOBJ_DTYPE_TXTBOX, null, false, 255);
     $this->initVar("item_tag", XOBJ_DTYPE_TXTAREA, null, false);
     // Non consistent values
     $this->initVar("pagescount", XOBJ_DTYPE_INT, 0, false);
     if (isset($id)) {
         $smartsection_item_handler =& smartsection_gethandler('item');
         $item =& $smartsection_item_handler->get($id);
         foreach ($item->vars as $k => $v) {
             $this->assignVar($k, $v['value']);
         }
         $this->assignOtherProperties();
     } else {
         // it's a new item
         // Check to see if $smartlanguage_tag_handler is available
         // Hack by marcan for condolegal.smartfactory.ca
         /*	$this->setVar('title', "[fr]entrez le texte en français[/fr][en]entrez le texte en anglais[/en]");
         			$this->setVar('summary', "[fr]entrez le texte en français[/fr][en]entrez le texte en anglais[/en]");
         			$this->setVar('body', "[fr]entrez le texte en français[/fr][en]entrez le texte en anglais[/en]");
         			// End of Hack by marcan for condolegal.smartfactory.ca
         
         			global $smartlanguage_tag_handler;
         			if (isset($smartlanguage_tag_handler)) {
         				$theLanguageTags = $smartlanguage_tag_handler->getAllTagsForInput();
         				$this->setVar('title', $theLanguageTags);
         				$this->setVar('summary', $theLanguageTags);
         				$this->setVar('body', $theLanguageTags);
         			}
         			*/
     }
 }
예제 #3
0
function smartsection_items_random_item_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $block = array();
    $smartsection_item_handler =& smartsection_gethandler('item');
    // creating the ITEM object
    $itemsObj = $smartsection_item_handler->getRandomItem('summary', array(_SSECTION_STATUS_PUBLISHED));
    if ($itemsObj) {
        $block['content'] = $itemsObj->summary();
        $block['id'] = $itemsObj->itemid();
        $block['url'] = $itemsObj->getItemUrl();
        $block['lang_fullitem'] = _MB_SSECTION_FULLITEM;
    }
    return $block;
}
예제 #4
0
function smartsection_items_recent_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $myts =& MyTextSanitizer::getInstance();
    $smartModule =& smartsection_getModuleInfo();
    $block = array();
    $selectedcatids = explode(',', $options[0]);
    if (in_array(0, $selectedcatids)) {
        $allcats = true;
    } else {
        $allcats = false;
    }
    $sort = $options[1];
    $order = smartsection_getOrderBy($sort);
    $limit = $options[2];
    $smartsection_item_handler =& smartsection_gethandler('item');
    // creating the ITEM objects that belong to the selected category
    if ($allcats) {
        $criteria = null;
    } else {
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN'));
    }
    $itemsObj = $smartsection_item_handler->getItems($limit, $start, array(_SSECTION_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true);
    $totalItems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalItems; $i++) {
            $newItems['itemid'] = $itemsObj[$i]->itemid();
            $newItems['title'] = $itemsObj[$i]->title();
            $newItems['categoryname'] = $itemsObj[$i]->getCategoryName();
            $newItems['categoryid'] = $itemsObj[$i]->categoryid();
            $newItems['date'] = $itemsObj[$i]->datesub();
            $newItems['poster'] = xoops_getLinkedUnameFromId($itemsObj[$i]->uid());
            $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65);
            $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink();
            $block['items'][] = $newItems;
        }
        $block['lang_title'] = _MB_SSECTION_ITEMS;
        $block['lang_category'] = _MB_SSECTION_CATEGORY;
        $block['lang_poster'] = _MB_SSECTION_POSTEDBY;
        $block['lang_date'] = _MB_SSECTION_DATE;
        $modulename = $myts->makeTboxData4Show($smartModule->getVar('name'));
        $block['lang_visitItem'] = _MB_SSECTION_VISITITEM . " " . $modulename;
    }
    return $block;
}
예제 #5
0
function smartsection_items_menu_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $block = array();
    /*if ($options[0] == 0) {
    		$categoryid = -1;
    	} else {
    		$categoryid = $options[0];
    	}
    
    	$sort = $options[1];
    	$order = smartsection_getOrderBy($sort);
    	$limit = $options[2];
    	*/
    $smartsection_item_handler =& smartsection_gethandler('item');
    $smartsection_category_handler =& smartsection_gethandler('category');
    // Are we in SmartSection ?
    global $xoopsModule;
    $block['inModule'] = isset($xoopsModule) && $xoopsModule->getVar('dirname') == 'smartsection';
    $catlink_class = 'menuMain';
    $categoryid = 0;
    if ($block['inModule']) {
        // Are we in a category and if yes, in which one ?
        $categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0;
        if ($categoryid != 0) {
            // if we are in a category, then the $categoryObj is already defined in smartsection/category.php
            global $categoryObj;
            $block['currentcat'] = $categoryObj->getCategoryLink('menuTop');
            $catlink_class = 'menuSub';
        }
    }
    // Getting all top cats
    $block_categoriesObj = $smartsection_category_handler->getCategories(0, 0, 0);
    $array_categoryids = array_keys($block_categoriesObj);
    $categoryids = implode(', ', $array_categoryids);
    foreach ($block_categoriesObj as $catid => $block_categoryObj) {
        if ($catid != $categoryid) {
            $block['categories'][$catid]['categoryLink'] = $block_categoryObj->getCategoryLink($catlink_class);
        }
    }
    return $block;
}
예제 #6
0
function smartsection_date_to_date_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $myts =& MyTextSanitizer::getInstance();
    $smartModule =& smartsection_getModuleInfo();
    $block = array();
    $fromArray = explode('/', $options[0]);
    //month, day, year
    $fromStamp = mktime(0, 0, 0, $fromArray[0], $fromArray[1], $fromArray[2]);
    $untilArray = explode('/', $options[1]);
    $untilStamp = mktime(0, 0, 0, $untilArray[0], $untilArray[1], $untilArray[2]);
    $criteria = new CriteriaCompo();
    $criteria->add(new Criteria('datesub', $fromStamp, '>'));
    $criteria->add(new Criteria('datesub', $untilStamp, '<'));
    $criteria->setSort('datesub');
    $criteria->setOrder('DESC');
    $smartsection_item_handler =& smartsection_gethandler('item');
    // creating the ITEM objects that belong to the selected category
    $itemsObj = $smartsection_item_handler->getObjects($criteria);
    $totalItems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalItems; $i++) {
            $newItems['itemid'] = $itemsObj[$i]->itemid();
            $newItems['title'] = $itemsObj[$i]->title();
            $newItems['categoryname'] = $itemsObj[$i]->getCategoryName();
            $newItems['categoryid'] = $itemsObj[$i]->categoryid();
            $newItems['date'] = $itemsObj[$i]->datesub();
            $newItems['poster'] = xoops_getLinkedUnameFromId($itemsObj[$i]->uid());
            $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65);
            $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink();
            $block['items'][] = $newItems;
        }
        $block['lang_title'] = _MB_SSECTION_ITEMS;
        $block['lang_category'] = _MB_SSECTION_CATEGORY;
        $block['lang_poster'] = _MB_SSECTION_POSTEDBY;
        $block['lang_date'] = _MB_SSECTION_DATE;
        $modulename = $myts->makeTboxData4Show($smartModule->getVar('name'));
        $block['lang_visitItem'] = _MB_SSECTION_VISITITEM . " " . $modulename;
        $block['lang_articles_from_to'] = sprintf(_MB_SSECTION_ARTICLES_FROM_TO, $options[0], $options[1]);
    }
    return $block;
}
예제 #7
0
function b_marquee_smartsection($limit, $dateformat, $itemssize)
{
    include_once XOOPS_ROOT_PATH . '/modules/smartsection/include/common.php';
    $myts =& MyTextSanitizer::getInstance();
    $smartModule =& smartsection_getModuleInfo();
    $block = array();
    $categoryid = -1;
    $sort = 'datesub';
    $order = smartsection_getOrderBy($sort);
    $smartsection_item_handler =& smartsection_gethandler('item');
    $itemsObj = $smartsection_item_handler->getAllPublished($limit, 0, $categoryid, $sort, $order);
    $totalItems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalItems; $i++) {
            if ($itemssize > 0) {
                $title = xoops_substr($itemsObj[$i]->title(), 0, $itemssize + 3);
            } else {
                $title = $itemsObj[$i]->title();
            }
            $block[] = array('date' => $itemsObj[$i]->datesub(), 'category' => $itemsObj[$i]->getCategoryName(), 'author' => xoops_getLinkedUnameFromId($itemsObj[$i]->uid()), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/smartsection/item.php?itemid=' . $itemsObj[$i]->itemid() . "'>" . $title . '</a>');
        }
    }
    return $block;
}
예제 #8
0
function smartsection_items_tree_edit($options)
{
    global $xoopsDB, $xoopsModule, $xoopsUser;
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/functions.php";
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    $form = "" . _MB_SSECTION_SELECTCAT . "&nbsp;\n<select name='options[]'>\n";
    $sel = "";
    if ($options[0] == -1) {
        $sel = " selected='selected'";
    }
    $form .= "<option value='-1'{$sel}>" . _MB_SSECTION_CURRENTCATEGORY . "</option>\n";
    if ($options[0] == 0) {
        $sel = " selected='selected'";
    }
    $form .= "<option value='0'{$sel}>" . _MB_SSECTION_ALLCAT . "</option>\n";
    // Creating the category handler object
    $category_handler =& smartsection_gethandler('category');
    // Creating category objects
    $categoriesObj = $category_handler->getCategories(0, 0, 0);
    if (count($categoriesObj) > 0) {
        foreach ($categoriesObj as $catID => $categoryObj) {
            $form .= smartsection_addCategoryOption($categoryObj, $options[0]);
        }
    }
    $form .= "</select>\n";
    $form .= "&nbsp;<br>" . _MB_SSECTION_ORDER . "&nbsp;<select name='options[]'>";
    $form .= "<option value='datesub'";
    if ($options[1] == "datesub") {
        $form .= " selected='selected'";
    }
    $form .= ">" . _MB_SSECTION_DATE . "</option>\n";
    $form .= "<option value='counter'";
    if ($options[1] == "counter") {
        $form .= " selected='selected'";
    }
    $form .= ">" . _MB_SSECTION_HITS . "</option>\n";
    $form .= "<option value='weight'";
    if ($options[1] == "weight") {
        $form .= " selected='selected'";
    }
    $form .= ">" . _MB_SSECTION_WEIGHT . "</option>\n";
    $form .= "</select>\n";
    $form .= "&nbsp;" . "<select name='options[]'>" . "<option value='ASC'";
    if ($options[2] == "ASC") {
        $form .= " selected='selected'";
    }
    $form .= ">" . _MB_SSECTION_ASC . "</option>" . "<option value='DESC'";
    if ($options[2] == "DESC") {
        $form .= " selected='selected'";
    }
    $form .= ">" . _MB_SSECTION_DESC . "</option>" . "</select>";
    $form .= "<br />" . _MB_SSECTION_LEVELS . "<input name='options[]' value='" . $options[3] . "' size='3' maxlenght='3'/>";
    $showItemsRadio = new XoopsFormRadioYN(_MB_SSECTION_SHOWITEMS, 'options[]', $options[4]);
    $form .= "<br />" . _MB_SSECTION_SHOWITEMS . "&nbsp;" . $showItemsRadio->render();
    return $form;
}
예제 #9
0
function smartsection_items_spot_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $opt_display_last = $options[0];
    $opt_items_count = $options[1];
    $opt_categoryid = $options[2];
    $sel_items = isset($options[3]) ? explode(',', $options[3]) : '';
    $opt_display_poster = $options[4];
    $opt_display_comment = $options[5];
    $opt_display_type = $options[6];
    if ($opt_categoryid == 0) {
        $opt_categoryid = -1;
    }
    $block = array();
    $smartsection_item_handler =& smartsection_gethandler('item');
    if ($opt_display_last == 1) {
        $itemsObj = $smartsection_item_handler->getAllPublished($opt_items_count, 0, $opt_categoryid, $sort = 'datesub', $order = 'DESC', 'summary');
        $i = 1;
        $itemsCount = count($itemsObj);
        if ($itemsObj) {
            foreach ($itemsObj as $key => $thisitem) {
                $item = array();
                $item = $thisitem->toArray();
                $item['who_when'] = sprintf(_MB_SSECTION_WHO_WHEN, $thisitem->posterName(), $thisitem->datesub());
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                $i++;
                $block['items'][] = $item;
            }
        }
    } else {
        $i = 1;
        $itemsCount = count($sel_items);
        foreach ($sel_items as $item_id) {
            $itemObj = new SmartsectionItem($item_id);
            if (!$itemObj->notLoaded() && $itemObj->checkPermission()) {
                $categoryObj = $itemObj->category();
                $item = array();
                $item = $itemObj->toArray();
                $item['who_when'] = sprintf(_MB_SSECTION_WHO_WHEN, $itemObj->posterName(), $itemObj->datesub());
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                $i++;
                $block['items'][] = $item;
            }
        }
    }
    if (isset($block['items']) && count($block['items']) == 0) {
        return false;
    }
    $block['lang_reads'] = _MB_SSECTION_READS;
    $block['lang_comments'] = _MB_SSECTION_COMMENTS;
    $block['lang_readmore'] = _MB_SSECTION_READMORE;
    $block['display_whowhen_link'] = $opt_display_poster;
    $block['display_comment_link'] = $opt_display_comment;
    $block['display_type'] = $opt_display_type;
    return $block;
}
예제 #10
0
function smartsection_createCategorySelect($selectedid = 0, $parentcategory = 0, $allCatOption = true, $selectname = 'options[0]')
{
    $selectedid = explode(',', $selectedid);
    $ret = "<select name='" . $selectname . "[]' multiple='multiple' size='10'>";
    if ($allCatOption) {
        $ret .= "<option value='0'";
        if (in_array(0, $selectedid)) {
            $ret .= " selected='selected'";
        }
        $ret .= ">" . _MB_SSECTION_ALLCAT . "</option>";
    }
    // Creating the category handler object
    $category_handler =& smartsection_gethandler('category');
    // Creating category objects
    $categoriesObj = $category_handler->getCategories(0, 0, $parentcategory);
    if (count($categoriesObj) > 0) {
        foreach ($categoriesObj as $catID => $categoryObj) {
            $ret .= smartsection_addCategoryOption($categoryObj, $selectedid);
        }
    }
    $ret .= "</select>";
    return $ret;
}
예제 #11
0
 /**
  * storeFaq: store the FAQ in the application's specific database (required)
  * @param xhelpFaq $faq The faq to add
  * @return bool true (success) / false (failure)
  * @access public
  */
 function storeFaq(&$faq)
 {
     global $xoopsUser, $smartsection_item_handler;
     $uid = $xoopsUser->getVar('uid');
     //fix for smartsectionItem::store assuming that smartsection handlers are globalized
     $GLOBALS['smartsection_item_handler'] =& smartsection_gethandler('item');
     $GLOBALS['smartsection_category_handler'] =& smartsection_gethandler('category');
     $ssConfig =& smartsection_getModuleConfig();
     // Create page in smartsection from xhelpFAQ object
     $hSSItem =& smartsection_gethandler('item');
     $itemObj =& $hSSItem->create();
     //$faq->getVar('categories') is an array. If your application
     //only supports single categories use the first element
     //in the array
     $categories = $faq->getVar('categories');
     $categories = intval($categories[0]);
     // Change array of categories to 1 category
     // Putting the values about the ITEM in the ITEM object
     $itemObj->setVar('categoryid', $categories);
     $itemObj->setVar('title', $faq->getVar('subject', 'e'));
     $itemObj->setVar('summary', '[b]' . ucfirst(_XHELP_TEXT_PROBLEM) . "[/b]\r\n" . $faq->getVar('problem', 'e'));
     $itemObj->setVar('body', '[b]' . ucfirst(_XHELP_TEXT_SOLUTION) . "[/b]\r\n" . $faq->getVar('solution', 'e'));
     $itemObj->setVar('dohtml', XHELP_SSECTION_DOHTML);
     $itemObj->setVar('dosmiley', XHELP_SSECTION_DOSMILEY);
     $itemObj->setVar('doxcode', XHELP_SSECTION_DOBBCODE);
     $itemObj->setVar('doimage', XHELP_SSECTION_DOIMAGE);
     $itemObj->setVar('dobr', XHELP_SSECTION_DOBR);
     $itemObj->setVar('notifypub', XHELP_SSECTION_NOTIFYPUB);
     $itemObj->setVar('uid', $uid);
     $itemObj->setVar('datesub', time());
     // Setting the status of the item
     if ($this->_articleNeedsApproval()) {
         $itemObj->setVar('status', _SSECTION_STATUS_SUBMITTED);
     } else {
         $itemObj->setVar('status', _SSECTION_STATUS_PUBLISHED);
     }
     // Storing the item object in the database
     if ($ret = $itemObj->store()) {
         $faq->setVar('id', $itemObj->getVar('itemid'));
         $faq->setVar('url', $this->makeFaqUrl($faq));
         if (!$this->_articleNeedsApproval()) {
             // Send notifications
             $itemObj->sendNotifications(array(_SSECTION_NOT_ITEM_PUBLISHED));
         } else {
             if (XHELP_SSECTION_NOTIFYPUB) {
                 include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
                 $notification_handler =& xoops_gethandler('notification');
                 $notification_handler->subscribe('item', $itemObj->itemid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
             }
             // Send notifications
             $itemObj->sendNotifications(array(_SSECTION_NOT_ITEM_SUBMITTED));
         }
     }
     return $ret;
 }