예제 #1
0
파일: joomfish.php 프로젝트: bizanto/Hooked
 function _plgListingAfterSave(&$model)
 {
     // Limit running this for new/edited listings. Not deletion of images or other listing actions.
     if ($this->c->name == 'listings' && in_array($this->c->action, array('_save'))) {
         include_once PATH_ROOT . 'administrator' . DS . 'components' . DS . 'com_joomfish' . DS . 'models' . DS . 'ContentObject.php';
         $lang =& JFactory::getLanguage();
         $language = $lang->getTag();
         $jfm =& JoomFishManager::getInstance();
         $contentElement = $jfm->getContentElement('content');
         $actContentObject = new ContentObject($jfm->getLanguageID($language), $contentElement);
         $object = (object) $model->data['Listing'];
         $actContentObject->loadFromContentID($object->id);
         $actContentObject->copyContentToTranslation($object, $object);
         $actContentObject->setPublished($this->autoPublishTranslation);
         //Automatically publishes the translations
         $actContentObject->store();
         if ($jfm->getCfg("transcaching", 1)) {
             // clean the cache!
             $cache = $jfm->getCache($language);
             $cache->clean();
         }
     }
 }
예제 #2
0
 function publishTranslation()
 {
     $catid = $this->_catid;
     $publish = $this->_task == "publish" ? 1 : 0;
     $cid = JRequest::getVar('cid', array(0));
     $model =& $this->view->getModel();
     if (strpos($cid[0], '|') >= 0) {
         list($translation_id, $contentid, $language_id) = explode('|', $cid[0]);
     }
     foreach ($cid as $cid_row) {
         list($translation_id, $contentid, $language_id) = explode('|', $cid_row);
         $contentElement = $this->_joomfishManager->getContentElement($catid);
         JLoader::import('models.ContentObject', JOOMFISH_ADMINPATH);
         $actContentObject = new ContentObject($language_id, $contentElement);
         $actContentObject->loadFromContentID($contentid);
         if ($actContentObject->state >= 0) {
             $actContentObject->setPublished($publish);
             $actContentObject->store();
             $model->setState('message', $publish ? JText::_('Translation published') : JText::_('Translation unpublished'));
         }
     }
     // redirect to overview
     $this->showTranslate();
 }
예제 #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();
     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);
     }
 }
예제 #4
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 updateObject($table, &$object, $keyName, $updateNulls = true, $passthru = false)
 {
     $params = JComponentHelper::getParams('com_falang');
     //1.4.5 if fronEdition is set to off , keep previous system
     if ($params->get('frontEndEdition', 0) == 0) {
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     }
     $pfunc = $this->_profile();
     $falangManager = FalangManager::getInstance();
     $current_lang = JFactory::getLanguage()->getTag();
     //default site language
     $default_lang = JComponentHelper::getParams('com_languages')->get('site');
     //we update if content language is set to all language or if content language is current_langauge
     // 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->language == '*') {
             if ($current_lang == $default_lang) {
                 return parent::updateObject($table, $object, $keyName, $updateNulls);
             }
         }
         if ($test->language == $current_lang) {
             return parent::updateObject($table, $object, $keyName, $updateNulls);
         }
     }
     if (isset($falangManager) && $table != "#__falang_content") {
         $tableName = preg_replace('/^#__/', '', $table);
         $contentElement = $falangManager->getContentElement($tableName);
         if (isset($contentElement) && $contentElement->getFrontEdit() == 1) {
             include_once JPATH_ADMINISTRATOR . "/components/com_falang/models/ContentObject.php";
             $actContentObject = new ContentObject($falangManager->getLanguageID($current_lang), $contentElement);
             $objectLanguague = isset($object->language) ? $object->language : null;
             //the object language must be a language tag
             $languageIsoList = array("*");
             foreach ($falangManager->getLanguagesIndexedByCode(false) as $language) {
                 $languageIsoList[] = $language->lang_code;
             }
             $validLanguage = in_array($objectLanguague, $languageIsoList);
             // 1 - si object * => objet joomla si langue cournate et langue en cours sont pareil
             // 2 - si object a une langue , alors object joolma si la langue de l'object = language en cours
             $joomlaObject = false;
             if ($objectLanguague == "*") {
                 if ($current_lang == $default_lang) {
                     $joomlaObject = true;
                 }
             }
             if ($objectLanguague == $current_lang) {
                 $joomlaObject = true;
             }
             //hikashop woraround //
             $lkeyName = method_exists($object, 'getKeyName') ? $object->getKeyName() : null;
             if (!empty($lkeyName) && $validLanguage && isset($objectLanguague) && !$joomlaObject) {
                 $actContentObject->loadFromContentID($object->id);
                 $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;
                     }
                 }
                 $actContentObject->setPublished($actContentObject->published);
                 $actContentObject->store();
                 return true;
             } else {
                 //hikashop workaround this update hit.
                 return parent::updateObject($table, $object, $keyName, $updateNulls);
             }
         } else {
             //content element not exist
             return parent::updateObject($table, $object, $keyName, $updateNulls);
         }
     } else {
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     }
 }
