/**
  * save
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function save()
 {
     $this->core->logger->debug('massiveart->generic->data->GenericDataTypeGlobal->save()');
     try {
         $this->getModelGlobals()->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:
                 $objGlobal = $this->objModelGlobals->add($this->setup);
                 $this->setup->setElementId($objGlobal->id);
                 if (isset($objGlobal->linkId)) {
                     $this->setup->setElementLinkId($objGlobal->linkId);
                 }
                 $this->insertCoreData('global', $objGlobal->globalId, $objGlobal->version);
                 $this->insertFileData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                 $this->insertMultiFieldData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                 $this->insertInstanceData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                 $this->insertMultiplyRegionData('global', $objGlobal->globalId, $objGlobal->version);
                 break;
             case $this->core->sysConfig->generic->actions->edit:
                 $objGlobal = $this->objModelGlobals->load($this->setup->getElementId());
                 if (count($objGlobal) > 0) {
                     $objGlobal = $objGlobal->current();
                     $this->objModelGlobals->update($this->setup, $objGlobal);
                     $this->updateCoreData('global', $objGlobal->globalId, $objGlobal->version);
                     $this->updateFileData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                     $this->updateMultiFieldData('global', $objGlobal->globalId, $objGlobal->version);
                     $this->updateInstanceData('global', $objGlobal->globalId, $objGlobal->version);
                     $this->updateMultiplyRegionData('global', $objGlobal->globalId, $objGlobal->version);
                 }
                 break;
             case $this->core->sysConfig->generic->actions->change_template:
                 $objGlobal = $this->objModelGlobals->load($this->setup->getElementId());
                 if (count($objGlobal) > 0) {
                     $objGlobal = $objGlobal->current();
                     $this->objModelGlobals->update($this->setup, $objGlobal);
                     $this->insertCoreData('global', $objGlobal->globalId, $objGlobal->version);
                     if ($this->blnHasLoadedFileData) {
                         $this->updateFileData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                     } else {
                         $this->insertFileData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                     }
                     if ($this->blnHasLoadedMultiFieldData) {
                         $this->updateMultiFieldData('global', $objGlobal->globalId, $objGlobal->version);
                     } else {
                         $this->insertMultiFieldData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                     }
                     if ($this->blnHasLoadedInstanceData) {
                         $this->updateInstanceData('global', $objGlobal->globalId, $objGlobal->version);
                     } else {
                         $this->insertInstanceData('global', array('Id' => $objGlobal->globalId, 'Version' => $objGlobal->version));
                     }
                     if ($this->blnHasLoadedMultiplyRegionData) {
                         $this->updateMultiplyRegionData('global', $objGlobal->globalId, $objGlobal->version);
                     } else {
                         $this->insertMultiplyRegionData('global', $objGlobal->globalId, $objGlobal->version);
                     }
                 }
                 break;
             case $this->core->sysConfig->generic->actions->change_template_id:
                 $objGlobal = $this->objModelGlobals->load($this->setup->getElementId());
                 if (count($objGlobal) > 0) {
                     $objGlobal = $objGlobal->current();
                     $this->objModelGlobals->update($this->setup, $objGlobal);
                 }
                 break;
         }
         /**
          * now save all the special fields
          */
         if (count($this->setup->SpecialFields()) > 0) {
             foreach ($this->setup->SpecialFields() as $objField) {
                 $objField->setGenericSetup($this->setup);
                 if ($objField->type == GenericSetup::FIELD_TYPE_URL && (int) $this->setup->getElementLinkId() > 0) {
                     $objField->save($this->setup->getElementLinkId(), 'global', $objGlobal->globalId, $objGlobal->version);
                 } else {
                     $objField->save($this->setup->getElementId(), 'global', $objGlobal->globalId, $objGlobal->version);
                 }
             }
         }
         //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('StartGlobal', 'GlobalType_' . $this->core->sysConfig->global_types->product_overview->id, 'GlobalType_' . $this->core->sysConfig->global_types->content_overview->id, 'GlobalType_' . $this->core->sysConfig->global_types->press_overview->id, 'GlobalType_' . $this->core->sysConfig->global_types->course_overview->id, 'GlobalType_' . $this->core->sysConfig->global_types->event_overview->id, 'GlobalId_' . $objGlobal->globalId . '_' . $this->setup->getLanguageId()));
         }
         //global index
         if ($this->setup->getStatusId() == $this->core->sysConfig->status->live) {
             if (substr(PHP_OS, 0, 3) === 'WIN') {
                 $this->core->logger->warning('Now indexing implemented at the moment!');
                 //TODO:FIXME $this->updateIndex(GLOBAL_ROOT_PATH.$this->core->sysConfig->path->search_index->global, $objGlobal->globalId.'_'.$this->setup->getLanguageId());
             } else {
                 $strIndexGlobalFilePath = GLOBAL_ROOT_PATH . 'cli/IndexGlobal.php';
                 //run global index in background
                 exec("php " . $strIndexGlobalFilePath . " --globalId='" . $objGlobal->globalId . "' --linkId='" . $this->setup->getElementLinkId() . "' --version=" . $objGlobal->version . " --languageId=" . $this->setup->getLanguageId() . " --rootLevelId=" . $this->setup->getRootLevelId() . " > /dev/null &#038;");
             }
         } else {
             //$this->removeFromIndex(GLOBAL_ROOT_PATH.$this->core->sysConfig->path->search_index->global, $objGlobal->globalId.'_'.$this->setup->getLanguageId().'_r*');
             $strIndexGlobalFilePath = GLOBAL_ROOT_PATH . 'cli/IndexRemoveGlobal.php';
             //run remove global from index in background
             exec("php " . $strIndexGlobalFilePath . " --key='" . $objGlobal->globalId . "_" . $this->setup->getLanguageId() . "_r*' > /dev/null &#038;");
         }
         return $this->setup->getElementId();
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }