/** Reads the information from the values of the form * The content element will be loaded first and then the values of the override * what is actually in the element * * @param array The values which should be bound to the object * @param string The field prefix * @param string An optional field * @param boolean try to bind the values to the object * @param boolean store original values too */ function bind($formArray, $prefix = "", $suffix = "", $tryBind = true, $storeOriginalText = false) { $user = JFactory::getUser(); $db = JFactory::getDBO(); if ($tryBind) { $this->_jfBindArrayToObject($formArray, $this); } if ($this->published == "") { $this->published = 0; } // Go thru all the fields of the element and try to copy the content values $elementTable = $this->_contentElement->getTable(); for ($i = 0; $i < count($elementTable->Fields); $i++) { $field = $elementTable->Fields[$i]; $fieldName = $field->Name; if (isset($formArray[$prefix . "refField_" . $fieldName . $suffix])) { // Handle magic quotes compatability if (get_magic_quotes_gpc() && $field->Type !== 'htmltext') { $formArray[$prefix . "refField_" . $fieldName . $suffix] = JRequest::_stripSlashesRecursive($formArray[$prefix . "refField_" . $fieldName . $suffix]); $formArray[$prefix . "origText_" . $fieldName . $suffix] = JRequest::_stripSlashesRecursive($formArray[$prefix . "origText_" . $fieldName . $suffix]); } else { $formArray[$prefix . "refField_" . $fieldName . $suffix] = JRequest::getVar($prefix . "refField_" . $fieldName . $suffix, '', 'post', 'string', JREQUEST_ALLOWRAW); $formArray[$prefix . "origText_" . $fieldName . $suffix] = JRequest::getVar($prefix . "origText_" . $fieldName . $suffix, '', 'post', 'string', JREQUEST_ALLOWRAW); } $translationValue = $formArray[$prefix . "refField_" . $fieldName . $suffix]; $fieldContent = new jfContent($db); // code cleaner for xhtml transitional compliance if ($field->Type == 'titletext' || $field->Type == 'text') { jimport('joomla.filter.output'); //$translationValue = JFilterOutput::ampReplace( $translationValue ); } if ($field->Type == 'htmltext') { $translationValue = str_replace('<br>', '<br />', $translationValue); // remove <br /> take being automatically added to empty fulltext $length = strlen($translationValue) < 9; $search = strstr($translationValue, '<br />'); if ($length && $search) { $translationValue = NULL; } } if ($field->Type == "params" && is_array($translationValue)) { $registry = new JRegistry(); $registry->loadArray($translationValue); $translationValue = $registry->toString(); } if ($field->posthandler != "") { if (method_exists($this, $field->posthandler)) { $handler = $field->posthandler; $this->{$handler}($translationValue, $elementTable->Fields, $formArray, $prefix, $suffix, $storeOriginalText); } } $originalValue = $formArray[$prefix . "origValue_" . $fieldName . $suffix]; $originalText = $storeOriginalText ? $formArray[$prefix . "origText_" . $fieldName . $suffix] : ""; $fieldContent->id = $formArray[$prefix . "id_" . $fieldName . $suffix]; $fieldContent->reference_id = intval($formArray[$prefix . "reference_id" . $suffix]) > 0 ? intval($formArray[$prefix . "reference_id" . $suffix]) : $this->id; $fieldContent->language_id = $this->language_id; $fieldContent->reference_table = $db->getEscaped($elementTable->Name); $fieldContent->reference_field = $db->getEscaped($fieldName); $fieldContent->value = $translationValue; // original value will be already md5 encoded - based on that any encoding isn't needed! $fieldContent->original_value = $originalValue; $fieldContent->original_text = !is_null($originalText) ? $originalText : ""; $datenow =& JFactory::getDate(); $fieldContent->modified = $datenow->toMySQL(); $fieldContent->modified_by = $user->id; $fieldContent->published = $this->published; $field->translationContent = $fieldContent; } } }
/** * Fetches and returns a request array. * * The default behaviour is fetching variables depending on the * current request method: GET and HEAD will result in returning * $_GET, POST and PUT will result in returning $_POST. * * You can force the source by setting the $hash parameter: * * post $_POST * get $_GET * files $_FILES * cookie $_COOKIE * method via current $_SERVER['REQUEST_METHOD'] * default $_REQUEST * * @static * @param string $hash to get (POST, GET, FILES, METHOD) * @param int $mask Filter mask for the variable * @return mixed Request hash * @since 1.5 */ function get($hash = 'default', $mask = 0) { $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } switch ($hash) { case 'GET': $input = $_GET; break; case 'POST': $input = $_POST; break; case 'FILES': $input = $_FILES; break; case 'COOKIE': $input = $_COOKIE; break; case 'REQUEST': $input = $_REQUEST; break; default: $input = $GLOBALS['_RSGINSTANCE']; $hash = 'rsgInstance'; break; } $result = JRequest::_cleanVar($input, $mask); // Handle magic quotes compatability if (get_magic_quotes_gpc() && $hash != 'FILES') { $result = JRequest::_stripSlashesRecursive($result); } return $result; }
/** * Fetches and returns a request array. * * The default behaviour is fetching variables depending on the * current request method: GET and HEAD will result in returning * $_GET, POST and PUT will result in returning $_POST. * * You can force the source by setting the $hash parameter: * * post $_POST * get $_GET * files $_FILES * cookie $_COOKIE * env $_ENV * server $_SERVER * method via current $_SERVER['REQUEST_METHOD'] * default $_REQUEST * * @static * @param string $hash to get (POST, GET, FILES, METHOD) * @param int $mask Filter mask for the variable * @return mixed Request hash * @since 1.5 */ function get($hash = 'default', $mask = 0) { $hash = strtoupper($hash); if ($hash === 'METHOD') { $hash = strtoupper($_SERVER['REQUEST_METHOD']); } switch ($hash) { case 'GET': $input = $_GET; break; case 'POST': $input = $_POST; break; case 'FILES': $input = $_FILES; break; case 'COOKIE': $input = $_COOKIE; break; case 'ENV': $input =& $_ENV; break; case 'SERVER': $input =& $_SERVER; break; default: $input = $_REQUEST; break; } $result = JRequest::_cleanVar($input, $mask); // Handle magic quotes compatability if (get_magic_quotes_gpc() && $hash != 'FILES') { $result = JRequest::_stripSlashesRecursive($result); $result = JRequest::_CleanStrip_tags($result); $result = JRequest::_CleanSqlInjection($result); $result = JRequest::_CleanHtmlspecialchars($result); } if ($hash == "GET" || $hash == "POST") { $result = JRequest::_stripSlashesRecursive($result); $result = JRequest::_CleanStrip_tags($result); $result = JRequest::_CleanSqlInjection($result); $result = JRequest::_CleanHtmlspecialchars($result); } return $result; }