예제 #1
0
 /**
  * save()
  * @param integer $intElementId
  * @param string $strType
  * @param string $strElementId
  * @param integet $intVersion
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function save($intElementId, $strType, $strElementId = null, $intVersion = null)
 {
     try {
         $this->getModelPages();
         $intParentId = $this->objElement->Setup()->getParentId();
         $intParentTypeId = $this->objElement->Setup()->getParentTypeId();
         $this->objModelPages->deletePageCollection($strElementId, $intVersion);
         $this->objModelPages->deletePageCollectionUrls($intParentId, $intParentTypeId);
         $this->objModelPages->addPageCollection($this->objElement->getValue(), $strElementId, $intVersion);
         $this->load($intElementId, $strType, $strElementId, $intVersion);
         $strBaseUrl = '';
         if ($this->objElement->Setup()->getField('url') instanceof GenericElementField) {
             $strBaseUrl = preg_replace('/^\\/[a-zA-Z]{2}\\//', '', $this->objElement->Setup()->getField('url')->getValue());
         }
         if (count($this->objElement->objPageCollection) > 0) {
             $objUrlHelper = new GenericDataHelper_Url();
             $objUrlHelper->setElement($this->objElement);
             $objUrlHelper->setType($strType);
             foreach ($this->objElement->objPageCollection as $objPageCollection) {
                 $objPageCollection->url = $objUrlHelper->checkUrlUniqueness($strBaseUrl . $objUrlHelper->makeUrlConform($objPageCollection->title));
             }
         }
         if ($this->objElement->objPageCollection) {
             $this->objModelPages->addPageCollectionUrls($this->objElement->objPageCollection, $intParentId, $intParentTypeId);
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }