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


PHP Tpl::getArg方法代码示例

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


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

示例1: smarty_function_buildurl

/**
 *
 * 链接构造函数
 *
 * @param array $params
 * @param Tpl $tpl
 */
function smarty_function_buildurl($params, &$tpl)
{
    $urls = array();
    $as = $tpl->getArg($params, 'as', 'query');
    unset($params['as']);
    $prefix = $tpl->getArg($params, 'prefix', '/');
    unset($params['prefix']);
    $hides = $tpl->getArg($params, 'hide', null);
    unset($params['hide']);
    if (!empty($hides)) {
        $hides = explode(',', $hides);
        $hides = array_map('trim', $hides);
    }
    if (!empty($params)) {
        foreach ($params as $key => $val) {
            if (strlen($val) == 0) {
                continue;
            }
            if (!$hides || !in_array($key, $hides)) {
                $urls[] = urlencode($key);
            }
            $urls[] = urlencode($val);
        }
    }
    if (!empty($urls)) {
        $tpl->assign($as, $prefix . join('/', $urls));
    } else {
        $tpl->assign($as, null);
    }
}
开发者ID:BGCX261,项目名称:zoeeyphp-hg-to-git,代码行数:37,代码来源:function.buildurl.php

示例2: smarty_function_newsView

/**
 * 单信息显示
 * @param type $params
 * @param Tpl $tpl
 * @return type
 */
function smarty_function_newsView($params, &$tpl)
{
    $values = array();
    $types = array();
    /* @var $acStr ZeActiveString */
    $acStr = new ZeActiveString();
    $acStr->putAll(array('select' => 'SELECT
                         `id`,`title`,`category`
                          ,`detail`,`create_time`,`edit_time`
                FROM `news_e` news
                WHERE 1=1
         ', 'where.id' => 'AND `id` = :id ', 'where.next' => 'AND `id` > :id ', 'where.category' => 'AND `category` = :category ', 'where.category.set' => 'AND FIND_IN_SET(`category`,:category) > 0 ', 'where.search' => 'AND (`title` LIKE "%" || :search || "%"
                                 OR `detail` LIKE "%" || :search || "%") ', 'limit' => 'LIMIT 1 '));
    $acStr->active('select');
    $acStr->active('limit');
    $id = $tpl->getArg($params, 'id', null);
    if (is_numeric($id) && $id > 0) {
        $values['id'] = intval($id);
        $types['id'] = PDO::PARAM_INT;
        $acStr->active('where.id');
    }
    $next = $tpl->getArg($params, 'next', null);
    if (is_numeric($next) && $next > 0) {
        $values['id'] = intval($next);
        $types['id'] = PDO::PARAM_INT;
        $acStr->active('where.next');
    }
    /* todo prev */
    /* @var $recorder ZeRecorder */
    $recorder = new ZeRecorder(Conn::getConn());
    /* @var $pageSet ZePageSet */
    $pageSet = $tpl->getPageSet($params);
    $as = $tpl->getArg($params, 'as', 'news');
    $sql = $acStr->toString();
    $row = $recorder->query($sql)->bind($values, $types)->fetch();
    $tpl->assign($as, $row);
}
开发者ID:BGCX261,项目名称:zoeeyphp-hg-to-git,代码行数:43,代码来源:function.newsView.php

示例3: smarty_function_newsList

/**
 *
 * 新闻列表调用函数
 *
 * @param array $params
 * @param Tpl $tpl
 * @param bool $repeat
 */
function smarty_function_newsList($params, &$tpl)
{
    $values = array();
    $types = array();
    /* @var $acStr ZeActiveString */
    $acStr = new ZeActiveString();
    $acStr->putAll(array('select' => 'SELECT
                          `id`,`title`,`category`
                          ,`detail`,`create_time`,`edit_time`
                   FROM news_e news ', 'count' => 'SELECT count(1) FROM news_e news ', 'where' => 'WHERE 1=1 ', 'where.category' => 'AND `category` = :category ', 'where.category.set' => 'AND FIELD(`category`,:categorys) > 0 ', 'where.search' => 'AND (`title` LIKE "%" || :search || "%"
                                 OR `detail` LIKE "%" || :search || "%") ', 'order' => 'ORDER BY ', 'order.id.desc' => '`id` DESC ', 'order.id.asc' => '`id` ASC ', 'order.editTime.desc' => '`edit_time` DESC ', 'order.editTime.asc' => '`edit_time` ASC ', 'limit' => 'LIMIT :offset,:pageSize '));
    $acStr->active('count');
    $acStr->active('where');
    /* @var $category Integer 分类编号 */
    $category = $tpl->getArg($params, 'category', null);
    $category = !is_null($category) ? $category : $tpl->getVar('info.category');
    /*  默认分类选择到的是 0 ,有时需要仅调用默认分类信息,所以将-1指定为所有分类 */
    if ($category > -1) {
        if (strpos($category, ',') === FALSE) {
            $values['category'] = $category;
            $types['category'] = PDO::PARAM_INT;
            $acStr->active('where.category');
        } else {
            $values['categorys'] = $category;
            $types['categorys'] = PDO::PARAM_STR;
            $acStr->active('where.category.set');
        }
    }
    /* @var $search string 搜索 标题,内容 */
    $search = $tpl->getArg($params, 'search');
    $search = $search = $search ? $search : $tpl->getVar('info.search');
    if (!empty($search)) {
        $values['search'] = $search;
        $types['search'] = PDO::PARAM_STR;
        $acStr->active('where.search');
    }
    /* @var $recorder ZeRecorder */
    $recorder = new ZeRecorder(Conn::getConn());
    /* @var $pageSet ZePageSet */
    $pageSet = $tpl->getPageSet($params);
    /* @var $pageAs String */
    $pageAs = $tpl->getArg($params, 'pageAs', null);
    if (!is_null($pageAs)) {
        $sql = $acStr->toString();
        $recordCount = $recorder->query($sql)->bind($values, $types)->getInt();
        $pageSet->setRecordCount($recordCount);
        $tpl->assign($pageAs, $pageSet);
    }
    $acStr->update('count', 'select');
    /**
     * order
     */
    $order = $tpl->getArg($params, 'order');
    $order = $order ? $order : $tpl->getVar('info.order', 'editTime.desc');
    if (!empty($order) && in_array($order, array('id.desc', 'id.asc', 'editTime.desc', 'editTime.asc'))) {
        $acStr->active('order');
        $acStr->active('order.' . $order);
    }
    /**
     * limit
     */
    $acStr->active('limit');
    $values['offset'] = $pageSet->getOffset();
    $types['offset'] = PDO::PARAM_INT;
    $values['pageSize'] = $pageSet->getPageSize();
    $types['pageSize'] = PDO::PARAM_INT;
    $sql = $acStr->toString();
    $list = $recorder->query($sql)->bind($values, $types)->fetchAll();
    $as = $tpl->getArg($params, 'as', 'news_list');
    $tpl->assign($as, $list);
}
开发者ID:BGCX261,项目名称:zoeeyphp-hg-to-git,代码行数:79,代码来源:function.newsList.php

示例4: smarty_function_dateformat

/**
 *
 * 日期时间格式化
 *
 * @param array $params
 * @param Tpl $tpl
 * @return string
 */
function smarty_function_dateformat($params, &$tpl)
{
    $time = $tpl->getArg($params, 'time', 0);
    $format = $tpl->getArg($params, 'format', 'Y-m-d H:i:s');
    return date($format, $time);
}
开发者ID:BGCX261,项目名称:zoeeyphp-hg-to-git,代码行数:14,代码来源:function.dateformat.php


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