function actionIndex()
 {
     $page = intval($this->_context->page);
     if ($page < 1) {
         $page = 1;
     }
     $form = new QForm('article', url('article/update'));
     //查询参数
     $agrs = null;
     //条件查询
     if (!empty($this->_context->find)) {
         $condition = null;
         $sortId = isset($this->_context->sorts) ? intval($this->_context->sorts) : null;
         $title = isset($this->_context->keywords) ? trim($this->_context->keywords) : null;
         //			$QCon = new QDB_Cond();
         //			if($sortId !=0){
         //				$QCon ->andCond('sort_id =?',$sortId);
         //			}
         //
         //			if(isset($title)){
         //				$QCon ->andCond('title like ?','%'.$title.'%');
         //			}
         if ($sortId != 0) {
             $condition .= "1 AND sort_id ={$sortId}";
         }
         if (!empty($title)) {
             $condition .= '1 AND title like ' . '\'%' . $title . '%\'';
         }
         $select = Articles::find($condition)->order('order_num DESC');
         $agrs = array('sorts' => $sortId, 'keywords' => $title, 'find' => 1);
     } else {
         //查询所有
         $select = Articles::find()->order('order_num DESC');
     }
     $select->limitPage($page, 20);
     $pagenation = $select->getPagination();
     $news = $select->query('newsort,user');
     //构建查询表单
     $findForm = new QForm('new_find', url('article/index'));
     $findForm->add(QForm::ELEMENT, 'keywords', array('_ui' => 'textbox', '_label' => '文章的标题'))->add(QForm::ELEMENT, 'sorts', array('_ui' => 'dropdownlist'))->add(QForm::ELEMENT, 'find', array('_ui' => 'hidden', 'value' => '1'));
     //查询新闻类别的子类信息
     $new = new Articles();
     $findForm['sorts']->items = $new->sorts;
     unset($new);
     $this->_view['form'] = $form;
     $this->_view['news'] = $news;
     $this->_view['pagination'] = $pagenation;
     $this->_view['findform'] = $findForm;
     $this->_view['agrs'] = $agrs;
 }
 /**
  * 茶叶的列表
  *
  */
 function actionIndex()
 {
     //得到页码
     $page = intval($this->_context->page);
     if ($page < 1) {
         $page = 1;
     }
     $agrs = null;
     if (!empty($this->_context->find)) {
         //查询新闻
         $condition = null;
         $type = isset($this->_context->type) ? intval($this->_context->type) : null;
         $name = isset($this->_context->name) ? trim($this->_context->name) : null;
         //			$QCon = new QDB_Cond();
         //			if($sortId !=0){
         //				$QCon ->andCond('sort_id =?',$sortId);
         //			}
         //
         //			if(isset($title)){
         //				$QCon ->andCond('title like ?','%'.$title.'%');
         //			}
         if ($type != -1) {
             $condition .= "1 AND type_id ={$type}";
         }
         if (!empty($name)) {
             $condition .= '1 AND name like ' . '\'%' . $name . '%\'';
         }
         $tea = Tea::find($condition)->order('order_num DESC');
         $agrs = array('type' => $type, 'name' => $name, 'find' => 1);
     } else {
         $tea = Tea::find()->order('order_num DESC');
     }
     $tea->limitPage($page, 20);
     //分页信息
     $pagination = $tea->getPagination();
     $teas = $tea->query('teatype');
     //构建查询表单
     $findForm = new QForm('tea_find', url('tea/index'));
     $findForm->add(QForm::ELEMENT, 'name', array('_ui' => 'textbox', '_label' => '茶叶名'))->add(QForm::ELEMENT, 'type', array('_ui' => 'admin_typelist'))->add(QForm::ELEMENT, 'find', array('_ui' => 'hidden', 'value' => '1'));
     //添加茶叶类别的列表信息
     $teaType = new TeaType();
     $findForm['type']->items = $teaType->list;
     unset($teaType);
     $this->_view['findform'] = $findForm;
     $this->_view['agrs'] = $agrs;
     $this->_view['pagination'] = $pagination;
     $this->_view['teas'] = $teas;
 }
Пример #3
0
 function testElements()
 {
     $form = new QForm('form1', self::URL1);
     $form->add(QForm::ELEMENT, 'username', array('_ui' => 'textbox', 'maxlength' => 15, 'class' => 'input'))->add(QForm::ELEMENT, 'password', array('_ui' => 'password', 'class' => 'input'));
     $this->assertTrue($form->existsElement('username'));
     $this->assertTrue($form->existsElement('password'));
     $this->assertEquals('textbox', $form->element('username')->_ui);
     $this->assertEquals('password', $form->element('password')->_ui);
     $form->remove('password');
     $this->assertFalse($form->existsElement('password'));
     $attrs = $form['username']->attrs();
     $this->assertEquals(array('id' => 'username', 'name' => 'username', 'maxlength' => 15, 'class' => 'input'), $attrs);
     $all_attrs = $form['username']->allAttrs();
     $this->assertEquals(array('id' => 'username', 'name' => 'username', 'maxlength' => 15, 'class' => 'input', '_ui' => 'textbox', '_data_binding' => true, '_nested_name' => 'form1'), $all_attrs);
     unset($form['username']);
     $this->assertFalse($form->existsElement('username'));
     $this->assertFalse(isset($form['username']));
 }
 /**
  * 编辑解决方案
  *
  */
 function actionEdit()
 {
     //创建表单
     $form = new QForm('solution', url('solutions/edit'));
     $form->add(QForm::ELEMENT, 'id', array('_ui' => 'hidden'))->add(QForm::ELEMENT, 'name', array('_ui' => 'textbox', '_label' => '解决方案名'))->add(QForm::ELEMENT, 'content', array('_ui' => 'fckeditor', '_label' => '内容', 'class' => "txt", 'height' => '500px', 'width' => '60%'));
     $form->addValidations(Solution::meta());
     $solu_id = (int) $this->_context->id;
     $data = Solution::find($solu_id)->query();
     //导入数据
     $form->import($data);
     if ($this->_context->isPOST() && $form->invalidate($_POST)) {
         try {
             $data->changeProps($form->values());
             $data->save();
             return $this->_redirectMessage('修改成功', '修改改页面成功', url('solutions/index'));
         } catch (QValidator_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     }
     $this->_view['form'] = $form;
 }