public function index()
 {
     $this->page();
     $flag = false;
     if (isset($_GET['sid'])) {
         $this->tpl->assign('oneNav', $this->model->findOne());
         $this->tpl->assign('prev_url', PREV_URL);
         $flag = true;
     }
     $this->tpl->assign('flag', $flag);
     $allNav = $this->model->findAll();
     if ($flag) {
         $allBrands = $this->brand->getAll();
         foreach ($allNav as $key => $value) {
             if (!empty($value->brand)) {
                 $value->brand = unserialize(htmlspecialchars_decode($value->brand));
             }
             if (Validate::isArray($value->brand)) {
                 $temp = $value->brand;
                 $value->brand = '';
                 foreach ($temp as $val) {
                     foreach ($allBrands as $k => $v) {
                         if ($val == $v->id) {
                             $value->brand[$k] = $v->name;
                         }
                     }
                 }
             }
             $value->brand = Validate::isArray($value->brand) ? implode(',', $value->brand) : '其他品牌';
         }
     }
     $this->tpl->assign('allNav', $allNav);
     $this->tpl->display(ADMIN_STYLE . 'nav/show.tpl');
 }
Example #2
0
 public static function setFormItem($data, $key, $value)
 {
     $item = array();
     if (Validate::isArray($data)) {
         foreach ($data as $v) {
             $item[$v->{$key}] = $v->{$value};
         }
     }
     return $item;
 }
Example #3
0
 public function filter(array $fields)
 {
     $selectDate = array();
     if (Validate::isArray($_POST) && !Validate::isNullArray($_POST)) {
         foreach ($_POST as $key => $value) {
             if (Validate::inArray($key, $fields)) {
                 $selectDate[$key] = $value;
             }
         }
     }
     return $selectDate;
 }
Example #4
0
 public function filter(array $_fields)
 {
     $_selectData = array();
     if (Validate::isArray($_POST) && !Validate::isNullArray($_POST)) {
         //筛选准备入库的字段和数据
         foreach ($_POST as $_key => $_value) {
             if (Validate::inArray($_key, $_fields)) {
                 $_selectData[$_key] = $_value;
             }
         }
     }
     return $_selectData;
 }
Example #5
0
 protected function update($where, $updateData, $tables)
 {
     $isWhere = $setData = '';
     foreach ($updateData as $key => $value) {
         if (Validate::isArray($value)) {
             $setData .= "{$key}={$value['0']},";
         } else {
             $setData .= "{$key}='{$value}',";
         }
     }
     foreach ($where as $key => $value) {
         $isWhere .= $value . ' AND ';
     }
     $isWhere = substr($isWhere, 0, -4);
     $setData = substr($setData, 0, -1);
     $sql = "UPDATE {$tables['0']} SET {$setData} WHERE {$isWhere}";
     return $this->execute($sql)->rowCount();
 }
 public function getCommendGoods()
 {
     $where = array("id='{$this->R['order_id']}'");
     $oneGoods = parent::select(array('goods'), array('where' => $where, 'limit' => '1'));
     $oneGoods[0]->goods = unserialize(htmlspecialchars_decode($oneGoods[0]->goods));
     if (Validate::isArray($oneGoods[0]->goods)) {
         foreach ($oneGoods[0]->goods as $key => $value) {
             $oneGoods[0]->goods[$key] = unserialize(htmlspecialchars_decode($value));
         }
     }
     $oneGoods = $oneGoods[0]->goods;
     return $oneGoods[$this->R['goods_id']];
 }
Example #7
0
 protected function select($_tables, array $_field, array $_param = array())
 {
     $_limit = '';
     $_order = '';
     $_where = '';
     $_like = '';
     if (Validate::isArray($_param) && !Validate::isNullArray($_param)) {
         $_limit = isset($_param['limit']) ? 'LIMIT ' . $_param['limit'] : '';
         $_order = isset($_param['order']) ? 'ORDER BY ' . $_param['order'] : '';
         $_where = '';
         if (isset($_param['where'])) {
             foreach ($_param['where'] as $_key => $_value) {
                 $_where .= $_value . ' AND ';
             }
             $_where = 'WHERE ' . substr($_where, 0, -4);
         }
         if (isset($_param['like'])) {
             foreach ($_param['like'] as $_key => $_value) {
                 $_like = "WHERE {$_key} LIKE '%{$_value}%'";
             }
         }
     }
     $_selectFields = implode(',', $_field);
     $_table = isset($_tables[1]) ? $_tables[0] . ',' . $_tables[1] : $_tables[0];
     $_sql = "SELECT {$_selectFields} FROM {$_table} {$_where} {$_like} {$_order} {$_limit} ";
     $_stmt = $this->execute($_sql);
     $_result = array();
     while (!!($_objs = $_stmt->fetchObject())) {
         $_result[] = $_objs;
     }
     return Tool::setHtmlString($_result);
 }
Example #8
0
 public static function setFormItem($_data, $_key, $_value)
 {
     $_items = array();
     if (Validate::isArray($_data)) {
         foreach ($_data as $_v) {
             $_items[$_v->{$_key}] = $_v->{$_value};
         }
     }
     return $_items;
 }
 /**
  * Adds the given key/value pair into array if the value doesn't satisfy empty().
  *
  * This function just validates that the given $array is actually array. If it's
  * NULL the function treats it as array.
  *
  * @param string $key    The key.
  * @param string $value  The value.
  * @param array  &$array The array. If NULL will be used as array.
  *
  * @static
  *
  * @return none
  */
 public static function addIfNotEmpty($key, $value, &$array)
 {
     if (!is_null($array)) {
         Validate::isArray($array, 'array');
     }
     if (!empty($value)) {
         $array[$key] = $value;
     }
 }
Example #10
0
 public function findUserDetails()
 {
     $_orderDetails = parent::select(array('id', 'user', 'buildings', 'code', 'address', 'tel', 'name', 'email', 'ordernum', 'date', 'goods', 'refund', 'delivery', 'pay', 'price', 'text', 'ps', 'order_state', 'order_pay', 'order_delivery', 'delivery_url', 'delivery_number', 'delivery_name'), array('where' => array("id='{$this->_R['id']}'")));
     $_orderDetails[0]->goods = unserialize(htmlspecialchars_decode($_orderDetails[0]->goods));
     if (Validate::isArray($_orderDetails[0]->goods)) {
         foreach ($_orderDetails[0]->goods as $_key => $_value) {
             $_orderDetails[0]->goods[$_key] = unserialize($_value);
         }
     }
     return $_orderDetails;
 }