示例#1
0
 public function indexAction()
 {
     $m_article = $this->load('Article');
     $userID = $this->getSession('userID');
     if ($userID) {
         $buffer['username'] = $this->getSession('username');
         // User Aritcles
         $where = array('userID' => USER_ID);
         $total = $m_article->Where($where)->Total();
         $page = $this->get('page');
         $page = $page ? $page : 1;
         $size = 10;
         $pages = ceil($total / $size);
         $order = array('addTime' => 'DESC');
         $start = ($page - 1) * $size;
         $limit = $start . ',' . $size;
         $url = '/user/profile';
         $buffer['pageNav'] = generatePageLink($page, $pages, $url, $total);
         $buffer['articles'] = $m_article->Where($where)->Order($order)->Limit($limit)->Select();
     } else {
         $this->redirect('/');
     }
     // 如果有 xhprof 则开启跟踪功能
     if (function_exists('xhprof_disable')) {
         $data = xhprof_disable();
         include_once LIB_PATH . '/xhprof_lib/utils/xhprof_lib.php';
         include_once LIB_PATH . '/xhprof_lib/utils/xhprof_runs.php';
         $objXhprofRun = new XHProfRuns_Default();
         $run_id = $objXhprofRun->save_run($data, 'xhprof');
     }
     $buffer['run_id'] = $run_id;
     $this->getView()->assign($buffer);
 }
示例#2
0
文件: Role.php 项目: jackton/YOF
 /**
  *  Index : list all roles
  */
 public function indexAction()
 {
     $total = $this->m_role->Total();
     $totalPages = ceil($total / 15);
     $order = array('id' => 'DESC');
     $limit = $this->getLimit(15);
     $buffer['pageNav'] = generatePageLink($page, $totalPages, $this->homeUrl, $total);
     $buffer['roles'] = $this->m_role->Order($order)->Limit($limit)->Select();
     $this->getView()->assign($buffer);
 }
示例#3
0
文件: User.php 项目: xn1224/YOF
 public function indexAction()
 {
     $total = $this->m_user->Total();
     $page = $this->get('page');
     $size = 10;
     $pages = ceil($total / $size);
     $order = array('id' => 'DESC');
     $limit = $this->getLimit();
     $buffer['pageNav'] = generatePageLink($page, $pages, $this->homeUrl, $total);
     $buffer['users'] = $this->m_user->Order($order)->Limit($limit)->Select();
     $this->getView()->assign($buffer);
 }
示例#4
0
文件: Article.php 项目: udeth/YOF
 public function indexAction()
 {
     $total = $this->m_article->Total();
     $page = $this->get('page');
     $page = $page ? $page : 1;
     $size = 10;
     $pages = ceil($total / $size);
     $order = array('id' => 'DESC');
     $start = ($page - 1) * $size;
     $limit = $start . ',' . $size;
     $buffer['pageNav'] = generatePageLink($page, $pages, $this->homeUrl, $total);
     $buffer['articles'] = $this->m_article->Order($order)->Limit($limit)->Select();
     $this->getView()->assign($buffer);
 }
示例#5
0
文件: Role.php 项目: GobYang/thaidh
 /**
  *  Index : list all roles
  */
 public function indexAction()
 {
     $page = $this->get('page');
     $page = isset($page) ? $page : 1;
     $total = $this->m_role->Total();
     $limit = 15;
     $totalPages = ceil($total / $limit);
     $page = verifyPage($page, $totalPages);
     $start = ($page - 1) * $limit;
     $buffer['pageNav'] = generatePageLink($page, $totalPages, $this->indexURL, $total);
     $order = array('id' => 'DESC');
     $limit = " {$start}, {$limit}";
     $buffer['roles'] = $this->m_role->Order($order)->Limit($limit)->Select();
     $this->getView()->assign($buffer);
 }
示例#6
0
文件: Role.php 项目: xn1224/YOF
 /**
  *  Index : list all roles
  */
 public function indexAction()
 {
     $keyword = $this->get('keyword');
     if ($keyword) {
         $query = '&keyword=' . $keyword;
         $buffer['keyword'] = $keyword;
         $total = $this->m_role->Where('username', 'LIKE', $keyword)->Total();
     } else {
         $total = $this->m_role->Total();
     }
     $totalPages = ceil($total / 10);
     $order = array('id' => 'DESC');
     $limit = $this->getLimit();
     $page = $this->get('page');
     $buffer['pageNav'] = generatePageLink($page, $totalPages, $this->homeUrl, $total, $query);
     if ($keyword) {
         $buffer['roles'] = $this->m_role->Where('username', 'LIKE', $keyword)->Order($order)->Limit($limit)->Select();
     } else {
         $buffer['roles'] = $this->m_role->Order($order)->Limit($limit)->Select();
     }
     $this->getView()->assign($buffer);
 }
