コード例 #1
0
ファイル: items_tree.php プロジェクト: severnaya99/Sg-2010
function smartsection_items_tree_show($options)
{
    /*
    	options(
    		[0] => category (-1: current; 0: all)
    		[1] => sort
    		[2] => order
    		[3] => maxlevel (-1: all)
    		[4] => show items
    	);
    */
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $block = array();
    switch ($options[0]) {
        case -1:
            global $xoopsModule;
            $smartModule =& smartsection_getModuleInfo();
            echo $xoopsModule->dirname() . "<br>";
            echo $smartModule->dirname();
            if ($xoopsModule->dirname() == $smartModule->dirname()) {
                if (isset($_GET['categoryid'])) {
                    $cat2show = $_GET['categoryid'];
                } else {
                    if (isset($_GET['itemid'])) {
                        $itemObj = new SmartsectionItem($_GET['itemid']);
                        $cat2show = $itemObj->categoryid();
                    } else {
                        $cat2show = 0;
                    }
                    //itemid
                }
                //categoryid
            }
            //dirname
            break;
        case 0:
            $cat2show = 0;
            break;
        default:
            $cat2show = $options[0];
            break;
    }
    $sort = $options[1];
    //$order = smartsection_getOrderBy($sort);
    $order = $options[2];
    $maxlevel = $options[3];
    $showItems = $options[4];
    $arrayTree = smartsection_tree($cat2show, 0, $sort, $order, $maxlevel, $showItems);
    $block["arrayTree"] = $arrayTree;
    return $block;
}
コード例 #2
0
ファイル: comment_new.php プロジェクト: severnaya99/Sg-2010
// it under the terms of the GNU General Public License as published by     //
// the Free Software Foundation; either version 2 of the License, or        //
// (at your option) any later version.                                      //
// //
// You may not change or alter any portion of this comment or credits       //
// of supporting developers from this source code or any supporting         //
// source code which is considered copyrighted (c) material of the          //
// original comment or credit authors.                                      //
// //
// This program is distributed in the hope that it will be useful,          //
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
// GNU General Public License for more details.                             //
// //
// You should have received a copy of the GNU General Public License        //
// along with this program; if not, write to the Free Software              //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
// ------------------------------------------------------------------------ //
include_once '../../mainfile.php';
include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/functions.php";
$com_itemid = isset($_GET['com_itemid']) ? intval($_GET['com_itemid']) : 0;
if ($com_itemid > 0) {
    $itemObj = new SmartsectionItem($com_itemid);
    $com_replytext = _POSTEDBY . '&nbsp;<b>' . smartsection_getLinkedUnameFromId($itemObj->uid()) . '</b>&nbsp;' . _DATE . '&nbsp;<b>' . $itemObj->dateSub() . '</b><br /><br />' . $itemObj->summary();
    $bodytext = $itemObj->body();
    if ($bodytext != '') {
        $com_replytext .= '<br /><br />' . $bodytext . '';
    }
    $com_replytitle = $itemObj->title();
    include_once XOOPS_ROOT_PATH . '/include/comment_new.php';
}
コード例 #3
0
ファイル: item.php プロジェクト: severnaya99/Sg-2010
 function getLastPublishedByCat($status = array(_SSECTION_STATUS_PUBLISHED))
 {
     $ret = array();
     $itemclause = "";
     if (!smartsection_userIsAdmin()) {
         $smartsectionPermHandler =& xoops_getmodulehandler('permission', 'smartsection');
         $items = $smartsectionPermHandler->getGrantedItems('item_read');
         $itemclause = " AND itemid IN (" . implode(',', $items) . ")";
     }
     $sql = "CREATE TEMPORARY TABLE tmp (categoryid INT(8) UNSIGNED NOT NULL,datesub int(11) DEFAULT '0' NOT NULL);";
     $sql2 = " LOCK TABLES " . $this->db->prefix('smartsection_items') . " READ;";
     $sql3 = " INSERT INTO tmp SELECT categoryid, MAX(datesub) FROM " . $this->db->prefix('smartsection_items') . " WHERE status IN (" . implode(',', $status) . ") {$itemclause} GROUP BY categoryid;";
     $sql4 = " SELECT " . $this->db->prefix('smartsection_items') . ".categoryid, itemid, title, short_url, uid, " . $this->db->prefix('smartsection_items') . ".datesub FROM " . $this->db->prefix('smartsection_items') . ", tmp\n\t                  WHERE " . $this->db->prefix('smartsection_items') . ".categoryid=tmp.categoryid AND " . $this->db->prefix('smartsection_items') . ".datesub=tmp.datesub;";
     /*
     //Old implementation
     $sql = "SELECT categoryid, itemid, question, uid, MAX(datesub) AS datesub FROM ".$this->db->prefix("smartitem_item")."
            WHERE status IN (". implode(',', $status).")";
     $sql .= " GROUP BY categoryid";
     */
     $this->db->queryF($sql);
     $this->db->queryF($sql2);
     $this->db->queryF($sql3);
     $result = $this->db->query($sql4);
     $error = $this->db->error();
     $this->db->queryF("UNLOCK TABLES;");
     $this->db->queryF("DROP TABLE tmp;");
     if (!$result) {
         trigger_error("Error in getLastPublishedByCat SQL: " . $error);
         return $ret;
     }
     while ($row = $this->db->fetchArray($result)) {
         $item = new SmartsectionItem();
         $item->assignVars($row);
         $ret[$row['categoryid']] =& $item;
         unset($item);
     }
     return $ret;
 }
コード例 #4
0
ファイル: items_spot.php プロジェクト: severnaya99/Sg-2010
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;
}