コード例 #1
0
 public function fillModel(Model $model)
 {
     parent::fillModel($model);
     if (!$this->submitted() && $model) {
         $this->allowComments->checked($model->hasFlag(BlogPostFlag::ALLOW_COMMENTS));
         $this->sticky->checked($model->hasFlag(BlogPostFlag::STICKY));
         // tags
         if (!empty($model->Tags)) {
             $tags = new IndexedArray();
             foreach ($model->Tags as $Tag) {
                 $tags[] = $Tag->get('name');
             }
             $this->tags->value($tags->implode(' '));
         }
     }
 }
コード例 #2
0
ファイル: BlogPost.php プロジェクト: Ephigenia/harrison
 public function similarEntries()
 {
     if (!$this->exists() || $this->Tags->count() == 0) {
         return false;
     }
     $queryFile = dirname(__FILE__) . '/../../console/sql/similarBlogPosts.sql';
     if (!file_exists($queryFile)) {
         return false;
     }
     $tmp = new IndexedArray();
     foreach ($this->Tags as $Tag) {
         $tmp[] = 'Tag.name = ' . DBQuery::quote($Tag->get('name'));
     }
     $tagConditions = $tmp->implode(' OR ');
     $query = sprintf(file_get_contents($queryFile), $tagConditions, $this->id);
     return $this->query($query);
 }