Example #1
0
 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();
         }
     }
 }
Example #2
0
 public function __construct($title, $content)
 {
     $number_of_parameters = func_num_args();
     if ($number_of_parameters <= 6) {
         $date = $number_of_parameters >= 3 ? func_get_arg(2) : '';
         $id = $number_of_parameters >= 4 ? func_get_arg(3) : '';
         $this->author = $number_of_parameters >= 5 ? func_get_arg(4) : '';
         $this->is_event = $number_of_parameters == 6 ? func_get_arg(5) : FALSE;
         parent::__construct($title, $content, $date, $id);
         $this->form_add->add_hidden("type", "Page")->add_text("title", "Page title")->add_checkbox("is_event", "TRUE", "&Eacute;v&egrave;nement")->add_textarea("content", "");
         $this->form_modify->add_hidden("type", "Page")->add_hidden("id", $this->id)->add_text("title", "", $this->title)->add_checkbox("is_event", "TRUE", "&Eacute;v&egrave;nement", $this->is_event)->add_textarea("content", "", $this->content);
     } else {
         throw new InvalidArgumentException("Too much parameters");
     }
 }
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volume/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aContentObject instanceof Persistent) {
             $this->aContentObject->clearAllReferences($deep);
         }
         if ($this->aLanguage instanceof Persistent) {
             $this->aLanguage->clearAllReferences($deep);
         }
         if ($this->aUserRelatedByCreatedBy instanceof Persistent) {
             $this->aUserRelatedByCreatedBy->clearAllReferences($deep);
         }
         if ($this->aUserRelatedByUpdatedBy instanceof Persistent) {
             $this->aUserRelatedByUpdatedBy->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aContentObject = null;
     $this->aLanguage = null;
     $this->aUserRelatedByCreatedBy = null;
     $this->aUserRelatedByUpdatedBy = null;
 }
Example #4
0
 /**
  * @param	ContentObject $contentObject The contentObject object to add.
  */
 protected function doAddContentObject($contentObject)
 {
     $this->collContentObjects[] = $contentObject;
     $contentObject->setPage($this);
 }