示例#7
0
function stocks_eshop($params)
{
    global $tpl, $template, $twig, $mysql, $SYSTEM_FLAGS, $config, $userROW, $CurrentHandler, $lang;
    $url = pluginGetVariable('eshop', 'url');
    switch ($CurrentHandler['handlerParams']['value']['pluginName']) {
        case 'core':
            if (isset($url) && !empty($url)) {
                return redirect_eshop(generateLink('eshop', 'stocks'));
            }
            break;
        case 'eshop':
            if (empty($url)) {
                return redirect_eshop(generateLink('core', 'plugin', array('plugin' => 'eshop')));
            }
            break;
    }
    $SYSTEM_FLAGS['info']['title']['group'] = $lang['eshop']['name_plugin'];
    $SYSTEM_FLAGS['info']['title']['others'] = $lang['eshop']['name_stocks'];
    $SYSTEM_FLAGS['template.main.name'] = pluginGetVariable('eshop', 'main_template') ? pluginGetVariable('eshop', 'main_template') : 'main';
    $SYSTEM_FLAGS['meta']['description'] = pluginGetVariable('eshop', 'description') ? pluginGetVariable('eshop', 'description') : $SYSTEM_FLAGS['meta']['description'];
    $SYSTEM_FLAGS['meta']['keywords'] = pluginGetVariable('eshop', 'keywords') ? pluginGetVariable('eshop', 'keywords') : $SYSTEM_FLAGS['meta']['keywords'];
    $tpath = locatePluginTemplates(array('stocks_eshop'), 'eshop', pluginGetVariable('eshop', 'localsource'), pluginGetVariable('eshop', 'localskin'));
    $xt = $twig->loadTemplate($tpath['stocks_eshop'] . 'stocks_eshop.tpl');
    if (isset($_REQUEST['mode']) && $_REQUEST['mode']) {
        $mode = filter_var($_REQUEST['mode'], FILTER_SANITIZE_STRING);
    } else {
        $mode = "stocks";
    }
    $conditions = array();
    array_push($conditions, "p.active = 1 ");
    switch ($mode) {
        case "stocks":
            array_push($conditions, "p.stocked = 1");
            $orderby = " ORDER BY p.editdate DESC ";
            break;
        default:
            array_push($conditions, "p.stocked = 1");
            $orderby = " ORDER BY p.editdate DESC ";
            break;
    }
    $limitCount = pluginGetVariable('eshop', 'count_stocks');
    $pageNo = intval($params['page']) ? intval($params['page']) : intval($_REQUEST['page']);
    if ($pageNo < 1) {
        $pageNo = 1;
    }
    if (!$limitStart) {
        $limitStart = ($pageNo - 1) * $limitCount;
    }
    $fSort = " GROUP BY p.id ORDER BY p.id DESC";
    $sqlQPart = "FROM " . prefix . "_eshop_products p LEFT JOIN " . prefix . "_eshop_products_categories pc ON p.id = pc.product_id LEFT JOIN " . prefix . "_eshop_categories c ON pc.category_id = c.id  " . (count($conditions) ? "WHERE " . implode(" AND ", $conditions) : '') . $fSort;
    $sqlQ = "SELECT p.id AS id, p.url as url, p.code AS code, p.name AS name, p.annotation AS annotation, p.body AS body, p.active AS active, p.featured AS featured, p.position AS position, p.meta_title AS meta_title, p.meta_keywords AS meta_keywords, p.meta_description AS meta_description, p.date AS date, p.editdate AS editdate, p.views AS views, c.id AS cid, c.url as curl, c.name AS category " . $sqlQPart;
    $sqlQCount = "SELECT COUNT(*) as CNT FROM (" . $sqlQ . ") AS T ";
    $count = $mysql->result($sqlQCount);
    $countPages = ceil($count / $limitCount);
    if ($countPages < $pageNo) {
        return msg(array("type" => "error", "text" => "Подстраницы не существует"));
    }
    if ($countPages > 1 && $countPages >= $pageNo) {
        $paginationParams = checkLinkAvailable('eshop', '') ? array('pluginName' => 'eshop', 'pluginHandler' => 'stocks', 'params' => array('keywords' => $get_url), 'xparams' => array(), 'paginator' => array('page', 0, false)) : array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'eshop'), 'xparams' => array('keywords' => $get_url), 'paginator' => array('page', 1, false));
        $navigations = LoadVariables();
        $pages = generatePagination($pageNo, 1, $countPages, 10, $paginationParams, $navigations);
    }
    $cmp_array = array();
    foreach ($SYSTEM_FLAGS["eshop"]["compare"]["entries"] as $cmp_row) {
        $cmp_array[] = $cmp_row['linked_fld'];
    }
    foreach ($mysql->select($sqlQ . ' LIMIT ' . $limitStart . ', ' . $limitCount) as $row) {
        $fulllink = checkLinkAvailable('eshop', 'show') ? generateLink('eshop', 'show', array('alt' => $row['url'])) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'show'), array('alt' => $row['url']));
        $catlink = checkLinkAvailable('eshop', '') ? generateLink('eshop', '', array('alt' => $row['curl'])) : generateLink('core', 'plugin', array('plugin' => 'eshop'), array('alt' => $row['curl']));
        $cmp_flag = in_array($row['id'], $cmp_array);
        $entries[$row['id']] = array('id' => $row['id'], 'code' => $row['code'], 'name' => $row['name'], 'annotation' => $row['annotation'], 'body' => $row['body'], 'active' => $row['active'], 'featured' => $row['featured'], 'price' => $row['price'], 'compare_price' => $row['compare_price'], 'stock' => $row['stock'], 'meta_title' => $row['meta_title'], 'meta_keywords' => $row['meta_keywords'], 'meta_description' => $row['meta_description'], 'fulllink' => $fulllink, 'date' => empty($row['date']) ? '' : $row['date'], 'editdate' => empty($row['editdate']) ? '' : $row['editdate'], 'views' => $row['views'], 'cat_name' => $row['category'], 'cid' => $row['cid'], 'catlink' => $catlink, 'compare' => $cmp_flag, 'home' => home, 'image_filepath' => $row['image_filepath'], 'tpl_url' => home . '/templates/' . $config['theme']);
    }
    $entries_array_ids = array_keys($entries);
    if (isset($entries_array_ids) && !empty($entries_array_ids)) {
        $entries_string_ids = implode(',', $entries_array_ids);
        foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_images i WHERE i.product_id IN (' . $entries_string_ids . ') ORDER BY i.position, i.id') as $irow) {
            $entries[$irow['product_id']]['images'][] = $irow;
        }
        foreach ($mysql->select('SELECT * FROM ' . prefix . '_eshop_variants v WHERE v.product_id IN (' . $entries_string_ids . ') ORDER BY v.position, v.id') as $vrow) {
            $entries[$vrow['product_id']]['variants'][] = $vrow;
        }
    }
    $tVars = array('info' => isset($info) ? $info : '', 'entries' => isset($entries) ? $entries : '', 'pages' => array('true' => isset($pages) && $pages ? 1 : 0, 'print' => isset($pages) ? $pages : ''), 'prevlink' => array('true' => !empty($limitStart) ? 1 : 0, 'link' => str_replace('%page%', "\$1", str_replace('%link%', checkLinkAvailable('eshop', '') ? generatePageLink(array('pluginName' => 'eshop', 'pluginHandler' => 'stocks', 'params' => array(), 'xparams' => array(), 'paginator' => array('page', 0, false)), $prev = floor($limitStart / $limitCount)) : generatePageLink(array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'eshop'), 'xparams' => array(), 'paginator' => array('page', 1, false)), $prev = floor($limitStart / $limitCount)), isset($navigations['prevlink']) ? $navigations['prevlink'] : ''))), 'nextlink' => array('true' => $prev + 2 <= $countPages ? 1 : 0, 'link' => str_replace('%page%', "\$1", str_replace('%link%', checkLinkAvailable('eshop', '') ? generatePageLink(array('pluginName' => 'eshop', 'pluginHandler' => 'stocks', 'params' => array(), 'xparams' => array(), 'paginator' => array('page', 0, false)), $prev + 2) : generatePageLink(array('pluginName' => 'core', 'pluginHandler' => 'plugin', 'params' => array('plugin' => 'eshop'), 'xparams' => array(), 'paginator' => array('page', 1, false)), $prev + 2), isset($navigations['nextlink']) ? $navigations['nextlink'] : ''))), 'tpl_url' => home . '/templates/' . $config['theme'], 'tpl_home' => admin_url);
    $template['vars']['mainblock'] .= $xt->render($tVars);
}