コード例 #1
0
ファイル: content.php プロジェクト: cwcw/cms
function show($row, $params, $gid, &$access, $pop, $option, $ItemidCount = NULL)
{
    global $database, $mainframe, $Itemid;
    global $mosConfig_live_site, $mosConfig_absolute_path;
    global $options, $cache;
    $noauth = !$mainframe->getCfg('shownoauth');
    if ($access->canEdit) {
        if ($row->id === null || $row->access > $gid) {
            mosNotAuth();
            return;
        }
    } else {
        if ($row->id === null || $row->state == 0) {
            mosNotAuth();
            return;
        }
        if ($row->access > $gid) {
            if ($noauth) {
                mosNotAuth();
                return;
            } else {
                if (!$params->get('intro_only')) {
                    mosNotAuth();
                    return;
                }
            }
        }
    }
    // GC Parameters
    $params->def('link_titles', $mainframe->getCfg('link_titles'));
    $params->def('author', !$mainframe->getCfg('hideAuthor'));
    $params->def('createdate', !$mainframe->getCfg('hideCreateDate'));
    $params->def('modifydate', !$mainframe->getCfg('hideModifyDate'));
    $params->def('print', !$mainframe->getCfg('hidePrint'));
    $params->def('pdf', !$mainframe->getCfg('hidePdf'));
    $params->def('email', !$mainframe->getCfg('hideEmail'));
    $params->def('rating', $mainframe->getCfg('vote'));
    $params->def('icons', $mainframe->getCfg('icons'));
    $params->def('readmore', $mainframe->getCfg('readmore'));
    // Other Params
    $params->def('image', 1);
    $params->def('section', 0);
    $params->def('section_link', 0);
    $params->def('category', 0);
    $params->def('category_link', 0);
    $params->def('introtext', 1);
    $params->def('pageclass_sfx', '');
    $params->def('item_title', 1);
    $params->def('url', 1);
    // loads the link for Section name
    if ($params->get('section_link')) {
        $query = "SELECT a.id" . "\n FROM #__menu AS a" . "\n WHERE a.componentid = " . $row->sectionid . "";
        $database->setQuery($query);
        $_Itemid = $database->loadResult();
        $link = sefRelToAbs('index.php?option=com_content&task=section&id=' . $row->sectionid . '&Itemid=' . $_Itemid);
        $row->section = '<a href="' . $link . '">' . $row->section . '</a>';
    }
    // loads the link for Category name
    if ($params->get('category_link')) {
        $query = "SELECT a.id" . "\n FROM #__menu AS a" . "\n WHERE a.componentid = " . $row->catid . "";
        $database->setQuery($query);
        $_Itemid = $database->loadResult();
        $link = sefRelToAbs('index.php?option=com_content&amp;task=category&amp;sectionid=' . $row->sectionid . '&amp;id=' . $row->catid . '&amp;Itemid=' . $_Itemid);
        $row->category = '<a href="' . $link . '">' . $row->category . '</a>';
    }
    // loads current template for the pop-up window
    $template = '';
    if ($pop) {
        $params->set('popup', 1);
        $database->setQuery("SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'");
        $template = $database->loadResult();
    }
    // show/hides the intro text
    if ($params->get('introtext')) {
        $row->text = $row->introtext . ($params->get('intro_only') ? '' : $row->fulltext);
    } else {
        $row->text = $row->fulltext;
    }
    // deal with the {mospagebreak} mambots
    // only permitted in the full text area
    $page = intval(mosGetParam($_REQUEST, 'limitstart', 0));
    // record the hit
    if (!$params->get('intro_only')) {
        $obj = new mosContent($database);
        $obj->hit($row->id);
    }
    $cache->call('HTML_content::show', $row, $params, $access, $page, $option, $ItemidCount);
}
コード例 #2
0
ファイル: content.php プロジェクト: jwest00724/Joomla-1.0
function show($row, $params, $gid, &$access, $pop, $option = 'com_content', $ItemidCount = NULL)
{
    global $database, $mainframe;
    global $cache;
    $noauth = !$mainframe->getCfg('shownoauth');
    if ($access->canEdit) {
        if ($row->id === null || $row->access > $gid) {
            mosNotAuth();
            return;
        }
    } else {
        if ($row->id === null || $row->state == 0) {
            mosNotAuth();
            return;
        }
        if ($row->access > $gid) {
            if ($noauth) {
                mosNotAuth();
                return;
            } else {
                if (!$params->get('intro_only')) {
                    mosNotAuth();
                    return;
                }
            }
        }
    }
    // GC Parameters
    $params->def('link_titles', $mainframe->getCfg('link_titles'));
    $params->def('author', !$mainframe->getCfg('hideAuthor'));
    $params->def('createdate', !$mainframe->getCfg('hideCreateDate'));
    $params->def('modifydate', !$mainframe->getCfg('hideModifyDate'));
    $params->def('print', !$mainframe->getCfg('hidePrint'));
    $params->def('pdf', !$mainframe->getCfg('hidePdf'));
    $params->def('email', !$mainframe->getCfg('hideEmail'));
    $params->def('rating', $mainframe->getCfg('vote'));
    $params->def('icons', $mainframe->getCfg('icons'));
    $params->def('readmore', $mainframe->getCfg('readmore'));
    // Other Params
    $params->def('image', 1);
    $params->def('section', 0);
    $params->def('section_link', 0);
    $params->def('category', 0);
    $params->def('category_link', 0);
    $params->def('introtext', 1);
    $params->def('pageclass_sfx', '');
    $params->def('item_title', 1);
    $params->def('url', 1);
    // if a popup item (e.g. print page) set popup param to correct value
    if ($pop) {
        $params->set('popup', 1);
    }
    // check if voting/rating enabled
    if ($params->get('rating')) {
        // voting query
        $query = "SELECT ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count" . "\n FROM #__content AS a" . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" . "\n WHERE a.id = " . (int) $row->id;
        $database->setQuery($query);
        $database->loadObject($voting);
        // add to $row info
        $row->rating = $voting->rating;
        $row->rating_count = $voting->rating_count;
    }
    $row->category = htmlspecialchars(stripslashes($row->category), ENT_QUOTES);
    if ($params->get('section_link') || $params->get('category_link')) {
        // loads the link for Section name
        if ($params->get('section_link') && $row->sectionid) {
            // pull values from mainframe
            $secLinkID = $mainframe->get('secID_' . $row->sectionid, -1);
            $secLinkURL = $mainframe->get('secURL_' . $row->sectionid);
            // check if values have already been placed into mainframe memory
            if ($secLinkID == -1) {
                $query = "SELECT id, link" . "\n FROM #__menu" . "\n WHERE published = 1" . "\n AND type IN ( 'content_section', 'content_blog_section' )" . "\n AND componentid = " . (int) $row->sectionid . "\n ORDER BY type DESC, ordering";
                $database->setQuery($query);
                //$secLinkID = $database->loadResult();
                $result = $database->loadRow();
                $secLinkID = $result[0];
                $secLinkURL = $result[1];
                if ($secLinkID == null) {
                    $secLinkID = 0;
                    // save 0 query result to mainframe
                    $mainframe->set('secID_' . $row->sectionid, 0);
                } else {
                    // save query result to mainframe
                    $mainframe->set('secID_' . $row->sectionid, $secLinkID);
                    $mainframe->set('secURL_' . $row->sectionid, $secLinkURL);
                }
            }
            $_Itemid = '';
            // use Itemid for section found in query
            if ($secLinkID != -1 && $secLinkID) {
                $_Itemid = '&amp;Itemid=' . $secLinkID;
            }
            if ($secLinkURL) {
                $secLinkURL = ampReplace($secLinkURL);
                $link = sefRelToAbs($secLinkURL . $_Itemid);
            } else {
                $link = sefRelToAbs('index.php?option=com_content&amp;task=section&amp;id=' . $row->sectionid . $_Itemid);
            }
            $row->section = '<a href="' . $link . '">' . $row->section . '</a>';
        }
        // loads the link for Category name
        if ($params->get('category_link') && $row->catid) {
            // pull values from mainframe
            $catLinkID = $mainframe->get('catID_' . $row->catid, -1);
            $catLinkURL = $mainframe->get('catURL_' . $row->catid);
            // check if values have already been placed into mainframe memory
            if ($catLinkID == -1) {
                $query = "SELECT id, link" . "\n FROM #__menu" . "\n WHERE published = 1" . "\n AND type IN ( 'content_category', 'content_blog_category' )" . "\n AND componentid = " . (int) $row->catid . "\n ORDER BY type DESC, ordering";
                $database->setQuery($query);
                //$catLinkID = $database->loadResult();
                $result = $database->loadRow();
                $catLinkID = $result[0];
                $catLinkURL = $result[1];
                if ($catLinkID == null) {
                    $catLinkID = 0;
                    // save 0 query result to mainframe
                    $mainframe->set('catID_' . $row->catid, 0);
                } else {
                    // save query result to mainframe
                    $mainframe->set('catID_' . $row->catid, $catLinkID);
                    $mainframe->set('catURL_' . $row->catid, $catLinkURL);
                }
            }
            $_Itemid = '';
            // use Itemid for category found in query
            if ($catLinkID != -1 && $catLinkID) {
                $_Itemid = '&amp;Itemid=' . $catLinkID;
            } else {
                if (isset($secLinkID) && $secLinkID != -1 && $secLinkID) {
                    // use Itemid for section found in query
                    $_Itemid = '&amp;Itemid=' . $secLinkID;
                }
            }
            if ($catLinkURL) {
                $link = sefRelToAbs($catLinkURL . $_Itemid);
            } else {
                $link = sefRelToAbs('index.php?option=com_content&amp;task=category&amp;sectionid=' . $row->sectionid . '&amp;id=' . $row->catid . $_Itemid);
            }
            $row->category = '<a href="' . $link . '">' . $row->category . '</a>';
        }
    }
    // show/hides the intro text
    if ($params->get('introtext')) {
        $row->text = $row->introtext . ($params->get('intro_only') ? '' : chr(13) . chr(13) . $row->fulltext);
    } else {
        $row->text = $row->fulltext;
    }
    // deal with the {mospagebreak} mambots
    // only permitted in the full text area
    $page = intval(mosGetParam($_REQUEST, 'limitstart', 0));
    // record the hit
    if (!$params->get('intro_only') && $page == 0) {
        $obj = new mosContent($database);
        $obj->hit($row->id);
    }
    // needed for caching purposes to stop different cachefiles being created for same item
    // does not affect anything else as hits data not outputted
    $row->hits = 0;
    $cache->call('HTML_content::show', $row, $params, $access, $page);
}