Example #5
0
 /**
  * Filter the query by a related ContentObject object
  *
  * @param   ContentObject|PropelObjectCollection $contentObject  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 PageQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByContentObject($contentObject, $comparison = null)
 {
     if ($contentObject instanceof ContentObject) {
         return $this->addUsingAlias(PagePeer::ID, $contentObject->getPageId(), $comparison);
     } elseif ($contentObject instanceof PropelObjectCollection) {
         return $this->useContentObjectQuery()->filterByPrimaryKeys($contentObject->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByContentObject() only accepts arguments of type ContentObject or PropelCollection');
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param ContentObject $obj A ContentObject object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         ContentObjectPeer::$instances[$key] = $obj;
     }
 }
 public function adminAddObjectToContainer($sContainerName, $sObjectType, $iSort = 0)
 {
     $oContentObject = new ContentObject();
     $oContentObject->setPageId($this->oPage->getId());
     $oContentObject->sortIntoNew($sContainerName, $iSort);
     $oContentObject->setObjectType($sObjectType);
     $oContentObject->save();
     return $this->paramsForObject($oContentObject);
 }
Example #8
0
 /**
  * This method checks the translation status
  * The process follows goes through out all existing translations and checks their individual status.
  * The output is a summary information based grouped by content element files and the languages
  *
  * @param array 	$translationStatus	array with translation state values
  * @param int		$phase	which phase of the status check
  * @param string	$statecheck_i	running row number starting with -1!
  * @param string	$message	system message
  */
 private function _testTranslationStatus($translationStatus, &$phase, &$statecheck_i, &$message)
 {
     $db = JFactory::getDBO();
     $sql = '';
     switch ($phase) {
         case 1:
             $sql = "SELECT jfc.reference_table, jfc.language_id, jfl.name AS language" . "\n FROM #__falang_content AS jfc" . "\n JOIN #__languages AS jfl ON jfc.language_id = jfl.id" . "\n GROUP BY jfc.reference_table, jfc.language_id";
             $db->setQuery($sql);
             $rows = $db->loadObjectList();
             $translationStatus = array();
             if (is_array($rows) && count($rows) > 0) {
                 foreach ($rows as $row) {
                     $status = array();
                     $contentElement = $this->_falangManager->getContentElement($row->reference_table);
                     $status['content'] = $contentElement->Name;
                     $status['catid'] = $row->reference_table;
                     $status['language_id'] = $row->language_id;
                     $status['language'] = $row->language;
                     $status['total'] = '';
                     $status['state_valid'] = '';
                     $status['state_unvalid'] = '';
                     $status['state_missing'] = '';
                     $status['state'] = '';
                     $status['published'] = '';
                     $sql = "SELECT * FROM #__falang_content" . "\n WHERE reference_table='" . $row->reference_table . "'" . "\n   AND language_id=" . $row->language_id . "\n GROUP BY reference_id";
                     $db->setQuery($sql);
                     $totalrows = $db->loadRowList();
                     if ($totalrows = $db->loadRowList()) {
                         $status['total'] = count($totalrows);
                     }
                     $translationStatus[] = $status;
                 }
                 $message = JText::_('TRANSLATION_PHASE1_GENERALCHECK');
                 $phase++;
             } else {
                 $message = JText::_('No Translation available');
                 $phase = 4;
                 // exit
             }
             break;
         case 2:
             if (is_array($translationStatus) && count($translationStatus) > 0) {
                 for ($i = 0; $i < count($translationStatus); $i++) {
                     $stateRow = $translationStatus[$i];
                     $sql = "select *" . "\n from #__falang_content as jfc" . "\n where published=1" . "\n and reference_table='" . $stateRow['catid'] . "'" . "\n and language_id=" . $stateRow['language_id'] . "\n group by reference_ID";
                     $db->setQuery($sql);
                     if ($rows = $db->loadRowList()) {
                         $stateRow['published'] = count($rows);
                     } else {
                         $stateRow['published'] = 0;
                     }
                 }
             }
             $message = JText::sprintf('TRANSLATION_PHASE2_PUBLISHEDCHECK', '');
             $phase++;
             break;
         case 3:
             if (is_array($translationStatus) && count($translationStatus) > 0) {
                 if ($statecheck_i >= 0 && $statecheck_i < count($translationStatus)) {
                     $stateRow = $translationStatus[$statecheck_i];
                     $contentElement = $this->_falangManager->getContentElement($stateRow['catid']);
                     $filters = array();
                     // we need to find an end, thats why the filter is at 10.000!
                     $db->setQuery($contentElement->createContentSQL($stateRow['language_id'], null, 0, 10000, $filters));
                     if ($rows = $db->loadObjectList()) {
                         $stateRow['state_valid'] = 0;
                         $stateRow['state_unvalid'] = 0;
                         $stateRow['state_missing'] = 0;
                         for ($i = 0; $i < count($rows); $i++) {
                             $contentObject = new ContentObject($stateRow['language_id'], $contentElement);
                             $contentObject->readFromRow($rows[$i]);
                             $rows[$i] = $contentObject;
                             switch ($contentObject->state) {
                                 case 1:
                                     $stateRow['state_valid']++;
                                     break;
                                 case 0:
                                     $stateRow['state_unvalid']++;
                                     break;
                                 case -1:
                                 default:
                                     $stateRow['state_missing']++;
                                     break;
                             }
                         }
                     }
                 }
                 if ($statecheck_i < count($translationStatus) - 1) {
                     $statecheck_i++;
                     $message = JText::sprintf('TRANSLATION_PHASE2_PUBLISHEDCHECK', ' (' . $translationStatus[$statecheck_i]['content'] . '/' . $translationStatus[$statecheck_i]['language'] . ')');
                 } else {
                     $message = JText::_('TRANSLATION_PHASE3_STATECHECK');
                     $phase = 4;
                     // exit
                 }
             } else {
                 $message = JText::_('TRANSLATION_PHASE3_STATECHECK');
                 $phase = 4;
                 // exit
             }
             break;
     }
     return $translationStatus;
 }
 /**
  * Cached extraction of content element field information
  * this cached version is shared between pages and hence makes a big improvement to load times
  * for newly visited pages in a cached scenario
  *
  * @param string $reference_table
  * @return value
  */
 public function contentElementFields($reference_table)
 {
     static $info;
     if (!isset($info)) {
         $info = array();
     }
     if (!isset($info[$reference_table])) {
         $cacheDir = JPATH_CACHE;
         $cacheFile = $cacheDir . "/" . $reference_table . "_cefields.cache";
         if (file_exists($cacheFile)) {
             $cacheFileContent = file_get_contents($cacheFile);
             $info[$reference_table] = unserialize($cacheFileContent);
         } else {
             $jfm = JoomFishManager::getInstance();
             $contentElement = $jfm->getContentElement($reference_table);
             // The language is not relevant for this function so just use the current language
             $registry = JFactory::getConfig();
             $lang = $registry->getValue("config.jflang");
             include_once JPATH_ADMINISTRATOR . DS . "components" . DS . "com_joomfish" . '/models/ContentObject.php';
             $contentObject = new ContentObject($jfm->getLanguageID($lang), $contentElement);
             $textFields = $contentObject->getTextFields();
             $info[$reference_table]["textFields"] = $textFields;
             $info[$reference_table]["fieldTypes"] = array();
             if ($textFields !== null) {
                 $defaultSet = false;
                 foreach ($textFields as $field) {
                     $info[$reference_table]["fieldTypes"][$field] = $contentObject->getFieldType($field);
                 }
             }
             $cacheFileContent = serialize($info[$reference_table]);
             $handle = @fopen($cacheFile, "w");
             if ($handle) {
                 fwrite($handle, $cacheFileContent);
                 fclose($handle);
             }
         }
     }
     return $info[$reference_table];
 }
