/**
  * Overwritten update function to enable storage of translated information.
  * Based on the configuration in the content elements the automatic storage of
  * information is activated or not. It is important that this upgraded method will ensure
  * that all information will be written into the translation table. Only in the case that the
  * default language is choosen the information will be updated directly within the original tables.
  * To make sure that all other information will be written into the tables as expected the
  * statements will be manipulated as needed.
  *
  * @param	string	table name
  * @param	object	instance with information to store
  * @param	string	primary key name of table
  * @param	boolean	update fields with null or not
  * @param	boolean	passthru without storing information in a translation table
  */
 function updateObject($table, &$object, $keyName, $updateNulls = true, $passthru = false)
 {
     if ($this->skipjf) {
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     }
     $pfunc = $this->profile();
     $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)) {
         $translationObject = null;
         if (isset($table) && $table != "") {
             $tableName = preg_replace('/^#__/', '', $table);
             if ($table != "#__jf_content") {
                 $contentElement = $jfManager->getContentElement($tableName);
                 if (isset($contentElement)) {
                     $translationClass = $contentElement->getTranslationObjectClass();
                     $translationObject = new $translationClass($jfManager->getLanguageID($language), $contentElement);
                     if (isset($object->{$keyName})) {
                         // load the native language version
                         $translationObject->loadFromContentID($object->{$keyName});
                         // update the translation object with the transalation and the status of any changes etc.
                         $translationObject->updateMLContent($object, $language);
                         // TODO move this to translation object class
                         if (isset($object->state)) {
                             $translationObject->published = $object->state == 1 ? true : false;
                         } else {
                             if (isset($object->published)) {
                                 $translationObject->published = $object->published == 1 ? true : false;
                             }
                         }
                         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);
                             }
                         }
                         $success = $translationObject->store();
                         if ($jfManager->getCfg("transcaching", 1)) {
                             // clean the cache!
                             $cache = $jfManager->getCache($language);
                             $cache->clean();
                         }
                     }
                 }
             }
         }
         $pfunc = $this->profile($pfunc);
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     } else {
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     }
 }
Ejemplo n.º 2
0
 /**
  * Overwritten update function to enable storage of translated information.
  * Based on the configuration in the content elements the automatic storage of
  * information is activated or not. It is important that this upgraded method will ensure
  * that all information will be written into the translation table. Only in the case that the
  * default language is choosen the information will be updated directly within the original tables.
  * To make sure that all other information will be written into the tables as expected the
  * statements will be manipulated as needed.
  *
  * @param	string	table name
  * @param	object	instance with information to store
  * @param	string	primary key name of table
  * @param	boolean	update fields with null or not
  * @param	boolean	passthru without storing information in a translation table
  */
 function updateObject($table, &$object, $keyName, $updateNulls = true, $passthru = false)
 {
     $pfunc = $this->_profile();
     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)) {
         $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 ($_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 parent::updateObject($table, $object, $keyName, $updateNulls);
     } else {
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     }
 }
Ejemplo n.º 3
0
 /**
  * Overwritten update function to enable storage of translated information.
  * Based on the configuration in the content elements the automatic storage of
  * information is activated or not. It is important that this upgraded method will ensure
  * that all information will be written into the translation table. Only in the case that the
  * default language is choosen the information will be updated directly within the original tables.
  * To make sure that all other information will be written into the tables as expected the
  * statements will be manipulated as needed.
  *
  * @param	string	table name
  * @param	object	instance with information to store
  * @param	string	primary key name of table
  * @param	boolean	update fields with null or not
  * @param	boolean	passthru without storing information in a translation table
  */
 function updateObject($table, &$object, $keyName, $updateNulls = true, $passthru = false)
 {
     $pfunc = $this->_profile();
     $jfManager = JoomFishManager::getInstance();
     if (isset($jfManager)) {
         $this->_setLanguage($language);
     }
     $conf = JFactory::getConfig();
     $default_lang = $conf->getValue('config.defaultlang');
     // check if marked langage of content is the detaul language:
     if ($table == '#__content' && isset($object->id) && $object->id > 0) {
         $test = JTable::getInstance("Content");
         $test->load($object->id);
         if ($test) {
             jimport('joomla.html.parameter');
             $testparams = new JParameter($test->attribs);
             $testlang = $testparams->get('language', false);
             if ($testlang == $language) {
                 // no translation should be created
                 $language = $default_lang;
             }
         }
     }
     // if the currect language is the site default language the translations will not be updated!
     $passthru = $language == $default_lang;
     if (!$passthru && isset($jfManager)) {
         $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 ($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 parent::updateObject($table, $object, $keyName, $updateNulls);
     } else {
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     }
 }