Help.php 3.57 KB
<?php

use Action\WebAction;
use Index\HelpModel;
//use LibModels\Web\Home\HelpData;
use WebPlugin\Helpers;
use WebPlugin\Paging;

/**
 * 帮助中心
 */
class helpController extends WebAction
{

    public static $fqaCateId = 37;

    public function indexAction()
    {
        //头部导航
        $channel = Helpers::getChannelNameByCookie();
        $this->setWebNavHeader($channel);
        $this->setTitle('帮助中心');

        $cateId = $this->get('category_id', 81);
        $problem = '';
        if (isset($_POST['problem'])) {
            $problem = trim($_POST['problem']);
        }
        else {
            $problem = $this->get('problem', '');
        }
        $helpList = HelpModel::getHelpList($cateId);
        $helpDetail = HelpModel::getHelpDetail($cateId);

        $data = array(
            'pathNav' => array(
                array(
                    'href' => SITE_MAIN,
                    'name' => 'YOHO!有货首页'
                ),
                array(
                    'name' => '帮助中心'
                )
            ),
            'helpNav' => $helpList,
            'contentHtml' => $helpDetail,
            'formAction' => '/help?category_id=' . self::$fqaCateId . '&problem=' . $problem,
            'problem' => $problem
        );

        if ($cateId == self::$fqaCateId) {
            $this->go(Helpers::url('/help/search', array('category_id' => self::$fqaCateId, 'problem' => $problem)));
        }
        else {
            $this->_view->display('index', array('helpIndexPage' => false, 'help' => $data));
        }
    }

    public function searchAction()
    {
        //头部导航
        $channel = Helpers::getChannelNameByCookie();
        $this->setWebNavHeader($channel);
        $this->setTitle('帮助中心');

        $cateId = self::$fqaCateId;
        if (isset($_POST['problem'])) {
            $problem = trim($_POST['problem']);
        }
        else {
            $problem = $this->get('problem', '');
        }

        //分页
        $page = $this->get('page', 1);
        $limit = 10;
        $paging = new Paging('yoho');


        $helpList = HelpModel::getHelpList($cateId);
        $question = HelpModel::getSearchDetail($cateId, $page, $limit, $problem);

        $total = isset($question['pager']['total']) ? $question['pager']['total'] : 0;
        $pageTotal = isset($question['pager']['pageTotal']) ? $question['pager']['pageTotal'] : 0;
        $page = isset($question['pager']['page']) ? $question['pager']['page'] : 0;
        unset($question['pager']);
        $paging->setTotal($total)->setSize($limit)->setQuery(array('page' => $page, 'category_id' => $cateId, 'problem' => $problem));

        //数据整合
        $data = array(
            'pathNav' => array(
                array(
                    'href' => SITE_MAIN,
                    'name' => 'YOHO!有货首页'
                ),
                array(
                    'name' => '帮助中心'
                )
            ),
            'helpNav' => $helpList,
            'questions' => $question,
            'pager' => array(
                'count' => $total,
                'curPage' => $page,
                'totalPages' => $pageTotal,
                'pagerHtml' => $paging->view(false)
            ),
            'formAction' => '/help/search?category_id=' . $cateId . '&problem=' . $problem,
            'problem' => $problem
        );

        $this->_view->display('search', array('helpSearchPage' => true, 'help' => $data));
    }

}