Пример #1
0
 /**
  * Method to get the template list and their properties
  *
  * @access	private
  * @return	array
  * @since	1.5
  */
 function _getTemplates()
 {
     $folders = flexicontent_tmpl::getThemes();
     $tmpl = flexicontent_tmpl::getTemplates();
     $themes = array();
     foreach ($folders as $folder) {
         $themes[$folder] = new stdClass();
         $themes[$folder]->name = $folder;
         $themes[$folder]->items = isset($tmpl->items->{$folder}) ? $tmpl->items->{$folder} : '';
         $themes[$folder]->category = isset($tmpl->category->{$folder}) ? $tmpl->category->{$folder} : '';
     }
     return $themes;
 }
Пример #2
0
 /**
  * Method to check if the field positions were converted
  * and if not, convert them
  *
  * @access public
  * @return	boolean	True on success
  */
 function getFieldsPositions()
 {
     $query = "SELECT name, positions" . " FROM #__flexicontent_fields" . " WHERE positions <> ''";
     $this->_db->setQuery($query);
     $fields = $this->_db->loadObjectList();
     if ($fields) {
         // create a temporary table to store the positions
         $this->_db->setQuery("DROP TABLE IF EXISTS #__flexicontent_positions_tmp");
         $this->_db->query();
         $query = "\r\n\t\t\t\t\tCREATE TABLE #__flexicontent_positions_tmp (\r\n\t\t\t\t\t  `field` varchar(100) NOT NULL default '',\r\n\t\t\t\t\t  `view` varchar(30) NOT NULL default '',\r\n\t\t\t\t\t  `folder` varchar(100) NOT NULL default '',\r\n\t\t\t\t\t  `position` varchar(255) NOT NULL default ''\r\n\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8\r\n\t\t\t\t\t";
         $this->_db->setQuery($query);
         $this->_db->query();
         foreach ($fields as $field) {
             $field->positions = explode("\n", $field->positions);
             foreach ($field->positions as $pos) {
                 $pos = explode('.', $pos);
                 $query = 'INSERT INTO #__flexicontent_positions_tmp (`field`, `view`, `folder`, `position`) VALUES(' . $this->_db->Quote($field->name) . ',' . $this->_db->Quote($pos[1]) . ',' . $this->_db->Quote($pos[2]) . ',' . $this->_db->Quote($pos[0]) . ')';
                 $this->_db->setQuery($query);
                 $this->_db->query();
             }
         }
         $templates = flexicontent_tmpl::getTemplates();
         $folders = flexicontent_tmpl::getThemes();
         $views = array('items', 'category');
         foreach ($folders as $folder) {
             foreach ($views as $view) {
                 $groups = @$templates->{$view}->{$folder}->positions;
                 if ($groups) {
                     foreach ($groups as $group) {
                         $query = 'SELECT field' . ' FROM #__flexicontent_positions_tmp' . ' WHERE view = ' . $this->_db->Quote($view) . ' AND folder = ' . $this->_db->Quote($folder) . ' AND position = ' . $this->_db->Quote($group);
                         $this->_db->setQuery($query);
                         $fieldstopos = FLEXI_J16GE ? $this->_db->loadColumn() : $this->_db->loadResultArray();
                         if ($fieldstopos) {
                             $field = implode(',', $fieldstopos);
                             $query = 'INSERT INTO #__flexicontent_templates (`template`, `layout`, `position`, `fields`) VALUES(' . $this->_db->Quote($folder) . ',' . $this->_db->Quote($view) . ',' . $this->_db->Quote($group) . ',' . $this->_db->Quote($field) . ')';
                             $this->_db->setQuery($query);
                             $this->_db->query();
                         }
                     }
                 }
             }
         }
         // delete the temporary table
         $query = 'DROP TABLE #__flexicontent_positions_tmp';
         $this->_db->setQuery($query);
         $this->_db->query();
         // delete the old positions
         $query = "UPDATE #__flexicontent_fields SET positions = ''";
         $this->_db->setQuery($query);
         $this->_db->query();
         // alter ordering field for releases prior to beta5
         $query = "ALTER TABLE #__flexicontent_cats_item_relations MODIFY `ordering` int(11) NOT NULL default '0'";
         $this->_db->setQuery($query);
         $this->_db->query();
         $query = "ALTER TABLE #__flexicontent_fields_type_relations MODIFY `ordering` int(11) NOT NULL default '0'";
         $this->_db->setQuery($query);
         $this->_db->query();
     }
     return $fields;
 }