예제 #5
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)
 {
     global $mosConfig_lang, $mosConfig_defaultLang, $_JOOMFISH_MANAGER;
     // if the currect language is the site default language the translations will not be updated!
     $passthru = $mosConfig_lang == $mosConfig_defaultLang;
     if (!$passthru && isset($_JOOMFISH_MANAGER)) {
         $actContentObject = null;
         if (isset($table) && $table != "") {
             $tableName = ereg_replace('^#__', '', $table);
             // *** 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)) {
                 $actContentObject = new ContentObject($_JOOMFISH_MANAGER->getLanguageID($mosConfig_lang), $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")) {
                         global $acl;
                         $user =& JFactory::getUser();
                         $access = new stdClass();
                         $access->canPublish = $acl->acl_check('action', 'publish', 'users', $user->usertype, 'content', 'all');
                         if ($access->canPublish) {
                             $actContentObject->setPublished($actContentObject->published);
                         }
                     }
                     $actContentObject->store();
                 }
             }
             //}
         }
         return $this->_db->updateObject($table, $object, $keyName, $updateNulls);
     } else {
         return $this->_db->updateObject($table, $object, $keyName, $updateNulls);
     }
 }
예제 #6
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);
     }
 }
예제 #7
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 updateObject($table, &$object, $keyName, $updateNulls = true, $passthru = false)
 {
     $params = JComponentHelper::getParams('com_falang');
     $pfunc = $this->_profile();
     $falangManager = FalangManager::getInstance();
     $current_lang = JFactory::getLanguage()->getTag();
     //default site language
     $default_lang = JComponentHelper::getParams('com_languages')->get('site');
     //we update if content language is set to all language or if content language is current_langauge
     // 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->language == '*') {
             if ($current_lang == $default_lang) {
                 return parent::updateObject($table, $object, $keyName, $updateNulls);
             }
         }
         if ($test->language == $current_lang) {
             return parent::updateObject($table, $object, $keyName, $updateNulls);
         }
     }
     if (isset($falangManager) && $table != "#__falang_content") {
         $tableName = preg_replace('/^#__/', '', $table);
         $contentElement = $falangManager->getContentElement($tableName);
         if (isset($contentElement)) {
             include_once JPATH_ADMINISTRATOR . "/components/com_falang/models/ContentObject.php";
             $actContentObject = new ContentObject($falangManager->getLanguageID($current_lang), $contentElement);
             //hikashop woraround //
             $lkeyName = method_exists($object, 'getKeyName') ? $object->getKeyName() : null;
             if (!empty($lkeyName)) {
                 $actContentObject->loadFromContentID($object->id);
                 $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 ( $falangManager->getCfg("frontEndPublish")){
                 if ($params->get('frontEndEdition', 0) == 1) {
                     $user = JFactory::getUser();
                     $access = new stdClass();
                     //$access->canPublish =  $user->authorize('com_content', 'publish', 'content', 'all');
                     //if ($access->canPublish) $actContentObject->setPublished($actContentObject->published);
                     $actContentObject->setPublished($actContentObject->published);
                 }
                 //if allow front-end translation
                 if ($params->get('frontEndEdition', 0) == 1) {
                     $actContentObject->store();
                 } else {
                     $application = JFactory::getApplication();
                     $application->enqueueMessage(JText::_('PLG_SYSTEM_FALANGDRIVER_FRONT_UPDATE_NOT_AUTHORIZED'), 'notice');
                     return false;
                 }
             } else {
                 //hikashop workaround this update hit.
                 return parent::updateObject($table, $object, $keyName, $updateNulls);
             }
         }
         //content element not exist
         $pfunc = $this->_profile($pfunc);
         //return parent::updateObject( $table, $object, $keyName, $updateNulls );
         return true;
     } else {
         return parent::updateObject($table, $object, $keyName, $updateNulls);
     }
 }