Exemple #1
0
 /**
  * validateTags
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 private function validateTags()
 {
     $this->getModelTags();
     $this->arrNewTagIds = array();
     $this->arrNewTags = preg_split('/[,|;]/', $this->objElement->getValue());
     /**
      * get tag ids
      */
     foreach ($this->arrNewTags as $strTag) {
         $strTag = trim($strTag);
         if ($strTag != '') {
             try {
                 $objTagData = $this->objModelTags->loadTagByName($strTag);
                 /**
                  * if the tag exists
                  */
                 if (count($objTagData) > 0) {
                     $objTag = $objTagData->current();
                     /**
                      * fill in tagIds array
                      */
                     $this->arrNewTagIds[] = $objTag->id;
                 } else {
                     /**
                      * else, insert new tag
                      */
                     $this->arrNewTagIds[] = $this->objModelTags->addTag($strTag);
                 }
             } catch (PDOException $exc) {
                 $this->core->logger->logException($exc);
             }
         }
     }
 }
Exemple #2
0
 /**
  * validateTags
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 private function validateTags()
 {
     $this->getModelTags();
     $this->arrNewTagIds = array();
     if ($this->objElement->getValue() instanceof Zend_Db_Table_Rowset_Abstract) {
         foreach ($this->objElement->getValue() as $objTag) {
             $this->arrNewTagIds[] = $objTag->id;
         }
     } elseif (is_string($this->objElement->getValue())) {
         $this->arrNewTags = split(',', $this->objElement->getValue());
         /**
          * get tag ids
          */
         foreach ($this->arrNewTags as $mixedTag) {
             $mixedTag = trim($mixedTag);
             if ($mixedTag != '') {
                 try {
                     if (is_numeric($mixedTag)) {
                         $objTagData = $this->objModelTags->loadTag($mixedTag);
                     } else {
                         $objTagData = $this->objModelTags->loadTagByName($mixedTag);
                     }
                     /**
                      * if the tag exists
                      */
                     if (count($objTagData) > 0) {
                         $objTag = $objTagData->current();
                         /**
                          * fill in tagIds array
                          */
                         if (!in_array($objTag->id, $this->arrNewTagIds)) {
                             $this->arrNewTagIds[] = $objTag->id;
                         }
                     } else {
                         /**
                          * else, insert new tag
                          */
                         $this->arrNewTagIds[] = $this->objModelTags->addTag($mixedTag);
                     }
                 } catch (PDOException $exc) {
                     $this->core->logger->logException($exc);
                 }
             }
         }
     }
 }
 /**
  * validateTags
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 private function validateTags()
 {
     $this->getModelTags();
     $this->arrNewTagIds = array();
     /**
      * get tag ids
      */
     foreach ($this->arrNewTags as $mixedTag) {
         $mixedTag = trim($mixedTag);
         if ($mixedTag != '') {
             try {
                 if (is_numeric($mixedTag)) {
                     $objTagData = $this->objModelTags->loadTag($mixedTag);
                 } else {
                     $objTagData = $this->objModelTags->loadTagByName($mixedTag);
                 }
                 /**
                  * if the tag exists
                  */
                 if (count($objTagData) > 0) {
                     $objTag = $objTagData->current();
                     /**
                      * fill in tagIds array
                      */
                     if (!in_array($objTag->id, $this->arrNewTagIds)) {
                         $this->arrNewTagIds[] = $objTag->id;
                     }
                 } else {
                     /**
                      * else, insert new tag
                      */
                     $this->arrNewTagIds[] = $this->objModelTags->addTag($mixedTag);
                 }
             } catch (PDOException $exc) {
                 $this->core->logger->logException($exc);
             }
         }
     }
 }