예제 #1
0
파일: taggroups.php 프로젝트: anqh/core
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        $groups = Model_Tag_Group::factory()->find_all();
        if (empty($groups)) {
            ?>

<div class="empty">
	<?php 
            echo __('No groups yet.');
            ?>
</div>

<?php 
        } else {
            ?>

<ul class="unstyled">

	<?php 
            foreach ($groups as $group) {
                ?>
	<li>
		<h3><?php 
                echo HTML::anchor(Route::model($group), $group->name);
                ?>
</h3>
		<sup><?php 
                echo $group->description;
                ?>
</sup><br />
		<?php 
                foreach ($group->tags() as $tag) {
                    echo HTML::anchor(Route::model($tag), $tag->name) . ' ';
                }
                ?>
	</li>
	<?php 
            }
            ?>

</ul>

<?php 
        }
        return ob_get_clean();
    }
예제 #2
0
파일: tags.php 프로젝트: anqh/anqh
 /**
  * Action: tag
  *
  * @param  integer  $group_id
  */
 public function action_tag($group_id = null)
 {
     $this->history = false;
     if ($group_id && $this->request->action() !== 'tag') {
         // Add new tag
         $group = Model_Tag_Group::factory($group_id);
         if (!$group->loaded()) {
             throw new Model_Exception($group, $group_id);
         }
         $tag = Model_Tag::factory();
         $tag->tag_group_id = $group_id;
         $tag->author_id = Visitor::$user->id;
         $tag->created = time();
         $this->view = View_Page::factory($group->name);
         $this->view->subtitle = HTML::chars($group->description);
     } else {
         if ($tag_id = (int) $this->request->param('id')) {
             // Edit old tag
             $tag = Model_Tag::factory($tag_id);
             if (!$tag->loaded()) {
                 throw new Model_Exception($tag, $tag_id);
             }
             $this->view = View_Page::factory($tag->name);
             $this->view->subtitle = HTML::chars($tag->description);
             $this->page_actions[] = array('link' => Route::model($tag, 'delete') . '?' . Security::csrf_query(), 'text' => '<i class="icon-trash icon-white"></i> ' . __('Delete tag'), 'class' => 'btn btn-danger tag-delete');
         } else {
             Request::back(Route::url('tags'));
         }
     }
     $errors = array();
     if ($_POST) {
         $tag->name = Arr::get($_POST, 'name');
         $tag->description = Arr::get($_POST, 'description');
         try {
             $tag->save();
             $this->request->redirect(Route::model($tag));
         } catch (Validation_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_tag($tag, $errors));
 }