/**
  * Overwritten insert function to enable storage of material created in non-default language.
  * Note that this creates a translation which is identical to the original - when we update
  * the original in the default language we then keep the translation (although it will appread out of date!).
  *
  * @param	string	table name
  * @param	object	instance with information to store
  * @param	string	primary key name of table
  * @param	boolean	debug info printed or not
  * @param	boolean	passthru without storing information in a translation table
  */
 function insertObject($table, &$object, $keyName = NULL, $verbose = false, $passthru = false)
 {
     if ($this->skipjf) {
         return parent::insertObject($table, $object, $keyName, $verbose);
     }
     $jfManager = JoomFishManager::getInstance();
     if (isset($jfManager)) {
         $this->setLanguage($language);
     }
     $conf = JFactory::getConfig();
     $default_lang = $conf->getValue('config.defaultlang');
     // if the currect language is the site default language the translations will not be updated!
     $passthru = $language == $default_lang;
     if (!$passthru && isset($jfManager)) {
         //Must insert parent first to get reference id !
         $parentInsertReturn = parent::insertObject($table, $object, $keyName, $verbose);
         $pfunc = $this->profile();
         $translationObject = null;
         if (isset($table) && $table != "") {
             $tableName = preg_replace('/^#__/', '', $table);
             if ($table != "#__jf_content") {
                 $contentElement = $jfManager->getContentElement($tableName);
                 if (isset($contentElement)) {
                     if ($contentElement->getTarget() == "native") {
                         // TODO need to know if this is an update calling an insert or a raw insert!
                         // if a raw insert then we may nee to do something extra here ??
                     } else {
                         $translationClass = $contentElement->getTranslationObjectClass();
                         $translationObject = new $translationClass($jfManager->getLanguageID($language), $contentElement);
                         if (isset($object->{$keyName})) {
                             $translationObject->loadFromContentID($object->{$keyName});
                             $translationObject->updateMLContent($object);
                             if (isset($object->state)) {
                                 $translationObject->published = $object->state == 1 ? true : false;
                             } else {
                                 if (isset($object->published)) {
                                     $translationObject->published = $object->published == 1 ? true : false;
                                 }
                             }
                             if ($translationObject->published) {
                                 if ($jfManager->getCfg("frontEndPublish")) {
                                     $user = JFactory::getUser();
                                     $access = new stdClass();
                                     $access->canPublish = $user->authorize('com_content', 'publish', 'content', 'all');
                                     if ($access->canPublish) {
                                         $translationObject->setPublished($translationObject->published);
                                     }
                                 }
                             }
                             $translationObject->store();
                             if ($jfManager->getCfg("transcaching", 1)) {
                                 // clean the cache!
                                 $cache = $jfManager->getCache($language);
                                 $cache->clean();
                             }
                         }
                     }
                 }
             }
             //}
         }
         $pfunc = $this->profile($pfunc);
         return $parentInsertReturn;
     } else {
         return parent::insertObject($table, $object, $keyName, $verbose);
     }
 }
