예제 #1
0
function listWeblinks($catid)
{
    global $mainframe, $database, $my;
    global $mosConfig_live_site;
    global $Itemid;
    $rows = array();
    $currentcat = null;
    if ($catid) {
        // url links info for category
        $query = "SELECT id, url, title, description, date, hits, params" . "\n FROM #__weblinks" . "\n WHERE catid = " . (int) $catid . "\n AND published = 1" . "\n AND archived = 0" . "\n ORDER BY ordering";
        $database->setQuery($query);
        $rows = $database->loadObjectList();
        // current cate info
        $query = "SELECT *" . "\n FROM #__categories" . "\n WHERE id = " . (int) $catid . "\n AND published = 1" . "\n AND access <= " . (int) $my->gid;
        $database->setQuery($query);
        $database->loadObject($currentcat);
        /*
        Check if the category is published or if access level allows access
        */
        if (!$currentcat->name) {
            mosNotAuth();
            return;
        }
    }
    /* Query to retrieve all categories that belong under the web links section and that are published. */
    $query = "SELECT cc.*, a.catid, a.title, a.url, COUNT(a.id) AS numlinks" . "\n FROM #__categories AS cc" . "\n LEFT JOIN #__weblinks AS a ON a.catid = cc.id" . "\n WHERE a.published = 1" . "\n AND section = 'com_weblinks'" . "\n AND cc.published = 1" . "\n AND cc.access <= " . (int) $my->gid . "\n GROUP BY cc.id" . "\n ORDER BY cc.ordering";
    $database->setQuery($query);
    $categories = $database->loadObjectList();
    // Parameters
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('header', $menu->name);
    $params->def('pageclass_sfx', '');
    $params->def('headings', 1);
    $params->def('hits', $mainframe->getCfg('hits'));
    $params->def('item_description', 1);
    $params->def('other_cat_section', 1);
    $params->def('other_cat', 1);
    $params->def('description', 1);
    $params->def('description_text', _WEBLINKS_DESC);
    $params->def('image', '-1');
    $params->def('weblink_icons', '');
    $params->def('image_align', 'right');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    if ($catid) {
        $params->set('type', 'category');
    } else {
        $params->set('type', 'section');
    }
    // page description
    $currentcat->descrip = '';
    if (@$currentcat->description != '') {
        $currentcat->descrip = $currentcat->description;
    } else {
        if (!$catid) {
            // show description
            if ($params->get('description')) {
                $currentcat->descrip = $params->get('description_text');
            }
        }
    }
    // page image
    $currentcat->img = '';
    $path = $mosConfig_live_site . '/images/stories/';
    if (@$currentcat->image != '') {
        $currentcat->img = $path . $currentcat->image;
        $currentcat->align = $currentcat->image_position;
    } else {
        if (!$catid) {
            if ($params->get('image') != -1) {
                $currentcat->img = $path . $params->get('image');
                $currentcat->align = $params->get('image_align');
            }
        }
    }
    // page header
    $currentcat->header = '';
    if (@$currentcat->name != '') {
        $currentcat->header = $currentcat->name;
    } else {
        $currentcat->header = $params->get('header');
    }
    // used to show table rows in alternating colours
    $tabclass = array('sectiontableentry1', 'sectiontableentry2');
    HTML_weblinks::displaylist($categories, $rows, $catid, $currentcat, $params, $tabclass);
}
예제 #2
0
파일: weblinks.php 프로젝트: cwcw/cms
function listWeblinks($catid)
{
    global $mainframe, $database, $my;
    global $mosConfig_shownoauth, $mosConfig_live_site, $mosConfig_absolute_path;
    global $cur_template, $Itemid;
    /* Query to retrieve all categories that belong under the web links section and that are published. */
    $query = "SELECT *, COUNT(a.id) AS numlinks FROM #__categories AS cc" . "\n LEFT JOIN #__weblinks AS a ON a.catid = cc.id" . "\n WHERE a.published='1' AND a.approved='1' AND section='com_weblinks' AND cc.published='1' AND cc.access <= '{$my->gid}'" . "\n GROUP BY cc.id" . "\n ORDER BY cc.ordering";
    $database->setQuery($query);
    $categories = $database->loadObjectList();
    $rows = array();
    $currentcat = NULL;
    if ($catid) {
        // url links info for category
        $query = "SELECT id, url, title, description, date, hits FROM #__weblinks" . "\nWHERE catid = '{$catid}' AND published='1' AND approved='1' AND archived=0" . "\nORDER BY ordering";
        $database->setQuery($query);
        $rows = $database->loadObjectList();
        // current cate info
        $query = "SELECT name, description, image, image_position FROM #__categories" . "\n WHERE id = '{$catid}'" . "\n AND published = '1'";
        $database->setQuery($query);
        $database->loadObject($currentcat);
    }
    // Parameters
    $menu =& new mosMenu($database);
    $menu->load($Itemid);
    $params =& new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('header', $menu->name);
    $params->def('pageclass_sfx', '');
    $params->def('headings', 1);
    $params->def('hits', $mainframe->getCfg('hits'));
    $params->def('item_description', 1);
    $params->def('other_cat', 1);
    $params->def('description', 1);
    $params->def('description_text', _WEBLINKS_DESC);
    $params->def('image', '-1');
    $params->def('weblink_icons', '');
    $params->def('image_align', 'right');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    // page description
    $currentcat->descrip = '';
    if (@$currentcat->description != '') {
        $currentcat->descrip = $currentcat->description;
    } else {
        if (!$catid) {
            // show description
            if ($params->get('description')) {
                $currentcat->descrip = $params->get('description_text');
            }
        }
    }
    // page image
    $currentcat->img = '';
    $path = $mosConfig_live_site . '/images/stories/';
    if (@$currentcat->image != '') {
        $currentcat->img = $path . $currentcat->image;
        $currentcat->align = $currentcat->image_position;
    } else {
        if (!$catid) {
            if ($params->get('image') != -1) {
                $currentcat->img = $path . $params->get('image');
                $currentcat->align = $params->get('image_align');
            }
        }
    }
    // page header
    $currentcat->header = '';
    if (@$currentcat->name != '') {
        $currentcat->header = $currentcat->name;
    } else {
        $currentcat->header = $params->get('header');
    }
    // used to show table rows in alternating colours
    $tabclass = array('sectiontableentry1', 'sectiontableentry2');
    HTML_weblinks::displaylist($categories, $rows, $catid, $currentcat, $params, $tabclass);
}