/**
  * save
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function save()
 {
     $this->core->logger->debug('massiveart->generic->data->GenericDataTypePage->save()');
     try {
         $this->getModelPages()->setLanguageId($this->setup->getLanguageId());
         $intUserId = Zend_Auth::getInstance()->getIdentity()->id;
         /**
          * add|edit|newVersion core and instance data
          */
         switch ($this->setup->getActionType()) {
             case $this->core->sysConfig->generic->actions->add:
                 $objPage = $this->objModelPages->add($this->setup);
                 $this->setup->setElementId($objPage->id);
                 $this->insertCoreData('page', $objPage->pageId, $objPage->version);
                 $this->insertFileData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                 $this->insertMultiFieldData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                 $this->insertInstanceData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                 $this->insertMultiplyRegionData('page', $objPage->pageId, $objPage->version);
                 break;
             case $this->core->sysConfig->generic->actions->edit:
                 $objPage = $this->objModelPages->load($this->setup->getElementId());
                 if (count($objPage) > 0) {
                     $objPage = $objPage->current();
                     $this->objModelPages->update($this->setup, $objPage);
                     $this->updateCoreData('page', $objPage->pageId, $objPage->version);
                     $this->updateFileData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                     $this->updateMultiFieldData('page', $objPage->pageId, $objPage->version);
                     $this->updateInstanceData('page', $objPage->pageId, $objPage->version);
                     $this->updateMultiplyRegionData('page', $objPage->pageId, $objPage->version);
                 }
                 break;
             case $this->core->sysConfig->generic->actions->change_template:
                 $objPage = $this->objModelPages->load($this->setup->getElementId());
                 if (count($objPage) > 0) {
                     $objPage = $objPage->current();
                     $this->objModelPages->update($this->setup, $objPage);
                     $this->insertCoreData('page', $objPage->pageId, $objPage->version);
                     if ($this->blnHasLoadedFileData) {
                         $this->updateFileData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                     } else {
                         $this->insertFileData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                     }
                     if ($this->blnHasLoadedMultiFieldData) {
                         $this->updateMultiFieldData('page', $objPage->pageId, $objPage->version);
                     } else {
                         $this->insertMultiFieldData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                     }
                     if ($this->blnHasLoadedInstanceData) {
                         $this->updateInstanceData('page', $objPage->pageId, $objPage->version);
                     } else {
                         $this->insertInstanceData('page', array('Id' => $objPage->pageId, 'Version' => $objPage->version));
                     }
                     if ($this->blnHasLoadedMultiplyRegionData) {
                         $this->updateMultiplyRegionData('page', $objPage->pageId, $objPage->version);
                     } else {
                         $this->insertMultiplyRegionData('page', $objPage->pageId, $objPage->version);
                     }
                 }
                 break;
             case $this->core->sysConfig->generic->actions->change_template_id:
                 $objPage = $this->objModelPages->load($this->setup->getElementId());
                 if (count($objPage) > 0) {
                     $objPage = $objPage->current();
                     $this->objModelPages->update($this->setup, $objPage);
                 }
                 break;
         }
         /**
          * now save all the special fields
          */
         if (count($this->setup->SpecialFields()) > 0) {
             foreach ($this->setup->SpecialFields() as $objField) {
                 $objField->setGenericSetup($this->setup);
                 $objField->save($this->setup->getElementId(), 'page', $objPage->pageId, $objPage->version);
             }
         }
         //page index
         if ($this->setup->getElementTypeId() != $this->core->sysConfig->page_types->link->id && $this->setup->getStatusId() == $this->core->sysConfig->status->live) {
             if (substr(PHP_OS, 0, 3) === 'WIN') {
                 $this->core->logger->warning('slow page index on windows based OS!');
                 $this->updateIndex(GLOBAL_ROOT_PATH . $this->core->sysConfig->path->search_index->page, $objPage->pageId . '_' . $this->setup->getLanguageId());
             } else {
                 $strIndexPageFilePath = GLOBAL_ROOT_PATH . 'cli/IndexPage.php';
                 //run page index in background
                 exec("php {$strIndexPageFilePath} --pageId='" . $objPage->pageId . "' --version=" . $objPage->version . " --languageId=" . $this->setup->getLanguageId() . " --rootLevelId=" . $this->setup->getRootLevelId() . " > /dev/null &#038;");
             }
         } else {
             $this->removeFromIndex(GLOBAL_ROOT_PATH . $this->core->sysConfig->path->search_index->page, $objPage->pageId . '_' . $this->setup->getLanguageId());
         }
         //cache expiring
         if ($this->Setup()->getField('url')) {
             $strUrl = $this->Setup()->getField('url')->url;
             $strUrlLanguageCode = $this->Setup()->getField('url')->languageCode;
             $arrFrontendOptions = array('lifetime' => null, 'automatic_serialization' => true);
             $arrBackendOptions = array('cache_dir' => GLOBAL_ROOT_PATH . $this->core->sysConfig->path->cache->pages);
             // getting a Zend_Cache_Core object
             $objCache = Zend_Cache::factory('Output', 'File', $arrFrontendOptions, $arrBackendOptions);
             $strCacheId = 'page_' . $this->Setup()->getRootLevelId() . '_' . strtolower(str_replace('-', '_', $strUrlLanguageCode)) . '_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $strUrl);
             $objCache->remove($strCacheId);
             $objCache->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('StartPage', 'PageType_' . $this->core->sysConfig->page_types->overview->id));
         }
         return $this->setup->getElementId();
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }