function clean($path) { $prefix = $this->ssl ? 'https://' : 'http://'; if (strstr($path, $prefix)) { //if we are cleaning up a full url then check that fabrik hasnt unwittingly prepended the JPATH_SITE to the start of the url $path = $this->removePrependedURL( $path); $part = Fabrikstring::ltrimword($path, $prefix); $path = $prefix . JPath::clean($part); } else { $path = JPath::clean($path); } $path = str_replace("\\", '/', $path); return $path; }
/** * Translate data * * @param array &$data data * * @deprecated Joomfish not available in J1.7 * * @return void */ protected function translateData(&$data) { return; $params = $this->getParams(); if (!JPluginHelper::isEnabled('system', 'jfdatabase')) { return; } if (defined('JOOMFISH_PATH') && $params->get('allow-data-translation')) { $table = $this->getTable(); $db = FabrikWorker::getDbo(); $jf = JoomFishManager::getInstance(); $tableName = str_replace($this->config->get('dbprefix'), '', $table->db_table_name); $contentElement = $jf->getContentElement($tableName); if (!is_object($contentElement)) { return; } $title = Fabrikstring::shortColName($params->get('joomfish-title')); $activeLangs = $jf->getActiveLanguages(); $langId = $activeLangs[$this->config->get("jflang")]->id; $db->setQuery($contentElement->createContentSQL($langId)); if ($title == '') { $contentTable = $contentElement->getTable(); foreach ($contentTable->Fields as $tableField) { if ($tableField->Type == 'titletext') { $title = $tableField->Name; } } } $longKey = FabrikString::safeColNameToArrayKey($table->db_primary_key); $res = $db->loadObjectList(FabrikString::shortColName($table->db_primary_key)); // $$$ hugh - if no JF results, bail out, otherwise we pitch warnings in the foreach loop. if (empty($res)) { return; } foreach ($data as &$row) { // $$$ rob if the id isn't published fall back to __pk_val $translateRow = array_key_exists($longKey, $row) ? $res[$row->{$longKey}] : $res[$row->__pk_val]; foreach ($row as $key => $val) { $shortKey = array_pop(explode('___', $key)); if ($shortKey === $title) { $row->{$key} = $translateRow->titleTranslation; $key = $key . '_raw'; $row->{$key} = $translateRow->titleTranslation; } else { if (array_key_exists($shortKey, $translateRow)) { $row->{$key} = $translateRow->{$shortKey}; $key = $key . '_raw'; if (array_key_exists($key, $row)) { $row->{$key} = $translateRow->{$shortKey}; } } } } } } }
/** * Returns javascript which creates an instance of the class defined in formJavascriptClass() * * @param int $repeatCounter Repeat group counter * * @return array */ public function elementJavascript($repeatCounter) { $params = $this->getParams(); $id = $this->getHTMLId($repeatCounter); FabrikHelperHTML::mcl(); $j3 = FabrikWorker::j3(); $element = $this->getElement(); $paramsKey = $this->getFullName(true, false); $paramsKey = Fabrikstring::rtrimword($paramsKey, $this->getElement()->name); $paramsKey .= 'params'; $formData = $this->getFormModel()->data; $imgParams = FArrayHelper::getValue($formData, $paramsKey); // Above paramsKey stuff looks really wonky - lets test if null and use something which seems to build the correct key if (is_null($imgParams)) { $paramsKey = $this->getFullName(true, false) . '___params'; $imgParams = FArrayHelper::getValue($formData, $paramsKey); } $value = $this->getValue(array(), $repeatCounter); $value = is_array($value) ? $value : FabrikWorker::JSONtoData($value, true); $value = $this->checkForSingleCropValue($value); // Repeat_image_repeat_image___params $rawValues = count($value) == 0 ? array() : array_fill(0, count($value), 0); $fileData = $this->getFormModel()->data; $rawKey = $this->getFullName(true, false) . '_raw'; $rawValues = FArrayHelper::getValue($fileData, $rawKey, $rawValues); if (!is_array($rawValues)) { $rawValues = explode(GROUPSPLITTER, $rawValues); } else { /* * $$$ hugh - nasty hack for now, if repeat group with simple * uploads, all raw values are in an array in $rawValues[0] */ if (is_array(FArrayHelper::getValue($rawValues, 0))) { $rawValues = $rawValues[0]; } } if (!is_array($imgParams)) { $imgParams = explode(GROUPSPLITTER, $imgParams); } $oFiles = new stdClass(); $iCounter = 0; // Failed validation for ajax upload elements if (is_array($value) && array_key_exists('id', $value)) { $imgParams = array_values($value['crop']); $value = array_keys($value['id']); $rawValues = $value; } for ($x = 0; $x < count($value); $x++) { if (is_array($value)) { if (array_key_exists($x, $value) && $value[$x] !== '') { if (is_array($value[$x])) { // From failed validation foreach ($value[$x]['id'] as $tKey => $parts) { $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_' . $iCounter; $o->name = array_pop(explode(DIRECTORY_SEPARATOR, $tKey)); $o->path = $tKey; if ($fileInfo = $this->getStorage()->getFileInfo($o->path)) { $o->size = $fileInfo['filesize']; } else { $o->size = 'unknown'; } $o->type = strstr($fileInfo['mime_type'], 'image/') ? 'image' : 'file'; $o->url = $this->getStorage()->pathToURL($tKey); $o->recordid = $rawValues[$x]; $o->params = json_decode($value[$x]['crop'][$tKey]); $oFiles->{$iCounter} = $o; $iCounter++; } } else { if (is_object($value[$x])) { // Single crop image (not sure about the 0 settings in here) $parts = explode(DIRECTORY_SEPARATOR, $value[$x]->file); $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_0'; $o->name = array_pop($parts); $o->path = $value[$x]->file; if ($fileInfo = $this->getStorage()->getFileInfo($o->path)) { $o->size = $fileInfo['filesize']; } else { $o->size = 'unknown'; } $o->type = strstr($fileInfo['mime_type'], 'image/') ? 'image' : 'file'; $o->url = $this->getStorage()->pathToURL($value[$x]->file); $o->recordid = 0; $o->params = json_decode($value[$x]->params); $oFiles->{$iCounter} = $o; $iCounter++; } else { $parts = explode('/', $value[$x]); $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_' . $rawValues[$x]; $o->name = array_pop($parts); $o->path = $value[$x]; if ($fileInfo = $this->getStorage()->getFileInfo($o->path)) { $o->size = $fileInfo['filesize']; } else { $o->size = 'unknown'; } $o->type = strstr($fileInfo['mime_type'], 'image/') ? 'image' : 'file'; $o->url = $this->getStorage()->pathToURL($value[$x]); $o->recordid = $rawValues[$x]; $o->params = json_decode(FArrayHelper::getValue($imgParams, $x, '{}')); $oFiles->{$iCounter} = $o; $iCounter++; } } } } } $opts = $this->getElementJSOptions($repeatCounter); $opts->id = $this->getId(); if ($this->isJoin()) { $opts->isJoin = true; $opts->joinId = $this->getJoinModel()->getJoin()->id; } $opts->elid = $element->id; $opts->defaultImage = $params->get('default_image'); $opts->folderSelect = $params->get('upload_allow_folderselect', 0); $opts->quality = (double) $params->get('image_quality') / 100; $opts->dir = JPATH_SITE . '/' . $params->get('ul_directory'); $opts->ajax_upload = (bool) $params->get('ajax_upload', false); $opts->ajax_runtime = $params->get('ajax_runtime', 'html5'); $opts->ajax_silverlight_path = COM_FABRIK_LIVESITE . 'plugins/fabrik_element/fileupload/lib/plupload/js/plupload.flash.swf'; $opts->ajax_flash_path = COM_FABRIK_LIVESITE . 'plugins/fabrik_element/fileupload/lib/plupload/js/plupload.flash.swf'; $opts->max_file_size = (double) $params->get('ul_max_file_size'); $opts->device_capture = (double) $params->get('ul_device_capture'); $opts->ajax_chunk_size = (int) $params->get('ajax_chunk_size', 0); $opts->filters = $this->ajaxFileFilters(); $opts->crop = $this->canCrop(); $opts->canvasSupport = FabrikHelperHTML::canvasSupport(); $opts->elementName = $this->getFullName(); $opts->cropwidth = (int) $params->get('fileupload_crop_width'); $opts->cropheight = (int) $params->get('fileupload_crop_height'); $opts->ajax_max = (int) $params->get('ajax_max', 4); $opts->dragdrop = true; $icon = $j3 ? 'picture' : 'image.png'; $resize = $j3 ? 'expand-2' : 'resize.png'; $opts->previewButton = FabrikHelperHTML::image($icon, 'form', @$this->tmpl, array('alt' => FText::_('PLG_ELEMENT_FILEUPLOAD_VIEW'))); $opts->resizeButton = FabrikHelperHTML::image($resize, 'form', @$this->tmpl, array('alt' => FText::_('PLG_ELEMENT_FILEUPLOAD_RESIZE'))); $opts->files = $oFiles; $opts->winWidth = (int) $params->get('win_width', 400); $opts->winHeight = (int) $params->get('win_height', 400); $opts->elementShortName = $element->name; $opts->listName = $this->getListModel()->getTable()->db_table_name; $opts->useWIP = (bool) $params->get('upload_use_wip', '0') == '1'; $opts->page_url = COM_FABRIK_LIVESITE; JText::script('PLG_ELEMENT_FILEUPLOAD_MAX_UPLOAD_REACHED'); JText::script('PLG_ELEMENT_FILEUPLOAD_DRAG_FILES_HERE'); JText::script('PLG_ELEMENT_FILEUPLOAD_UPLOAD_ALL_FILES'); JText::script('PLG_ELEMENT_FILEUPLOAD_RESIZE'); JText::script('PLG_ELEMENT_FILEUPLOAD_CROP_AND_SCALE'); JText::script('PLG_ELEMENT_FILEUPLOAD_PREVIEW'); JText::script('PLG_ELEMENT_FILEUPLOAD_CONFIRM_SOFT_DELETE'); JText::script('PLG_ELEMENT_FILEUPLOAD_CONFIRM_HARD_DELETE'); JText::script('PLG_ELEMENT_FILEUPLOAD_FILE_TOO_LARGE_SHORT'); return array('FbFileUpload', $id, $opts); }
/** * return the javascript to create an instance of the class defined in formJavascriptClass * @return string javascript to create instance. Instance name must be 'el' */ function elementJavascript($repeatCounter) { $params = $this->getParams(); $id = $this->getHTMLId($repeatCounter); //if ((int)$params->get('fileupload_crop', 0) == 1) { //FabrikHelperHTML::script('media/com_fabrik/js/mcl-min.js'); FabrikHelperHTML::mcl(); /* $src = array('media/com_fabrik/js/lib/mcl/CANVAS.js', 'media/com_fabrik/js/lib/mcl/CanvasItem.js', 'media/com_fabrik/js/lib/mcl/Cmorph.js', 'media/com_fabrik/js/lib/mcl/Layer.js', 'media/com_fabrik/js/lib/mcl/LayerHash.js', 'media/com_fabrik/js/lib/mcl/Thread.js', 'media/com_fabrik/js/lib/canvas-extra.js' ); FabrikHelperHTML::script($src); */ //} $element = $this->getElement(); $paramsKey = $this->getFullName(false, true, false); $paramsKey = Fabrikstring::rtrimword($paramsKey, $this->getElement()->name); $paramsKey .= 'params'; $formData = $this->getForm()->_data; $imgParams = JArrayHelper::getValue($formData, $paramsKey); $value = $this->getValue(array(), $repeatCounter); $value = is_array($value) ? $value : FabrikWorker::JSONtoData($value, true); $value = $this->checkForSingleCropValue($value); //repeat_image_repeat_image___params $rawvalues = count($value) == 0 ? array() : array_fill(0, count($value), 0); $fdata = $this->getForm()->_data; $rawkey = $this->getFullName(false, true, false) . '_raw'; $rawvalues = JArrayHelper::getValue($fdata, $rawkey, $rawvalues); if (!is_array($rawvalues)) { $rawvalues = explode(GROUPSPLITTER, $rawvalues); } if (!is_array($imgParams)) { $imgParams = explode(GROUPSPLITTER, $imgParams); } $oFiles = new stdClass(); $iCounter = 0; for ($x = 0; $x < count($value); $x++) { if (is_array($value)) { if (array_key_exists($x, $value) && $value[$x] !== '') { if (is_array($value[$x])) { //from failed validation foreach ($value[$x]['id'] as $tkey => $parts) { $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_' . $iCounter; //$rawvalues[$x]; $o->name = array_pop(explode(DS, $tkey)); $o->path = $tkey; $o->url = $this->getStorage()->pathToURL($tkey); $o->recordid = $rawvalues[$x]; $o->params = json_decode($value[$x]['crop'][$tkey]); $oFiles->{$iCounter} = $o; $iCounter++; } } else { if (is_object($value[$x])) { //single crop image (not sure about the 0 settings in here) $parts = explode(DS, $value[$x]->file); $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_0'; $o->name = array_pop($parts); $o->path = $value[$x]->file; $o->url = $this->getStorage()->pathToURL($value[$x]->file); $o->recordid = 0; $o->params = json_decode($value[$x]->params); $oFiles->{$iCounter} = $o; $iCounter++; } else { $parts = explode(DS, $value[$x]); $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_' . $rawvalues[$x]; $o->name = array_pop($parts); $o->path = $value[$x]; $o->url = $this->getStorage()->pathToURL($value[$x]); $o->recordid = $rawvalues[$x]; $o->params = json_decode(JArrayHelper::getValue($imgParams, $x, '{}')); $oFiles->{$iCounter} = $o; $iCounter++; } } } } } $opts = $this->getElementJSOptions($repeatCounter); $opts->id = $this->_id; if ($this->isJoin()) { $opts->isJoin = true; $opts->joinId = $this->getJoinModel()->getJoin()->id; } $opts->elid = $element->id; $opts->defaultImage = $params->get('default_image'); $opts->folderSelect = $params->get('upload_allow_folderselect', 0); $opts->dir = JPATH_SITE . DS . $params->get('ul_directory'); $opts->ajax_upload = (bool) $params->get('ajax_upload', false); $opts->ajax_runtime = $params->get('ajax_runtime', 'html5'); $opts->max_file_size = $params->get('ul_max_file_size'); $opts->ajax_chunk_size = (int) $params->get('ajax_chunk_size', 0); $opts->crop = (int) $params->get('fileupload_crop', 0); $opts->elementName = $this->getFullName(true, true, true); $opts->cropwidth = (int) $params->get('fileupload_crop_width'); $opts->cropheight = (int) $params->get('fileupload_crop_height'); $opts->ajax_max = (int) $params->get('ajax_max', 4); $opts->dragdrop = true; $opts->previewButton = FabrikHelperHTML::image('image.png', 'form', @$this->tmpl, array('alt' => JText::_('PLG_ELEMENT_FILEUPLOAD_VIEW'))); $opts->resizeButton = FabrikHelperHTML::image('resize.png', 'form', @$this->tmpl, array('alt' => JText::_('PLG_ELEMENT_FILEUPLOAD_RESIZE'))); $opts->files = $oFiles; $opts = json_encode($opts); JText::script('PLG_ELEMENT_FILEUPLOAD_MAX_UPLOAD_REACHED'); JText::script('PLG_ELEMENT_FILEUPLOAD_DRAG_FILES_HERE'); JText::script('PLG_ELEMENT_FILEUPLOAD_UPLOAD_ALL_FILES'); JText::script('PLG_ELEMENT_FILEUPLOAD_RESIZE'); JText::script('PLG_ELEMENT_FILEUPLOAD_CROP_AND_SCALE'); JText::script('PLG_ELEMENT_FILEUPLOAD_PREVIEW'); return "new FbFileUpload('{$id}', {$opts})"; }
/** * return tehe javascript to create an instance of the class defined in formJavascriptClass * @return string javascript to create instance. Instance name must be 'el' */ function elementJavascript($repeatCounter) { $p =& $this->getParams(); if ((int) $p->get('fileupload_crop', 0) == 1) { FabrikHelperHTML::mocha(); $config =& JFactory::getConfig(); $debug = $config->getValue('config.debug'); //$$$ rob commenting out for now as I've altered CANVAS.js for IE8/9 rendering issues /*if (!$debug) { FabrikHelperHTML::script('mcl-min.js', 'media/com_fabrik/js/', false); } else {*/ FabrikHelperHTML::script('CANVAS.js', 'media/com_fabrik/js/mcl/', false); FabrikHelperHTML::script('CanvasItem.js', 'media/com_fabrik/js/mcl/', false); FabrikHelperHTML::script('Cmorph.js', 'media/com_fabrik/js/mcl/', false); FabrikHelperHTML::script('Layer.js', 'media/com_fabrik/js/mcl/', false); FabrikHelperHTML::script('LayerHash.js', 'media/com_fabrik/js/mcl/', false); FabrikHelperHTML::script('Thread.js', 'media/com_fabrik/js/mcl/', false); //} //FabrikHelperHTML::script('canvas-extra.js', 'media/com_fabrik/js/', false); } $element =& $this->getElement(); $paramsKey = $this->getFullName(false, true, false); $paramsKey = Fabrikstring::rtrimword($paramsKey, $this->getElement()->name); $paramsKey .= 'params'; $formData = $this->getForm()->_data; $elParams =& $this->getParams(); $params = JArrayHelper::getValue($formData, $paramsKey); $value = $this->getValue(array(), $repeatCounter); if ($elParams->get('ajax_upload') && $elParams->get('ajax_max', 4) == 1) { $singleCropImg = json_decode($value); $value = array(); $rawvalues = array(); $params = array(); if (!empty($singleCropImg)) { $singleCropImg = $singleCropImg[0]; if (trim($singleCropImg->file) !== '') { $value[] = $singleCropImg->file; $rawvalues[] = 0; $params[] = $singleCropImg->params; } } } else { $value = explode(GROUPSPLITTER, $value); $rawvalues = array_fill(0, count($value), 0); $fdata = $this->getForm()->_data; $rawkey = $this->getFullName(false, true, false) . '_raw'; $rawvalues = JArrayHelper::getValue($fdata, $rawkey, $rawvalues); if (!is_array($rawvalues)) { $rawvalues = explode(GROUPSPLITTER, $rawvalues); } } if (!is_array($params)) { $params = explode(GROUPSPLITTER, $params); } $oFiles = new stdClass(); for ($x = 0; $x < count($value); $x++) { if ($value[$x] !== '') { $parts = explode(DS, $value[$x]); $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_' . $rawvalues[$x]; $o->name = array_pop($parts); $o->path = $value[$x]; $o->url = $this->getStorage()->pathToURL($value[$x]); $o->recordid = $rawvalues[$x]; $o->params = json_decode(JArrayHelper::getValue($params, $x, '{}')); $oFiles->{$x} = $o; } } $params =& $this->getParams(); $id = $this->getHTMLId($repeatCounter); $opts =& $this->getElementJSOptions($repeatCounter); $opts->liveSite = COM_FABRIK_LIVESITE; $opts->id = $this->_id; $opts->elid = $element->id; $opts->defaultImage = $params->get('default_image'); $opts->folderSelect = $params->get('upload_allow_folderselect', 0); $opts->dir = JPATH_SITE . DS . $params->get('ul_directory'); $opts->ds = DS; $opts->ajax_upload = $params->get('ajax_upload', false); $opts->ajax_runtime = $params->get('ajax_runtime', 'html5'); $opts->max_file_size = $params->get('ul_max_file_size'); $opts->ajax_chunk_size = (int) $params->get('ajax_chunk_size', 0); $opts->crop = (int) $params->get('fileupload_crop', 0); $opts->elementName = $this->getFullName(true, true, true); $opts->cropwidth = (int) $params->get('fileupload_crop_width'); $opts->cropheight = (int) $params->get('fileupload_crop_height'); $opts->ajax_max = (int) $params->get('ajax_max', 4); $opts->dragdrop = true; $opts->files = $oFiles; $opts = json_encode($opts); $lang = new stdClass(); $lang->max_upload_reached = JText::_('PLG_ELEMENT_FILEUPLOAD_MAX_UPLOAD_REACHED'); $lang->dragfiles = JText::_('PLG_ELEMENT_FILEUPLOAD_DRAG_FILES_HERE'); $lang->uploadallfiles = JText::_('PLG_ELEMENT_FILEUPLOAD_UPLOAD_ALL_FILES'); $lang = json_encode($lang); return "new FbFileUpload('{$id}', {$opts}, {$lang})"; }
/** * return the javascript to create an instance of the class defined in formJavascriptClass * @return string javascript to create instance. Instance name must be 'el' */ function elementJavascript($repeatCounter) { $params = $this->getParams(); $id = $this->getHTMLId($repeatCounter); if ((int) $params->get('fileupload_crop', 0) == 1) { //FabrikHelperHTML::script('media/com_fabrik/js/mcl-min.js', false); $src = array('media/com_fabrik/js/mcl/CANVAS.js', 'media/com_fabrik/js/mcl/CanvasItem.js', 'media/com_fabrik/js/mcl/Cmorph.js', 'media/com_fabrik/js/mcl/Layer.js', 'media/com_fabrik/js/mcl/LayerHash.js', 'media/com_fabrik/js/mcl/Thread.js', 'media/com_fabrik/js/canvas-extra.js'); FabrikHelperHTML::script($src, true); } $element = $this->getElement(); $paramsKey = $this->getFullName(false, true, false); $paramsKey = Fabrikstring::rtrimword($paramsKey, $this->getElement()->name); $paramsKey .= 'params'; $formData = $this->getForm()->_data; $imgParams = JArrayHelper::getValue($formData, $paramsKey); $value = $this->getValue(array(), $repeatCounter); $value = is_array($value) ? $value : explode(GROUPSPLITTER, $value); //repeat_image_repeat_image___params $rawvalues = array_fill(0, count($value), 0); $fdata = $this->getForm()->_data; $rawkey = $this->getFullName(false, true, false) . '_raw'; $rawvalues = JArrayHelper::getValue($fdata, $rawkey, $rawvalues); if (!is_array($rawvalues)) { $rawvalues = explode(GROUPSPLITTER, $rawvalues); } if (!is_array($imgParams)) { $imgParams = explode(GROUPSPLITTER, $imgParams); } $oFiles = new stdClass(); # $iCounter = 0; for ($x = 0; $x < count($value); $x++) { if ($value[$x] !== '') { if (is_array($value[$x])) { //from failed validation foreach ($value[$x]['id'] as $tkey => $parts) { $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_' . $iCounter; //$rawvalues[$x]; $o->name = array_pop(explode(DS, $tkey)); $o->path = $tkey; $o->url = $this->getStorage()->pathToURL($tkey); $o->recordid = $rawvalues[$x]; $o->params = json_decode($value[$x]['crop'][$tkey]); $oFiles->{$iCounter} = $o; $iCounter++; } } else { $parts = explode(DS, $value[$x]); $o = new stdClass(); $o->id = 'alreadyuploaded_' . $element->id . '_' . $rawvalues[$x]; $o->name = array_pop($parts); $o->path = $value[$x]; $o->url = $this->getStorage()->pathToURL($value[$x]); $o->recordid = $rawvalues[$x]; $o->params = json_decode(JArrayHelper::getValue($imgParams, $x, '{}')); $oFiles->{$iCounter} = $o; $iCounter++; } } } $opts =& $this->getElementJSOptions($repeatCounter); $opts->id = $this->_id; $opts->elid = $element->id; $opts->defaultImage = $params->get('default_image'); $opts->folderSelect = $params->get('upload_allow_folderselect'); $opts->dir = JPATH_SITE . DS . $params->get('ul_directory'); $opts->ds = DS; $opts->ajax_upload = $params->get('ajax_upload', false); $opts->ajax_runtime = $params->get('ajax_runtime', 'html5'); $opts->max_file_size = $params->get('ul_max_file_size'); $opts->ajax_chunk_size = (int) $params->get('ajax_chunk_size', 0); $opts->crop = (int) $params->get('fileupload_crop', 0); $opts->elementName = $this->getFullName(true, true, true); $opts->cropwidth = (int) $params->get('fileupload_crop_width'); $opts->cropheight = (int) $params->get('fileupload_crop_height'); $opts->ajax_max = (int) $params->get('ajax_max', 4); $opts->files = $oFiles; $opts = json_encode($opts); JText::script('PLG_ELEMENT_FILEUPLOAD_MAX_UPLOAD_REACHED'); JText::script('PLG_ELEMENT_FILEUPLOAD_DRAG_FILES_HERE'); JText::script('PLG_ELEMENT_FILEUPLOAD_UPLOAD_ALL_FILES'); JText::script('PLG_ELEMENT_FILEUPLOAD_RESIZE'); return "new FbFileUpload('{$id}', {$opts})"; }
function translateData(&$data) { $params =& $this->getParams(); if (!JPluginHelper::isEnabled('system', 'jfdatabase')) { return; } if (defined('JOOMFISH_PATH') && $params->get('allow-data-translation')) { $table = $this->getTable(); $db = JFactory::getDBO(); $jf =& JoomFishManager::getInstance(); $config =& JFactory::getConfig(); $tableName = str_replace($config->getValue('dbprefix'), '', $table->db_table_name); $contentElement =& $jf->getContentElement($tableName); if (!is_object($contentElement)) { return; } // @TODO need top make and get xml file for any db join elements - otherwise their labels are replaced with the values $title = Fabrikstring::shortColName($params->get('joomfish-title')); $activelangs = $jf->getActiveLanguages(); $registry =& JFactory::getConfig(); $langid = $activelangs[$registry->getValue("config.jflang")]->id; $db->setQuery($contentElement->createContentSQL($langid)); if ($title == '') { $contentTable = $contentElement->getTable(); foreach ($contentTable->Fields as $tableField) { if ($tableField->Type == 'titletext') { $title = $tableField->Name; } } } $longKey = FabrikString::safeColNameToArrayKey($table->db_primary_key); $res =& $db->loadObjectList($this->_shortKey(null, true)); // $$$ hugh - if no JF results, bail out, otherwise we pitch warnings in the foreach loop. if (empty($res)) { return; } foreach ($data as &$row) { //$$$ rob if the id isnt published fall back to __pk_val $translateRow = array_key_exists($longKey, $row) ? $res[$row->{$longKey}] : $res[$row->__pk_val]; foreach ($row as $key => $val) { $shortkey = array_pop(explode("___", $key)); if ($shortkey === $title) { $row->{$key} = $translateRow->titleTranslation; $key = $key . "_raw"; $row->{$key} = $translateRow->titleTranslation; } else { if (array_key_exists($shortkey, $translateRow)) { $row->{$key} = $translateRow->{$shortkey}; $key = $key . "_raw"; if (array_key_exists($key, $row)) { $row->{$key} = $translateRow->{$shortkey}; } } } } } } }