Example #10
0
 /**
  * Adds the translation toolbar button to the toolbar based on the
  * given parameters.
  *
  */
 public function addToolbar()
 {
     //check if we are in backend
     $app = JFactory::getApplication();
     if (!$app->isAdmin()) {
         return;
     }
     $doc = JFactory::getDocument();
     $falangManager = FalangManager::getInstance();
     $input = JFactory::getApplication()->input;
     $option = $input->get('option', false, 'cmd');
     $view = $input->get('view', false, 'cmd');
     $task = $input->get('task', false, 'cmd');
     $layout = $input->get('layout', 'default', 'string');
     if (!$option || !$view && !$task || !$layout) {
         return;
     }
     $mapping = $this->loadComponent();
     if (!isset($mapping)) {
         return;
     }
     //GET KEY FROM CONTENT ELEMENT
     $id = $input->get($mapping[2], 0, 'int');
     if (empty($id)) {
         return;
     }
     //Load ToolBar
     $bar = JToolBar::getInstance('toolbar');
     //Load Language
     $languages = $this->getLanguages();
     // @deprecated used for Joomla 2.5
     //TODO use library ?
     $bar->addButtonPath(JPATH_PLUGINS . '/system/falangquickjump/toolbar/button/');
     $buttontype = 'itrPopup';
     $width = '95%';
     $height = '99%';
     //Add Stylesheet for button icons
     JHTML::_('stylesheet', 'administrator/components/com_falang/assets/css/falang.css', array(), false);
     //Add button by language
     foreach ($languages as $language) {
         //get Falang Object info
         $contentElement = $falangManager->getContentElement($mapping[1]);
         JLoader::import('models.ContentObject', FALANG_ADMINPATH);
         $actContentObject = new ContentObject($language->lang_id, $contentElement);
         $actContentObject->loadFromContentID($id);
         $class = "quickmodal ";
         //-1 not exist, 0 old , 1 uptodate
         switch ($actContentObject->state) {
             case 1:
                 $class .= "uptodate";
                 break;
             case 0:
                 $class .= "old";
                 break;
             case -1:
                 $class .= "notexist";
                 break;
             default:
                 $class .= "notexist";
                 break;
         }
         $publish = isset($actContentObject->published) && $actContentObject->published == 1 ? " icon-publish" : " icon-unpublish";
         //free and paid mmust be on 1 line
         /* >>> [FREE] >>> */
         $url = 'index.php?option=com_falang&task=translate.editfree&tmpl=component&direct=1';
         /* <<< [FREE] <<< */
         $bar->appendButton($buttontype, 'falang-quicktranslate-' . $language->lang_id, $language->title, $url, $width, $height, null, null, null, null, $language->image, $class, $publish);
     }
 }
