当前位置: 首页>>代码示例>>PHP>>正文


PHP Paging::sanity_check方法代码示例

本文整理汇总了PHP中Paging::sanity_check方法的典型用法代码示例。如果您正苦于以下问题:PHP Paging::sanity_check方法的具体用法?PHP Paging::sanity_check怎么用?PHP Paging::sanity_check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Paging的用法示例。


在下文中一共展示了Paging::sanity_check方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_paging

/**
 * Creates a way to navigate between pages.
 *
 * @param array $params
 * @param object $smarty
 * @return string
 */
function smarty_paging($params, &$smarty)
{
    global $PIVOTX, $modifier;
    $params = cleanParams($params);
    $action = getDefault($params['action'], "digg");
    $showalways = getDefault($params['showalways'], false);
    $funcs = new Paging("paging");
    // Check if we are called correctly and on the correct page
    $msg = $funcs->sanity_check($action);
    if ($msg != "" && $showalways == false) {
        return $msg;
    }
    // Currently only finds the offset
    $msg = $funcs->setup($action);
    if ($msg != "" && $showalways == false) {
        return $msg;
    }
    $subweblogs = $PIVOTX['weblogs']->getSubweblogs();
    $num_entries = 0;
    $cats = array();
    // Find the number of entries displayed on the page, as defined
    // in the weblog configuration, unless specified as a parameter
    if (!empty($params['amount'])) {
        $num_entries = intval($params['amount']);
    } else {
        if (!empty($params['showme'])) {
            // Note: 'showme' is deprecated. included for backwards compatibility.
            $num_entries = intval($params['showme']);
        } else {
            foreach ($subweblogs as $subweblog) {
                $subweblog = $PIVOTX['weblogs']->getSubweblog('', $subweblog);
                $num_entries = max($subweblog['num_entries'], $num_entries);
            }
        }
    }
    // Find the categories displayed on the page, as defined in
    // the weblog configuration, unless specified as a parameter
    //
    // If we have a 'c=' parameter, use the cats in that to display..
    // To prevent weird things from happening, we only allow changing weblogs
    // with a name like 'default', 'standard', 'main' or 'weblog'.
    // Alternatively, we check if the template specifies the categories to
    // display, like [[ weblog name='weblog' category="default, movies, music" ]]
    if (!empty($modifier['category'])) {
        $cats = explode(",", safeString($modifier['category']));
        $cats = array(array_map("trim", $cats));
    } else {
        if (!empty($params['category']) && $params['category'] == "*") {
            $cats = array($PIVOTX['categories']->getCategorynames());
            $params['catsinlink'] = true;
        } else {
            if (!empty($params['category'])) {
                $cats = explode(",", safeString($params['category']));
                $cats = array(array_map("trim", $cats));
                $params['catsinlink'] = true;
            } else {
                // We have to keep the subweblogs separate, because we need to be able to figure
                // out which subweblog has the most entries, and _not_ the entries combined.
                foreach ($subweblogs as $subweblog) {
                    $subweblog = $PIVOTX['weblogs']->getSubweblog('', $subweblog);
                    // Only add categories from subweblogs that have any categories assigned.
                    if (count($subweblog['categories']) > 0) {
                        $cats[] = $subweblog['categories'];
                    }
                }
            }
        }
    }
    return $funcs->doit($action, $text, $cats, $num_entries, $params);
}
开发者ID:laiello,项目名称:pivotx-sqlite,代码行数:77,代码来源:module_smarty.php


注:本文中的Paging::sanity_check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。