示例#1
0
文件: news.php 项目: uzura8/flockbird
 public static function _init()
 {
     $format_options = conf('form.formats.options', 'news');
     static::$_properties['format']['form']['options'] = $format_options;
     static::$_properties['format']['validation']['in_array'][] = array_keys($format_options);
     if (\Config::get('news.category.isEnabled')) {
         static::$_properties['news_category_id']['label'] = term('news.category.simple');
         $news_category_id_options = \Util_Orm::conv_cols2assoc(Model_NewsCategory::get_all(array('sort_order' => 'asc')), 'id', 'label');
         static::$_properties['news_category_id']['form']['options'] = $news_category_id_options;
         static::$_properties['news_category_id']['validation']['in_array'][] = array_keys($news_category_id_options);
     } else {
         static::$_properties['news_category_id']['form']['type'] = false;
     }
     //if (!Site_Util::check_editor_enabled('html_editor') || !(conf('image.isEnabled', 'news') && conf('image.isInsertBody', 'news')))
     //{
     //	static::$_properties['body']['validation'][] = 'required';
     //}
     if (conf('form.isSecure.isEnabled', 'news')) {
         $is_secure_options = \Site_Form::get_form_options4config('term.isSecure.options');
         static::$_properties['is_secure']['form']['type'] = 'radio';
         static::$_properties['is_secure']['label'] = term('isSecure.label');
         static::$_properties['is_secure']['form']['options'] = $is_secure_options;
         static::$_properties['is_secure']['validation'] = array('required');
         static::$_properties['is_secure']['validation']['in_array'][] = array_keys($is_secure_options);
     }
 }
示例#2
0
文件: news.php 项目: uzura8/flockbird
 /**
  * News category
  * 
  * @access  public
  * @return  Response
  */
 public function action_category($category_name = null)
 {
     if (is_null($category_name) || !($news_category = Model_NewsCategory::get4name($category_name))) {
         throw new \HttpNotFoundException();
     }
     list($limit, $page) = $this->common_get_pager_list_params();
     $data = Site_Model::get_list($limit, $page, \Auth::check(), $news_category->id);
     $data['category_name'] = $category_name;
     $this->set_title_and_breadcrumbs($news_category->label, array('news/list' => term('site.latest', 'news.view', 'site.list')));
     $this->template->post_footer = \View::forge('_parts/list_footer');
     $this->template->content = \View::forge('_parts/list', $data);
     $this->template->content->set_safe('html_bodys', Site_Model::convert_raw_bodys($data['list']));
 }
示例#3
0
 /**
  * Get note list
  * 
  * @access  public
  * @return  Response (html)
  * @throws  Exception in Controller_Base::controller_common_api
  * @see  Controller_Base::controller_common_api
  */
 public function get_list()
 {
     $this->api_accept_formats = 'html';
     $this->controller_common_api(function () {
         $category_name = \Input::get('category');
         $news_category = $category_name ? Model_NewsCategory::get4name($category_name) : null;
         $tag_string = \Input::get('tag');
         $tags = \Site_Util::validate_tags($tag_string);
         $ids = $tags ? Model_NewsTag::get_news_ids4tags($tags) : array();
         list($limit, $page) = $this->common_get_pager_list_params();
         $data = Site_Model::get_list($limit, $page, \Auth::check(), $news_category ? $news_category->id : 0, $ids);
         $data['category_name'] = $category_name;
         $data['tag_string'] = implode(', ', $tags);
         $this->set_response_body_api($data, '_parts/list', array('html_bodys' => Site_Model::convert_raw_bodys($data['list'])));
     });
 }
示例#4
0
文件: util.php 项目: uzura8/flockbird
 public static function get_category_uris($is_add_all_link_to_tail = false)
 {
     $categories = Model_NewsCategory::get_assoc('label', 'name', null, array('sort_order' => 'asc'));
     foreach ($categories as $label => $name) {
         $categories[$label] = 'news/category/' . $name;
     }
     if ($is_add_all_link_to_tail) {
         $categories[term('site.see_all')] = 'news';
     }
     return $categories;
 }