Example #11
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);
     }
 }
 /**
  * Exclude object from result
  *
  * @param   ContentObject $contentObject Object to remove from the list of results
  *
  * @return ContentObjectQuery The current query, for fluid interface
  */
 public function prune($contentObject = null)
 {
     if ($contentObject) {
         $this->addUsingAlias(ContentObjectPeer::ID, $contentObject->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Filter the query by a related ContentObject object
  *
  * @param   ContentObject|PropelObjectCollection $contentObject The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 LanguageObjectHistoryQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByContentObject($contentObject, $comparison = null)
 {
     if ($contentObject instanceof ContentObject) {
         return $this->addUsingAlias(LanguageObjectHistoryPeer::OBJECT_ID, $contentObject->getId(), $comparison);
     } elseif ($contentObject instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(LanguageObjectHistoryPeer::OBJECT_ID, $contentObject->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByContentObject() only accepts arguments of type ContentObject or PropelCollection');
     }
 }
 public function create($is_root = false)
 {
     $crypted_password = SimpleAuthenticator::getCryptedPassword($this->getIdentifier(), $this->get('password'));
     $this->set('password', $crypted_password);
     return parent::create($is_root);
 }
Example #15
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);
     }
 }
Example #16
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);
     }
 }
Example #17
0
 /**
  * show original value in an IFrame - for form safety
  *
  */
 function originalValue()
 {
     $cid = trim(JRequest::getVar('cid', ""));
     $language_id = JRequest::getInt('lang', 0);
     if ($cid == "") {
         echo JText::_("Invalid paramaters");
         return;
     }
     $translation_id = 0;
     $contentid = intval($cid);
     $catid = $this->_catid;
     global $mainframe;
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     $actContentObject = null;
     if (isset($catid) && $catid != "") {
         $contentElement = $this->_joomfishManager->getContentElement($catid);
         JLoader::import('models.ContentObject', JOOMFISH_ADMINPATH);
         $actContentObject = new ContentObject($language_id, $contentElement);
         $actContentObject->loadFromContentID($contentid);
     }
     $fieldname = JRequest::getString('field', '');
     // get the view
     $this->view =& $this->getView('translate');
     // Set the layout
     $this->view->setLayout('originalvalue');
     // Assign data for view - should really do this as I go along
     $this->view->assignRef('actContentObject', $actContentObject);
     $this->view->assignRef('field', $fieldname);
     $this->view->display();
 }
