function __construct($original, $translation, $fieldname, $fields = null) { if (FALANG_J30) { require_once JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php'; } parent::__construct($original, $translation, $fieldname, $fields); $lang = JFactory::getLanguage(); $lang->load("com_content", JPATH_ADMINISTRATOR); $cid = JRequest::getVar('cid', array(0)); $oldcid = $cid; $translation_id = 0; if (strpos($cid[0], '|') !== false) { list($translation_id, $contentid, $language_id) = explode('|', $cid[0]); } JRequest::setVar("cid", array($contentid)); JRequest::setVar("edit", true); // model's populate state method assumes the id is in the request object! $oldid = JRequest::getInt("article_id", 0); // Take care of the name of the id for the item JRequest::setVar("article_id", $contentid); JLoader::import('models.JFContentModelItem', FALANG_ADMINPATH); $this->orig_contentModelItem = new JFContentModelItem(); // Get The Original form // JRequest does NOT this for us in articles!! $this->orig_contentModelItem->setState('article.id', $contentid); $jfcontentModelForm = $this->orig_contentModelItem->getForm(); // NOW GET THE TRANSLATION - IF AVAILABLE $this->trans_contentModelItem = new JFContentModelItem(); $this->trans_contentModelItem->setState('article.id', $contentid); if ($translation != "") { $translation = json_decode($translation); } $translationcontentModelForm = $this->trans_contentModelItem->getForm(); if (isset($translation->jfrequest)) { $translationcontentModelForm->bind(array("attribs" => $translation, "request" => $translation->jfrequest)); } else { $translationcontentModelForm->bind(array("attribs" => $translation)); } // reset old values in REQUEST array $cid = $oldcid; JRequest::setVar('cid', $cid); JRequest::setVar("article_id", $oldid); // $this->origparams = new JFContentParams( $jfcontentModelForm); $this->transparams = new JFContentParams($translationcontentModelForm); }
function __construct($original, $translation, $fieldname, $fields = null) { if (FALANG_J30) { require_once JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php'; } parent::__construct($original, $translation, $fieldname, $fields); $lang = JFactory::getLanguage(); $lang->load("com_categories", JPATH_ADMINISTRATOR); $cid = JRequest::getVar('cid', array(0)); $oldcid = $cid; $translation_id = 0; if (strpos($cid[0], '|') !== false) { list($translation_id, $contentid, $language_id) = explode('|', $cid[0]); } // if we have an existing translation then load this directly! // This is important for modules to populate the assignement fields //$contentid = $translation_id?$translation_id : $contentid; //TODO sbou check this JRequest::setVar("cid", array($contentid)); JRequest::setVar("edit", true); JLoader::import('models.JFCategoryModelItem', FALANG_ADMINPATH); // Get The Original State Data // model's populate state method assumes the id is in the request object! $oldid = JRequest::getInt("id", 0); JRequest::setVar("id", $contentid); // NOW GET THE TRANSLATION - IF AVAILABLE $this->trans_modelItem = new JFCategoryModelItem(); $this->trans_modelItem->setState('category.id', $contentid); if ($translation != "") { $translation = json_decode($translation); } $translationCategoryModelForm = $this->trans_modelItem->getForm(); if (isset($translation->jfrequest)) { $translationCategoryModelForm->bind(array("params" => $translation, "request" => $translation->jfrequest)); } else { $translationCategoryModelForm->bind(array("params" => $translation)); } $cid = $oldcid; JRequest::setVar('cid', $cid); JRequest::setVar("id", $oldid); $this->transparams = new JFCategoryParams($translationCategoryModelForm, $this->trans_modelItem->getItem()); }
function __construct($original, $translation, $fieldname, $fields = null) { $options = array(); $options['option'] = 'com_content'; $options['ident'] = 'article_id'; $options['state_ident'] = 'article.id'; $options['model_item'] = 'JFContentModelItem'; $options['trans_params'] = 'JFContentParams'; $options['params_fieldset'] = 'attribs'; return $this->setup($original, $translation, $fieldname, $fields, $options); ///////////////////////////////////////////////////////////////////////// parent::__construct($original, $translation, $fieldname, $fields); $lang = JFactory::getLanguage(); $lang->load("com_content", JPATH_ADMINISTRATOR); $cid = JRequest::getVar('cid', array(0)); $oldcid = $cid; $translation_id = 0; if (strpos($cid[0], '|') !== false) { list($translation_id, $contentid, $language_id) = explode('|', $cid[0]); } JRequest::setVar("cid", array($contentid)); JRequest::setVar("edit", true); // model's populate state method assumes the id is in the request object! $oldid = JRequest::getInt("article_id", 0); // Take care of the name of the id for the item JRequest::setVar("article_id", $contentid); JLoader::import('models.JFContentModelItem', JOOMFISH_ADMINPATH); $this->orig_contentModelItem = new JFContentModelItem(); // Get The Original form // JRequest does NOT this for us in articles!! $this->orig_contentModelItem->setState('article.id', $contentid); $jfcontentModelForm = $this->orig_contentModelItem->getForm(array(), true, false); if ($original != "") { $original = json_decode($original); } // NOW GET THE TRANSLATION - IF AVAILABLE $this->trans_contentModelItem = new JFContentModelItem(); $this->trans_contentModelItem->setState('article.id', $translation_id); if ($translation != "") { $translation = json_decode($translation); } $translationcontentModelForm = $this->trans_contentModelItem->getForm(array(), true, true); $transfreeform = JFForm::getInstance($translationcontentModelForm); //$xml = $freeform->get('xml'); foreach ($jfcontentModelForm->getFieldsets('attribs') as $name => $ffff) { if ($name == 'basic-limited') { continue; } //$attrfieldset = $jfcontentModelForm->getFieldset($name); $fieldset = $jfcontentModelForm->getFieldset($name); $result = $transfreeform->xml->xpath('//*/fieldset[@name="' . $name . '"]'); foreach ($fieldset as $field) { $freefield = JFFormField::getInstance($field); if ($freefield->type == 'Spacer') { continue; } //$jfcontentModelForm->setFieldAttribute($freefield->name, 'readonly', 'true'); //foreach ($xml->fields as $xmlfield) { //$result= & $xmlfield->xpath('//*[@name="attribs"]'); $freefieldname = $freefield->get('fieldname'); $freefield->set('fieldname', $freefieldname . '_orig'); $freefield->set('name', $freefield->getName($freefieldname . '_orig')); $freefield->set('label', 'Original ' . $freefield->get('label')); $freeelement = $freefield->get('element')->asXML(); $freeelement = new JXMLElement($freeelement); //$freeelement['label'] = 'Original'.$freeelement['label']; //$freeelement['fieldname'] = 'orig_'.$freeelement['fieldname']; $newname = $freeelement['name'] . '_orig'; if (isset($original->{$freeelement}['name'])) { $original->{$newname} = $original->{$freeelement}['name']; unset($original->{$freeelement}['name']); } $freeelement['name'] = $newname; $freeelement['label'] = JText::_('ORIGINAL') . ' ' . JText::_($freeelement['label']); $freeelement['readonly'] = 'true'; $freeelement['disabled'] = 'true'; $freeelement['filter'] = 'UNSET'; //$result = $freeform->findField($name); if ($result) { $transfreeform->addNode($result[0], $freeelement); } $transfreeform->setFieldAttribute($freeelement['name'], 'filter', 'unset'); $transfreeform->setFieldAttribute($freeelement['name'], 'readonly', 'true'); $transfreeform->setFieldAttribute($freeelement['name'], 'disabled', 'true'); $transfreeform->setValue($freeelement['name'], $name, $freefield->get('value')); } $fieldarray = array(); foreach ($result[0]->field as $fld) { $fxml = $fld->asXML(); $fieldarray[] = new JXMLElement($fxml); } // we need to unset in reverse as indexes keep changing otherwise for ($c = count($result[0]->field); $c >= 0; $c--) { /*$dom = dom_import_simplexml($fldr); $dom->parentNode->removeChild($dom);*/ unset($result[0]->field[$c]); } $this->_nodesort($fieldarray, SORT_ASC); $parent = dom_import_simplexml($result[0]); foreach ($fieldarray as $far) { //$result[0]->addChild('field',$far); $child = dom_import_simplexml($far); // Import the <cat> into the dictionary document $child = $parent->ownerDocument->importNode($child, TRUE); $parent->appendChild($child); } } //$freeform->set('xml', $xml); if (isset($translation->jfrequest)) { $transfreeform->bind(array("attribs" => $translation, "request" => $translation->jfrequest)); $transfreeform->bind(array("attribs" => $original)); } else { $transfreeform->bind(array("attribs" => $translation)); $transfreeform->bind(array("attribs" => $original)); } // reset old values in REQUEST array $cid = $oldcid; JRequest::setVar('cid', $cid); JRequest::setVar("article_id", $oldid); // $this->origparams = new JFContentParams( $jfcontentModelForm); $this->transparams = new JFContentParams($transfreeform); }