コード例 #1
0
ファイル: area_edit.php プロジェクト: anqh/forum
		<legend><?php 
echo __('Settings');
?>
</legend>
		<ul>
			<?php 
echo Form::select_wrap('access_read', array(Model_Forum_Area::READ_NORMAL => __('Everybody'), Model_Forum_Area::READ_MEMBERS => __('Members only')), $area, null, __('Read access'));
?>
			<?php 
echo Form::select_wrap('access_write', array(Model_Forum_Area::WRITE_NORMAL => __('Members'), Model_Forum_Area::WRITE_ADMINS => __('Admins only')), $area, null, __('Write access'));
?>
			<?php 
echo Form::select_wrap('type', array(Model_Forum_Area::TYPE_NORMAL => __('Normal'), Model_Forum_Area::TYPE_BIND => __('Bind, topics bound to content')), $area, null, __('Type'));
?>
			<?php 
echo Form::select_wrap('bind', array('' => __('None')) + Model_Forum_Area::get_binds(), $area, null, __('Bind config'));
?>
			<?php 
echo Form::select_wrap('status', array(Model_Forum_Area::STATUS_NORMAL => __('Normal'), Model_Forum_Area::STATUS_HIDDEN => __('Hidden')), $area, null, __('Status'));
?>
		</ul>
	</fieldset>

	<fieldset>
		<?php 
echo Form::submit_wrap('save', __('Save'), null, Request::back(Route::get('forum_group')->uri(), true));
?>
	</fieldset>

<?php 
echo Form::close();
コード例 #2
0
ファイル: topic.php プロジェクト: anqh/forum
 /**
  * Load topic by bound model
  *
  * @static
  * @param   Model   $bind_model  Bound model
  * @param   string  $bind_name   Bind config if multiple binds per model
  * @return  Model_Forum_Topic
  */
 public static function find_by_bind(Model $bind_model, $bind_name = null)
 {
     $model = Model::model_name($bind_model);
     // Get correct bind config
     if (!$bind_name) {
         foreach (Model_Forum_Area::get_binds(false) as $bind_name => $bind_config) {
             if ($bind_config['model'] == $model) {
                 $config = $bind_config;
                 break;
             }
         }
     } else {
         $config = Model_Forum_Area::get_binds($bind_name);
     }
     if ($config) {
         // Get area
         $area = Model_Forum_Area::factory();
         $area = $area->load(DB::select_array($area->fields())->where('area_type', '=', Model_Forum_Area::TYPE_BIND)->where('bind', '=', $bind_name));
         if ($area->loaded()) {
             // Get topic
             $topic = Model_Forum_Topic::factory();
             $topic = $topic->load(DB::select_array($topic->fields())->where('forum_area_id', '=', $area->id)->where('bind_id', '=', $bind_model->id()));
             // If topic found, go there!
             if ($topic->loaded()) {
                 return $topic;
             }
         }
     }
     return null;
 }