Example #18
0
    /**
     * render content state information
     */
    function renderContentState()
    {
        $joomFishManager = JoomFishManager::getInstance();
        $output = '';
        $alertContent = false;
        if (array_key_exists('unpublished', $this->contentInfo) && is_array($this->contentInfo['unpublished'])) {
            $alertContent = true;
        }
        ob_start();
        ?>
		<table class="adminlist">
			<tr>
				<th><?php 
        echo JText::_("UNPUBLISHED CONTENT ELEMENTS");
        ?>
</th>
				<th style="text-align: center;"><?php 
        echo JText::_("Language");
        ?>
</th>
				<th style="text-align: center;"><?php 
        echo JText::_("Publish");
        ?>
</th>
			</tr>
			<?php 
        $k = 0;
        if ($alertContent) {
            $curReftable = '';
            foreach ($this->contentInfo['unpublished'] as $ceInfo) {
                $contentElement = $joomFishManager->getContentElement($ceInfo['catid']);
                // Trap for content elements that may have been removed
                if (is_null($contentElement)) {
                    $name = "<span style='font-style:italic'>" . JText::sprintf("CONTENT_ELEMENT_MISSING", $ceInfo["reference_table"]) . "</span>";
                } else {
                    $name = $contentElement->Name;
                }
                if ($ceInfo["reference_table"] != $curReftable) {
                    $curReftable = $ceInfo["reference_table"];
                    $k = 0;
                    ?>
			<tr><td colspan="3"><strong><?php 
                    echo $name;
                    ?>
</strong></td></tr>
						<?php 
                }
                JLoader::import('models.ContentObject', JOOMFISH_ADMINPATH);
                $contentObject = new ContentObject($ceInfo['language_id'], $contentElement);
                $contentObject->loadFromContentID($ceInfo['reference_id']);
                $link = 'index2.php?option=com_joomfish&amp;task=translate.edit&amp;&amp;catid=' . $ceInfo['catid'] . '&cid[]=0|' . $ceInfo['reference_id'] . '|' . $ceInfo['language_id'];
                $hrefEdit = "<a href='" . $link . "'>" . $contentObject->title . "</a>";
                $link = 'index2.php?option=com_joomfish&amp;task=translate.publish&amp;catid=' . $ceInfo['catid'] . '&cid[]=0|' . $ceInfo['reference_id'] . '|' . $ceInfo['language_id'];
                $hrefPublish = '<a href="' . $link . '"><img src="images/publish_x.png" width="12" height="12" border="0" alt="" /></a>';
                ?>
			<tr class="row<?php 
                echo $k;
                ?>
">
				<td align="left"><?php 
                echo $hrefEdit;
                ?>
</td>
				<td style="text-align: center;"><?php 
                echo $ceInfo['language'];
                ?>
</td>
					<td style="text-align: center;"><?php 
                echo $hrefPublish;
                ?>
</td>
			</tr>
					<?php 
                $k = 1 - $k;
            }
        } else {
            ?>
			<tr class="row0">
				<td colspan="3"><?php 
            echo JText::_("No unpublished translations found");
            ?>
</td>
			</tr>
					<?php 
        }
        ?>
		</table>
		<?php 
        $output .= ob_get_clean();
        return $output;
    }
Example #19
0
 function __construct($id)
 {
     $this->id = $id;
     parent::__construct();
 }
Example #20
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);
     }
 }