Пример #3
0
    /**
     * Creates the Entrypage
     *
     * @since 1.0
     */
    function display($tpl = null)
    {
        $app = JFactory::getApplication();
        $config = JFactory::getConfig();
        $params = JComponentHelper::getParams('com_flexicontent');
        $document = JFactory::getDocument();
        $session = JFactory::getSession();
        $user = JFactory::getUser();
        $db = JFactory::getDBO();
        $print_logging_info = $params->get('print_logging_info');
        // Special displaying when getting flexicontent version
        $layout = JRequest::getVar('layout', 'default');
        if ($layout == 'fversion') {
            $this->fversion($tpl, $params);
            return;
        }
        // Load the file system librairies
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        // activate the tooltips
        //JHTML::_('behavior.tooltip');
        // handle jcomments integration
        if (JPluginHelper::isEnabled('system', 'jcomments')) {
            $JComments_Installed = 1;
            $destpath = JPATH_SITE . DS . 'components' . DS . 'com_jcomments' . DS . 'plugins';
            $dest = $destpath . DS . 'com_flexicontent.plugin.php';
            $source = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'jcomments' . DS . 'com_flexicontent.plugin.php';
            if (!JFile::exists($dest)) {
                if (!JFolder::exists($destpath)) {
                    if (!JFolder::create($destpath)) {
                        JError::raiseWarning(100, JText::_('FLEXIcontent: Unable to create jComments plugin folder'));
                    }
                }
                if (!JFile::copy($source, $dest)) {
                    JError::raiseWarning(100, JText::_('FLEXIcontent: Unable to copy jComments plugin'));
                } else {
                    $app->enqueueMessage(JText::_('Copied FLEXIcontent jComments plugin'));
                }
            }
        } else {
            $JComments_Installed = 0;
        }
        // handle joomfish integration
        if (JPluginHelper::isEnabled('system', 'jfdatabase')) {
            $files = new stdClass();
            $files->fields = new stdClass();
            $files->files = new stdClass();
            $files->tags = new stdClass();
            $files->fields->dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomfish' . DS . 'contentelements' . DS . 'flexicontent_fields.xml';
            $files->fields->source = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'joomfish' . DS . 'flexicontent_fields.xml';
            $files->files->dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomfish' . DS . 'contentelements' . DS . 'flexicontent_files.xml';
            $files->files->source = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'joomfish' . DS . 'flexicontent_files.xml';
            $files->tags->dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomfish' . DS . 'contentelements' . DS . 'flexicontent_tags.xml';
            $files->tags->source = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'joomfish' . DS . 'flexicontent_tags.xml';
            foreach ($files as $file) {
                if (!JFile::exists($file->dest)) {
                    JFile::copy($file->source, $file->dest);
                }
            }
        }
        // Get model
        $model = $this->getModel('flexicontent');
        // initialise template related variables
        if (!FLEXI_J16GE) {
            $pane = JPane::getInstance('sliders');
        }
        $template = $app->getTemplate();
        $themes = flexicontent_tmpl::getThemes();
        // Get data from the model
        if ($print_logging_info) {
            global $fc_run_times;
        }
        if ($print_logging_info) {
            $start_microtime = microtime(true);
        }
        $totalrows = array();
        $_total = 0;
        $draft = $model->getDraft($_total);
        $totalrows['draft'] = $_total;
        $pending = $model->getPending($_total);
        $totalrows['pending'] = $_total;
        $revised = $model->getRevised($_total);
        $totalrows['revised'] = $_total;
        $inprogress = $model->getInprogress($_total);
        $totalrows['inprogress'] = $_total;
        if ($print_logging_info) {
            $fc_run_times['quick_sliders'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
        }
        // 1. CHECK REQUIRED NON-AUTOMATIC TASKs
        //  THEY ARE TASKs THAT USER MUST COMPLETE MANUALLY
        $existcat = $model->getExistcat();
        if (!FLEXI_J16GE) {
            $existsec = $model->getExistsec();
        }
        $existmenu = $model->getExistmenu();
        // 2. OPTIONAL AUTOMATIC TASKS,
        //  THESE ARE SEPARETELY CHECKED, AS THEY ARE NOT OBLIGATORY BUT RATHER RECOMMENDED
        $allplgpublish = $session->get('flexicontent.allplgpublish');
        if ($allplgpublish === NULL || $allplgpublish === false) {
            $allplgpublish = $model->getAllPluginsPublished();
        }
        $optional_tasks = !$allplgpublish;
        // || ..
        // 3. OBLIGATORY AUTOMATIC TASKS, THAT WILL BLOCK COMPONENT USE UNTIL THEY ARE COMPLETED
        $postinst_integrity_ok = $session->get('flexicontent.postinstall');
        // THE FOLLOWING WILL ONLY BE DISPLAYED IF $DOPOSTINSTALL IS INCOMPLETE
        // SO WHY CALCULATE THEM, WE SKIP THEM, USER MUST LOG OUT ANYWAY TO SEE THEM ...
        if ($postinst_integrity_ok === NULL || $postinst_integrity_ok === false) {
            $use_versioning = $params->get('use_versioning', 1);
            $existtype = $model->getExistType();
            $existmenuitems = $model->getExistMenuItems();
            $existfields = $model->getExistFields();
            $existfplg = $model->getExistFieldsPlugins();
            $existseplg = $model->getExistSearchPlugin();
            $existsyplg = $model->getExistSystemPlugin();
            $existcats = !$model->getItemsNoCat();
            $existlang = $model->getExistLanguageColumns() && !$model->getItemsNoLang();
            $existversions = $model->getExistVersionsTable();
            $existversionsdata = !$use_versioning || $model->getExistVersionsPopulated();
            $existauthors = $model->getExistAuthorsTable();
            $deprecatedfiles = $model->getDeprecatedFiles();
            $nooldfieldsdata = $model->getNoOldFieldsData();
            $missingversion = true;
            //!$use_versioning || !$model->checkCurrentVersionData();
            $cachethumb = $model->getCacheThumbChmod();
            $existdbindexes = !(bool) ($missingindexes = $model->getExistDBindexes($check_only = false));
            $itemcountingdok = $model->getItemCountingDataOK();
            $initialpermission = $model->checkInitialPermission();
        } else {
            if ($optional_tasks) {
                // IF optional tasks do not recheck instead just set the FLAGS to true
                $existtype = $existmenuitems = $existfields = true;
                $existfplg = $existseplg = $existsyplg = true;
                $existcats = $existlang = $existversions = $existversionsdata = $existauthors = true;
                $deprecatedfiles = $nooldfieldsdata = $missingversion = $cachethumb = true;
                $existdbindexes = $itemcountingdok = $initialpermission = true;
                $missingindexes = array();
            }
        }
        // **************************
        // 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);
        $css = '.install-ok { background: url(components/com_flexicontent/assets/images/accept.png) 0% 50% no-repeat transparent; padding:1px 0; width: 20px; height:16px; display:block; }
				 .install-notok { background: url(components/com_flexicontent/assets/images/delete.png) 0% 50% no-repeat transparent; padding:1px 0; width: 20px; height:16px; display:block; float:left;}';
        $document->addStyleDeclaration($css);
        // *****************************
        // Get user's global permissions
        // *****************************
        $perms = FlexicontentHelperPerm::getPerm();
        // ************************
        // Create Submenu & Toolbar
        // ************************
        // Create Submenu (and also check access to current view)
        FLEXISubmenu('notvariable');
        // Create document/toolbar titles
        $doc_title = JText::_('FLEXI_DASHBOARD');
        $site_title = $document->getTitle();
        JToolBarHelper::title($doc_title, 'flexicontent');
        $document->setTitle($doc_title . ' - ' . $site_title);
        // Create the toolbar
        if (version_compare(PHP_VERSION, '5.0.0', '>')) {
            $js = "jQuery(document).ready(function(){";
            if ($perms->CanConfig) {
                $toolbar = JToolBar::getInstance('toolbar');
                $btn_task = '';
                $popup_load_url = JURI::base() . 'index.php?option=com_flexicontent&layout=import&tmpl=component';
                if (!FLEXI_J16GE) {
                    $js .= "\n\t\t\t\t\t\tjQuery('#toolbar-download a.toolbar, #toolbar-download button')\n\t\t\t\t\t\t\t.attr('onclick', 'javascript:;')\n\t\t\t\t\t\t\t.attr('href', '" . $popup_load_url . "')\n\t\t\t\t\t\t\t.attr('rel', '{handler: \\'iframe\\', size: {x: 800, y: 500}, onClose: function() {}}');\n\t\t\t\t\t";
                    JToolBarHelper::custom($btn_task, 'download.png', 'download_f2.png', 'FLEXI_IMPORT_JOOMLA', false);
                    JHtml::_('behavior.modal', '#toolbar-download a.toolbar, #toolbar-download button');
                } else {
                    //$toolbar->appendButton('Popup', 'download', JText::_('FLEXI_IMPORT_JOOMLA'), str_replace('&', '&amp;', $popup_load_url), 400, 300);
                }
                /*$btn_task = '';
                		$popup_load_url = JURI::base().'index.php?option=com_flexicontent&layout=language&tmpl=component';
                		if (FLEXI_J16GE) {
                			$js .= "
                				jQuery('#toolbar-language a.toolbar, #toolbar-language button')
                					.attr('onclick', 'javascript:;')
                					.attr('href', '".$popup_load_url."')
                					.attr('rel', '{handler: \'iframe\', size: {x: 800, y: 500}, onClose: function() {}}');
                			";
                			JToolBarHelper::custom( $btn_task, 'language.png', 'language_f2.png', 'FLEXI_SEND_LANGUAGE', false );
                			JHtml::_('behavior.modal', '#toolbar-language a.toolbar, #toolbar-language button');
                		} else {
                			$toolbar->appendButton('Popup', 'language', JText::_('FLEXI_SEND_LANGUAGE'), str_replace('&', '&amp;', $popup_load_url), 800, 500);
                		}*/
                $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');
            }
            $js .= "});";
            $document->addScriptDeclaration($js);
        }
        // Lists
        jimport('joomla.filesystem.folder');
        $lists = array();
        $options = array();
        $folder = JPATH_ADMINISTRATOR . DS . 'language';
        $langs = JFolder::folders($folder);
        $activelang = JComponentHelper::getParams('com_languages')->get('administrator', 'en-GB');
        foreach ($langs as $lang) {
            $options[] = JHTML::_('select.option', $lang, $lang);
        }
        $lists['languages'] = JHTML::_('select.genericlist', $options, 'lang', '', 'value', 'text', $activelang);
        // Missing files
        $lists['missing_lang'] = $model->processlanguagefiles();
        // Get the default copyright values to populate the form automatically
        $mailfrom = $app->getCfg('mailfrom');
        $fromname = $app->getCfg('fromname');
        $website = $app->getCfg('live_site');
        $this->assignRef('pending', $pending);
        $this->assignRef('revised', $revised);
        $this->assignRef('draft', $draft);
        $this->assignRef('inprogress', $inprogress);
        $this->assignRef('totalrows', $totalrows);
        $this->assignRef('existcat', $existcat);
        if (!FLEXI_J16GE) {
            $this->assignRef('existsec', $existsec);
        }
        $this->assignRef('existmenu', $existmenu);
        $this->assignRef('template', $template);
        $this->assignRef('params', $params);
        $this->assignRef('lists', $lists);
        $this->assignRef('activelang', $activelang);
        $this->assignRef('mailfrom', $mailfrom);
        $this->assignRef('fromname', $fromname);
        $this->assignRef('website', $website);
        // install check
        $this->assignRef('dopostinstall', $postinst_integrity_ok);
        $this->assignRef('allplgpublish', $allplgpublish);
        $this->assignRef('existtype', $existtype);
        $this->assignRef('existmenuitems', $existmenuitems);
        $this->assignRef('existfields', $existfields);
        $this->assignRef('existfplg', $existfplg);
        $this->assignRef('existseplg', $existseplg);
        $this->assignRef('existsyplg', $existsyplg);
        $this->assignRef('existcats', $existcats);
        $this->assignRef('existlang', $existlang);
        $this->assignRef('existversions', $existversions);
        $this->assignRef('existversionsdata', $existversionsdata);
        $this->assignRef('existauthors', $existauthors);
        $this->assignRef('deprecatedfiles', $deprecatedfiles);
        $this->assignRef('nooldfieldsdata', $nooldfieldsdata);
        $this->assignRef('missingversion', $missingversion);
        $this->assignRef('cachethumb', $cachethumb);
        $this->assignRef('existdbindexes', $existdbindexes);
        $this->assignRef('missingindexes', $missingindexes);
        $this->assignRef('itemcountingdok', $itemcountingdok);
        $this->assignRef('initialpermission', $initialpermission);
        // assign Rights to the template
        $this->assignRef('perms', $perms);
        $this->assignRef('document', $document);
        $this->sidebar = FLEXI_J30GE ? JHtmlSidebar::render() : null;
        parent::display($tpl);
    }
Пример #4
0
 /**
  * Method to check if the field positions were converted
  * and if not, convert them
  *
  * @access public
  * @return	boolean	True on success
  */
 function convertOldFieldsPositions()
 {
     static $return;
     if ($return !== null) {
         return $return;
     }
     $return = true;
     // only call once
     $query = "SELECT name, positions" . " FROM #__flexicontent_fields" . " WHERE positions <> ''";
     $this->_db->setQuery($query);
     $fields = $this->_db->loadObjectList();
     if (empty($fields)) {
         return $return;
     }
     // create a temporary table to store the positions
     $this->_db->setQuery("DROP TABLE IF EXISTS #__flexicontent_positions_tmp");
     $this->_db->query();
     $query = "\r\n\t\t\t\tCREATE TABLE #__flexicontent_positions_tmp (\r\n\t\t\t\t  `field` varchar(100) NOT NULL default '',\r\n\t\t\t\t  `view` varchar(30) NOT NULL default '',\r\n\t\t\t\t  `folder` varchar(100) NOT NULL default '',\r\n\t\t\t\t  `position` varchar(255) NOT NULL default ''\r\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8\r\n\t\t\t\t";
     $this->_db->setQuery($query);
     $this->_db->query();
     foreach ($fields as $field) {
         $field->positions = explode("\n", $field->positions);
         foreach ($field->positions as $pos) {
             $pos = explode('.', $pos);
             $query = 'INSERT INTO #__flexicontent_positions_tmp (`field`, `view`, `folder`, `position`) VALUES(' . $this->_db->Quote($field->name) . ',' . $this->_db->Quote($pos[1]) . ',' . $this->_db->Quote($pos[2]) . ',' . $this->_db->Quote($pos[0]) . ')';
             $this->_db->setQuery($query);
             $this->_db->query();
         }
     }
     $templates = flexicontent_tmpl::getTemplates();
     $folders = flexicontent_tmpl::getThemes();
     $views = array('items', 'category');
     foreach ($folders as $folder) {
         foreach ($views as $view) {
             $groups = @$templates->{$view}->{$folder}->positions;
             if ($groups) {
                 foreach ($groups as $group) {
                     $query = 'SELECT field' . ' FROM #__flexicontent_positions_tmp' . ' WHERE view = ' . $this->_db->Quote($view) . ' AND folder = ' . $this->_db->Quote($folder) . ' AND position = ' . $this->_db->Quote($group);
                     $this->_db->setQuery($query);
                     $fieldstopos = FLEXI_J16GE ? $this->_db->loadColumn() : $this->_db->loadResultArray();
                     if ($fieldstopos) {
                         $field = implode(',', $fieldstopos);
                         $query = 'INSERT INTO #__flexicontent_templates (`template`, `layout`, `position`, `fields`) VALUES(' . $this->_db->Quote($folder) . ',' . $this->_db->Quote($view) . ',' . $this->_db->Quote($group) . ',' . $this->_db->Quote($field) . ')';
                         $this->_db->setQuery($query);
                         // By catching SQL error (e.g. layout configuration of template already exists),
                         // we will allow execution to continue, thus clearing "positions" column in fields table
                         try {
                             $this->_db->query();
                         } catch (Exception $e) {
                         }
                         if ($this->_db->getErrorNum()) {
                             echo $this->_db->getErrorMsg();
                         }
                     }
                 }
             }
         }
     }
     // delete the temporary table
     $query = 'DROP TABLE #__flexicontent_positions_tmp';
     $this->_db->setQuery($query);
     $this->_db->query();
     // delete the old positions
     $query = "UPDATE #__flexicontent_fields SET positions = ''";
     $this->_db->setQuery($query);
     $this->_db->query();
     // alter ordering field for releases prior to beta5
     $query = "ALTER TABLE #__flexicontent_cats_item_relations MODIFY `ordering` int(11) NOT NULL default '0'";
     $this->_db->setQuery($query);
     $this->_db->query();
     $query = "ALTER TABLE #__flexicontent_fields_type_relations MODIFY `ordering` int(11) NOT NULL default '0'";
     $this->_db->setQuery($query);
     $this->_db->query();
     return $return;
 }