Exemplo n.º 1
0
 /**
  * 从配置文件中生成新闻表单
  * @param string $id 表单的id 号
  * @param string $action 表单的url
  * @param string $config 配置文件的名字
  * @return object 表单对象
  */
 static function _createFormConfig($id, $action, $config)
 {
     $form = new Form_Admin_News($id, $action);
     $fileName = dirname(__FILE__) . DS . "{$config}";
     $form->loadFromConfig(Helper_YAML::load($fileName));
     //验证的模型选择
     if ($id == 'news') {
         $form->addValidations(News::meta());
     } else {
         $form->addValidations(Articles::meta());
     }
     //类别表的选择
     if ('news' == $id) {
         $news = new News();
         $form['sort_id']->items = $news->sorts;
     } else {
         $article = new Articles();
         $form['sort_id']->items = $article->sorts;
     }
     return $form;
 }
 /**
  * 是否显示新闻
  *
  */
 function actionAjaxIsShow()
 {
     if ($this->_context->isAJAX()) {
         $new_id = $this->_context->news_id;
         $is_show = $this->_context->isShow;
         try {
             Articles::meta()->updateWhere(array('is_show' => $is_show), 'id =?', $new_id);
             echo true;
         } catch (QDB_Exception $ex) {
             echo false;
         }
     } else {
         echo false;
     }
 }