Example #21
0
 /**
  * This method copies originals content items to one selected language
  *
  * @param unknown_type $original2languageInfo
  * @param unknown_type $phase
  * @param unknown_type $statecheck_i
  * @param unknown_type $message
  * @return array	Information result array
  */
 function copyOriginalToLanguage($original2languageInfo, &$phase, &$state_catid, $language_id, $overwrite, &$message)
 {
     $db = JFactory::getDBO();
     $jfManager = JoomFishManager::getInstance();
     $sql = '';
     switch ($phase) {
         case 1:
             $original2languageInfo = array();
             $sql = "select distinct CONCAT('" . $db->getPrefix() . "',reference_table) from #__jf_content";
             $db->setQuery($sql);
             $tablesWithTranslations = $db->loadResultArray();
             $sql = "SHOW TABLES";
             $db->setQuery($sql);
             $tables = $db->loadResultArray();
             $allContentElements = $jfManager->getContentElements();
             foreach ($allContentElements as $catid => $ce) {
                 $ceInfo = array();
                 $ceInfo['name'] = $ce->Name;
                 $ceInfo['catid'] = $catid;
                 $ceInfo['total'] = '??';
                 $ceInfo['existing'] = '??';
                 $ceInfo['processed'] = '0';
                 $ceInfo['copied'] = '0';
                 $ceInfo['copy'] = false;
                 $contentTable = $ce->getTable();
                 $tablename = $db->getPrefix() . $contentTable->Name;
                 if (in_array($tablename, $tables)) {
                     // get total count of table entries
                     $sql = 'SELECT COUNT(*) FROM ' . $tablename . ' AS c';
                     if ($contentTable->Filter != '') {
                         $sql .= ' WHERE ' . $contentTable->Filter;
                     }
                     $db->setQuery($sql);
                     $ceInfo['total'] = $db->loadResult();
                 }
                 $original2languageInfo[$catid] = $ceInfo;
             }
             $phase = 1;
             // stays with 1 as the second phase needs the bottom to be clicked
             $message = JText::_('COPY2LANGUAGE_INFO');
             break;
         case 2:
             if ($state_catid != '') {
                 // removing all content information which are not to be copied!
                 $celements = explode(',', $state_catid);
                 if (count($celements) < count($original2languageInfo)) {
                     $shortList = array();
                     foreach ($celements as $element) {
                         $shortList[$element] = $original2languageInfo[$element];
                     }
                     $original2languageInfo = $shortList;
                 }
             }
             $phase = 3;
         case 3:
             if ($state_catid != '') {
                 $celements = explode(',', $state_catid);
                 // copy the information per content element file, starting with the first in the list
                 $catid = array_shift($celements);
                 $catidCompleted = false;
                 // coyping the information from the selected content element
                 if ($catid != '' && $language_id != 0) {
                     // get's the config settings on how to store original files
                     $storeOriginalText = $jfManager->getCfg('storageOfOriginal') == 'md5' ? false : true;
                     // make sure we are only transfering data within parts (max 100 items at a time)
                     $ceInfo =& $original2languageInfo[$catid];
                     if (intval($ceInfo['processed']) < intval($ceInfo['total'])) {
                         $contentElement = $jfManager->getContentElement($catid);
                         $db->setQuery($contentElement->createContentSQL($language_id, null, $ceInfo['processed'], 10, array()));
                         $rows = $db->loadObjectList();
                         if ($db->getErrorNum()) {
                             JError::raiseError(500, JTEXT::_('Invalid Content SQL : ') . $db->getErrorMsg());
                             return false;
                         } else {
                             for ($i = 0; $i < count($rows); $i++) {
                                 $contentObject = new ContentObject($language_id, $contentElement);
                                 $contentObject->readFromRow($rows[$i]);
                                 if ($overwrite || $contentObject->translation_id == 0) {
                                     $contentObject->copyContentToTranslation($rows[$i], $rows[$i]);
                                     $contentObject->store();
                                     $ceInfo['copied'] += 1;
                                 }
                                 $rows[$i] = $contentObject;
                             }
                             $ceInfo['processed'] += $i;
                             if ($ceInfo['processed'] >= $ceInfo['total']) {
                                 $catidCompleted = true;
                             }
                         }
                     }
                 }
                 if ($catidCompleted) {
                     if (count($celements) > 0) {
                         $state_catid = implode(',', $celements);
                     } else {
                         $state_catid = '';
                     }
                 }
             }
             $message = JText::_('COPY2LANGUAGE_PROCESS');
             if ($state_catid == '') {
                 $phase = 4;
                 // Successfully finished phase 3
                 $message = JText::_('COPY2LANGUAGE_COMPLETED');
             }
             break;
     }
     return $original2languageInfo;
 }
 /**
  * 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);
     }
 }