예제 #1
0
파일: Tag.php 프로젝트: phirecms/phire-tags
 /**
  * Get all tag values for the form object
  *
  * @param  AbstractController $controller
  * @param  Application        $application
  * @return void
  */
 public static function getAll(AbstractController $controller, Application $application)
 {
     if (!$_POST && $controller->hasView() && null !== $controller->view()->form && $controller->view()->form !== false && (int) $controller->view()->form->id != 0 && null !== $controller->view()->form && $controller->view()->form instanceof \Phire\Content\Form\Content) {
         $contentId = $controller->view()->form->id;
         $tags = [];
         if (null !== $contentId) {
             $sql = Table\TagItems::sql();
             $sql->select()->join(DB_PREFIX . 'tags', [DB_PREFIX . 'tags.id' => DB_PREFIX . 'tag_items.tag_id']);
             $sql->select()->where('content_id = :content_id');
             $c2t = Table\TagItems::execute($sql, ['content_id' => $contentId]);
             if ($c2t->hasRows()) {
                 foreach ($c2t->rows() as $c) {
                     $tags[] = $c->title;
                 }
             }
             if (count($tags) > 0) {
                 $controller->view()->form->content_tags = implode(',', $tags);
             }
         }
     }
 }