/** * Method is called by * * @access public */ public function onAfterExport($context, &$xml, $options) { JLog::add(new JLogEntry(__METHOD__, JLOG::DEBUG, 'plg_j2xml_attachments')); JLog::add(new JLogEntry($context, JLOG::DEBUG, 'plg_j2xml_attachments')); JLog::add(new JLogEntry(print_r($this->_params, true), JLOG::DEBUG, 'plg_j2xml_attachments')); if (PHP_SAPI == 'cli') { JLog::addLogger(array('logger' => 'echo', 'extension' => 'plg_j2xml_attachments'), JLOG::ALL & ~JLOG::DEBUG, array('plg_j2xml_attachments')); } else { JLog::addLogger(array('logger' => $options->get('logger', 'messagequeue'), 'extension' => 'plg_j2xml_attachments'), JLOG::ALL & ~JLOG::DEBUG, array('plg_j2xml_attachments')); } if (version_compare(J2XMLVersion::getShortVersion(), '15.9.5') == -1) { JLog::add(new JLogEntry(JText::_('PLG_J2XML_ATTACHMENTS') . ' ' . JText::_('PLG_J2XML_ATTACHMENTS_MSG_REQUIREMENTS_LIB'), JLOG::WARNING, 'plg_j2xml_attachments')); return false; } // Ignore warnings because component may not be installed $warnHandlers = JERROR::getErrorHandling(E_WARNING); JERROR::setErrorHandling(E_WARNING, 'ignore'); // Check if component is installed if (!JComponentHelper::isEnabled('com_attachments', true)) { JLog::add(new JLogEntry(JText::_('PLG_J2XML_ATTACHMENTS') . ' ' . JText::_('PLG_J2XML_ATTACHMENTS_MSG_REQUIREMENTS_COM'), JLOG::WARNING, 'plg_j2xml_attachments')); return false; } // Reset the warning handler(s) foreach ($warnHandlers as $mode) { JERROR::setErrorHandling(E_WARNING, $mode); } if ($ids = implode(',', $xml->xpath("/j2xml/content/id"))) { $db = JFactory::getDbo(); $doc = dom_import_simplexml($xml)->ownerDocument; $fragment = $doc->createDocumentFragment(); require_once dirname(__FILE__) . '/attachment.php'; $query = $db->getQuery(true); $query->select('id')->from('#__attachments')->where('parent_type = "com_content"')->where('parent_entity = "article"')->where('parent_id IN (' . $ids . ')'); $db->setQuery($query); $ids_attachment = $db->loadColumn(); if ($ids_attachment) { foreach ($ids_attachment as $id) { $item = JTable::getInstance('attachment', 'eshTable'); $item->load($id); JLog::add(new JLogEntry(print_r($item, true), JLOG::DEBUG, 'plg_j2xml_attachments')); $attachment = $item->toXML(); if ($item->uri_type == 'file') { // Check the file size $max_attachment_size = (int) $this->_params->get('max_attachment_size', 0); if ($max_attachment_size > 0) { $file_size_kb = filesize($item->filename_sys) / 1024; if ($file_size_kb > $max_attachment_size) { $attachment = preg_replace('/<file>.+?<\\/file>/im', '', $attachment); } } } $fragment->appendXML($attachment); $doc->documentElement->appendChild($fragment); } } } return true; }
function display($tpl = null) { // ******************** // Initialise variables // ******************** $app = JFactory::getApplication(); $jinput = $app->input; $option = $jinput->get('option', '', 'cmd'); $view = $jinput->get('view', '', 'cmd'); $task = $jinput->get('task', '', 'cmd'); $cparams = JComponentHelper::getParams('com_flexicontent'); $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $session = JFactory::getSession(); // Get model $model = $this->getModel(); // Some flags $has_zlib = function_exists("zlib_encode"); //version_compare(PHP_VERSION, '5.4.0', '>='); // Get session information $conf = $session->get('csvimport_config', "", 'flexicontent'); $conf = unserialize($conf ? $has_zlib ? zlib_decode(base64_decode($conf)) : base64_decode($conf) : ""); $lineno = $session->get('csvimport_lineno', 999999, 'flexicontent'); $session->set('csvimport_parse_log', null, 'flexicontent'); // This is the flag if CSV file has been parsed (import form already submitted), thus to display the imported data // ************************** // Add css and js to document // ************************** $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/flexicontentbackend.css', FLEXI_VHASH); $document->addStyleSheetVersion(JURI::base(true) . '/components/com_flexicontent/assets/css/j3x.css', FLEXI_VHASH); // 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_VHASH); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/validate.js', FLEXI_VHASH); // ***************************** // Get user's global permissions // ***************************** $perms = FlexicontentHelperPerm::getPerm(); // ************************ // Create Submenu & Toolbar // ************************ // Create Submenu (and also check access to current view) FLEXISubmenu('CanImport'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_IMPORT'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'import'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $toolbar = JToolBar::getInstance('toolbar'); if (!empty($conf)) { if ($task != 'processcsv') { $ctrl_task = 'import.processcsv'; $import_btn_title = empty($lineno) ? 'FLEXI_IMPORT_START_TASK' : 'FLEXI_IMPORT_CONTINUE_TASK'; JToolBarHelper::custom($ctrl_task, 'save.png', 'save.png', $import_btn_title, $list_check = false); } $ctrl_task = 'import.clearcsv'; JToolBarHelper::custom($ctrl_task, 'cancel.png', 'cancel.png', 'FLEXI_IMPORT_CLEAR_TASK', $list_check = false); } else { $ctrl_task = 'import.initcsv'; JToolBarHelper::custom($ctrl_task, 'import.png', 'import.png', 'FLEXI_IMPORT_PREPARE_TASK', $list_check = false); $ctrl_task = 'import.testcsv'; JToolBarHelper::custom($ctrl_task, 'test.png', 'test.png', 'FLEXI_IMPORT_TEST_FILE_FORMAT', $list_check = false); } //JToolBarHelper::Back(); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } // Get types $types = flexicontent_html::getTypesList($_type_ids = false, $_check_perms = false, $_published = true); // Get Languages $languages = FLEXIUtilities::getLanguages('code'); // Get categories global $globalcats; $categories = $globalcats; // ************************************ // Decide layout to load: 'import*.php' // ************************************ $this->setLayout('import'); $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null; // Execute the import task, load the log-like AJAX-based layout (import_process.php), to display results including any warnings if (!empty($conf) && $task == 'processcsv') { $this->assignRef('conf', $conf); parent::display('process'); return; } else { if (!empty($conf)) { $this->assignRef('conf', $conf); $this->assignRef('cparams', $cparams); $this->assignRef('types', $types); $this->assignRef('languages', $languages); $this->assignRef('categories', $globalcats); parent::display('list'); return; } } // Session config is empty, means import form has not been submited, display the form // We will display import form which is not 'default.php', it is 'import.php' // else ... // Check is session table DATA column is not mediumtext (16MBs, it can be 64 KBs ('text') in some sites that were not properly upgraded) $tblname = 'session'; $dbprefix = $app->getCfg('dbprefix'); $dbname = $app->getCfg('db'); $db->setQuery("SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '" . $dbname . "' AND TABLE_NAME = '" . $dbprefix . $tblname . "'"); $jession_coltypes = $db->loadAssocList('COLUMN_NAME'); $_dataColType = strtolower($jession_coltypes['data']['DATA_TYPE']); $_dataCol_wrongSize = $_dataColType != 'mediumtext' && $_dataColType != 'longtext'; // If data type is "text" it is safe to assume that it can be converted to "mediumtext", // since "text" means that session table is not memory storage, // plus it is already stored externally aka operation will be quick ? /*if ($_dataCol_wrongSize && $_dataColType == 'text') { $db->setQuery("ALTER TABLE `#__session` MODIFY `data` MEDIUMTEXT"); $db->execute(); $_dataCol_wrongSize = false; }*/ if ($_dataCol_wrongSize) { $app->enqueueMessage("Joomla DB table: <b>'session'</b> has a <b>'data'</b> column with type: <b>'" . $_dataColType . "'</b>, instead of expected type <b>'mediumtext'</b>. Trying to import large data files may fail", "notice"); } $formvals = array(); // Retrieve Basic configuration $formvals['type_id'] = $model->getState('type_id'); $formvals['language'] = $model->getState('language'); $formvals['state'] = $model->getState('state'); $formvals['access'] = $model->getState('access'); // Main and secondary categories, tags $formvals['maincat'] = $model->getState('maincat'); $formvals['maincat_col'] = $model->getState('maincat_col'); $formvals['seccats'] = $model->getState('seccats'); $formvals['seccats_col'] = $model->getState('seccats_col'); $formvals['tags_col'] = $model->getState('tags_col'); // Publication: Author/modifier $formvals['created_by_col'] = $model->getState('created_by_col'); $formvals['modified_by_col'] = $model->getState('modified_by_col'); // Publication: META data $formvals['metadesc_col'] = $model->getState('metadesc_col'); $formvals['metakey_col'] = $model->getState('metakey_col'); // Publication: dates $formvals['modified_col'] = $model->getState('modified_col'); $formvals['created_col'] = $model->getState('modified_col'); $formvals['publish_up_col'] = $model->getState('publish_up_col'); $formvals['publish_down_col'] = $model->getState('publish_down_col'); // Advanced configuration $formvals['ignore_unused_cols'] = $model->getState('ignore_unused_cols'); $formvals['id_col'] = $model->getState('id_col'); $formvals['items_per_step'] = $model->getState('items_per_step'); // CSV file format $formvals['mval_separator'] = $model->getState('mval_separator'); $formvals['mprop_separator'] = $model->getState('mprop_separator'); $formvals['field_separator'] = $model->getState('field_separator'); $formvals['enclosure_char'] = $model->getState('enclosure_char'); $formvals['record_separator'] = $model->getState('record_separator'); $formvals['debug_records'] = $model->getState('debug_records'); // ****************** // Create form fields // ****************** $lists['type_id'] = flexicontent_html::buildtypesselect($types, 'type_id', $formvals['type_id'], true, 'class="required use_select2_lib"', 'type_id'); $actions_allowed = array('core.create'); // Creating categorories tree for item assignment, we use the 'create' privelege // build the main category select list $attribs = 'class="use_select2_lib required"'; $fieldname = 'maincat'; $lists['maincat'] = flexicontent_cats::buildcatselect($categories, $fieldname, $formvals['maincat'], 2, $attribs, false, true, $actions_allowed); // build the secondary categories select list $class = "use_select2_lib"; $attribs = 'multiple="multiple" size="10" class="' . $class . '"'; $fieldname = 'seccats[]'; $lists['seccats'] = flexicontent_cats::buildcatselect($categories, $fieldname, $formvals['seccats'], false, $attribs, false, true, $actions_allowed, $require_all = true); // build languages list // Retrieve author configuration $authorparams = flexicontent_db::getUserConfig($user->id); $allowed_langs = $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); // 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('language', ' style="vertical-align:top;" onchange="var m=jQuery(\'#fc_import_about_langcol\'); this.value ? m.hide(600) : m.show(600);"', $formvals['language'], 6, $allowed_langs, $published_only = true, $disable_langs = null, $add_all = true, $conf = array('required' => true)) . ' <span class="fc-mssg-inline fc-note fc-nobgimage" id="fc_import_about_langcol" style="display:none;"> ' . JText::_('FLEXI_USE_LANGUAGE_COLUMN_TIP') . ' </span>'; $lists['states'] = flexicontent_html::buildstateslist('state', ' style="vertical-align:top;" onchange="var m=jQuery(\'#fc_import_about_statecol\'); this.value ? m.hide(600) : m.show(600);"', $formvals['state'], 2) . '<span class="fc-mssg-inline fc-note fc-nobgimage" id="fc_import_about_statecol" style="display:none;"> ' . JText::_('FLEXI_USE_STATE_COLUMN_TIP') . ' </span>'; // build access level filter $access_levels = JHtml::_('access.assetgroups'); array_unshift($access_levels, JHtml::_('select.option', '0', "Use 'access' column")); array_unshift($access_levels, JHtml::_('select.option', '', 'FLEXI_SELECT_ACCESS_LEVEL')); $fieldname = 'access'; // make multivalue $elementid = 'access'; $attribs = 'class="required use_select2_lib"'; $lists['access'] = JHTML::_('select.genericlist', $access_levels, $fieldname, $attribs, 'value', 'text', $formvals['access'], $elementid, $translate = true); // Ignore warnings because component may not be installed $warnHandlers = JERROR::getErrorHandling(E_WARNING); JERROR::setErrorHandling(E_WARNING, 'ignore'); // Reset the warning handler(s) foreach ($warnHandlers as $mode) { JERROR::setErrorHandling(E_WARNING, $mode); } // ******************************************************************************** // Get field names (from the header line (row 0), and remove it form the data array // ******************************************************************************** $file_field_types_list = '"image","file"'; $q = 'SELECT id, name, label, field_type FROM #__flexicontent_fields AS fi' . ' WHERE fi.field_type IN (' . $file_field_types_list . ')'; $db->setQuery($q); $file_fields = $db->loadObjectList('name'); //assign data to template $this->assignRef('model', $model); $this->assignRef('lists', $lists); $this->assignRef('user', $user); $this->assignRef('cparams', $cparams); $this->assignRef('file_fields', $file_fields); $this->assignRef('formvals', $formvals); parent::display($tpl); }
function display($tpl = null) { $mainframe =& JFactory::getApplication(); // ajax in event form, or standalone ? $standalone = Jrequest::getVar('standalone', 0); if (!$standalone && $this->getLayout() == 'closexref') { $this->_displayclosexref($tpl); return; } if ($standalone) { $document =& JFactory::getDocument(); $document->setTitle(JText::_('COM_REDEVENT_PAGETITLE_EDITSESSION')); $document->addStyleSheet('components/com_redevent/assets/css/redeventbackend.css'); // Set toolbar items for the page $edit = JRequest::getVar('edit', true); $text = !$edit ? JText::_('COM_REDEVENT_New') : JText::_('COM_REDEVENT_Edit'); JToolBarHelper::title(JText::_('COM_REDEVENT_SESSION') . ': <small><small>[ ' . $text . ' ]</small></small>'); JToolBarHelper::save(); JToolBarHelper::apply(); if (JPluginHelper::isEnabled('system', 'autotweetredevent')) { //If the AutoTweet NG Component is installed // Ignore warnings because component may not be installed $warnHandlers = JERROR::getErrorHandling(E_WARNING); JERROR::setErrorHandling(E_WARNING, 'ignore'); if (JComponentHelper::isEnabled('com_autotweet', true)) { JToolBarHelper::save('saveAndTwit', 'Save & twit'); } // Reset the warning handler(s) foreach ($warnHandlers as $mode) { JERROR::setErrorHandling(E_WARNING, $mode); } } if (!$edit) { JToolBarHelper::cancel(); } else { // for existing items the button is renamed `close` JToolBarHelper::cancel('cancel', 'Close'); } } //initialise variables $editor =& JFactory::getEditor(); $document =& JFactory::getDocument(); $uri =& JFactory::getURI(); $elsettings = JComponentHelper::getParams('com_redevent'); //add css and js to document //JHTML::_('behavior.modal', 'a.modal'); JHTML::_('behavior.tooltip'); JHTML::_('behavior.formvalidation'); jimport('joomla.html.pane'); $document->addScript(JURI::root() . 'components/com_redevent/assets/js/xref_recurrence.js'); $document->addScript(JURI::root() . 'components/com_redevent/assets/js/xref_roles.js'); $document->addScript(JURI::root() . 'components/com_redevent/assets/js/xref_prices.js'); $document->addScriptDeclaration('var txt_remove = "' . JText::_('COM_REDEVENT_REMOVE') . '";'); //Build the image select functionality $js = "\n\t\tfunction elSelectImage(image, imagename) {\n\t\t\tdocument.getElementById('a_image').value = image;\n\t\t\tdocument.getElementById('a_imagename').value = imagename;\n\t\t\tdocument.getElementById('sbox-window').close();\n\t\t}"; $xref = $this->get('xref'); $xref->eventid = $xref->eventid ? $xref->eventid : JRequest::getVar('eventid', 0, 'request', 'int'); $customfields =& $this->get('XrefCustomfields'); $roles =& $this->get('SessionRoles'); $prices =& $this->get('SessionPrices'); $lists = array(); // venues selector $venues = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_Select_Venue'))); $venues = array_merge($venues, $this->get('VenuesOptions')); $lists['venue'] = JHTML::_('select.genericlist', $venues, 'venueid', 'class="validate-venue"', 'value', 'text', $xref->venueid); // group selector $options = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_Select_group'))); $options = array_merge($options, $this->get('GroupsOptions')); $lists['group'] = JHTML::_('select.genericlist', $options, 'groupid', '', 'value', 'text', $xref->groupid); // if this is not the first xref of the recurrence, we shouldn't modify it $lockedrecurrence = $xref->count > 0; // Recurrence selector $recur_type = array(JHTML::_('select.option', 'NONE', JText::_('COM_REDEVENT_NO_REPEAT')), JHTML::_('select.option', 'DAILY', JText::_('COM_REDEVENT_DAILY')), JHTML::_('select.option', 'WEEKLY', JText::_('COM_REDEVENT_WEEKLY')), JHTML::_('select.option', 'MONTHLY', JText::_('COM_REDEVENT_MONTHLY')), JHTML::_('select.option', 'YEARLY', JText::_('COM_REDEVENT_YEARLY'))); $lists['recurrence_type'] = JHTML::_('select.radiolist', $recur_type, 'recurrence_type', '', 'value', 'text', $xref->rrules->type); // published state selector $published = array(JHTML::_('select.option', '1', JText::_('COM_REDEVENT_PUBLISHED')), JHTML::_('select.option', '0', JText::_('COM_REDEVENT_UNPUBLISHED')), JHTML::_('select.option', '-1', JText::_('COM_REDEVENT_ARCHIVED'))); $lists['published'] = JHTML::_('select.radiolist', $published, 'published', '', 'value', 'text', $xref->published); // featured state selector $options = array(JHTML::_('select.option', '0', JText::_('COM_REDEVENT_SESSION_NOT_FEATURED')), JHTML::_('select.option', '1', JText::_('COM_REDEVENT_SESSION_IS_FEATURED'))); $lists['featured'] = JHTML::_('select.booleanlist', 'featured', '', $xref->featured); $pane =& JPane::getInstance('tabs'); $rolesoptions = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_Select_role'))); $rolesoptions = array_merge($rolesoptions, $this->get('RolesOptions')); $pricegroupsoptions = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_PRICEGROUPS_SELECT_PRICEGROUP'))); $pricegroupsoptions = array_merge($pricegroupsoptions, $this->get('PricegroupsOptions')); if (JRequest::getVar('task') == 'copy') { $xref->id = null; $xref->recurrence_id = null; } //assign to template $this->assignRef('xref', $xref); $this->assignRef('editor', $editor); $this->assignRef('lists', $lists); $this->assignRef('request_url', $uri->toString()); $this->assignRef('elsettings', $elsettings); $this->assignRef('customfields', $customfields); $this->assignRef('pane', $pane); $this->assignRef('roles', $roles); $this->assignRef('rolesoptions', $rolesoptions); $this->assignRef('prices', $prices); $this->assignRef('pricegroupsoptions', $pricegroupsoptions); $this->assign('standalone', $standalone); parent::display($tpl); }
function display($tpl = null) { $mainframe =& JFactory::getApplication(); if ($this->getLayout() == 'editxref') { $this->_displayeditxref($tpl); return; } else { if ($this->getLayout() == 'closexref') { $this->_displayclosexref($tpl); return; } } //Load behavior jimport('joomla.html.pane'); JHTML::_('behavior.tooltip'); JHTML::_('behavior.formvalidation'); JHTML::_('behavior.mootools'); require_once JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'helper.php'; require_once JPATH_COMPONENT_SITE . DS . 'classes' . DS . 'output.class.php'; //initialise variables $editor =& JFactory::getEditor(); $document =& JFactory::getDocument(); $pane =& JPane::getInstance('tabs'); $user =& JFactory::getUser(); $params = JComponentHelper::getParams('com_redevent'); //get vars $cid = JRequest::getVar('cid'); $task = JRequest::getVar('task'); $url = JURI::root(); $document->setTitle(JText::_('COM_REDEVENT_PAGETITLE_EDITEVENT')); //add the custom stylesheet and the seo javascript $document->addStyleSheet($url . 'administrator/components/com_redevent/assets/css/redeventbackend.css'); $document->addScript($url . 'administrator/components/com_redevent/assets/js/seo.js'); $document->addScript($url . 'administrator/components/com_redevent/assets/js/xrefedit.js'); $document->addScript($url . 'administrator/components/com_redevent/assets/js/editevent.js'); $document->addScript($url . 'components/com_redevent/assets/js/attachments.js'); $document->addScriptDeclaration('var removemsg = "' . JText::_('COM_REDEVENT_ATTACHMENT_CONFIRM_MSG') . '";'); //get data from model $form = $this->get('form'); $model =& $this->getModel(); if ($task == 'add') { $model->setId($params->get('default_content')); } $row =& $this->get('Data'); if ($task == 'copy') { $row->id = null; $row->title .= ' ' . JText::_('COM_REDEVENT_copy'); $row->alias = ''; } if ($task == 'add') { $row->id = null; $row->title = ''; $row->alias = ''; } $customfields =& $this->get('Customfields'); /* Check if we have a redFORM id */ if (empty($row->redform_id)) { $row->redform_id = $params->get('defaultredformid', 1); } // fail if checked out not by 'me' if ($row->id) { if ($model->isCheckedOut($user->get('id'))) { JError::raiseWarning('REDEVENT_GENERIC_ERROR', $row->titel . ' ' . JText::_('COM_REDEVENT_EDITED_BY_ANOTHER_ADMIN')); $mainframe->redirect('index.php?option=com_redevent&view=events'); } } //make data safe JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'datdescription'); //Create category list $lists = array(); $lists['category'] = $model->getCategories(); /* Create venue selection tab */ $venueslist = $this->get('Venues'); $xrefs = $this->get('xrefs'); // categories selector $selected = array(); foreach ((array) $row->categories_ids as $cat) { $selected[] = $cat; } $lists['categories'] = JHTML::_('select.genericlist', (array) $this->get('Categories'), 'categories[]', 'class="inputbox required validate-categories" multiple="multiple" size="10"', 'value', 'text', $selected); // event layout $options = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_DEFAULT')), JHTML::_('select.option', 1, JText::_('COM_REDEVENT_EVENT_LAYOUT_TAGS')), JHTML::_('select.option', 2, JText::_('COM_REDEVENT_EVENT_LAYOUT_FIXED'))); $lists['details_layout'] = JHTML::_('select.genericlist', $options, 'details_layout', '', 'value', 'text', $row->details_layout); // enable ical button $options = array(JHTML::_('select.option', 0, JText::_('COM_REDEVENT_DEFAULT')), JHTML::_('select.option', 1, JText::_('COM_REDEVENT_Yes')), JHTML::_('select.option', 2, JText::_('COM_REDEVENT_No'))); $lists['enable_ical'] = JHTML::_('select.genericlist', $options, 'enable_ical', '', 'value', 'text', $row->enable_ical); /* Create submission types */ $submission_types = explode(',', $row->submission_types); /* Check if redFORM is installed */ $redform_install = $this->get('CheckredFORM'); $hasattendees = $model->hasAttendees(); if ($redform_install) { /* Get a list of redFORM forms */ $redforms = $this->get('RedForms'); if ($redforms) { if ($hasattendees) { // can't reassign the form in that case ! foreach ($redforms as $aform) { if ($aform->id == $row->redform_id) { $lists['redforms'] = $aform->formname . '<input type="hidden" name="redform_id" value="' . $row->redform_id . '"/>'; break; } } } else { $lists['redforms'] = JHTML::_('select.genericlist', $redforms, 'redform_id', '', 'id', 'formname', $row->redform_id); } } else { $lists['redforms'] = ''; } /* Check if a redform ID exists, if so, get the fields */ if (isset($row->redform_id) && $row->redform_id > 0) { $formfields = $this->get('formfields'); if (!$formfields) { $formfields = array(); } } } else { $lists['redforms'] = ''; $formfields = ''; } JHTML::script('modal.js'); JHTML::stylesheet('modal.css'); //build toolbar if ($task == 'copy') { JToolBarHelper::title(JText::_('COM_REDEVENT_COPY_EVENT'), 'eventedit'); } elseif ($cid) { JToolBarHelper::title(JText::_('COM_REDEVENT_EDIT_EVENT') . ' - ' . $row->title, 'eventedit'); } else { JToolBarHelper::title(JText::_('COM_REDEVENT_ADD_EVENT'), 'eventedit'); //set the submenu JSubMenuHelper::addEntry(JText::_('COM_REDEVENT'), 'index.php?option=com_redevent'); JSubMenuHelper::addEntry(JText::_('COM_REDEVENT_EVENTS'), 'index.php?option=com_redevent&view=events'); JSubMenuHelper::addEntry(JText::_('COM_REDEVENT_VENUES'), 'index.php?option=com_redevent&view=venues'); JSubMenuHelper::addEntry(JText::_('COM_REDEVENT_CATEGORIES'), 'index.php?option=com_redevent&view=categories'); JSubMenuHelper::addEntry(JText::_('COM_REDEVENT_ARCHIVESCREEN'), 'index.php?option=com_redevent&view=archive'); JSubMenuHelper::addEntry(JText::_('COM_REDEVENT_GROUPS'), 'index.php?option=com_redevent&view=groups'); JSubMenuHelper::addEntry(JText::_('COM_REDEVENT_HELP'), 'index.php?option=com_redevent&view=help'); if ($user->get('gid') > 24) { JSubMenuHelper::addEntry(JText::_('COM_REDEVENT_SETTINGS'), 'index.php?option=com_redevent&controller=settings&task=edit'); } } JToolBarHelper::apply(); JToolBarHelper::spacer(); JToolBarHelper::save(); if (JPluginHelper::isEnabled('system', 'autotweetredevent')) { //If the AutoTweet NG Component is installed // Ignore warnings because component may not be installed $warnHandlers = JERROR::getErrorHandling(E_WARNING); JERROR::setErrorHandling(E_WARNING, 'ignore'); if (JComponentHelper::isEnabled('com_autotweet', true) && !$row->id) { JToolBarHelper::save('saveAndTwit', 'Save & twit'); } // Reset the warning handler(s) foreach ($warnHandlers as $mode) { JERROR::setErrorHandling(E_WARNING, $mode); } } JToolBarHelper::spacer(); JToolBarHelper::cancel(); JToolBarHelper::spacer(); //JToolBarHelper::help( 'el.editevents', true ); //assign vars to the template $this->assignRef('lists', $lists); $this->assignRef('row', $row); $this->assignRef('formfields', $formfields); $this->assignRef('imageselect', $imageselect); $this->assignRef('submission_types', $submission_types); $this->assignRef('editor', $editor); $this->assignRef('pane', $pane); $this->assignRef('task', $task); $this->assignRef('params', $params); $this->assignRef('formfields', $formfields); $this->assignRef('venueslist', $venueslist); $this->assignRef('redform_install', $redform_install); $this->assignRef('customfields', $customfields); $this->assignRef('access', redEVENTHelper::getAccesslevelOptions()); $this->assignRef('xrefs', $xrefs); $this->assignRef('form', $form); if (!$row->id) { $this->_prepareSessionTab(); } parent::display($tpl); }
function display($tpl = null) { $mainframe = JFactory::getApplication(); //initialise variables $user = JFactory::getUser(); $db = JFactory::getDBO(); $document = JFactory::getDocument(); $option = JRequest::getCmd('option'); $context = 'com_flexicontent'; $task = JRequest::getVar('task', ''); $cid = JRequest::getVar('cid', array()); $cparams = JComponentHelper::getParams('com_flexicontent'); $this->setLayout('import'); //initialise variables $user = JFactory::getUser(); $document = JFactory::getDocument(); $context = 'com_flexicontent'; $has_zlib = version_compare(PHP_VERSION, '5.4.0', '>='); FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); JHTML::_('behavior.tooltip'); //add css to document $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css'); if (FLEXI_J30GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css'); } else { if (FLEXI_J16GE) { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css'); } else { $document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css'); } } // Get filter vars $filter_order = $mainframe->getUserStateFromRequest($context . '.import.filter_order', 'filter_order', '', 'cmd'); $filter_order_Dir = $mainframe->getUserStateFromRequest($context . '.import.filter_order_Dir', 'filter_order_Dir', '', 'word'); // Get session information $session = JFactory::getSession(); $conf = $session->get('csvimport_config', "", 'flexicontent'); $conf = unserialize($conf ? $has_zlib ? zlib_decode(base64_decode($conf)) : base64_decode($conf) : ""); $lineno = $session->get('csvimport_lineno', 999999, 'flexicontent'); $session->set('csvimport_parse_log', null, 'flexicontent'); // Get User's Global Permissions $perms = FlexicontentHelperPerm::getPerm(); // Create Submenu (and also check access to current view) FLEXISubmenu('CanImport'); // Create document/toolbar titles $doc_title = JText::_('FLEXI_IMPORT'); $site_title = $document->getTitle(); JToolBarHelper::title($doc_title, 'import'); $document->setTitle($doc_title . ' - ' . $site_title); // Create the toolbar $toolbar = JToolBar::getInstance('toolbar'); if (!empty($conf)) { if ($task != 'processcsv') { $ctrl_task = FLEXI_J16GE ? 'import.processcsv' : 'processcsv'; $import_btn_title = empty($lineno) ? 'FLEXI_IMPORT_START_TASK' : 'FLEXI_IMPORT_CONTINUE_TASK'; JToolBarHelper::custom($ctrl_task, 'save.png', 'save.png', $import_btn_title, $list_check = false); } $ctrl_task = FLEXI_J16GE ? 'import.clearcsv' : 'clearcsv'; JToolBarHelper::custom($ctrl_task, 'cancel.png', 'cancel.png', 'FLEXI_IMPORT_CLEAR_TASK', $list_check = false); } else { $ctrl_task = FLEXI_J16GE ? 'import.initcsv' : 'initcsv'; JToolBarHelper::custom($ctrl_task, 'import.png', 'import.png', 'FLEXI_IMPORT_PREPARE_TASK', $list_check = false); $ctrl_task = FLEXI_J16GE ? 'import.testcsv' : 'testcsv'; JToolBarHelper::custom($ctrl_task, 'test.png', 'test.png', 'FLEXI_IMPORT_TEST_FILE_FORMAT', $list_check = false); } //JToolBarHelper::Back(); if ($perms->CanConfig) { JToolBarHelper::divider(); JToolBarHelper::spacer(); $session = JFactory::getSession(); $fc_screen_width = (int) $session->get('fc_screen_width', 0, 'flexicontent'); $_width = $fc_screen_width && $fc_screen_width - 84 > 940 ? $fc_screen_width - 84 > 1400 ? 1400 : $fc_screen_width - 84 : 940; $fc_screen_height = (int) $session->get('fc_screen_height', 0, 'flexicontent'); $_height = $fc_screen_height && $fc_screen_height - 128 > 550 ? $fc_screen_height - 128 > 1000 ? 1000 : $fc_screen_height - 128 : 550; JToolBarHelper::preferences('com_flexicontent', $_height, $_width, 'Configuration'); } if (!empty($conf) && $task == 'processcsv') { $this->assignRef('conf', $conf); parent::display('process'); return; } // Get types $query = 'SELECT id, name' . ' FROM #__flexicontent_types' . ' WHERE published = 1' . ' ORDER BY name ASC'; $db->setQuery($query); $types = $db->loadObjectList('id'); // Get Languages $languages = FLEXI_FISH || FLEXI_J16GE ? FLEXIUtilities::getLanguages('code') : array(); // Get categories global $globalcats; $categories = $globalcats; if (!empty($conf)) { $this->assignRef('conf', $conf); $this->assignRef('cparams', $cparams); $this->assignRef('types', $types); $this->assignRef('languages', $languages); $this->assignRef('categories', $globalcats); parent::display('list'); return; } // ****************** // Create form fields // ****************** $lists['type_id'] = flexicontent_html::buildtypesselect($types, 'type_id', '', true, 'class="fcfield_selectval" size="1"', 'type_id'); $actions_allowed = array('core.create'); // Creating categorories tree for item assignment, we use the 'create' privelege // build the secondary categories select list $class = "fcfield_selectmulval"; $attribs = 'multiple="multiple" size="10" class="' . $class . '"'; $fieldname = FLEXI_J16GE ? 'seccats[]' : 'seccats[]'; $lists['seccats'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', false, $attribs, false, true, $actions_allowed, $require_all = true); // build the main category select list $attribs = 'class="fcfield_selectval"'; $fieldname = FLEXI_J16GE ? 'maincat' : 'maincat'; $lists['maincat'] = flexicontent_cats::buildcatselect($categories, $fieldname, '', 2, $attribs, false, true, $actions_allowed); /* // build the main category select list $lists['maincat'] = flexicontent_cats::buildcatselect($categories, 'maincat', '', 0, 'class="inputbox" size="10"', false, false); // build the secondary categories select list $lists['seccats'] = flexicontent_cats::buildcatselect($categories, 'seccats[]', '', 0, 'class="inputbox" multiple="multiple" size="10"', false, false); */ //build languages list // Retrieve author configuration $db->setQuery('SELECT author_basicparams FROM #__flexicontent_authors_ext WHERE user_id = ' . $user->id); if ($authorparams = $db->loadResult()) { $authorparams = FLEXI_J16GE ? new JRegistry($authorparams) : new JParameter($authorparams); } $allowed_langs = !$authorparams ? null : $authorparams->get('langs_allowed', null); $allowed_langs = !$allowed_langs ? null : FLEXIUtilities::paramToArray($allowed_langs); // 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 if (FLEXI_FISH || FLEXI_J16GE) { $default_lang = $cparams->get('import_lang', '*'); $lists['languages'] = flexicontent_html::buildlanguageslist('language', '', $default_lang, 6, $allowed_langs, $published_only = true); } else { $default_lang = flexicontent_html::getSiteDefaultLang(); $_langs[] = JHTML::_('select.option', $default_lang, JText::_('Default') . ' (' . flexicontent_html::getSiteDefaultLang() . ')'); $lists['languages'] = JHTML::_('select.radiolist', $_langs, 'language', $class = '', 'value', 'text', $default_lang); } $default_state = $cparams->get('import_state', 1); $lists['states'] = flexicontent_html::buildstateslist('state', '', $default_state, 2); // Ignore warnings because component may not be installed $warnHandlers = JERROR::getErrorHandling(E_WARNING); JERROR::setErrorHandling(E_WARNING, 'ignore'); if (FLEXI_J30GE) { // J3.0+ adds an warning about component not installed, commented out ... till time ... $fleximport_comp_enabled = false; //JComponentHelper::isEnabled('com_fleximport'); } else { $fleximport_comp = JComponentHelper::getComponent('com_fleximport', true); $fleximport_comp_enabled = $fleximport_comp && $fleximport_comp->enabled; } // Reset the warning handler(s) foreach ($warnHandlers as $mode) { JERROR::setErrorHandling(E_WARNING, $mode); } if ($fleximport_comp_enabled) { $fleximport = JText::sprintf('FLEXI_FLEXIMPORT_INSTALLED', JText::_('FLEXI_FLEXIMPORT_INFOS')); } else { $fleximport = JText::sprintf('FLEXI_FLEXIMPORT_NOT_INSTALLED', JText::_('FLEXI_FLEXIMPORT_INFOS')); } // ******************************************************************************** // Get field names (from the header line (row 0), and remove it form the data array // ******************************************************************************** $file_field_types_list = '"image","file"'; $q = 'SELECT id, name, label, field_type FROM #__flexicontent_fields AS fi' . ' WHERE fi.field_type IN (' . $file_field_types_list . ')'; $db->setQuery($q); $file_fields = $db->loadObjectList('name'); //assign data to template $this->assignRef('lists', $lists); $this->assignRef('cid', $cid); $this->assignRef('user', $user); $this->assignRef('fleximport', $fleximport); $this->assignRef('cparams', $cparams); $this->assignRef('file_fields', $file_fields); parent::display($tpl); }