コード例 #3
0
ファイル: topic.php プロジェクト: anqh/forum
 /**
  * Action: index
  */
 public function action_index()
 {
     // Go to post?
     $topic_id = (int) $this->request->param('topic_id');
     if ($topic_id) {
         $post_id = (int) $this->request->param('id');
     } else {
         $topic_id = (int) $this->request->param('id');
     }
     // Load topic
     /** @var  Model_Forum_Private_Topic|Model_Forum_Topic  $topic */
     $topic = $this->private ? Model_Forum_Private_Topic::factory($topic_id) : Model_Forum_Topic::factory($topic_id);
     if (!$topic->loaded()) {
         throw new Model_Exception($topic, $topic_id);
     }
     Permission::required($topic, Model_Forum_Topic::PERMISSION_READ, self::$user);
     // Did we request single post with ajax?
     if (($this->ajax || $this->internal) && isset($post_id)) {
         $this->history = false;
         $post = $this->private ? Model_Forum_Private_Post::factory($post_id) : Model_Forum_Post::factory($post_id);
         if (!$post->loaded()) {
             throw new Model_Exception($topic, $topic_id);
         }
         // Permission is already checked by the topic, no need to check for post
         $this->response->body($this->section_post($topic, $post));
         return;
     }
     // Update counts
     if ($this->private) {
         $topic->mark_as_read(self::$user);
     }
     if (!self::$user || $topic->author_id != self::$user->id) {
         $topic->read_count++;
         $topic->save();
     }
     // Build page
     $this->view = new View_Page();
     $this->view->title_html = Forum::topic($topic);
     $this->view->subtitle = __($topic->post_count == 1 ? ':posts post' : ':posts posts', array(':posts' => Num::format($topic->post_count, 0)));
     $this->view->tab = 'topic';
     $this->page_actions['topic'] = array('link' => Route::model($topic), 'text' => '<i class="icon-comment icon-white"></i> ' . __('Topic'));
     // Public topic extras
     if (!$this->private) {
         // Quotes are supported only in public forum as we get notifications anyway in private
         if (self::$user) {
             $quotes = Model_Forum_Quote::factory()->find_by_user(self::$user);
             if (count($quotes)) {
                 foreach ($quotes as $quote) {
                     if ($topic->id == $quote->forum_topic_id) {
                         $quote->delete();
                         break;
                     }
                 }
             }
         }
         // Facebook
         if (Kohana::$config->load('site.facebook')) {
             Anqh::open_graph('title', $topic->name);
             Anqh::open_graph('url', URL::site(Route::url('forum_topic', array('id' => $topic->id, 'action' => '')), true));
         }
         Anqh::share(true);
         // Model binding
         $area = $topic->area();
         if ($area->type == Model_Forum_Area::TYPE_BIND && $topic->bind_id) {
             if ($bind = Model_Forum_Area::get_binds($area->bind)) {
                 $model = AutoModeler::factory($bind['model'], $topic->bind_id);
                 if ($model->loaded()) {
                     // Set actions
                     $this->page_actions[] = array('link' => Route::model($model), 'text' => $bind['link']);
                     // Set views
                     foreach ((array) $bind['view'] as $view) {
                         $this->view->add(View_Page::COLUMN_SIDE, View_Module::factory($view, array($bind['model'] => $model)), Widget::TOP);
                     }
                 }
             }
         }
     }
     // Public topic extras
     // Set actions
     if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, self::$user)) {
         $this->view->actions[] = array('link' => Request::current_uri() . '#reply', 'text' => '<i class="icon-comment icon-white"></i> ' . __('Reply to topic'), 'class' => 'btn btn-primary topic-post');
     }
     if (Permission::has($topic, Model_Forum_Topic::PERMISSION_UPDATE, self::$user)) {
         $this->view->actions[] = array('link' => Route::model($topic, 'edit'), 'text' => '<i class="icon-edit icon-white"></i> ' . __('Edit topic'));
     }
     // Breadcrumbs
     $this->page_breadcrumbs[] = HTML::anchor(Route::url('forum_group'), __('Forum'));
     $this->page_breadcrumbs[] = HTML::anchor(Route::model($topic->area()), $topic->area()->name);
     // Pagination
     $this->view->add(View_Page::COLUMN_MAIN, $pagination = $this->section_pagination($topic));
     $this->view->subtitle .= ', ' . __($pagination->total_pages == 1 ? ':pages page' : ':pages pages', array(':pages' => Num::format($pagination->total_pages, 0)));
     $this->view->subtitle .= ', ' . __($topic->read_count == 1 ? ':views view' : ':views views', array(':views' => Num::format($topic->read_count, 0)));
     // Go to post?
     if (isset($post_id)) {
         $pagination->item($topic->get_post_number($post_id) + 1);
         // We need to set pagination urls manually if jumped to a post
         $pagination->base_url = Route::model($topic);
     }
     // Recipients
     if ($this->private) {
         $this->view->add(View_Page::COLUMN_MAIN, $this->section_recipients($topic));
         $this->view->add(View_Page::COLUMN_MAIN, '<hr />');
     }
     // Posts
     $this->view->add(View_Page::COLUMN_MAIN, $this->section_topic($topic, $pagination));
     // Reply
     if (Permission::has($topic, Model_Forum_Topic::PERMISSION_POST, self::$user)) {
         $section = $this->section_post_edit(View_Forum_PostEdit::REPLY, $this->private ? Model_Forum_Private_Post::factory() : Model_Forum_Post::factory());
         $section->forum_topic = $topic;
         $this->view->add(View_Page::COLUMN_MAIN, $section);
     }
     // Pagination
     $this->view->add(View_Page::COLUMN_MAIN, $pagination);
     $this->_side_views();
 }
