function display($tpl = NULL) { /** * @var JSite $app */ $app = JFactory::getApplication(); $this->params = $app->getParams(); /* Default Page fallback*/ $active = $app->getMenu()->getActive(); if (NULL == $active) { $this->params->merge($app->getMenu()->getDefault()->params); $active = $app->getMenu()->getDefault(); } $this->currentItemid = $active->id; $entriesPerPage = $this->params->get('max_events_per_page', 12); $model = $this->getModel('events'); $eventModel = JModelLegacy::getInstance('Event', 'EventgalleryModel'); $recursive = $this->params->get('show_items_per_category_recursive', false); $user = JFactory::getUser(); $usergroups = JUserHelper::getUserGroups($user->id); $entries = $model->getEntries(JRequest::getVar('start', 0), $entriesPerPage, $this->params->get('tags'), $this->params->get('sort_events_by'), $usergroups, $this->params->get('catid', null), $recursive); $this->pageNav = $model->getPagination(); $this->entries = $entries; $this->eventModel = $eventModel; $this->_prepareDocument(); parent::display($tpl); }
function display($tpl = NULL) { /** * @var JSite $app */ $app = JFactory::getApplication(); $this->params = $app->getParams(); /* Default Page fallback*/ $active = $app->getMenu()->getActive(); if (NULL == $active) { $this->params->merge($app->getMenu()->getDefault()->params); $active = $app->getMenu()->getDefault(); } $this->currentItemid = $active->id; $this->catid = JRequest::getInt('catid', 0); if ($this->catid == 0) { $this->catid = 'root'; } $options = array(); $options['countItems'] = $this->params->get('show_items_per_category_count', 0); /** * @var JCategories $categories */ $categories = JCategories::getInstance('Eventgallery', $options); /** * @var JCategoryNode $root */ if (null != $this->catid) { $this->category = $categories->get($this->catid); } if ($this->category == null || $this->category->published != 1) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } $entriesPerPage = $this->params->get('max_events_per_page', 12); $model = $this->getModel('categories'); $eventModel = JModelLegacy::getInstance('Event', 'EventgalleryModel'); $user = JFactory::getUser(); $usergroups = JUserHelper::getUserGroups($user->id); $entries = $model->getEntries(JRequest::getVar('start', 0), $entriesPerPage, $this->params->get('tags'), $this->params->get('sort_events_by'), $usergroups, $this->catid); $this->pageNav = $model->getPagination(); $this->entries = $entries; $this->eventModel = $eventModel; $this->_prepareDocument(); /** * @var JPathway $pathway */ $pathway = $app->getPathway(); $rootCategoryId = 0; if (isset($active->query['catid'])) { $rootCategoryId = $active->query['catid']; } EventgalleryHelpersCategories::addCategoryPathToPathway($pathway, $rootCategoryId, JRequest::getInt('catid', 0), $this->currentItemid); parent::display($tpl); }
function display($tpl = NULL) { /** * @var JSite $app */ $app = JFactory::getApplication(); $this->state = $this->get('State'); $this->params = $app->getParams(); $model = $this->getModel('singleimage'); $model->getData(JRequest::getString('folder'), JRequest::getString('file')); $this->model = $model; $this->file = $model->file; if (!isset($this->file) || strlen($this->file->getFileName()) == 0 || $this->file->isPublished() != 1) { JError::raiseError(404, JText::_('COM_EVENTGALLERY_SINGLEIMAGE_NO_PUBLISHED_MESSAGE')); } $this->folder = $this->file->getFolder(); if (!isset($this->file) || strlen($this->file->getFileName()) == 0 || $this->file->isPublished() != 1) { JError::raiseError(404, JText::_('COM_EVENTGALLERY_SINGLEIMAGE_NO_PUBLISHED_MESSAGE')); } $this->position = $model->position; /* Default Page fallback*/ $active = $app->getMenu()->getActive(); if (NULL == $active) { $this->params->merge($app->getMenu()->getDefault()->params); $active = $app->getMenu()->getDefault(); } $this->currentItemid = $active->id; $this->use_comments = $this->params->get('use_comments'); if (!$this->folder->isVisible()) { $user = JFactory::getUser(); if ($user->guest) { $redirectUrl = JRoute::_("index.php?option=com_eventgallery&view=singleimage&folder=" . $this->folder->getFolderName() . "&file=" . $this->file->getFileName(), false); $redirectUrl = urlencode(base64_encode($redirectUrl)); $redirectUrl = '&return=' . $redirectUrl; $joomlaLoginUrl = 'index.php?option=com_users&view=login'; $finalUrl = JRoute::_($joomlaLoginUrl . $redirectUrl, false); $app->redirect($finalUrl); } else { $this->setLayout('noaccess'); } } $password = JRequest::getString('password', ''); $accessAllowed = EventgalleryHelpersFolderprotection::isAccessAllowed($this->folder, $password); if (!$accessAllowed) { $app->redirect(JRoute::_("index.php?option=com_eventgallery&view=password&folder=" . $this->folder->getFolderName(), false)); } $this->setLayout(JRequest::getString('layout', 'minipage')); parent::display($tpl); }
/** * Renders a module script and returns the results as a string * * @param string $name The name of the module to render * @param array $attribs Associative array of values * * @return string The output of the script * @since 1.0 */ public function render($module, $attribs = array(), $content = null) { // add the environment data to attributes of module $registry = JRegistry::getInstance('document.environment'); $env = $registry->getValue('params', array()); $attribs = array_merge($env, $attribs); if (!is_object($module)) { $title = isset($attribs['title']) ? $attribs['title'] : null; $module = MigurModuleHelper::getModule($module, $title); if (!is_object($module)) { if (is_null($content)) { return ''; } else { /** * If module isn't found in the database but data has been pushed in the buffer * we want to render it */ $tmp = $module; $module = new stdClass(); $module->params = null; $module->module = $tmp; $module->id = 0; $module->user = 0; } } } // get the user and configuration object //$user = JFactory::getUser(); $conf = JFactory::getConfig(); // set the module content if (!is_null($content)) { $module->content = $content; } //get module parameters $params = new JRegistry(); $params->loadJSON($module->params); // use parameters from template if (isset($attribs['params'])) { $template_params = new JRegistry(); $template_params->loadJSON(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8')); $params->merge($template_params); $module = clone $module; $module->params = (string) $params; } $contents = ''; $cachemode = $params->get('cachemode', 'oldstatic'); // default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the module instead if ($params->get('cache', 0) == 1 && $conf->get('caching') >= 1 && $cachemode != 'id' && $cachemode != 'safeuri') { // default to itemid creating mehod and workarounds on $cacheparams = new stdClass(); $cacheparams->cachemode = $cachemode; $cacheparams->class = 'JModuleHelper'; $cacheparams->method = 'renderModule'; $cacheparams->methodparams = array($module, $attribs); $contents = MigurModuleHelper::ModuleCache($module, $params, $cacheparams); } else { $contents = MigurModuleHelper::renderModule($module, $attribs); } return $contents; }
function render($position = "") { global $gantry; $output = ''; $renderer = $gantry->document->loadRenderer('module'); $options = array('style' => "raw"); $params = array(); $group_params = $gantry->getParams($this->_feature_prefix . "-" . $this->_feature_name, true); $group_params_reg = new JRegistry(); foreach ($group_params as $param_name => $param_value) { $group_params_reg->set($param_name, $param_value['value']); } if ($position == $this->get('mainmenu-position')) { $params = $gantry->getParams($this->_feature_prefix . "-" . $this->_feature_name . "-mainmenu", true); $module = JModuleHelper::getModule('mod_menu', '_z_empty'); $reg = new JRegistry(); foreach ($params as $param_name => $param_value) { $reg->set($param_name, $param_value['value']); } $reg->merge($group_params_reg); $module->params = $reg->toString(); $output .= $renderer->render($module, $options); } return $output; }
function __construct($params = array()) { $app = JFactory::getApplication(); $cparams = $app->getParams('com_djcatalog2'); $ncparams = new JRegistry(); $ncparams->merge($cparams); $this->_cparams = $ncparams; $this->_mparams = $params; }
/** * Method to get a list of items. * Overriden to inject convert the attribs field into a JParameter object. * * @return mixed $items An array of objects on success, false on failure. */ public function getItems() { $items = parent::getItems(); $base_path = JPATH_ROOT . '/media/com_projectfork/repo/0/logo'; $base_url = JURI::root(true) . '/media/com_projectfork/repo/0/logo'; $tasks_exists = PFApplicationHelper::enabled('com_pftasks'); $repo_exists = PFApplicationHelper::enabled('com_pfrepo'); $pks = JArrayHelper::getColumn($items, 'id'); // Get aggregate data $progress = array(); $total_tasks = array(); $completed_tasks = array(); $total_files = array(); if ($tasks_exists) { JLoader::register('PFtasksModelTasks', JPATH_SITE . '/components/com_pftasks/models/tasks.php'); $tmodel = JModelLegacy::getInstance('Tasks', 'PFtasksModel', array('ignore_request' => true)); $progress = $tmodel->getAggregatedProgress($pks, 'project_id'); $total_tasks = $tmodel->getAggregatedTotal($pks, 'project_id'); $completed_tasks = $tmodel->getAggregatedTotal($pks, 'project_id', 1); } if ($repo_exists) { JLoader::register('PFrepoModelFiles', JPATH_SITE . '/components/com_pfrepo/models/files.php'); $fmodel = JModelLegacy::getInstance('Files', 'PFrepoModel', array('ignore_request' => true)); $total_files = $fmodel->getProjectCount($pks); } // Loop over each row to inject data foreach ($items as $i => &$item) { $params = new JRegistry(); $params->loadString($item->attribs); // Convert the parameter fields into objects. $items[$i]->params = $params->merge(clone $this->getState('params')); // Create slug $items[$i]->slug = $items[$i]->alias ? $items[$i]->id . ':' . $items[$i]->alias : $items[$i]->id; // Try to find the logo img $items[$i]->logo_img = null; if (JFile::exists($base_path . '/' . $item->id . '.jpg')) { $items[$i]->logo_img = $base_url . '/' . $item->id . '.jpg'; } elseif (JFile::exists($base_path . '/' . $item->id . '.jpeg')) { $items[$i]->logo_img = $base_url . '/' . $item->id . '.jpeg'; } elseif (JFile::exists($base_path . '/' . $item->id . '.png')) { $items[$i]->logo_img = $base_url . '/' . $item->id . '.png'; } elseif (JFile::exists($base_path . '/' . $item->id . '.gif')) { $items[$i]->logo_img = $base_url . '/' . $item->id . '.gif'; } // Inject task count $items[$i]->tasks = isset($total_tasks[$item->id]) ? $total_tasks[$item->id] : 0; // Inject completed task count $items[$i]->completed_tasks = isset($completed_tasks[$item->id]) ? $completed_tasks[$item->id] : 0; // Inject progress $items[$i]->progress = isset($progress[$item->id]) ? $progress[$item->id] : 0; // Inject attached files $items[$i]->attachments = isset($total_files[$item->id]) ? $total_files[$item->id] : 0; } return $items; }
/** * Save method is diff here because we're writing to a file * (non-PHPdoc) * @see Citruscart/admin/CitruscartController::save() */ function save() { $app = JFactory::getApplication(); $id = $app->input->get('id', 'en-GB'); $temp_values = $app->input->getArray($_POST); $model = $this->getModel('Emails', 'CitruscartModel'); // Filter values $prefix = $model->email_prefix; $values = array(); foreach ($temp_values as $k => $v) { if (stripos($k, $prefix) === 0) { $values[$k] = $v; } } $lang = $model->getItem($id); $path = $lang->path; $msg = JText::_('COM_CITRUSCART_SAVED'); jimport('joomla.filesystem.file'); if (JFile::exists($path)) { $original = new JRegistry(); $original->loadFile($path); $registry = new JRegistry(); $registry->loadArray($values); $original->merge($registry); $txt = $original->__toString('INI'); $success = JFile::write($path, $txt); if (!$success) { $msg = JText::_('COM_CITRUSCART_ERROR_SAVING_NEW_LANGUAGE_FILE'); } } $model->clearCache(); //$task = JRequest::getVar('task'); $task = $app->input->getString('task'); $redirect = "index.php?option=com_citruscart"; switch ($task) { case "apply": $redirect .= '&view=' . $this->get('suffix') . '&task=edit&id=' . $id; break; case "save": default: $redirect .= "&view=" . $this->get('suffix'); break; } $redirect = JRoute::_($redirect, false); $this->setRedirect($redirect, $this->message, $this->messagetype); }
function save() { $app = JFactory::getApplication(); $data = $app->input->getArray($_POST); $save_params = new JRegistry(); $save_params->loadArray($data['params']); $plugin_data = JPluginHelper::getPlugin('j2store', $this->_element); $params = new JRegistry(); $params->loadString($plugin_data->params); $params->merge($save_params); $json = $params->toString(); $db = JFactory::getDbo(); $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($json))->where($db->qn('element') . ' = ' . $db->q($this->_element))->where($db->qn('folder') . ' = ' . $db->q('j2store'))->where($db->qn('type') . ' = ' . $db->q('plugin')); $db->setQuery($query); $db->execute(); if ($data['promotionTask'] == 'apply' && isset($data['promotion_id'])) { $url = 'index.php?option=com_j2store&view=promotions&task=view&id=' . $data['promotion_id']; } else { $url = 'index.php?option=com_j2store&view=promotions'; } $this->setRedirect($url, JText::_('J2STORE_CHANGES_SAVED'), 'message'); }
/** * Method to load content article parameters * * @access private * @return void * @since 1.5 */ function _loadItemParams($force = false) { if (!$force && !empty($this->_item->parameters)) { return; } $app = JFactory::getApplication(); $menu = $app->getMenu()->getActive(); // Retrieve currently active menu item (NOTE: this applies when Itemid variable or menu item alias exists in the URL) $isnew = !$this->_id; // ********************************************************************** // Retrieve RELATED parameters that will be merged into item's parameters // ********************************************************************** // Retrieve COMPONENT parameters $compParams = JComponentHelper::getComponent('com_flexicontent')->params; // Retrieve parameters of current category (NOTE: this applies when cid variable exists in the URL) $catParams = ""; if ($this->_cid) { $query = 'SELECT c.title, c.params FROM #__categories AS c WHERE c.id = ' . (int) $this->_cid; $this->_db->setQuery($query); $catData = $this->_db->loadObject(); $catParams = $catData->params; $this->_item->category_title = $catData->title; } $catParams = new JRegistry($catParams); // Retrieve/Create item's Content Type parameters $typeParams = $this->getTypeparams(); $typeParams = new JRegistry($typeParams); // Create item parameters if (!is_object($this->_item->attribs)) { $itemParams = new JRegistry($this->_item->attribs); } else { $itemParams = $this->_item->attribs; } // Retrieve Layout's parameters, also deciding the layout $this->decideLayout($compParams, $typeParams, $itemParams); $layoutParams = $this->getLayoutparams(); $layoutParams = new JRegistry($layoutParams); //print_r($layoutParams); // *************************************************************************************************** // Merge parameters in order: component, menu, (item 's) current category, (item's) content type, item // *************************************************************************************************** // a. Start with empty registry, then merge COMPONENT parameters $params = new JRegistry(); $params->merge($compParams); // b. Merge parameters from current category $catParams->set('show_title', ''); // Prevent show_title from propagating ... to the item, it is meant for category view only $catParams->set('title_linkable', ''); // Prevent title_linkable from propagating ... to the item, it is meant for category view only $catParams->set('show_editbutton', ''); // Prevent title_linkable from propagating ... to the item, it is meant for category view only $params->merge($catParams); // c0. Merge Layout parameters into the page configuration $params->merge($layoutParams); // c1. Merge TYPE parameters into the page configuration $params->merge($typeParams); // d. Merge ITEM parameters into the page configuration $params->merge($itemParams); // e. Merge ACCESS permissions into the page configuration $accessperms = $this->getItemAccess(); $params->merge($accessperms); // d. Merge the active menu parameters, verify menu item points to current FLEXIcontent object if ($menu && !empty($this->mergeMenuParams)) { if (!empty($this->isForm)) { $this->menu_matches = false; $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view']; $this->menu_matches = $view_ok; } else { $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view']; $cid_ok = JRequest::getInt('cid') == (int) @$menu->query['cid']; $id_ok = JRequest::getInt('id') == (int) @$menu->query['id']; $this->menu_matches = $view_ok && $id_ok; } } else { $this->menu_matches = false; } // MENU ITEM matched, merge parameters and use its page heading (but use menu title if the former is not set) if ($this->menu_matches) { $params->merge($menu->params); $default_heading = $menu->title; // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->def('page_heading', $params->get('page_title', $default_heading)); $params->def('page_title', $params->get('page_heading', $default_heading)); $params->def('show_page_heading', $params->get('show_page_title', 0)); $params->def('show_page_title', $params->get('show_page_heading', 0)); } else { // Clear some menu parameters //$params->set('pageclass_sfx', ''); // CSS class SUFFIX is behavior, so do not clear it ? // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ... $default_heading = empty($this->isForm) ? $this->_item->title : (!$isnew ? JText::_('FLEXI_EDIT') : JText::_('FLEXI_NEW')); // Decide to show page heading (=J1.5 page title), there is no need for this in item view $show_default_heading = 0; // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->set('page_title', $default_heading); $params->set('page_heading', $default_heading); $params->set('show_page_heading', $show_default_heading); $params->set('show_page_title', $show_default_heading); } // Prevent showing the page heading if (a) IT IS same as item title and (b) item title is already configured to be shown if ($params->get('show_title', 1)) { if ($params->get('page_heading') == $this->_item->title) { $params->set('show_page_heading', 0); } if ($params->get('page_title') == $this->_item->title) { $params->set('show_page_title', 0); } } // Also convert metadata property string to parameters object if (!empty($this->_item->metadata)) { $this->_item->metadata = new JRegistry($this->_item->metadata); } else { $this->_item->metadata = new JRegistry(); } // ********************************************* // Finally set 'parameters' property of the item // ********************************************* $this->_item->parameters = $params; }
function getParams($component = true) { // we have to take clear JRegistry object to avoid overriding static component params $params = new JRegistry(); // global params first $cparams = JComponentHelper::getParams('com_djmediatools'); $params->merge($cparams); // override global params with menu params only for component view if ($component) { $app = JFactory::getApplication(); $mparams = $app->getParams('com_djmediatools'); //$mparams = clone($mparams); $params->merge($mparams); } // override global/menu params with category params $id = $this->getState('category.id'); $category = $this->getItem($id); if ($category && $category != 'root') { $cparams = $category->params; $params->merge($cparams); } return $params; }
/** * Test the JRegistry::merge method. * * @covers JRegistry::merge * * @return void */ public function testMerge() { $array1 = array('foo' => 'bar', 'hoo' => 'hum', 'dum' => array('dee' => 'dum')); $array2 = array('foo' => 'soap', 'dum' => 'huh'); $registry1 = new JRegistry(); $registry1->loadArray($array1); $registry2 = new JRegistry(); $registry2->loadArray($array2); $registry1->merge($registry2); // Test getting a known value. $this->assertThat($registry1->get('foo'), $this->equalTo('soap'), 'Line: ' . __LINE__ . '.'); $this->assertThat($registry1->get('dum'), $this->equalTo('huh'), 'Line: ' . __LINE__ . '.'); // Test merge with zero and blank value $json1 = '{"param1":1, "param2":"value2"}'; $json2 = '{"param1":2, "param2":"", "param3":0, "param4":-1, "param5":1}'; $a = new JRegistry($json1); $b = new JRegistry(); $b->loadString($json2, 'JSON'); $a->merge($b); // New param with zero value should show in merged registry $this->assertEquals(2, $a->get('param1'), '$b value should override $a value'); $this->assertEquals('value2', $a->get('param2'), '$a value should override blank $b value'); $this->assertEquals(0, $a->get('param3'), '$b value of 0 should override $a value'); $this->assertEquals(-1, $a->get('param4'), '$b value of -1 should override $a value'); $this->assertEquals(1, $a->get('param5'), '$b value of 1 should override $a value'); $a = new JRegistry(); $b = new stdClass(); $this->assertFalse($a->merge($b), 'Line: ' . __LINE__ . '. Attempt to merge non JRegistry should return false'); }
/** * Method to load parameters * * @access private * @return void * @since 1.5 */ function _loadParams() { if ($this->_params !== NULL) { return; } $app = JFactory::getApplication(); $menu = $app->getMenu()->getActive(); // Retrieve active menu // Get the COMPONENT only parameter $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); // Merge the active menu parameters if ($menu) { $params->merge($menu->params); } // Merge module parameters overriding current configuration // (this done when module id is present in the HTTP request) (tags cloud module include tags view configuration) if (JRequest::getInt('module', 0)) { // load by module name, not used //jimport( 'joomla.application.module.helper' ); //$module_name = JRequest::getInt('module', 0 ); //$module = JModuleHelper::getModule('mymodulename'); // load by module id $module_id = JRequest::getInt('module', 0); $module = JTable::getInstance('Module', 'JTable'); if ($module->load($module_id)) { $moduleParams = new JRegistry($module->params); $params->merge($moduleParams); } else { JError::raiseNotice(500, $module->getError()); } } $this->_params = $params; }
/** * Creates the item submit form * * @since 1.0 */ function _displayForm($tpl) { jimport('joomla.html.parameter'); // ... we use some strings from administrator part // load english language file for 'com_content' component then override with current language file JFactory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_content', JPATH_ADMINISTRATOR, null, true); // load english language file for 'com_flexicontent' component then override with current language file JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, 'en-GB', true); JFactory::getLanguage()->load('com_flexicontent', JPATH_ADMINISTRATOR, null, true); // ******************************** // Initialize variables, flags, etc // ******************************** $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $document = JFactory::getDocument(); $session = JFactory::getSession(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $uri = JFactory::getURI(); $nullDate = $db->getNullDate(); $menu = $app->getMenu()->getActive(); // We do not have item parameters yet, but we need to do some work before creating the item // Get the COMPONENT only parameter $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); // Merge the active menu parameters if ($menu) { $params->merge($menu->params); } // Some flags $enable_translation_groups = flexicontent_db::useAssociations(); //$params->get("enable_translation_groups"); $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // ***************** // Load JS/CSS files // ***************** FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); flexicontent_html::loadFramework('jQuery'); flexicontent_html::loadFramework('select2'); flexicontent_html::loadFramework('flexi-lib'); // Load custom behaviours: form validation, popup tooltips JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden JHTML::_('behavior.tooltip'); if (FLEXI_J30GE) { JHtml::_('bootstrap.tooltip'); } //JHTML::_('script', 'joomla.javascript.js', 'includes/js/'); // Add css files to the document <head> section (also load CSS joomla template override) $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontent.css'); if (file_exists(JPATH_SITE . DS . 'templates' . DS . $app->getTemplate() . DS . 'css' . DS . 'flexicontent.css')) { $document->addStyleSheet($this->baseurl . '/templates/' . $app->getTemplate() . '/css/flexicontent.css'); } // Fields common CSS $document->addStyleSheet($this->baseurl . '/components/com_flexicontent/assets/css/flexi_form_fields.css'); // Load backend / frontend shared and Joomla version specific CSS (different for frontend / backend) FLEXI_J30GE ? $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css') : $document->addStyleSheet(JURI::base(true) . '/components/com_flexicontent/assets/css/j25.css'); // Add js function to overload the joomla submitform $document->addScript(JURI::base(true) . '/components/com_flexicontent/assets/js/admin.js'); $document->addScript(JURI::base(true) . '/components/com_flexicontent/assets/js/validate.js'); // Add js function for custom code used by FLEXIcontent item form $document->addScript(JURI::base(true) . '/components/com_flexicontent/assets/js/itemscreen.js'); // ********************************************************* // Get item data and create item form (that loads item data) // ********************************************************* if ($print_logging_info) { $start_microtime = microtime(true); } $model = $this->getModel(); // ** WE NEED TO get OR decide the Content Type, before we call the getItem // ** We rely on typeid Request variable to decide type for new items so make sure this is set, // ZERO means allow user to select type, but if user is only allowed a single type, then autoselect it! // Try type from session $jdata = $app->getUserState('com_flexicontent.edit.item.data'); //print_r($jdata); if (!empty($jdata['type_id'])) { JRequest::setVar('typeid', (int) $jdata['type_id']); // This also forces zero if value not set } else { if ($menu && isset($menu->query['typeid'])) { JRequest::setVar('typeid', (int) $menu->query['typeid']); // This also forces zero if value not set } } $new_typeid = JRequest::getVar('typeid', 0, '', 'int'); // Verify type is allowed to the user if (!$new_typeid) { $types = $model->getTypeslist($type_ids_arr = false, $check_perms = true, $_published = true); if ($types && count($types) == 1) { $new_typeid = $types[0]->id; } JRequest::setVar('typeid', $new_typeid); $canCreateType = true; } // FORCE model to load versioned data (URL specified version or latest version (last saved)) $version = JRequest::getVar('version', 0, 'request', 'int'); // Load specific item version (non-zero), 0 version: is unversioned data, -1 version: is latest version (=default for edit form) $item = $model->getItem(null, $check_view_access = false, $no_cache = true, $force_version = $version != 0 ? $version : -1); // -1 version means latest // Replace component/menu 'params' with thee merged component/category/type/item/menu ETC ... parameters $params =& $item->parameters; if ($print_logging_info) { $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // Load permissions (used by form template) $perms = $this->_getItemPerms($item); // Create submit configuration (for new items) into the session, this is needed before creating the item form $submitConf = $this->_createSubmitConf($item, $perms); // Most core field are created via calling methods of the form (J2.5) $form = $this->get('Form'); // is new item and ownership Flags $isnew = !$item->id; $isOwner = $item->created_by == $user->get('id'); // Get available types and the currently selected/requested type $types = $model->getTypeslist(); $typesselected = $model->getTypesselected(); // Get type parameters, these are needed besides the 'merged' item parameters, e.g. to get Type's default layout $tparams = $this->get('Typeparams'); $tparams = new JRegistry($tparams); // ********************************************************************************************************* // Get language stuff, and also load Template-Specific language file to override or add new language strings // ********************************************************************************************************* if ($enable_translation_groups) { $langAssocs = $params->get('uselang_fe') == 1 ? $this->get('LangAssocs') : false; } $langs = FLEXIUtilities::getLanguages('code'); FLEXIUtilities::loadTemplateLanguageFile($params->get('ilayout', 'default')); // ************************************* // Create captcha field via custom logic // ************************************* // create and set (into HTTP request) a unique item id for plugins that needed it if ($item->id) { $unique_tmp_itemid = $item->id; } else { $unique_tmp_itemid = $app->getUserState('com_flexicontent.edit.item.unique_tmp_itemid'); $unique_tmp_itemid = $unique_tmp_itemid ? $unique_tmp_itemid : date('_Y_m_d_h_i_s_', time()) . uniqid(true); } //print_r($unique_tmp_itemid); JRequest::setVar('unique_tmp_itemid', $unique_tmp_itemid); // Component / Menu Item parameters $allowunauthorize = $params->get('allowunauthorize', 0); // allow unauthorised user to submit new content $unauthorized_page = $params->get('unauthorized_page', ''); // page URL for unauthorized users (via global configuration) $notauth_itemid = $params->get('notauthurl', ''); // menu itemid (to redirect) when user is not authorized to create content // Create captcha field or messages // Maybe some code can be removed by using Joomla's built-in form element (in XML file), instead of calling the captcha plugin ourselves $use_captcha = $params->get('use_captcha', 1); // 1 for guests, 2 for any user $captcha_formop = $params->get('captcha_formop', 0); // 0 for submit, 1 for submit/edit (aka always) $display_captcha = $use_captcha >= 2 || $use_captcha == 1 && $user->guest; $display_captcha = $display_captcha && ($isnew || $captcha_formop); // Trigger the configured captcha plugin if ($display_captcha) { // Get configured captcha plugin $c_plugin = $params->get('captcha', $app->getCfg('captcha')); // TODO add param to override default if ($c_plugin) { $c_name = 'captcha_response_field'; $c_id = $c_plugin == 'recaptcha' ? 'dynamic_recaptcha_1' : 'fc_dynamic_captcha'; $c_class = ' required'; $c_namespace = 'fc_item_form'; // Try to load the configured captcha plugin, (check if disabled or uninstalled), Joomla will enqueue an error message if needed $captcha_obj = JCaptcha::getInstance($c_plugin, array('namespace' => $c_namespace)); if ($captcha_obj) { $captcha_field = $captcha_obj->display($c_name, $c_id, $c_class); $label_class = 'flexi_label'; $label_class .= FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; $label_tooltip = flexicontent_html::getToolTip(null, 'FLEXI_CAPTCHA_ENTER_CODE_DESC', 1, 1); $captcha_field = ' <label id="' . $c_name . '-lbl" for="' . $c_name . '" class="' . $label_class . '" title="' . $label_tooltip . '" > ' . JText::_('FLEXI_CAPTCHA_ENTER_CODE') . ' </label> <div id="container_fcfield_' . $c_plugin . '" class="container_fcfield container_fcfield_name_' . $c_plugin . '"> <div class="fcfieldval_container valuebox fcfieldval_container_' . $c_plugin . '"> ' . $captcha_field . ' </div> </div>'; } } } // ******************************* // CHECK EDIT / CREATE PERMISSIONS // ******************************* // User Group / Author parameters $authorparams = flexicontent_db::getUserConfig($user->id); $max_auth_limit = intval($authorparams->get('max_auth_limit', 0)); // maximum number of content items the user can create $hasTmpEdit = false; $hasCoupon = false; // Check session if ($session->has('rendered_uneditable', 'flexicontent')) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $hasTmpEdit = !empty($rendered_uneditable[$model->get('id')]); $hasCoupon = !empty($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')] == 2; // editable via coupon } if (!$isnew) { // EDIT action // Finally check if item is currently being checked-out (currently being edited) if ($model->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('FLEXI_DESCBEINGEDITTED', $model->get('title')); $app->redirect(JRoute::_('index.php?view=' . FLEXI_ITEMVIEW . '&cid=' . $model->get('catid') . '&id=' . $model->get('id'), false), $msg); } //Checkout the item $model->checkout(); // Get edit access, this includes privileges edit and edit-own and the temporary EDIT flag ('rendered_uneditable') $canEdit = $model->getItemAccess()->get('access-edit'); // If no edit privilege, check if edit COUPON was provided if (!$canEdit) { $edittok = JRequest::getCmd('edittok', false); if ($edittok) { $query = 'SHOW TABLES LIKE "' . $app->getCfg('dbprefix') . 'flexicontent_edit_coupons"'; $db->setQuery($query); $tbl_exists = (bool) count($db->loadObjectList()); if ($tbl_exists) { $query = 'SELECT * FROM #__flexicontent_edit_coupons ' . ' WHERE token = ' . $db->Quote($edittok) . ' AND id = ' . $model->get('id'); $db->setQuery($query); $tokdata = $db->loadObject(); if ($tokdata) { $hasCoupon = true; $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = 2; // 2: indicates, that has edit via EDIT Coupon $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } else { JError::raiseNotice(403, JText::_('EDIT_TOKEN_IS_INVALID') . ' : ' . $edittok); } } } } // Edit check finished, throw error if needed if (!$canEdit) { if ($user->guest) { $uri = JFactory::getURI(); $return = $uri->toString(); $fcreturn = serialize(array('id' => @$this->_item->id, 'cid' => $cid)); // a special url parameter, used by some SEF code $com_users = FLEXI_J16GE ? 'com_users' : 'com_user'; $url = $params->get('login_page', 'index.php?option=' . $com_users . '&view=login'); $return = strtr(base64_encode($return), '+/=', '-_,'); $url .= '&return=' . $return; //$url .= '&return='.urlencode(base64_encode($return)); $url .= '&fcreturn=' . base64_encode($fcreturn); JError::raiseWarning(403, JText::sprintf("FLEXI_LOGIN_TO_ACCESS", $url)); $app->redirect($url); } else { if ($unauthorized_page) { // unauthorized page via global configuration JError::raiseNotice(403, JText::_('FLEXI_ALERTNOTAUTH_TASK')); $app->redirect($unauthorized_page); } else { // user isn't authorize to edit this content $msg = JText::_('FLEXI_ALERTNOTAUTH_TASK'); if (FLEXI_J16GE) { throw new Exception($msg, 403); } else { JError::raiseError(403, $msg); } } } } } else { // CREATE action // Get create access, this includes check of creating in at least one category, and type's "create items" $canAdd = $model->getItemAccess()->get('access-create'); $not_authorised = !$canAdd; // Check if Content Type can be created by current user if (empty($canCreateType)) { if ($new_typeid) { // not needed, already done be model when type_id is set, check and remove $canCreateType = $model->canCreateType(array($new_typeid)); // Can create given Content Type } else { // needed not done be model yet $canCreateType = $model->canCreateType(); // Can create at least one Content Type } } $not_authorised = $not_authorised || !$canCreateType; // Allow item submission by unauthorized users, ... even guests ... if ($allowunauthorize == 2) { $allowunauthorize = !$user->guest; } if ($not_authorised && !$allowunauthorize) { if (!$canCreateType) { $type_name = isset($types[$new_typeid]) ? '"' . JText::_($types[$new_typeid]->name) . '"' : JText::_('FLEXI_ANY'); $msg = JText::sprintf('FLEXI_NO_ACCESS_CREATE_CONTENT_OF_TYPE', $type_name); } else { $msg = JText::_('FLEXI_ALERTNOTAUTH_CREATE'); } } else { if ($max_auth_limit) { $db->setQuery('SELECT COUNT(id) FROM #__content WHERE created_by = ' . $user->id); $authored_count = $db->loadResult(); $content_is_limited = $authored_count >= $max_auth_limit; $msg = $content_is_limited ? JText::sprintf('FLEXI_ALERTNOTAUTH_CREATE_MORE', $max_auth_limit) : ''; } } if ($not_authorised && !$allowunauthorize || @$content_is_limited) { // User isn't authorize to add ANY content if ($notauth_menu = $app->getMenu()->getItem($notauth_itemid)) { // a. custom unauthorized submission page via menu item $internal_link_vars = @$notauth_menu->component ? '&Itemid=' . $notauth_itemid . '&option=' . $notauth_menu->component : ''; $notauthurl = JRoute::_($notauth_menu->link . $internal_link_vars, false); JError::raiseNotice(403, $msg); $app->redirect($notauthurl); } else { if ($unauthorized_page) { // b. General unauthorized page via global configuration JError::raiseNotice(403, $msg); $app->redirect($unauthorized_page); } else { // c. Finally fallback to raising a 403 Exception/Error that will redirect to site's default 403 unauthorized page if (FLEXI_J16GE) { throw new Exception($msg, 403); } else { JError::raiseError(403, $msg); } } } } } // ***************************************************************************** // Get (CORE & CUSTOM) fields and their VERSIONED values and then // (a) Apply Content Type Customization to CORE fields (label, description, etc) // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField' // ***************************************************************************** // Check if saving an item that translates an original content in site's default language $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2); $is_content_default_lang = $site_default == substr($item->language, 0, 2); //$modify_untraslatable_values = $enable_translation_groups && !$is_content_default_lang; // && $item->lang_parent_id && $item->lang_parent_id!=$item->id; if ($print_logging_info) { $start_microtime = microtime(true); } $fields = $this->get('Extrafields'); $item->fields =& $fields; if ($print_logging_info) { $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } if ($print_logging_info) { $start_microtime = microtime(true); } $jcustom = $app->getUserState('com_flexicontent.edit.item.custom'); //print_r($jcustom); foreach ($fields as $field) { // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations if ($field->iscore) { FlexicontentFields::loadFieldConfig($field, $item); } // b. Create field 's editing HTML (the form field) // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow) if (!$field->iscore) { if (isset($jcustom[$field->name])) { $field->value = array(); foreach ($jcustom[$field->name] as $i => $_val) { $field->value[$i] = $_val; } } $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id); if ($is_editable) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item)); if ($field->untranslatable) { $field->html = '<div class="alert alert-info fc-small fc-iblock">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . $field->html; } } else { if ($field->valueseditable == 1) { $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>'; } else { if ($field->valueseditable == 2) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display; } else { if ($field->valueseditable == 3) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = $field->display; } else { if ($field->valueseditable == 4) { $field->html = ''; $field->formhidden = 4; } } } } } } // c. Create main text field, via calling the display function of the textarea field (will also check for tabs) if ($field->field_type == 'maintext') { if (isset($item->item_translations)) { $shortcode = substr($item->language, 0, 2); foreach ($item->item_translations as $lang_id => $t) { if ($shortcode == $t->shortcode) { continue; } $field->name = array('jfdata', $t->shortcode, 'text'); $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8'); FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); $t->fields->text->tab_labels = $field->tab_labels; $t->fields->text->html = $field->html; unset($field->tab_labels); unset($field->html); } } $field->name = 'text'; // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data $field->value[0] = $item->text; // do not decode special characters this was handled during saving ! // Render the field's (form) HTML FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); } } if ($print_logging_info) { $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // Tags used by the item $usedtagsids = $this->get('UsedtagsIds'); // NOTE: This will normally return the already set versioned value of tags ($item->tags) $usedtagsdata = $model->getUsedtagsData($usedtagsids); // Get the edit lists $lists = $this->_buildEditLists($perms, $params, $authorparams); // Get number of subscribers $subscribers = $this->get('SubscribersCount'); // Get menu overridden categories/main category fields $menuCats = $this->_getMenuCats($item, $perms); // Create placement configuration for CORE properties $placementConf = $this->_createPlacementConf($item, $fields); // Item language related vars $languages = FLEXIUtilities::getLanguages(); $itemlang = new stdClass(); $itemlang->shortcode = substr($item->language, 0, 2); $itemlang->name = $languages->{$item->language}->name; $itemlang->image = '<img src="' . @$languages->{$item->language}->imgsrc . '" alt="' . $languages->{$item->language}->name . '" />'; //Load the JEditor object $editor = JFactory::getEditor(); // ********************************************************** // Calculate a (browser window) page title and a page heading // ********************************************************** // Verify menu item points to current FLEXIcontent object if ($menu) { $menu_matches = false; $view_ok = FLEXI_ITEMVIEW == @$menu->query['view'] || 'article' == @$menu->query['view']; $menu_matches = $view_ok; //$menu_params = $menu->params; // Get active menu item parameters } else { $menu_matches = false; } // MENU ITEM matched, use its page heading (but use menu title if the former is not set) if ($menu_matches) { $default_heading = FLEXI_J16GE ? $menu->title : $menu->name; // Cross set (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->def('page_heading', $params->get('page_title', $default_heading)); $params->def('page_title', $params->get('page_heading', $default_heading)); $params->def('show_page_heading', $params->get('show_page_title', 0)); $params->def('show_page_title', $params->get('show_page_heading', 0)); } else { // Calculate default page heading (=called page title in J1.5), which in turn will be document title below !! ... $default_heading = !$isnew ? JText::_('FLEXI_EDIT') : JText::_('FLEXI_NEW'); // Decide to show page heading (=J1.5 page title), there is no need for this in item view $show_default_heading = 0; // Set both (show_) page_heading / page_title for compatibility of J2.5+ with J1.5 template (and for J1.5 with J2.5 template) $params->set('page_title', $default_heading); $params->set('page_heading', $default_heading); $params->set('show_page_heading', $show_default_heading); $params->set('show_page_title', $show_default_heading); } // ************************************************************ // Create the document title, by from page title and other data // ************************************************************ // Use the page heading as document title, (already calculated above via 'appropriate' logic ...) $doc_title = $params->get('page_title'); // Check and prepend or append site name // Add Site Name to page title if ($app->getCfg('sitename_pagetitles', 0) == 1) { $doc_title = $app->getCfg('sitename') . " - " . $doc_title; } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $doc_title = $doc_title . " - " . $app->getCfg('sitename'); } // Finally, set document title $document->setTitle($doc_title); // Add title to pathway $pathway = $app->getPathWay(); $pathway->addItem($doc_title, ''); // Get pageclass suffix $pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); // Ensure the row data is safe html // @TODO: check if this is really required as it conflicts with the escape function in the tmpl //JFilterOutput::objectHTMLSafe( $item ); $this->assign('action', $uri->toString()); $this->assignRef('item', $item); $this->assignRef('form', $form); // most core field are created via calling methods of the form (J2.5) if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } $this->assignRef('langs', $langs); $this->assignRef('params', $params); $this->assignRef('lists', $lists); $this->assignRef('subscribers', $subscribers); $this->assignRef('editor', $editor); $this->assignRef('user', $user); $this->assignRef('usedtagsdata', $usedtagsdata); $this->assignRef('fields', $fields); $this->assignRef('tparams', $tparams); $this->assignRef('perms', $perms); $this->assignRef('document', $document); $this->assignRef('nullDate', $nullDate); $this->assignRef('menuCats', $menuCats); $this->assignRef('submitConf', $submitConf); $this->assignRef('placementConf', $placementConf); $this->assignRef('itemlang', $itemlang); $this->assignRef('pageclass_sfx', $pageclass_sfx); $this->assign('captcha_errmsg', @$captcha_errmsg); $this->assign('captcha_field', @$captcha_field); // **************************************************************** // SET INTO THE FORM, parameter values for various parameter groups // **************************************************************** if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $nullDate) { $item->publish_down = JText::_('FLEXI_NEVER'); } // **************************** // Handle Template related work // **************************** // (a) Get the templates structures used to create form fields for template parameters $themes = flexicontent_tmpl::getTemplates(); $tmpls_all = $themes->items; // (b) Get Content Type allowed templates $allowed_tmpls = $tparams->get('allowed_ilayouts'); $type_default_layout = $tparams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } if (!is_array($allowed_tmpls)) { $allowed_tmpls = explode("|", $allowed_tmpls); } // (c) Add default layout, unless all templates allowed (=array is empty) if (count($allowed_tmpls) && !in_array($type_default_layout, $allowed_tmpls)) { $allowed_tmpls[] = $type_default_layout; } // (d) Create array of template data according to the allowed templates for current content type if (count($allowed_tmpls)) { foreach ($tmpls_all as $tmpl) { if (in_array($tmpl->name, $allowed_tmpls)) { $tmpls[] = $tmpl; } } } else { $tmpls = $tmpls_all; } // (e) Apply Template Parameters values into the form fields structures foreach ($tmpls as $tmpl) { if (FLEXI_J16GE) { $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; foreach ($tmpl->params->getGroup('attribs') as $field) { $fieldname = $field->__get('fieldname'); $value = $item->itemparams->get($fieldname); if (strlen($value)) { $tmpl->params->setValue($fieldname, 'attribs', $value); } } } else { $tmpl->params->loadINI($item->attribs); } } $this->assignRef('tmpls', $tmpls); // Clear custom form data from session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', false); $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', false); $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', false); if ($print_logging_info) { $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { $fc_run_times['form_rendering'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } }
/** * Method to merge config params and Menu params * @return params */ function getMergedParams() { $app = JFactory::getApplication(); if ($app->isAdmin()) { $params = new JRegistry(); $params->loadString('{}'); return $params; } //first get the menu params $aparams = $app->getParams(); $menuParams = new JRegistry(); if ($menu = $app->getMenu()->getActive()) { $menuParams->loadString($menu->params); } $mergedParams = clone $menuParams; $mergedParams->merge($aparams); //now load the configurations $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('*')->from('#__j2store_configurations'); $db->setQuery($query); $results = $db->loadObjectList('config_meta_key'); $config = array(); foreach ($results as $key => $value) { $config[$key] = $value->config_meta_value; } $configparams = new JRegistry(); $configparams->loadArray($config); $configparams->merge($mergedParams); /* //get the active menu details $menu = JFactory::getApplication()->getMenu()->getActive(); $menu_array=array(); //if any menu template choosen then that template will if(isset($menu->params)){ $menu_params = $menu->params; $registry = new JRegistry($menu_params); $registry->loadObject($menu_params); $result_array = $registry->toArray($menu_params); $menu_array = isset($result_array['data']) ? $result_array['data'] :array(); } $params = array_merge($config,$menu_array); $registry = new JRegistry(); $registry->loadArray($params); */ //merged params return $configparams; }
/** * Method to get component + type parameters these are enough for the backend, * also they are needed before frontend view's FULL item parameters are created * * @access public * @return int item identifier */ function getComponentTypeParams() { // Calculate component + type parameters if ($this->_cparams) { return $this->_cparams; } $app = JFactory::getApplication(); // Get component parameters $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); // Merge into them the type parameters, *(type was set/verified above) if ($this->_typeid) { $tparams = $this->getTypeparams(); $tparams = new JRegistry($tparams); $params->merge($tparams); } // Set and return component + type parameters $this->_cparams = $params; return $this->_cparams; }
/** * Load's EasyBlog's settings object * * @since 4.0 * @access public * @param string * @return */ public static function config() { static $config = null; if (is_null($config)) { // Load up default configuration file $file = EBLOG_ADMIN_ROOT . '/defaults/configuration.ini'; $raw = JFile::read($file); $registry = new JRegistry($raw); // Get config stored in db $table = EB::table('Configs'); $table->load('config'); // Load the stored config as a registry $stored = new JRegistry($table->params); $registry->merge($stored); $config = $registry; } return $config; }
/** * Logic to save an item * * @access public * @return void * @since 1.0 */ function save() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); //echo '<html> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <body>'; // Initialize variables $app = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $config = JFactory::getConfig(); $session = JFactory::getSession(); $task = JRequest::getVar('task'); $ctrl_task = 'task=items.'; // ********************* // Get data from request // ********************* // Retrieve form data these are subject to basic filtering $data = JRequest::getVar('jform', array(), 'post', 'array'); // Core Fields and and item Parameters $custom = JRequest::getVar('custom', array(), 'post', 'array'); // Custom Fields $jfdata = JRequest::getVar('jfdata', array(), 'post', 'array'); // Joomfish Data // Set into model: id (needed for loading correct item), and type id (e.g. needed for getting correct type parameters for new items) $data_id = (int) $data['id']; $isnew = $data_id == 0; // If new make sure that type id is set too, before creating the model if ($isnew) { $typeid = JRequest::setvar('typeid', (int) @$data['type_id']); } // Get the model $model = $this->getModel('item'); $model->setId($data_id); // Make sure id is correct // Get some flags this will also trigger item loading if not already loaded $isOwner = $model->get('created_by') == $user->get('id'); // Get merged parameters: component, type, menu (FE) $params = new JRegistry(); $model_params = $model->getComponentTypeParams(); $params->merge($model_params); // Unique id for new items, needed by some fields for temporary data $unique_tmp_itemid = JRequest::getVar('unique_tmp_itemid'); // Auto title for some content types if ($params->get('auto_title', 0)) { $data['title'] = (int) $data['id']; } // item id or ZERO for new items // ************************************* // ENFORCE can change category ACL perms // ************************************* $perms = FlexicontentHelperPerm::getPerm(); // Per content type change category permissions $current_type_id = $isnew || !$model->get('type_id') ? (int) @$data['type_id'] : $model->get('type_id'); // GET current (existing/old) item TYPE ID $CanChangeFeatCat = $user->authorise('flexicontent.change.cat.feat', 'com_flexicontent.type.' . $current_type_id); $CanChangeSecCat = $user->authorise('flexicontent.change.cat.sec', 'com_flexicontent.type.' . $current_type_id); $CanChangeCat = $user->authorise('flexicontent.change.cat', 'com_flexicontent.type.' . $current_type_id); $AutoApproveChanges = $perms->AutoApproveChanges; $enable_featured_cid_selector = $perms->MultiCat && $CanChangeFeatCat; $enable_cid_selector = $perms->MultiCat && $CanChangeSecCat; $enable_catid_selector = $isnew && !$params->get('catid_default') || !$isnew && !$model->get('catid') || $CanChangeCat; // Enforce maintaining featured categories $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); if ($featured_cats_parent && !$enable_featured_cid_selector) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_cid = array(); if (!$isnew) { foreach ($model->get('categories') as $item_cat) { if (isset($featured_tree[$item_cat]) && !isset($disabled_cats[$item_cat])) { $featured_cid[] = $item_cat; } } } $data['featured_cid'] = $featured_cid; } // Enforce maintaining secondary categories if (!$enable_cid_selector) { if ($isnew) { $data['cid'] = $params->get('cid_default'); } else { if (isset($featured_cid)) { $featured_cid_arr = array_flip($featured_cid); $sec_cid = array(); foreach ($model->get('cats') as $item_cat) { if (!isset($featured_cid_arr[$item_cat])) { $sec_cid[] = $item_cat; } } $data['cid'] = $sec_cid; } else { $data['cid'] = $model->get('cats'); } } } if (!$enable_catid_selector) { if ($isnew && $params->get('catid_default')) { $data['catid'] = $params->get('catid_default'); } else { if ($model->get('catid')) { $data['catid'] = $model->get('catid'); } } } // ************************** // Basic Form data validation // ************************** // Get the JForm object, but do not pass any data we only want the form object, // in order to validate the data and not create a filled-in form $form = $model->getForm(); // Validate Form data for core fields and for parameters $post = $model->validate($form, $data); // Check for validation error if (!$post) { // Get the validation messages and push up to three validation messages out to the user $errors = $form->getErrors(); for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) { $app->enqueueMessage($errors[$i] instanceof Exception ? $errors[$i]->getMessage() : $errors[$i], 'error'); } // Set POST form date into the session, so that they get reloaded $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data); // Save the jform data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom); // Save the custom fields data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata); // Save the falang translations into the session $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid); // Save temporary unique item id into the session // Redirect back to the item form $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return false; //die('error'); } // Some values need to be assigned after validation $post['attribs'] = @$data['attribs']; // Workaround for item's template parameters being clear by validation since they are not present in item.xml $post['custom'] =& $custom; // Assign array of custom field values, they are in the 'custom' form array instead of jform $post['jfdata'] =& $jfdata; // Assign array of Joomfish field values, they are in the 'jfdata' form array instead of jform // Assign template parameters of the select ilayout as an sub-array (the DB model will handle the merging of parameters) $ilayout = $data['attribs']['ilayout']; if (!empty($data['layouts'][$ilayout])) { //echo "<pre>"; print_r($post['attribs']); //$post['attribs'] = array_merge($post['attribs'], $data['layouts'][$ilayout]); $post['attribs']['layouts'] = $data['layouts']; //echo "<pre>"; print_r($post['attribs']); exit; } // USEFULL FOR DEBUGING for J2.5 (do not remove commented code) //$diff_arr = array_diff_assoc ( $data, $post); //echo "<pre>"; print_r($diff_arr); jexit(); // Make sure Content ID in the REQUEST is set, this is needed in BACKEND, needed in some cases // NOTE this is not the same as jform['cid'] which is the category IDs of the Content Item JRequest::setVar('cid', array($model->getId()), 'post', 'array'); // ******************************************************************************** // PERFORM ACCESS CHECKS, NOTE: we need to check access again, despite having // checked them on edit form load, because user may have tampered with the form ... // ******************************************************************************** $itemAccess = $model->getItemAccess(); $canAdd = $itemAccess->get('access-create'); // includes check of creating in at least one category $canEdit = $itemAccess->get('access-edit'); // includes privileges edit and edit-own $type_id = (int) @$post['type_id']; // Typecast to int, (already done for J2.5 via validating) if (!$isnew && $model->get('type_id') == $type_id) { // Existing item with Type not being ALTERED, content type can be maintained regardless of privilege $canCreateType = true; } else { // New item or existing item with Type is being ALTERED, check privilege to create items of this type $canCreateType = $model->canCreateType(array($type_id), true, $types); } // ***************************************************************** // Calculate user's CREATE / EDIT privileges on current content item // ***************************************************************** $hasCoupon = false; // Normally used in frontend only if (!$isnew) { // If no edit privilege, check if item is editable till logoff if (!$canEdit) { if ($session->has('rendered_uneditable', 'flexicontent')) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $canEdit = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')]; $hasCoupon = isset($rendered_uneditable[$model->get('id')]) && $rendered_uneditable[$model->get('id')] == 2; // editable via coupon } } } else { // No special CREATE allowing case for backend } // New item: check if user can create in at least one category if ($isnew && !$canAdd) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_CREATE')); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } // Existing item: Check if user can edit current item if (!$isnew && !$canEdit) { JError::raiseWarning(403, JText::_('FLEXI_NO_ACCESS_EDIT')); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } if (!$canCreateType) { $msg = isset($types[$type_id]) ? JText::sprintf('FLEXI_NO_ACCESS_CREATE_CONTENT_OF_TYPE', JText::_($types[$type_id]->name)) : ' Content Type ' . $type_id . ' was not found OR is not published'; JError::raiseWarning(403, $msg); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; } // Get "BEFORE SAVE" categories for information mail $before_cats = array(); if (!$isnew) { $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id'); $db->setQuery($query); $before_cats = $db->loadObjectList('id'); $before_maincat = $model->get('catid'); $original_item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = 0); } // **************************************** // Try to store the form data into the item // **************************************** if (!$model->store($post)) { // Set error message about saving failed, and also the reason (=model's error message) $msg = JText::_('FLEXI_ERROR_STORING_ITEM'); JError::raiseWarning(500, $msg . ": " . $model->getError()); // Set POST form date into the session, so that they get reloaded $app->setUserState($form->option . '.edit.' . $form->context . '.data', $data); // Save the jform data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', $custom); // Save the custom fields data in the session $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', $jfdata); // Save the falang translations into the session $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', $unique_tmp_itemid); // Save temporary unique item id into the session // Saving has failed check-in and redirect back to the item form, // redirect back to the item form reloading the posted data $model->checkin(); $this->setRedirect($_SERVER['HTTP_REFERER']); if (JRequest::getVar('fc_doajax_submit')) { echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } return; //die('save error'); } // ************************************************** // Check in model and get item id in case of new item // ************************************************** $model->checkin(); $post['id'] = $isnew ? (int) $model->get('id') : $post['id']; // Get items marked as newly submitted $newly_submitted = $session->get('newly_submitted', array(), 'flexicontent'); if ($isnew) { // Mark item as newly submitted, to allow to a proper "THANKS" message after final save & close operation (since user may have clicked add instead of add & close) $newly_submitted[$model->get('id')] = 1; $session->set('newly_submitted', $newly_submitted, 'flexicontent'); } $newly_submitted_item = @$newly_submitted[$model->get('id')]; // *********************************************************************************************************** // Get newly saved -latest- version (store task gets latest) of the item, and also calculate publish privelege // *********************************************************************************************************** $item = $model->getItem($post['id'], $check_view_access = false, $no_cache = true, $force_version = -1); $canPublish = $model->canEditState($item, $check_cat_perm = true) || $hasCoupon; // ******************************************************************************************** // Use session to detect multiple item saves to avoid sending notification EMAIL multiple times // ******************************************************************************************** $is_first_save = true; if ($session->has('saved_fcitems', 'flexicontent')) { $saved_fcitems = $session->get('saved_fcitems', array(), 'flexicontent'); $is_first_save = $isnew ? true : !isset($saved_fcitems[$model->get('id')]); } // Add item to saved items of the corresponding session array $saved_fcitems[$model->get('id')] = $timestamp = time(); // Current time as seconds since Unix epoc; $session->set('saved_fcitems', $saved_fcitems, 'flexicontent'); // ******************************************** // Get categories added / removed from the item // ******************************************** $query = 'SELECT DISTINCT c.id, c.title FROM #__categories AS c' . ' JOIN #__flexicontent_cats_item_relations AS rel ON rel.catid = c.id' . ' WHERE rel.itemid = ' . (int) $model->get('id'); $db->setQuery($query); $after_cats = $db->loadObjectList('id'); if (!$isnew) { $cats_added_ids = array_diff(array_keys($after_cats), array_keys($before_cats)); foreach ($cats_added_ids as $cats_added_id) { $cats_added_titles[] = $after_cats[$cats_added_id]->title; } $cats_removed_ids = array_diff(array_keys($before_cats), array_keys($after_cats)); foreach ($cats_removed_ids as $cats_removed_id) { $cats_removed_titles[] = $before_cats[$cats_removed_id]->title; } $cats_altered = count($cats_added_ids) + count($cats_removed_ids); $after_maincat = $model->get('catid'); } // ******************************************************************************************************************* // We need to get emails to notify, from Global/item's Content Type parameters -AND- from item's categories parameters // ******************************************************************************************************************* $notify_emails = array(); if ($is_first_save || $cats_altered || $params->get('nf_enable_debug', 0)) { // Get needed flags regarding the saved items $approve_version = 2; $pending_approval_state = -3; $draft_state = -4; $current_version = FLEXIUtilities::getCurrentVersions($item->id, true); // Get current item version $last_version = FLEXIUtilities::getLastVersions($item->id, true); // Get last version (=latest one saved, highest version id), // $post variables vstate & state may have been (a) tampered in the form, and/or (b) altered by save procedure so better not use them $needs_version_reviewal = !$isnew && $last_version > $current_version && !$canPublish && !$AutoApproveChanges; $needs_publication_approval = $isnew && $item->state == $pending_approval_state && !$canPublish; $draft_from_non_publisher = $item->state == $draft_state && !$canPublish; if ($draft_from_non_publisher) { // Suppress notifications for draft-state items (new or existing ones), for these each author will publication approval manually via a button $nConf = false; } else { // Get notifications configuration and select appropriate emails for current saving case $nConf = $model->getNotificationsConf($params); //echo "<pre>"; print_r($nConf); "</pre>"; } if ($nConf) { $states_notify_new = $params->get('states_notify_new', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5)); if (empty($states_notify_new)) { $states_notify_new = array(); } else { if (!is_array($states_notify_new)) { $states_notify_new = !FLEXI_J16GE ? array($states_notify_new) : explode("|", $states_notify_new); } } $states_notify_existing = $params->get('states_notify_existing', array(1, 0, FLEXI_J16GE ? 2 : -1, -3, -4, -5)); if (empty($states_notify_existing)) { $states_notify_existing = array(); } else { if (!is_array($states_notify_existing)) { $states_notify_existing = !FLEXI_J16GE ? array($states_notify_existing) : explode("|", $states_notify_existing); } } $n_state_ok = in_array($item->state, $states_notify_new); $e_state_ok = in_array($item->state, $states_notify_existing); if ($needs_publication_approval) { $notify_emails = $nConf->emails->notify_new_pending; } else { if ($isnew && $n_state_ok) { $notify_emails = $nConf->emails->notify_new; } else { if ($isnew) { $notify_emails = array(); } else { if ($needs_version_reviewal) { $notify_emails = $nConf->emails->notify_existing_reviewal; } else { if (!$isnew && $e_state_ok) { $notify_emails = $nConf->emails->notify_existing; } else { if (!$isnew) { $notify_emails = array(); } } } } } } if ($needs_publication_approval) { $notify_text = $params->get('text_notify_new_pending'); } else { if ($isnew) { $notify_text = $params->get('text_notify_new'); } else { if ($needs_version_reviewal) { $notify_text = $params->get('text_notify_existing_reviewal'); } else { if (!$isnew) { $notify_text = $params->get('text_notify_existing'); } } } } //print_r($notify_emails); jexit(); } } // ********************************************************************************************************************* // If there are emails to notify for current saving case, then send the notifications emails, but // ********************************************************************************************************************* if (!empty($notify_emails) && count($notify_emails)) { $notify_vars = new stdClass(); $notify_vars->needs_version_reviewal = $needs_version_reviewal; $notify_vars->needs_publication_approval = $needs_publication_approval; $notify_vars->isnew = $isnew; $notify_vars->notify_emails = $notify_emails; $notify_vars->notify_text = $notify_text; $notify_vars->before_cats = $before_cats; $notify_vars->after_cats = $after_cats; $notify_vars->original_item = @$original_item; $model->sendNotificationEmails($notify_vars, $params, $manual_approval_request = 0); } // *************************************************** // CLEAN THE CACHE so that our changes appear realtime // *************************************************** $cache = FLEXIUtilities::getCache($group = '', 0); $cache->clean('com_flexicontent_items'); $cache->clean('com_flexicontent_filters'); $cache = FLEXIUtilities::getCache($group = '', 1); $cache->clean('com_flexicontent_items'); $cache->clean('com_flexicontent_filters'); // **************************************************************************************************************************** // Recalculate EDIT PRIVILEGE of new item. Reason for needing to do this is because we can have create permission in a category // and thus being able to set this category as item's main category, but then have no edit/editown permission for this category // **************************************************************************************************************************** $asset = 'com_content.article.' . $model->get('id'); $canEdit = $user->authorise('core.edit', $asset) || $user->authorise('core.edit.own', $asset) && $isOwner; // ALTERNATIVE 1 //$canEdit = $model->getItemAccess()->get('access-edit'); // includes privileges edit and edit-own // ALTERNATIVE 2 //$rights = FlexicontentHelperPerm::checkAllItemAccess($user->get('id'), 'item', $model->get('id')); //$canEdit = in_array('edit', $rights) || (in_array('edit.own', $rights) && $isOwner) ; // ******************************************************************************************************* // Check if user can not edit item further (due to changed main category, without edit/editown permission) // ******************************************************************************************************* if (!$canEdit) { if ($task == 'apply' || $task == 'apply_type') { // APPLY TASK: Temporarily set item to be editable till closing it and not through all session // (we will/should clear this flag when item is closed, since we have another flag to indicate new items $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = -1; $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } else { if ($newly_submitted_item) { // NEW ITEM: Do not use editable till logoff behaviour // ALSO: Clear editable FLAG set in the case that 'apply' button was used during new item creation if (!$params->get('items_session_editable', 0)) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); if (isset($rendered_uneditable[$model->get('id')])) { unset($rendered_uneditable[$model->get('id')]); $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); } } } else { // EXISTING ITEM: (if enabled) Use the editable till logoff behaviour if ($params->get('items_session_editable', 0)) { // Set notice for existing item being editable till logoff JError::raiseNotice(403, JText::_('FLEXI_CANNOT_EDIT_AFTER_LOGOFF')); // Allow item to be editable till logoff $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); $rendered_uneditable[$model->get('id')] = 1; $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); $canEdit = 1; } } } // Set notice about saving an item that cannot be changed further if (!$canEdit) { $app->enqueueMessage(JText::_('FLEXI_CANNOT_MAKE_FURTHER_CHANGES_TO_CONTENT'), 'message'); } } // **************************************************************** // Check for new Content Item is being closed, and clear some flags // **************************************************************** if ($task != 'apply' && $task != 'apply_type' && $newly_submitted_item) { // Clear item from being marked as newly submitted unset($newly_submitted[$model->get('id')]); $session->set('newly_submitted', $newly_submitted, 'flexicontent'); // The 'apply' task may set 'editable till logoff' FLAG ... // CLEAR IT, since NEW content this is meant to be used temporarily if (!$params->get('items_session_editable', 0)) { $rendered_uneditable = $session->get('rendered_uneditable', array(), 'flexicontent'); if (isset($rendered_uneditable[$model->get('id')])) { unset($rendered_uneditable[$model->get('id')]); $session->set('rendered_uneditable', $rendered_uneditable, 'flexicontent'); } } } // **************************************** // Saving is done, decide where to redirect // **************************************** switch ($task) { case 'apply': case 'apply_type': $link = 'index.php?option=com_flexicontent&' . $ctrl_task . 'edit&cid=' . (int) $model->get('id'); break; case 'saveandnew': $link = $type_id ? 'index.php?option=com_flexicontent&view=item&typeid=' . $type_id : 'index.php?option=com_flexicontent&view=item'; break; default: $link = 'index.php?option=com_flexicontent&view=items'; break; } $msg = JText::_('FLEXI_ITEM_SAVED'); $this->setRedirect($link, $msg); if (JRequest::getVar('fc_doajax_submit')) { JFactory::getApplication()->enqueueMessage($msg, 'message'); echo flexicontent_html::get_system_messages_html(); exit; // Ajax submit, do not rerender the view } }
/** * Method to load content article parameters * * @access private * @return void * @since 1.5 */ function _loadCategoryParams() { if ($this->_params !== NULL) { return; } $id = (int) $this->_id; $app = JFactory::getApplication(); $menu = $app->getMenu()->getActive(); // Retrieve active menu item if ($menu) { $menu_params = FLEXI_J16GE ? $menu->params : new JParameter($menu->params); } // Get active menu item parameters // a. Clone component parameters ... we will use these as parameters base for merging $compParams = clone JComponentHelper::getComponent('com_flexicontent')->params; // Get the COMPONENT only parameters $debug_inheritcid = JRequest::getCmd('print') ? 0 : $compParams->get('debug_inheritcid'); if ($debug_inheritcid) { $merge_stack = array(); array_push($merge_stack, "CLONED COMPONENT PARAMETERS"); array_push($merge_stack, "MERGED LAYOUT PARAMETERS"); } // b. Retrieve category parameters and create parameter object if ($id) { $query = 'SELECT params FROM #__categories WHERE id = ' . $id; $this->_db->setQuery($query); $catParams = $this->_db->loadResult(); $catParams = new JRegistry($catParams); } else { $catParams = new JRegistry(); } // c. Retrieve author parameters if using displaying AUTHOR/MYITEMS layouts, and merge them into category parameters if ($this->_authorid != 0) { $query = 'SELECT author_basicparams, author_catparams FROM #__flexicontent_authors_ext WHERE user_id = ' . $this->_authorid; $this->_db->setQuery($query); $author_extdata = $this->_db->loadObject(); if ($author_extdata) { // Merge author basic parameters $_author_basicreg = new JRegistry($author_extdata->author_basicparams); if ($_author_basicreg->get('orderbycustomfieldid') === "0") { $_author_basicreg->set('orderbycustomfieldid', ''); } $catParams->merge($_author_basicreg); // Merge author OVERRIDDEN category parameters $_author_catreg = new JRegistry($author_extdata->author_catparams); if ($_author_basicreg->get('override_currcat_config', 0)) { if ($_author_catreg->get('orderbycustomfieldid') === "0") { $_author_catreg->set('orderbycustomfieldid', ''); } $catParams->merge($_author_catreg); } } } // d. Retrieve inherited parameter and create parameter objects global $globalcats; $heritage_stack = array(); $inheritcid = $catParams->get('inheritcid', ''); $inheritcid_comp = $compParams->get('inheritcid', -1); $inherit_parent = $inheritcid === '-1' || $inheritcid === '' && $inheritcid_comp; // CASE A: inheriting from parent category tree if ($id && $inherit_parent && !empty($globalcats[$id]->ancestorsonly)) { $order_clause = 'level'; // 'FIELD(id, ' . $globalcats[$id]->ancestorsonly . ')'; $query = 'SELECT title, id, params FROM #__categories' . ' WHERE id IN ( ' . $globalcats[$id]->ancestorsonly . ')' . ' ORDER BY ' . $order_clause . ' DESC'; $this->_db->setQuery($query); $catdata = $this->_db->loadObjectList('id'); if (!empty($catdata)) { foreach ($catdata as $parentcat) { $parentcat->params = new JRegistry($parentcat->params); array_push($heritage_stack, $parentcat); $inheritcid = $parentcat->params->get('inheritcid', ''); $inherit_parent = $inheritcid === '-1' || $inheritcid === '' && $inheritcid_comp; if (!$inherit_parent) { break; } // Stop inheriting from further parent categories } } } else { if ($id && $inheritcid > 0 && !empty($globalcats[$inheritcid])) { $query = 'SELECT title, params FROM #__categories WHERE id = ' . $inheritcid; $this->_db->setQuery($query); $catdata = $this->_db->loadObject(); if ($catdata) { $catdata->params = new JRegistry($catdata->params); array_push($heritage_stack, $catdata); } } } // *************************** // Start merging of parameters // *************************** // 0. Start from component parameters $params = new JRegistry(); $params->merge($compParams); // 1. Merge category's inherited parameters (e.g. ancestor categories or specific category) while (!empty($heritage_stack)) { $catdata = array_pop($heritage_stack); if ($catdata->params->get('orderbycustomfieldid') === "0") { $catdata->params->set('orderbycustomfieldid', ''); } $params->merge($catdata->params); if ($debug_inheritcid) { array_push($merge_stack, "MERGED CATEGORY PARAMETERS of (inherit-from) category: " . $catdata->title); } } // 2. Merge category parameters (potentially overriden via author's category parameters) if ($catParams->get('orderbycustomfieldid') === "0") { $catParams->set('orderbycustomfieldid', ''); } $params->merge($catParams); if ($debug_inheritcid && $id) { array_push($merge_stack, "MERGED CATEGORY PARAMETERS of current category"); } if ($debug_inheritcid && $this->_authorid && !empty($_author_catreg) && $_author_catreg->get('override_currcat_config', 0)) { array_push($merge_stack, "MERGED CATEGORY PARAMETERS of (current) author: {$this->_authorid}"); } // g. Verify menu item points to current FLEXIcontent object, and then merge menu item parameters if (!empty($menu)) { $this->_menu_itemid = $menu->id; $view_ok = @$menu->query['view'] == 'category'; $cid_ok = @$menu->query['cid'] == $this->_id; $layout_ok = @$menu->query['layout'] == $this->_layout; // Examine author only for author layout, !! thus ignoring empty author_id when layout is 'myitems' or 'favs', for them this is set explicitely (* see populateCategoryState() function) $authorid_ok = $this->_layout != 'author' || @$menu->query['authorid'] == $this->_authorid; // Examine tagid only for tags layout $tagid_ok = $this->_layout != 'tags' || @$menu->query['tagid'] == $this->_tagid; // We will merge menu parameters last, thus overriding the default categories parameters if either // (a) override is enabled in the menu or (b) category Layout is 'myitems' or 'favs' or 'tags' or 'mcats' which has no default parameters $overrideconf = $menu_params->get('override_defaultconf', 0) || $this->_layout == 'myitems' || $this->_layout == 'favs' || $this->_layout == 'mcats' || $this->_layout == 'tags'; $menu_matches = $view_ok && $cid_ok & $layout_ok && $authorid_ok; if ($menu_matches && $overrideconf) { // Add - all - menu parameters related or not related to category parameters override if ($menu_params->get('orderbycustomfieldid') === "0") { $menu_params->set('orderbycustomfieldid', ''); } $params->merge($menu_params); if ($debug_inheritcid) { array_push($merge_stack, "MERGED CATEGORY PARAMETERS of (current) menu item: " . $menu->id); } } else { if ($menu_matches) { // Add menu parameters - not - related to category parameters override $params->set('item_depth', $menu_params->get('item_depth')); $params->set('page_title', $menu_params->get('page_title')); $params->set('show_page_heading', $menu_params->get('show_page_heading')); $params->set('page_heading', $menu_params->get('page_heading')); $params->set('pageclass_sfx', $menu_params->get('pageclass_sfx')); } } } // Parameters meant for lists $params->set('show_editbutton', $params->get('show_editbutton_lists', 1)); // Parameter meant for lists $params->set('show_title', $params->get('show_title_lists', 1)); // Parameter meant for lists $params->set('link_titles', $params->get('link_titles_lists', 1)); // Parameter meant for lists // Set filter values (initial or locked) via configuration parameters if ($params->get('use_persistent_filters')) { FlexicontentFields::setFilterValues($params, 'persistent_filters', $is_persistent = 1); } FlexicontentFields::setFilterValues($params, 'initial_filters', $is_persistent = 0); // Bugs of v2.0 RC2 if (FLEXI_J16GE) { if (is_array($orderbycustomfieldid = $params->get('orderbycustomfieldid', 0))) { JError::raiseNotice(0, "FLEXIcontent versions up to to v2.0 RC2a, had a bug, please open category and resave it, you can use 'copy parameters' to quickly update many categories"); $params->set('orderbycustomfieldid', $orderbycustomfieldid[0]); } if (preg_match("/option=com_user&/", $params->get('login_page', ''))) { JError::raiseNotice(0, "The login url seems to be wrongly set in the FLEXIcontent component configuration.<br /> Please replace: <u>option=com_user</u> with <u>option=com_users</u>"); $params->set('login_page', str_replace("com_user&", "com_users&", $params->get('login_page', ''))); } } // Retrieve Layout's parameters, also deciding the layout $this->decideLayout($params); $layoutParams = $this->getLayoutparams(); $layoutParams = new JRegistry($layoutParams); //print_r($layoutParams); // Allow global layout parameters to be inherited properly $this->_params = clone $layoutParams; $this->_params->merge($params); $merge_stack[1] = "MERGED LAYOUT PARAMETERS of '" . $this->_clayout . "'"; if ($debug_inheritcid) { $app->enqueueMessage(implode("<br/>\n", $merge_stack)); } // Also set into a global variable global $fc_catview; $fc_catview['params'] = $this->_params; }
function shGetDefaultDisplayNum($menuItemid, $url, $fromSession = false, $includeBlogLinks = false) { $app = JFactory::getApplication(); // default value is general configuration list length param $ret = $app->getCfg('list_limit', 10); // get elements of the url $option = shGetURLVar($url, 'option'); $layout = shGetURLVar($url, 'layout'); if (empty($layout)) { $layout = 'default'; } $view = shGetURLVar($url, 'view'); // if there is a menu item, we can try read more params if (!empty($menuItemid)) { // itemid, try read params from the menu item $menu = JFactory::getApplication()->getMenu(); $menuItem = $menu->getItem($menuItemid); // load menu item from DB if (empty($menuItem)) { return $ret; } // if none, default jimport('joomla.html.parameter'); // Load the parameters. Merge Global and Menu Item params into new object $currentOption = JRequest::getCmd('option'); $params = new JRegistry($menuItem->params); // get params from menu item if (!empty($currentOption)) { $appParams = $app->getParams(); $params->merge($appParams); } // layout = blog and frontpage if ($option == 'com_content' && $layout == 'blog' || $option == 'com_content' && $view == 'featured') { $num_leading_articles = $params->get('num_leading_articles'); $num_intro_articles = $params->get('num_intro_articles'); //adjust limit and listLimit for page calculation as blog views include //# of links in the limit value, while it should not be included for // page number calculation $num_links = $includeBlogLinks ? $params->get('num_links') : 0; $ret = $num_leading_articles + $num_intro_articles + $num_links; // calculate how many items on a page return $ret; } // elements with a display_num parameter $displayNum = intval($params->get('display_num')); $ret = !empty($displayNum) ? $displayNum : $ret; } if ($fromSession) { // now handle special cases if ($option == 'com_content' && $layout != 'blog' && ($view == 'category' || $view == 'section')) { $limit = $app->getUserStateFromRequest('com_content.sh.' . $view . '.' . $layout . '.limit', 'limit', null); if (!is_null($limit)) { return $limit; } } if ($option == 'com_contact') { $limit = $app->getUserState($option . '.' . $view . '.limit'); if (!is_null($limit)) { return $limit; } } if ($option == 'com_weblinks') { $limit = $app->getUserState($option . '.limit'); if (!is_null($limit)) { return $limit; } } } // return calculated value return $ret; }
public static function getAjax() { $input = JFactory::getApplication()->input; jimport('joomla.application.module.helper'); require_once JPATH_BASE . '/administrator/components/com_modules/models/module.php'; $lang = JFactory::getLanguage(); $lang->load('mod_featcats', JPATH_SITE, $lang->getTag(), true); $modModel = JModelLegacy::getInstance('Module', 'ModulesModel', array('ignore_request' => true)); $mid = $input->getInt('mid'); $mymodule = $modModel->getItem($mid); $myparams = new JRegistry(); $myparams->loadArray($mymodule->params); $myparams->mid = $mid; $module = JModuleHelper::getModule('mod_featcats'); $registry = new JRegistry(); $registry->loadString($module->params); $registry->merge($myparams); $registry->set('mid', $mid); $registry->set('ajaxed', 1); $module->params = $registry->toString(); return JModuleHelper::renderModule($module); }
private function chain_install(&$parent) { $manifest = $parent->get("manifest"); if (!isset($manifest->chain->extension)) { return; } $result = array(); foreach ($manifest->chain->extension as $extension) { // We absolutely need to create a new installer instance each cycle, // otherwise the first failing extension would roll-back previuosly installed extensions. // Note that the library is the first in install chain and it contains the language files. $installer = new JInstaller(); $attributes = $extension->attributes(); $item = $parent->getParent()->getPath("source") . '/' . $attributes["directory"] . '/' . $attributes["name"]; $result["type"] = (string) $attributes["type"]; $result["result"] = $installer->install($item) ? "INSTALLED" : "NOT_INSTALLED"; $this->results[(string) $attributes["name"]] = $result; } // If Installscript is running, the component is already installed $result["type"] = "COMPONENT"; $result["result"] = "INSTALLED"; $this->results[$this->component_name] = $result; // Language files are installed within the library $result["type"] = "LANGUAGES"; $result["result"] = $this->results["lib_" . $this->extension_name]["result"]; $this->results["lan_" . $this->extension_name] = $result; if ($this->event == 'install') { $params = array(); $params["bubble_url"] = JURI::root() . "media/oziochat/images/chat-bubble.png"; $table = JTable::getInstance('Module'); if ($table->load(array('module' => 'mod_oziochat'))) { $dbParameter = new JRegistry(); $dbParameter->loadString($table->params); $parameter = new JRegistry(); $parameter->loadArray($params); $parameter->merge($dbParameter); $table->params = (string) $parameter; if (!$table->store()) { //echo $table->getError().'<br />'; //return; } } } }
/** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * return void * * @since 1.0.0 */ protected function populateState($ordering = null, $direction = null) { // Initiliase variables. $app = JFactory::getApplication(); $pk = $app->input->getInt('id'); $this->setState('category.id', $pk); // Load the parameters. Merge Global and Menu Item params into new object $params = $app->getParams('com_content'); if ($menu = $app->getMenu()->getActive()) { $mergedParams = $menu->params instanceof JRegistry ? clone $menu->params : new JRegistry($menu->params); } else { $mergedParams = new JRegistry(); } $mergedParams->merge($params); $this->setState('params', $mergedParams); $user = JFactory::getUser(); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) { // limit to published for people who can't edit or edit.state. $this->setState('filter.published', 1); // Filter by start and end dates. $nullDate = $db->Quote($db->getNullDate()); $nowDate = $db->Quote(JFactory::getDate()->toSQL()); $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); } else { $this->setState('filter.published', array(0, 1, 2)); } // process show_noauth parameter if (!$params->get('show_noauth')) { $this->setState('filter.access', true); } else { $this->setState('filter.access', false); } // Optional filter text $this->setState('list.filter', $app->input->getString('filter-search')); // filter.order $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'a.ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $this->setState('list.start', $app->input->get('limitstart', 0, 'uint')); // set limit for query. If list, use parameter. If blog, add blog parameters for limit. if ($app->input->get('layout') == 'blog' || $params->get('layout_type') == 'blog') { $limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links'); $this->setState('list.links', $params->get('num_links')); } else { $limit = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint'); } $this->setState('list.limit', $limit); // set the depth of the category query based on parameter $showSubcategories = $params->get('show_subcategory_content', '0'); if ($showSubcategories) { $this->setState('filter.max_category_levels', $params->get('show_subcategory_content', '1')); $this->setState('filter.subcategories', true); } $this->setState('filter.language', JLanguageMultilang::isEnabled()); $this->setState('layout', $app->input->get('layout')); }
public function getIndexCount() { $cparams = Djcatalog2Helper::getParams(); $params = new JRegistry(); $params->merge($cparams); $letters_str = trim($cparams->get('atoz_letters', '')); $letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); if (!empty($letters_str)) { $letters = explode(',', $letters_str); } $obj = array(); $query = ''; if ((int) $params->get('atoz_check_available', 0) == 1) { $db = JFactory::getDBO(); $model = JModelLegacy::getInstance('Items', 'Djcatalog2Model'); $state = $model->getState(); //$params->set('product_catalogue', 0); //$params->set('limit_items_show', 0); $model->setState('params', $params); $model->setState('list.start', 0); $model->setState('list.limit', 0); $model->setState('list.select', 'i.id'); $model->setState('filter.catalogue', false); $model->setState('filter.index', false); $model->setState('list.ordering', 'i.id'); $model->setState('list.direction', 'asc'); $items_query = $model->buildQuery(); $select = $join = array(); foreach ($letters as $letter) { if ($letter && $letter != ',') { $tbljoin = 'table_' . $letter; if ($letter == 'num') { $select[] = ' count(' . $tbljoin . '.id) as count_' . $letter; $join[] = 'left join #__djc2_items as ' . $tbljoin . ' on ' . $tbljoin . '.id = items.id and ' . $tbljoin . '.name REGEXP \'^[0-9]\''; } else { $select[] = ' count(' . $tbljoin . '.id) as count_' . $letter; $join[] = 'left join #__djc2_items as ' . $tbljoin . ' on ' . $tbljoin . '.id = items.id and lower(' . $tbljoin . '.name) like \'' . $letter . '%\''; } } } $query .= 'SELECT ' . implode(', ', $select) . PHP_EOL . ' FROM #__djc2_items as items ' . PHP_EOL . implode(PHP_EOL, $join) . ' where items.id in (' . $items_query . ')'; $db->setQuery($query); $obj = $db->loadAssoc(); foreach ($obj as $k => $v) { $justletter = str_replace('count_', '', $k); $obj[$justletter] = $k; unset($obj[$k]); } } if (empty($obj)) { $obj = array(); foreach ($letters as $letter) { if ($letter && $letter != ',') { $obj[$letter] = 1; } } } return $obj; }
/** * Method to load parameters * * @access private * @return void * @since 1.5 */ function _loadParams() { if ($this->_params !== NULL) { return; } $app = JFactory::getApplication(); $menu = $app->getMenu()->getActive(); // Retrieve active menu // Get the COMPONENT only parameter $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); // Merge the active menu parameters if ($menu) { $params->merge($menu->params); } $this->_params = $params; }
public static function getParams($catId = null, $listingId = null) { // If set listingId but don't set catId -> get catId by listingId if (!$catId && $listingId) { $listingObj = self::getListingById($listingId); if ($listingObj) { $catId = $listingObj->cat_id; } } // Only override if cat existed, override by params of top level cat // Find the top level category, assign to $catId if top level cat is found if ($catId) { $path = self::getCategoryPath($catId); $rootCat = $path[0]; } else { $rootCat = JUDirectoryFrontHelperCategory::getRootCategory(); } $catIdToGetParams = $rootCat->id; // Cache by catId $storeId = md5(__METHOD__ . "::{$catIdToGetParams}"); // Set params by top level catId(or root) if it has not already set if (!isset(self::$cache[$storeId])) { // Get global config params(of root cat) by default $registry = new JRegistry(); $registry->loadString($rootCat->config_params); // Override params from active menu if is a menu of component(Use merge to ignore empty string and null param value) $app = JFactory::getApplication(); $activeMenu = $app->getMenu()->getActive(); if ($activeMenu && $activeMenu->component == 'com_judirectory') { $registry->merge($activeMenu->params); } self::$cache[$storeId] = $registry; } return self::$cache[$storeId]; }
'); if (isset($_REQUEST['skin']) && $skins->{$_REQUEST['skin']}) { $skin = $skins->{$_REQUEST['skin']}[0]; foreach ($skin as $s) { $name = $s->getName(); $value = (string) $s; $params->set($name, $value); } $_SESSION[$module->module . "_params"] = $params->toString(); } } $params->def('theme', 'elegant'); $theme = $params->get('theme', 'elegant'); if (is_object($theme)) { //For 1.6, 1.7, 2.5 $params->merge(new JRegistry($params->get('theme'))); $params->set('theme', $theme->theme); $theme = $params->get('theme'); } $searchresultwidth = $params->get('resultareawidth', 250); $dynamicresult = $params->get('dynamicresult', 0); $productimageheight = $params->get('productimageheight', 40); $productsperplugin = $params->get('itemsperplugin', 3); $minchars = $params->get('minchars', 2); $resultalign = $params->get('resultalign', 0); // 0-left 1-right $scrolling = $params->get('scrolling', 1); $intro = $params->get('intro', 1); $scount = $params->get('scount', 10); $stext = $params->get('stext'); $catchooser = $params->get('catchooser', 1);
/** * @return String */ function display($params, $return = false) { /*echo '<p>Before</p><pre>'; print_r($params); echo '</pre>';*/ $this->params->merge($params); /* echo '<p>After</p><pre>'; print_r($this->params); echo '</pre>';*/ $tmpl = $this->params->get('display', 'form'); $this->params->set('style', $this->params->get('style') && $this->params->get('style') != 'none' && $this->params->get('style') != -1 ? $this->params->get('style') : false); $hiddenFields = array(); if ($tmpl != "popup") { $mailto = $this->params->get('mailto'); if (!$mailto || !strlen($mailto)) { $this->params->set('message', JText::_('PLG_SYSTEM_CONTACTFORMPRO_MAILTO_MISSING')); $this->params->set('label', 'WARNING: contactformpro tag must have a mailto attribute'); } if ($this->params->get('error_message')) { $hiddenFields['error_message'] = $this->params->get('error_message'); } if ($this->params->get('success_message')) { $hiddenFields['success_message'] = $this->params->get('success_message'); } if (!self::validateKey($this->params->get('appkey'))) { $this->params->set('copy', '<p style="text-align:center;font-size:80% !important;">ContactForm plugin by <a href="http://joomfever.com" class="cfp-copy" title="ContactForm plugin for Joomla!">uuebdesign.com</a></p>'); } } else { //$tmpl == "popup" $this->params->set('label', html_entity_decode($this->params->get('label', JText::_('PLG_SYSTEM_CONTACTFORMPRO_TEXT_FOR_POPUP')))); } $user = JFactory::getUser(); if ($user->id && $tmpl != 'popup') { $this->params->set('sender_name', $user->name); $this->params->set('sender_email', $user->email); } if ($tmpl != 'modal') { $id = $this->params->get('id', 'cfpForm_' . rand(1, 99999)); $this->params->set("id", $id); if ($tmpl == 'popup') { $this->params->set("display", "modal"); } $json = $this->params->get('id') . '=' . json_encode($this->params->toArray()); $document = JFactory::getDocument(); $document->addScriptDeclaration($json); JHtml::_('behaviour.framework'); if ($style = $this->params->get('style')) { $document->addStyleSheet(CFP_URI . 'styles/icons.css'); $document->addStyleSheet(CFP_URI . 'styles/blank.css'); if (is_dir(implode(DS, array(CFP_PATH, 'styles', $style)))) { $document->addStyleSheet(CFP_URI . '/styles/' . $style . '/style.css'); } else { if (is_dir(implode(DS, array(JF_PREMIUM_PATH, 'contactformpro', $style)))) { $document->addStyleSheet(JF_PREMIUM_URI . 'contactformpro/' . $style . '/style.css'); } } } } $footer = defined('JF_PREMIUM_PATH') ? '' : '<p class="jf-copy" style="display:block !important;position:absolute;bottom:0;left:0;background: none #ffffff;margin:0;padding:0;"><small><a href="http://joomfever.com/extensions-joomla/viewcategory/24-banner-rotator">Joomla! Banner Rotator</a></small></p>'; $tmplPath = 'tmpl' . DS . $tmpl . '.php'; if (!file_exists(dirname(__FILE__) . DS . $tmplPath)) { $tmplPath = 'tmpl' . DS . 'form.php'; } if ($return) { ob_start(); } include $tmplPath; if ($return) { $content = ob_get_length() ? ob_get_clean() : ''; } return $content; }
# ------------------------------------------------------------------------ # author Jesús Vargas Garita # Copyright (C) 2010 www.joomlahill.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://www.joomlahill.com # Technical Support: Forum - http://www.joomlahill.com/forum -------------------------------------------------------------------------*/ define('_JEXEC', 1); define('DS', DIRECTORY_SEPARATOR); define('JPATH_BASE', dirname(__FILE__) . DS . '..' . DS . '..' . DS . '..'); require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php'; require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php'; $app = JFactory::getApplication('site'); $app->initialise(); $document = JFactory::getDocument(); require_once JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_modules' . DS . 'models' . DS . 'module.php'; $modModel = JModelLegacy::getInstance('Module', 'ModulesModel', array('ignore_request' => true)); $mid = JRequest::getInt('mid'); $mymodule = $modModel->getItem($mid); $myparams = new JRegistry(); $myparams->loadArray($mymodule->params); $myparams->mid = $mid; $module = JModuleHelper::getModule('mod_featcats'); $registry = new JRegistry(); $registry->loadString($module->params); $registry->merge($myparams); $registry->set('mid', $mid); $registry->set('ajaxed', 1); $module->params = $registry->toString(); $renderer = $document->loadRenderer('module'); echo $renderer->render($module, array('style' => 'none'));
/** * Creates the item page * * @since 1.0 */ function display($tpl = null) { // ******************************** // Initialize variables, flags, etc // ******************************** global $globalcats; $categories = $globalcats; $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $document = JFactory::getDocument(); $config = JFactory::getConfig(); $session = JFactory::getSession(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $option = JRequest::getVar('option'); $nullDate = $db->getNullDate(); // Get the COMPONENT only parameters // Get component parameters $params = new JRegistry(); $cparams = JComponentHelper::getParams('com_flexicontent'); $params->merge($cparams); $params = clone JComponentHelper::getParams('com_flexicontent'); // Some flags $enable_translation_groups = flexicontent_db::useAssociations(); //$params->get("enable_translation_groups"); $print_logging_info = $params->get('print_logging_info'); if ($print_logging_info) { global $fc_run_times; } // ***************** // Load JS/CSS files // ***************** // Add css to document $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VERSION); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VERSION); // Fields common CSS $document->addStyleSheetVersion(JURI::root(true) . '/components/com_flexicontent/assets/css/flexi_form_fields.css', FLEXI_VERSION); // Add JS frameworks flexicontent_html::loadFramework('select2'); $prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable'); flexicontent_html::loadFramework('flexi-lib'); // Add js function to overload the joomla submitform validation JHTML::_('behavior.formvalidation'); // load default validation JS to make sure it is overriden $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/admin.js', FLEXI_VERSION); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VERSION); // Add js function for custom code used by FLEXIcontent item form $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/itemscreen.js', FLEXI_VERSION); // *********************** // Get data from the model // *********************** if ($print_logging_info) { $start_microtime = microtime(true); } $model = $this->getModel(); $item = $model->getItem(); $form = $this->get('Form'); if ($print_logging_info) { $fc_run_times['get_item_data'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // *************************** // Get Associated Translations // *************************** if ($enable_translation_groups) { $langAssocs = $this->get('LangAssocs'); } $langs = FLEXIUtilities::getLanguages('code'); // Get item id and new flag $cid = $model->getId(); $isnew = !$cid; // Create and set a unique item id for plugins that needed it if ($cid) { $unique_tmp_itemid = $cid; } else { $unique_tmp_itemid = $app->getUserState('com_flexicontent.edit.item.unique_tmp_itemid'); $unique_tmp_itemid = $unique_tmp_itemid ? $unique_tmp_itemid : date('_Y_m_d_h_i_s_', time()) . uniqid(true); } //print_r($unique_tmp_itemid); JRequest::setVar('unique_tmp_itemid', $unique_tmp_itemid); // Get number of subscribers $subscribers = $model->getSubscribersCount(); // ****************** // Version Panel data // ****************** // Get / calculate some version related variables $versioncount = $model->getVersionCount(); $versionsperpage = $params->get('versionsperpage', 10); $pagecount = (int) ceil($versioncount / $versionsperpage); // Data need by version panel: (a) current version page, (b) currently active version $current_page = 1; $k = 1; $allversions = $model->getVersionList(); foreach ($allversions as $v) { if ($k > 1 && ($k - 1) % $versionsperpage == 0) { $current_page++; } if ($v->nr == $item->version) { break; } $k++; } // Finally fetch the version data for versions in current page $versions = $model->getVersionList(($current_page - 1) * $versionsperpage, $versionsperpage); // Create display of average rating $ratings = $model->getRatingDisplay(); // ***************** // Type related data // ***************** // Get available types and the currently selected/requested type $types = $model->getTypeslist(); $typesselected = $model->getTypesselected(); // Get and merge type parameters $tparams = $this->get('Typeparams'); $tparams = new JRegistry($tparams); $params->merge($tparams); // Apply type configuration if it type is set // Get user allowed permissions on the item ... to be used by the form rendering // Also hide parameters panel if user can not edit parameters $perms = $this->_getItemPerms($item); if (!$perms['canparams']) { $document->addStyleDeclaration('#details-options {display:none;}'); } // ****************** // Create the toolbar // ****************** $toolbar = JToolBar::getInstance('toolbar'); $tip_class = FLEXI_J30GE ? ' hasTooltip' : ' hasTip'; // SET toolbar title if ($cid) { JToolBarHelper::title(JText::_('FLEXI_EDIT_ITEM'), 'itemedit'); // Editing existing item } else { JToolBarHelper::title(JText::_('FLEXI_NEW_ITEM'), 'itemadd'); // Creating new item } // ************** // Common Buttons // ************** // Applying new item type is a special case that has not loaded custom fieds yet JToolBarHelper::apply($item->type_id ? 'items.apply' : 'items.apply_type', !$isnew ? 'FLEXI_APPLY' : ($typesselected->id ? 'FLEXI_ADD' : 'FLEXI_APPLY_TYPE'), false); /*if (!$isnew || $item->version) flexicontent_html::addToolBarButton( 'FLEXI_FAST_APPLY', $btn_name='apply_ajax', $full_js="Joomla.submitbutton('items.apply_ajax')", $msg_alert='', $msg_confirm='', $btn_task='items.apply_ajax', $extra_js='', $btn_list=false, $btn_menu=true, $btn_confirm=false, $btn_class="".$tip_class, $btn_icon="icon-loop", 'data-placement="bottom" title="Fast saving, without reloading the form. <br/><br/>Note: new files will not be uploaded, <br/>- in such a case please use \'Apply\'"');*/ if (!$isnew || $item->version) { JToolBarHelper::save('items.save'); } if (!$isnew || $item->version) { JToolBarHelper::custom('items.saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false); } JToolBarHelper::cancel('items.cancel'); // *********************** // Add a preview button(s) // *********************** //$_sh404sef = JPluginHelper::isEnabled('system', 'sh404sef') && $config->get('sef'); $_sh404sef = defined('SH404SEF_IS_RUNNING') && $config->get('sef'); if ($cid) { // Domain URL and autologin vars $server = JURI::getInstance()->toString(array('scheme', 'host', 'port')); $autologin = ''; //$params->get('autoflogin', 1) ? '&fcu='.$user->username . '&fcp='.$user->password : ''; // Check if we are in the backend, in the back end we need to set the application to the site app instead // we do not remove 'isAdmin' check so that we can copy later without change, e.g. to a plugin $isAdmin = JFactory::getApplication()->isAdmin(); if ($isAdmin && !$_sh404sef) { JFactory::$application = JApplication::getInstance('site'); } // Create the URL $item_url = FlexicontentHelperRoute::getItemRoute($item->id . ':' . $item->alias, $categories[$item->catid]->slug) . ($item->language != '*' ? '&lang=' . substr($item->language, 0, 2) : ''); $item_url = $_sh404sef ? Sh404sefHelperGeneral::getSefFromNonSef($item_url, $fullyQualified = true, $xhtml = false, $ssl = null) : JRoute::_($item_url); // Check if we are in the backend again // In backend we need to remove administrator from URL as it is added even though we've set the application to the site app if ($isAdmin && !$_sh404sef) { $admin_folder = str_replace(JURI::root(true), '', JURI::base(true)); $item_url = str_replace($admin_folder . '/', '/', $item_url); // Restore application JFactory::$application = JApplication::getInstance('administrator'); } $previewlink = $item_url . (strstr($item_url, '?') ? '&' : '?') . 'preview=1' . $autologin; //$previewlink = str_replace('&', '&', $previewlink); //$previewlink = JRoute::_(JURI::root() . FlexicontentHelperRoute::getItemRoute($item->id.':'.$item->alias, $categories[$item->catid]->slug)) .$autologin; // PREVIEW for latest version if (!$params->get('use_versioning', 1) || $item->version == $item->current_version && $item->version == $item->last_version) { $toolbar->appendButton('Custom', '<button class="preview btn btn-small btn-info spaced-btn" onClick="window.open(\'' . $previewlink . '\');"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('Preview') . '</button>', 'preview'); } else { // Add a preview button for (currently) LOADED version of the item $previewlink_loaded_ver = $previewlink . '&version=' . $item->version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_loaded_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FORM_LOADED_VERSION') . ' [' . $item->version . ']</button>', 'preview'); // Add a preview button for currently ACTIVE version of the item $previewlink_active_ver = $previewlink . '&version=' . $item->current_version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_active_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_FRONTEND_ACTIVE_VERSION') . ' [' . $item->current_version . ']</button>', 'preview'); // Add a preview button for currently LATEST version of the item $previewlink_last_ver = $previewlink; //'&version='.$item->last_version; $toolbar->appendButton('Custom', '<button class="preview btn btn-small" onClick="window.open(\'' . $previewlink_last_ver . '\');" target="_blank"><span title="' . JText::_('Preview') . '" class="icon-screen"></span>' . JText::_('FLEXI_PREVIEW_LATEST_SAVED_VERSION') . ' [' . $item->last_version . ']</button>', 'preview'); } JToolBarHelper::spacer(); JToolBarHelper::divider(); JToolBarHelper::spacer(); } // ************************ // Add modal layout editing // ************************ if ($perms['cantemplates']) { JToolBarHelper::divider(); if (!$isnew || $item->version) { flexicontent_html::addToolBarButton('FLEXI_EDIT_LAYOUT', $btn_name = 'apply_ajax', $full_js = "var url = jQuery(this).attr('data-href'); fc_showDialog(url, 'fc_modal_popup_container'); return false;", $msg_alert = '', $msg_confirm = '', $btn_task = 'items.apply_ajax', $extra_js = '', $btn_list = false, $btn_menu = true, $btn_confirm = false, $btn_class = "btn-info" . $tip_class, $btn_icon = "icon-pencil", 'data-placement="bottom" data-href="index.php?option=com_flexicontent&view=template&type=items&tmpl=component&ismodal=1&folder=' . $item->itemparams->get('ilayout', $tparams->get('ilayout', 'default')) . '" title="Edit the display layout of this item. <br/><br/>Note: this layout maybe assigned to content types or other items, thus changing it will effect them too"'); } } // Check if saving an item that translates an original content in site's default language $site_default = substr(flexicontent_html::getSiteDefaultLang(), 0, 2); $is_content_default_lang = $site_default == substr($item->language, 0, 2); // ***************************************************************************** // Get (CORE & CUSTOM) fields and their VERSIONED values and then // (a) Apply Content Type Customization to CORE fields (label, description, etc) // (b) Create the edit html of the CUSTOM fields by triggering 'onDisplayField' // ***************************************************************************** if ($print_logging_info) { $start_microtime = microtime(true); } $fields = $this->get('Extrafields'); $item->fields =& $fields; if ($print_logging_info) { $fc_run_times['get_field_vals'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } if ($print_logging_info) { $start_microtime = microtime(true); } $jcustom = $app->getUserState('com_flexicontent.edit.item.custom'); //print_r($jcustom); foreach ($fields as $field) { // a. Apply CONTENT TYPE customizations to CORE FIELDS, e.g a type specific label & description // NOTE: the field parameters are already created so there is not need to call this for CUSTOM fields, which do not have CONTENT TYPE customizations if ($field->iscore) { FlexicontentFields::loadFieldConfig($field, $item); } // b. Create field 's editing HTML (the form field) // NOTE: this is DONE only for CUSTOM fields, since form field html is created by the form for all CORE fields, EXCEPTION is the 'text' field (see bellow) if (!$field->iscore) { if (isset($jcustom[$field->name])) { $field->value = array(); foreach ($jcustom[$field->name] as $i => $_val) { $field->value[$i] = $_val; } } $is_editable = !$field->valueseditable || $user->authorise('flexicontent.editfieldvalues', 'com_flexicontent.field.' . $field->id); if ($is_editable) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayField', array(&$field, &$item)); if ($field->untranslatable) { $field->html = (!isset($field->html) ? '<div class="fc-mssg-inline fc-warning" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_PLEASE_PUBLISH_THIS_PLUGIN') . '</div><div class="clear"></div>' : '') . '<div class="alert alert-info fc-small fc-iblock" style="margin:0 4px 6px 4px; max-width: unset;">' . JText::_('FLEXI_FIELD_VALUE_IS_NON_TRANSLATABLE') . '</div>' . "\n" . (isset($field->html) ? '<div class="clear"></div>' . $field->html : ''); } } else { if ($field->valueseditable == 1) { $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>'; } else { if ($field->valueseditable == 2) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = '<div class="fc-mssg fc-note">' . JText::_($field->parameters->get('no_acc_msg_form') ? $field->parameters->get('no_acc_msg_form') : 'FLEXI_NO_ACCESS_LEVEL_TO_EDIT_FIELD') . '</div>' . "\n" . $field->display; } else { if ($field->valueseditable == 3) { FLEXIUtilities::call_FC_Field_Func($field->field_type, 'onDisplayFieldValue', array(&$field, $item)); $field->html = $field->display; } else { if ($field->valueseditable == 4) { $field->html = ''; $field->formhidden = 4; } } } } } } // c. Create main text field, via calling the display function of the textarea field (will also check for tabs) if ($field->field_type == 'maintext') { if (isset($item->item_translations)) { $shortcode = substr($item->language, 0, 2); foreach ($item->item_translations as $lang_id => $t) { if ($shortcode == $t->shortcode) { continue; } $field->name = array('jfdata', $t->shortcode, 'text'); $field->value[0] = html_entity_decode($t->fields->text->value, ENT_QUOTES, 'UTF-8'); FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); $t->fields->text->tab_labels = $field->tab_labels; $t->fields->text->html = $field->html; unset($field->tab_labels); unset($field->html); } } $field->name = 'text'; // NOTE: We use the text created by the model and not the text retrieved by the CORE plugin code, which maybe overwritten with JoomFish/Falang data $field->value[0] = $item->text; // do not decode special characters this was handled during saving ! // Render the field's (form) HTML FLEXIUtilities::call_FC_Field_Func('textarea', 'onDisplayField', array(&$field, &$item)); } } if ($print_logging_info) { $fc_run_times['render_field_html'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } // ************************* // Get tags used by the item // ************************* $usedtagsIds = $this->get('UsedtagsIds'); // NOTE: This will normally return the already set versioned value of tags ($item->tags) $usedtags = $model->getUsedtagsData($usedtagsIds); // ******************************* // Get categories used by the item // ******************************* if ($isnew) { // Case for preselected main category for new items $maincat = $item->catid ? $item->catid : JRequest::getInt('maincat', 0); if (!$maincat) { $maincat = $app->getUserStateFromRequest($option . '.items.filter_cats', 'filter_cats', '', 'int'); } if ($maincat) { $selectedcats = array($maincat); $item->catid = $maincat; } else { $selectedcats = array(); } if ($tparams->get('cid_default')) { $selectedcats = $tparams->get('cid_default'); } if ($tparams->get('catid_default')) { $item->catid = $tparams->get('catid_default'); } } else { // NOTE: This will normally return the already set versioned value of categories ($item->categories) $selectedcats = $this->get('Catsselected'); } //$selectedcats = $isnew ? array() : $fields['categories']->value; //echo "<br/>row->tags: "; print_r($item->tags); //echo "<br/>usedtagsIds: "; print_r($usedtagsIds); //echo "<br/>usedtags (data): "; print_r($usedtags); //echo "<br/>row->categories: "; print_r($item->categories); //echo "<br/>selectedcats: "; print_r($selectedcats); // ********************************************************************************************* // Build select lists for the form field. Only few of them are used in J1.6+, since we will use: // (a) form XML file to declare them and then (b) getInput() method form field to create them // ********************************************************************************************* // First clean form data, we do this after creating the description field which may contain HTML JFilterOutput::objectHTMLSafe($item, ENT_QUOTES); $lists = array(); // build state list $non_publishers_stategrp = $perms['isSuperAdmin'] || $item->state == -3 || $item->state == -4; $special_privelege_stategrp = $item->state == 2 || $perms['canarchive'] || ($item->state == -2 || $perms['candelete']); $state = array(); // Using <select> groups if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_PUBLISHERS_WORKFLOW_STATES')); } $state[] = JHTML::_('select.option', 1, JText::_('FLEXI_PUBLISHED')); $state[] = JHTML::_('select.option', 0, JText::_('FLEXI_UNPUBLISHED')); $state[] = JHTML::_('select.option', -5, JText::_('FLEXI_IN_PROGRESS')); // States reserved for workflow if ($non_publishers_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_NON_PUBLISHERS_WORKFLOW_STATES')); } if ($item->state == -3 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -3, JText::_('FLEXI_PENDING')); } if ($item->state == -4 || $perms['isSuperAdmin']) { $state[] = JHTML::_('select.option', -4, JText::_('FLEXI_TO_WRITE')); } // Special access states if ($special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); $state[] = JHTML::_('select.optgroup', JText::_('FLEXI_SPECIAL_ACTION_STATES')); } if ($item->state == 2 || $perms['canarchive']) { $state[] = JHTML::_('select.option', 2, JText::_('FLEXI_ARCHIVED')); } if ($item->state == -2 || $perms['candelete']) { $state[] = JHTML::_('select.option', -2, JText::_('FLEXI_TRASHED')); } // Close last <select> group if ($non_publishers_stategrp || $special_privelege_stategrp) { $state[] = JHTML::_('select.optgroup', ''); } $fieldname = 'jform[state]'; $elementid = 'jform_state'; $class = 'use_select2_lib'; $attribs = 'class="' . $class . '"'; $lists['state'] = JHTML::_('select.genericlist', $state, $fieldname, $attribs, 'value', 'text', $item->state, $elementid); if (!FLEXI_J16GE) { $lists['state'] = str_replace('<optgroup label="">', '</optgroup>', $lists['state']); } // *** BOF: J2.5 SPECIFIC SELECT LISTS if (FLEXI_J16GE) { // build featured flag $fieldname = 'jform[featured]'; $elementid = 'jform_featured'; /* $options = array(); $options[] = JHTML::_('select.option', 0, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['featured'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', $item->featured, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(0 => JText::_('FLEXI_NO'), 1 => JText::_('FLEXI_YES')); $lists['featured'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == $item->featured ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['featured'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['featured'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['featured'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } } // *** EOF: J1.5 SPECIFIC SELECT LISTS // build version approval list $fieldname = 'jform[vstate]'; $elementid = 'jform_vstate'; /* $options = array(); $options[] = JHTML::_('select.option', 1, JText::_( 'FLEXI_NO' ) ); $options[] = JHTML::_('select.option', 2, JText::_( 'FLEXI_YES' ) ); $attribs = FLEXI_J16GE ? ' style ="float:left!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['vstate'] = JHTML::_('select.radiolist', $options, $fieldname, $attribs, 'value', 'text', 2, $elementid); */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $i = 1; $options = array(1 => JText::_('FLEXI_NO'), 2 => JText::_('FLEXI_YES')); $lists['vstate'] = ''; foreach ($options as $option_id => $option_label) { $checked = $option_id == 2 ? ' checked="checked"' : ''; $elementid_no = $elementid . '_' . $i; if (!$prettycheckable_added) { $lists['vstate'] .= '<label class="fccheckradio_lbl" for="' . $elementid_no . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . JText::_($option_label) . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['vstate'] .= ' <input type="radio" id="' . $elementid_no . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="' . $option_id . '" ' . $checked . $extra_params . ' />'; if (!$prettycheckable_added) { $lists['vstate'] .= ' ' . JText::_($option_label) . '</label>'; } $i++; } // build field for notifying subscribers if (!$subscribers) { $lists['notify'] = !$isnew ? JText::_('FLEXI_NO_SUBSCRIBERS_EXIST') : ''; } else { // b. Check if notification emails to subscribers , were already sent during current session $subscribers_notified = $session->get('subscribers_notified', array(), 'flexicontent'); if (!empty($subscribers_notified[$item->id])) { $lists['notify'] = JText::_('FLEXI_SUBSCRIBERS_ALREADY_NOTIFIED'); } else { // build favs notify field $fieldname = 'jform[notify]'; $elementid = 'jform_notify'; /* $attribs = FLEXI_J16GE ? ' style ="float:none!important;" ' : ''; // this is not right for J1.5' style ="float:left!important;" '; $lists['notify'] = '<input type="checkbox" name="jform[notify]" id="jform_notify" '.$attribs.' /> '. $lbltxt; */ $classes = !$prettycheckable_added ? '' : ' use_prettycheckable '; $attribs = ' class="' . $classes . '" '; $lbltxt = $subscribers . ' ' . JText::_($subscribers > 1 ? 'FLEXI_SUBSCRIBERS' : 'FLEXI_SUBSCRIBER'); if (!$prettycheckable_added) { $lists['notify'] .= '<label class="fccheckradio_lbl" for="' . $elementid . '">'; } $extra_params = !$prettycheckable_added ? '' : ' data-labeltext="' . $lbltxt . '" data-labelPosition="right" data-customClass="fcradiocheck"'; $lists['notify'] = ' <input type="checkbox" id="' . $elementid . '" data-element-grpid="' . $elementid . '" name="' . $fieldname . '" ' . $attribs . ' value="1" ' . $extra_params . ' checked="checked" />'; if (!$prettycheckable_added) { $lists['notify'] .= ' ' . $lbltxt . '</label>'; } } } // Retrieve author configuration $authorparams = flexicontent_db::getUserConfig($user->id); // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; '); JText::script('FLEXI_TOO_MANY_ITEM_CATEGORIES', true); // Creating categorories tree for item assignment, we use the 'create' privelege $actions_allowed = array('core.create'); // Featured categories form field $featured_cats_parent = $params->get('featured_cats_parent', 0); $featured_cats = array(); $enable_featured_cid_selector = $perms['multicat'] && $perms['canchange_featcat']; if ($featured_cats_parent) { $featured_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $featured_cats_parent, $depth_limit = 0); $disabled_cats = $params->get('featured_cats_parent_disable', 1) ? array($featured_cats_parent) : array(); $featured_sel = array(); foreach ($selectedcats as $item_cat) { if (isset($featured_tree[$item_cat])) { $featured_sel[] = $item_cat; } } $class = "use_select2_lib select2_list_selected"; $attribs = 'class="' . $class . '" multiple="multiple" size="8"'; $attribs .= $enable_featured_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[featured_cid][]'; $lists['featured_cid'] = ($enable_featured_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($featured_tree, $fieldname, $featured_sel, 3, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { // Do not display, if not configured or not allowed to the user $lists['featured_cid'] = false; } // Multi-category form field, for user allowed to use multiple categories $lists['cid'] = ''; $enable_cid_selector = $perms['multicat'] && $perms['canchange_seccat']; if (1) { if ($tparams->get('cid_allowed_parent')) { $cid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('cid_allowed_parent'), $depth_limit = 0); $disabled_cats = $tparams->get('cid_allowed_parent_disable', 1) ? array($tparams->get('cid_allowed_parent')) : array(); } else { $cid_tree =& $categories; $disabled_cats = array(); } // Get author's maximum allowed categories per item and set js limitation $max_cat_assign = !$authorparams ? 0 : intval($authorparams->get('max_cat_assign', 0)); $document->addScriptDeclaration(' max_cat_assign_fc = ' . $max_cat_assign . '; existing_cats_fc = ["' . implode('","', $selectedcats) . '"]; '); $class = "mcat use_select2_lib select2_list_selected"; $class .= $max_cat_assign ? " validate-fccats" : " validate"; $attribs = 'class="' . $class . '" multiple="multiple" size="20"'; $attribs .= $enable_cid_selector ? '' : ' disabled="disabled"'; $fieldname = 'jform[cid][]'; $skip_subtrees = $featured_cats_parent ? array($featured_cats_parent) : array(); $lists['cid'] = ($enable_cid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($cid_tree, $fieldname, $selectedcats, false, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees, $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { if (count($selectedcats) > 1) { foreach ($selectedcats as $catid) { $cat_titles[$catid] = $globalcats[$catid]->title; } $lists['cid'] .= implode(', ', $cat_titles); } else { $lists['cid'] = false; } } // Main category form field $class = 'scat use_select2_lib'; if ($perms['multicat']) { $class .= ' validate-catid'; } else { $class .= ' required'; } $attribs = 'class="' . $class . '"'; $fieldname = 'jform[catid]'; $enable_catid_selector = $isnew && !$tparams->get('catid_default') || !$isnew && empty($item->catid) || $perms['canchange_cat']; if ($tparams->get('catid_allowed_parent')) { $catid_tree = flexicontent_cats::getCategoriesTree($published_only = 1, $parent_id = $tparams->get('catid_allowed_parent'), $depth_limit = 0); $disabled_cats = $tparams->get('catid_allowed_parent_disable', 1) ? array($tparams->get('catid_allowed_parent')) : array(); } else { $catid_tree =& $categories; $disabled_cats = array(); } $lists['catid'] = false; if (!empty($catid_tree)) { $disabled = $enable_catid_selector ? '' : ' disabled="disabled"'; $attribs .= $disabled; $lists['catid'] = ($enable_catid_selector ? '' : '<label class="label" style="float:none; margin:0 6px 0 0 !important;">locked</label>') . flexicontent_cats::buildcatselect($catid_tree, $fieldname, $item->catid, 2, $attribs, true, true, $actions_allowed, $require_all = true, $skip_subtrees = array(), $disable_subtrees = array(), $custom_options = array(), $disabled_cats); } else { if (!$isnew && $item->catid) { $lists['catid'] = $globalcats[$item->catid]->title; } } //buid types selectlist $class = 'required use_select2_lib'; $attribs = 'class="' . $class . '"'; $fieldname = 'jform[type_id]'; $elementid = 'jform_type_id'; $lists['type'] = flexicontent_html::buildtypesselect($types, $fieldname, $typesselected->id, 1, $attribs, $elementid, $check_perms = true); //build languages list $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); if (!$isnew && $allowed_langs) { $allowed_langs[] = $item->language; } // We will not use the default getInput() function of J1.6+ since we want to create a radio selection field with flags // we could also create a new class and override getInput() method but maybe this is an overkill, we may do it in the future $lists['languages'] = flexicontent_html::buildlanguageslist('jform[language]', 'class="use_select2_lib"', $item->language, 2, $allowed_langs); // Label for current item state: published, unpublished, archived etc switch ($item->state) { case 0: $published = JText::_('FLEXI_UNPUBLISHED'); break; case 1: $published = JText::_('FLEXI_PUBLISHED'); break; case -1: $published = JText::_('FLEXI_ARCHIVED'); break; case -3: $published = JText::_('FLEXI_PENDING'); break; case -5: $published = JText::_('FLEXI_IN_PROGRESS'); break; case -4: default: $published = JText::_('FLEXI_TO_WRITE'); break; } // ************************************************************** // Handle Item Parameters Creation and Load their values for J1.5 // In J1.6+ we declare them in the item form XML file // ************************************************************** if (JHTML::_('date', $item->publish_down, 'Y') <= 1969 || $item->publish_down == $db->getNullDate() || empty($item->publish_down)) { $form->setValue('publish_down', null, ''); // Setting to text will break form date element } // **************************** // Handle Template related work // **************************** // (a) Get the templates structures used to create form fields for template parameters $themes = flexicontent_tmpl::getTemplates(); $tmpls_all = $themes->items; // (b) Get Content Type allowed templates $allowed_tmpls = $tparams->get('allowed_ilayouts'); $type_default_layout = $tparams->get('ilayout', 'default'); if (empty($allowed_tmpls)) { $allowed_tmpls = array(); } else { if (!is_array($allowed_tmpls)) { $allowed_tmpls = explode("|", $allowed_tmpls); } } // (c) Add default layout, unless all templates allowed (=array is empty) if (count($allowed_tmpls) && !in_array($type_default_layout, $allowed_tmpls)) { $allowed_tmpls[] = $type_default_layout; } // (d) Create array of template data according to the allowed templates for current content type if (count($allowed_tmpls)) { foreach ($tmpls_all as $tmpl) { if (in_array($tmpl->name, $allowed_tmpls)) { $tmpls[] = $tmpl; } } } else { $tmpls = $tmpls_all; } // (e) Apply Template Parameters values into the form fields structures foreach ($tmpls as $tmpl) { $jform = new JForm('com_flexicontent.template.item', array('control' => 'jform', 'load_data' => true)); $jform->load($tmpl->params); $tmpl->params = $jform; foreach ($tmpl->params->getGroup('attribs') as $field) { $fieldname = $field->__get('fieldname'); $value = $item->itemparams->get($fieldname); if (strlen($value)) { $tmpl->params->setValue($fieldname, 'attribs', $value); } } } // ****************************** // Assign data to VIEW's template // ****************************** $this->assignRef('document', $document); $this->assignRef('lists', $lists); $this->assignRef('row', $item); if (FLEXI_J16GE) { $this->assignRef('form', $form); } else { $this->assignRef('editor', $editor); $this->assignRef('pane', $pane); $this->assignRef('formparams', $formparams); } if ($enable_translation_groups) { $this->assignRef('lang_assocs', $langAssocs); } if (FLEXI_FISH || FLEXI_J16GE) { $this->assignRef('langs', $langs); } $this->assignRef('typesselected', $typesselected); $this->assignRef('published', $published); $this->assignRef('nullDate', $nullDate); $this->assignRef('subscribers', $subscribers); $this->assignRef('fields', $fields); $this->assignRef('versions', $versions); $this->assignRef('ratings', $ratings); $this->assignRef('pagecount', $pagecount); $this->assignRef('params', $params); $this->assignRef('tparams', $tparams); $this->assignRef('tmpls', $tmpls); $this->assignRef('usedtags', $usedtags); $this->assignRef('perms', $perms); $this->assignRef('current_page', $current_page); // Clear custom form data from session $app->setUserState($form->option . '.edit.' . $form->context . '.custom', false); $app->setUserState($form->option . '.edit.' . $form->context . '.jfdata', false); $app->setUserState($form->option . '.edit.' . $form->context . '.unique_tmp_itemid', false); if ($print_logging_info) { $start_microtime = microtime(true); } parent::display($tpl); if ($print_logging_info) { $fc_run_times['form_rendering'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10; } }