コード例 #1
0
 /**
  * @return string
  */
 protected function exampleTagID()
 {
     $AllTags = $this->Factory->allTags();
     if (!empty($AllTags)) {
         return $AllTags[0]->id();
     }
     return '';
 }
コード例 #2
0
ファイル: ChosenInserter.php プロジェクト: guancio/Runalyze
 private function checkForNewTags()
 {
     $Factory = new Model\Factory(\SessionAccountHandler::getId());
     $allTagIDs = array_map(function ($tag) {
         return $tag->id();
     }, $Factory->allTags());
     foreach ($this->TagArrayFromChosen as $key => $Tag) {
         if (!in_array($Tag, $allTagIDs)) {
             $this->setObjectwithTag($Tag);
             $this->TagArrayFromChosen[$key] = $this->insertNewTag();
         }
     }
     $Factory->clearCache('tag');
 }
コード例 #3
0
 /**
  * Display fieldset: Tag
  */
 protected function initTagFieldset()
 {
     $isCreateForm = $this->submitMode == StandardFormular::$SUBMIT_MODE_CREATE;
     $Factory = new Factory(SessionAccountHandler::getId());
     $CurrentTags = $isCreateForm ? array() : $Factory->tagForActivity($this->dataObject->id(), true);
     $Fieldset = new FormularFieldset(__('Tags'));
     $Fieldset->addField(new FormularInputHidden('tag_old', '', implode(',', $CurrentTags)));
     if (isset($_POST['tags'])) {
         $CurrentTags = self::readTagFromPost();
     }
     $Field = new FormularSelectBox('tags', 'Tags', $CurrentTags);
     foreach ($Factory->allTags() as $tag) {
         $Field->addOption($tag->id(), $tag->tag());
     }
     $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100_IN_W50);
     $Field->addCSSclass('chosen-select-create full-size');
     $Field->setMultiple();
     $Field->addAttribute('data-placeholder', __('Choose tags'));
     $Field->addAttribute('style', 'width=50px;');
     $Fieldset->addField($Field);
     $this->addFieldset($Fieldset);
 }