<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * 道具展示页
 *
 * @author yzxh24
 */
class IndexAction extends BaseAction
{
    public function run()
    {
        $type = empty($_GET['t']) ? 0 : (key_exists($_GET['t'],$this->getController()->typeList) ? S::gp('t', 'G', 2) : 0);
        $pagesize = 5;
        $condition = empty($type) ? '' : ' AND `type` = '.$type;
        $count = $this->getController()->db()->getValue('SELECT COUNT(*) FROM '.Property::table()."  WHERE status = 1 {$condition} AND propertyid <> 16");
        $pageObj = new iPage();
        $pageObj->setTotalRecord($count);
        $pageObj->setPageSize($pagesize);
        $offset = $pageObj->getOffset();
        $floor = $pageObj->getFloor();

        $properties = $this->getController()->db()->select()->from(Property::table())->where("propertyid <> 16 AND status=1 {$condition}")->desc('sort')->limit($offset,$pagesize)->find();

        $this->getController()->render('index',array(
                'properties'=>$properties,
                'pageObj'=>$pageObj,
                'floor' => $floor,
                'type' => $type,
            )
        );
    }
}
