Exemple #1
0
    /**
     * @return void
     */
    public function afterDelete()
    {
        // remove Entry relations
        EntryHasTag::model()->deleteAllByAttributes(array('tagId' => $this->id));

        parent::afterDelete();
    }
Exemple #2
0
    public function run()
    {
        /* @var WebUser $webUser */
        /** @noinspection PhpUndefinedFieldInspection */
        $webUser = Yii::app()->user;

        $models = Tag::model()->userId($webUser->id)->findAll();
        $tagCount = EntryHasTag::model()->userId($webUser->id)->count();

        $tags = array();
        foreach ($models as $model) {
            /* @var Tag $model */

            $entryCount = 0;
            foreach ($model->entries as $entry) {
                if ($entry->userId == $webUser->id) {
                    $entryCount++;
                }
            }

            if ($entryCount > 0) {
                $tags[] = array(
                    'name' => $model->name,
                    'weight' => ceil($entryCount / $tagCount * 10)
                );
            }
        }

        $this->render('cloud', array('tags' => $tags));
    }
Exemple #3
0
 /**
  *
  * @return void
  */
 public function deleteTags()
 {
     $relations = EntryHasTag::model()->entryId($this->id)->findAll();
     foreach ($relations as $relation) {
         $relation->delete();
     }
 }
Exemple #4
0
 /**
  * (non-PHPdoc)
  * @see yii/CWidget#run()
  */
 public function run()
 {
     $models = Tag::model()->userId(Yii::app()->user->id)->findAll();
     $tagCount = EntryHasTag::model()->userId(Yii::app()->user->id)->count();
     $tags = array();
     foreach ($models as $model) {
         $entryCount = 0;
         foreach ($model->entries as $entry) {
             if ($entry->userId == Yii::app()->user->id) {
                 $entryCount++;
             }
         }
         if ($entryCount > 0) {
             $tags[] = array('name' => $model->name, 'weight' => ceil($entryCount / $tagCount * 10));
         }
     }
     $this->render('cloud', array('tags' => $tags));
 }