コード例 #4
0
ファイル: areaedit.php プロジェクト: anqh/forum
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        // Build available groups list
        $groups = array();
        foreach (Model_Forum_Group::factory()->find_all() as $_group) {
            $groups[$_group->id] = $_group->name;
        }
        echo Form::open();
        ?>

	<fieldset>

		<?php 
        echo Form::control_group(Form::select('forum_group_id', $groups, $this->area->id), array('forum_group_id' => __('Group')), Arr::get($this->errors, 'forum_group_id'));
        ?>

		<?php 
        echo Form::control_group(Form::input('name', $this->area->name), array('name' => __('Name')), Arr::get($this->errors, 'name'));
        ?>

		<?php 
        echo Form::control_group(Form::input('description', $this->area->description), array('description' => __('Description')), Arr::get($this->errors, 'description'));
        ?>

		<?php 
        echo Form::control_group(Form::input('sort', $this->area->sort, array('class' => 'input-mini')), array('sort' => __('Sort')), Arr::get($this->errors, 'sort'));
        ?>

	</fieldset>

	<fieldset>
		<legend><?php 
        echo __('Settings');
        ?>
</legend>

		<?php 
        echo Form::control_group(Form::select('access_read', array(Model_Forum_Area::READ_NORMAL => __('Everybody'), Model_Forum_Area::READ_MEMBERS => __('Members only')), $this->area->access_read), array('access_read' => __('Read access')), Arr::get($this->errors, 'access_read'));
        ?>

		<?php 
        echo Form::control_group(Form::select('access_write', array(Model_Forum_Area::WRITE_NORMAL => __('Members'), Model_Forum_Area::WRITE_ADMINS => __('Admins only')), $this->area->access_write), array('access_write' => __('Write access')), Arr::get($this->errors, 'access_write'));
        ?>

		<?php 
        echo Form::control_group(Form::select('type', array(Model_Forum_Area::TYPE_NORMAL => __('Normal'), Model_Forum_Area::TYPE_BIND => __('Bind, topics bound to content')), $this->area->type), array('type' => __('Type')), Arr::get($this->errors, 'type'));
        ?>

		<?php 
        echo Form::control_group(Form::select('bind', array('' => __('None')) + Model_Forum_Area::get_binds(), $this->area->bind), array('bind' => __('Bind config')), Arr::get($this->errors, 'bind'));
        ?>

		<?php 
        echo Form::control_group(Form::select('status', array(Model_Forum_Area::STATUS_NORMAL => __('Normal'), Model_Forum_Area::STATUS_HIDDEN => __('Hidden')), $this->area->status), array('status' => __('Status')), Arr::get($this->errors, 'status'));
        ?>

	</fieldset>

	<fieldset class="form-actions">
		<?php 
        echo Form::button('save', __('Save'), array('type' => 'submit', 'class' => 'btn btn-success btn-large'));
        ?>
		<?php 
        echo HTML::anchor(Request::back(Route::url('forum_group'), true), __('Cancel'), array('class' => 'cancel'));
        ?>

		<?php 
        echo Form::csrf();
        ?>
	</fieldset>

<?php 
        echo Form::close();
        return ob_get_clean();
    }