Exemplo n.º 2
0
 /**
  * Overwritten insert function to enable storage of material created in non-default language.
  * Note that this creates a translation which is identical to the original - when we update
  * the original in the default language we then keep the translation (although it will appread out of date!).
  *
  * @param	string	table name
  * @param	object	instance with information to store
  * @param	string	primary key name of table
  * @param	boolean	debug info printed or not
  * @param	boolean	passthru without storing information in a translation table
  */
 function insertObject($table, &$object, $keyName = NULL, $verbose = false, $passthru = false)
 {
     global $_JOOMFISH_MANAGER;
     if (isset($_JOOMFISH_MANAGER)) {
         $this->_setLanguage($language);
     }
     $conf =& JFactory::getConfig();
     $default_lang = $conf->getValue('config.defaultlang');
     // if the currect language is the site default language the translations will not be updated!
     $passthru = $language == $default_lang;
     if (!$passthru && isset($_JOOMFISH_MANAGER)) {
         //Must insert parent first to get reference id !
         $parentInsertReturn = parent::insertObject($table, $object, $keyName, $verbose);
         $pfunc = $this->_profile();
         $actContentObject = null;
         if (isset($table) && $table != "") {
             $tableName = ereg_replace('^#__', '', $table);
             if ($table != "#__jf_content") {
                 // *** QUESTION ***//
                 // IS THIS TEST APPROPRIATE HERE - I THINK IT MEANS YOU CAN'T DO A FIRST TRANSLATION FOR A TABLE VIA THE FRONT END
                 // ** TEST BEFORE 1.8 **//
                 //if ($this->translatedContentAvailable($table)) {
                 $contentElement = $_JOOMFISH_MANAGER->getContentElement($tableName);
                 if (isset($contentElement)) {
                     include_once JPATH_ADMINISTRATOR . "/components/com_joomfish/models/ContentObject.php";
                     $actContentObject = new ContentObject($_JOOMFISH_MANAGER->getLanguageID($language), $contentElement);
                     if (isset($object->{$keyName})) {
                         $actContentObject->loadFromContentID($object->{$keyName});
                         $actContentObject->updateMLContent($object);
                         if (isset($object->state)) {
                             $actContentObject->published = $object->state == 1 ? true : false;
                         } else {
                             if (isset($object->published)) {
                                 $actContentObject->published = $object->published == 1 ? true : false;
                             }
                         }
                         if ($actContentObject->published) {
                             if ($_JOOMFISH_MANAGER->getCfg("frontEndPublish")) {
                                 $user =& JFactory::getUser();
                                 $access = new stdClass();
                                 $access->canPublish = $user->authorize('com_content', 'publish', 'content', 'all');
                                 if ($access->canPublish) {
                                     $actContentObject->setPublished($actContentObject->published);
                                 }
                             }
                         }
                         $actContentObject->store();
                         if ($_JOOMFISH_MANAGER->getCfg("transcaching", 1)) {
                             // clean the cache!
                             $cache = $_JOOMFISH_MANAGER->getCache($language);
                             $cache->clean();
                         }
                     }
                 }
             }
             //}
         }
         $pfunc = $this->_profile($pfunc);
         return $parentInsertReturn;
     } else {
         return parent::insertObject($table, $object, $keyName, $verbose);
     }
 }
Exemplo n.º 3
0
 /**
  * Overwritten insert function to enable storage of material created in non-default language.
  * Note that this creates a translation which is identical to the original - when we update
  * the original in the default language we then keep the translation (although it will appread out of date!).
  *
  * @param	string	table name
  * @param	object	instance with information to store
  * @param	string	primary key name of table
  * @param	boolean	debug info printed or not
  * @param	boolean	passthru without storing information in a translation table
  */
 function insertObject($table, &$object, $keyName = NULL, $verbose = false, $passthru = false)
 {
     $jfManager = JoomFishManager::getInstance();
     if (isset($jfManager)) {
         $this->_setLanguage($language);
     }
     $conf = JFactory::getConfig();
     $default_lang = $conf->getValue('config.defaultlang');
     // if the currect language is the site default language the translations will not be updated!
     $passthru = $language == $default_lang;
     if (!$passthru && isset($jfManager)) {
         //Must insert parent first to get reference id !
         $parentInsertReturn = parent::insertObject($table, $object, $keyName, $verbose);
         $pfunc = $this->_profile();
         $actContentObject = null;
         if (isset($table) && $table != "") {
             $tableName = preg_replace('/^#__/', '', $table);
             if ($table != "#__jf_content") {
                 $contentElement = $jfManager->getContentElement($tableName);
                 if (isset($contentElement)) {
                     include_once JPATH_ADMINISTRATOR . "/components/com_joomfish/models/ContentObject.php";
                     $actContentObject = new ContentObject($jfManager->getLanguageID($language), $contentElement);
                     if (isset($object->{$keyName})) {
                         $actContentObject->loadFromContentID($object->{$keyName});
                         $actContentObject->updateMLContent($object);
                         if (isset($object->state)) {
                             $actContentObject->published = $object->state == 1 ? true : false;
                         } else {
                             if (isset($object->published)) {
                                 $actContentObject->published = $object->published == 1 ? true : false;
                             }
                         }
                         if ($actContentObject->published) {
                             if ($jfManager->getCfg("frontEndPublish")) {
                                 $user = JFactory::getUser();
                                 $access = new stdClass();
                                 $access->canPublish = $user->authorize('com_content', 'publish', 'content', 'all');
                                 if ($access->canPublish) {
                                     $actContentObject->setPublished($actContentObject->published);
                                 }
                             }
                         }
                         $actContentObject->store();
                         if ($jfManager->getCfg("transcaching", 1)) {
                             // clean the cache!
                             $cache = $jfManager->getCache($language);
                             $cache->clean();
                         }
                     }
                 }
             }
             //}
         }
         $pfunc = $this->_profile($pfunc);
         return $parentInsertReturn;
     } else {
         return parent::insertObject($table, $object, $keyName, $verbose);
     }
 }