Example #1
0
 /**
  * display method
  * @return void
  **/
 function display($tpl = null)
 {
     global $option, $mainframe;
     $html = '';
     $selected_template = NULL;
     $templates = JYAML::getTemplates();
     $db =& JFactory::getDBO();
     // Get the current default template
     $query = ' SELECT template ' . ' FROM #__templates_menu ' . ' WHERE client_id = 0' . ' AND menuid = 0 ';
     $db->setQuery($query);
     $defaultemplate = $db->loadResult();
     $switch_template = JRequest::getVar('switch_template', false, 'POST');
     if ($switch_template) {
         setcookie('switch_template', $switch_template, time() + 600);
         $selected_template = $switch_template;
         $mainframe->enqueueMessage(JText::_('YAML SWITCH TEMPLATE MSG') . ': ' . $selected_template);
         $mainframe->redirect(JURI::base() . 'index.php?option=' . $option);
     } elseif (isset($_COOKIE['switch_template'])) {
         $selected_template = $_COOKIE['switch_template'];
     }
     if (!$selected_template) {
         $first = true;
         foreach ($templates as $template) {
             if ($first) {
                 $selected_template = $template->name;
             }
             if ($defaultemplate == $template->name) {
                 $selected_template = $defaultemplate;
             }
             $first = false;
         }
     }
     /* Mask default template in list */
     $i = 0;
     $no_tpl_activ = true;
     foreach ($templates as $template) {
         if ($defaultemplate == $template->name) {
             $templates[$i]->text = $template->name . ' (default)';
             $no_tpl_activ = false;
         }
         $i++;
     }
     $this->assignRef('no_tpl_activ', $no_tpl_activ);
     if (!$selected_template) {
         echo '<p class="yaml_msg">' . JText::_('YAML NO TEMPLATES FOUND') . '</p>';
         $html .= '<form id="install_tpl_pgl" enctype="multipart/form-data" action="index.php" method="post" name="adminForm_tpl_install">';
         $html .= '<input type="hidden" id="install_url" name="install_url" class="input_box" size="70" value="' . JYAML::getDownloadURL('template') . '" />';
         $html .= '<p style="text-align:center;"><input type="submit" class="button" value="' . JText::_('YAML TEMPLATE INSTALL ACTIVATE DEFAULT') . '" /></p>';
         $html .= '<input type="hidden" name="type" value="" />';
         $html .= '<input type="hidden" name="installtype" value="url" />';
         $html .= '<input type="hidden" name="task" value="installDefaultTemplate" />';
         $html .= '<input type="hidden" name="option" value="' . $option . '" />';
         $html .= JHTML::_('form.token');
         $html .= '</form>';
         $html .= '<div id="installresult"></div>';
         echo $html;
         return false;
     }
     JToolBarHelper::title(JText::_('YAML COMPONENT TITLE') . ': <small>[' . $selected_template . ']</small>', 'yamlconfig');
     $this->assignRef('selected_template', $selected_template);
     $this->assignRef('template_name', $selected_template);
     $lists['switch_template'] = JHTML::_('select.genericlist', $templates, 'switch_template', '', 'name', 'text', $selected_template);
     // Global XML for referenz view
     $xmlfile = JPATH_SITE . DS . 'templates' . DS . $selected_template . DS . 'config' . DS . '_global.xml';
     $config_global = JYAML::readConfig($selected_template, $xmlfile);
     $conf_global = JYAML::parseConfigDesign($config_global);
     $this->assignRef('conf_global', $conf_global);
     $designlist = JYAML::getDesignList();
     $this->assignRef('designlist', $designlist);
     $this->assignRef('lists', $lists);
     $bar =& JToolBar::getInstance('toolbar');
     $bar->appendButton('Popup', 'upload', 'YAML IMPORT DESIGN', 'index3.php?option=' . $option . '&controller=fileControl&task=importDesign&template=' . $selected_template);
     $bar->appendButton('Popup', 'config', 'YAML DEFAULT CONF TXT', 'index3.php?option=' . $option . '&controller=defaultConfig&task=edit&template_name=' . $selected_template);
     $template_plugins = JYAML::getPlugins($selected_template);
     $this->assignRef('template_plugins', $template_plugins);
     JYAML::getPluginStatus();
     // FTP-Mode
     $ftp = !JClientHelper::hasCredentials('ftp');
     $this->assignRef('require_ftp_login', $ftp);
     parent::display($tpl);
 }
Example #2
0
    function processUpdate()
    {
        global $option, $mainframe;
        $allow_url_fopen = ini_get('allow_url_fopen');
        if (!$allow_url_fopen) {
            echo '<p class="yaml_msg">allow_url_fopen on PHP is disabled on your host. Please make a manual Update.</p>';
            $mainframe->close();
        } else {
            $data = JYAML::getVersionInfo(true);
            $version = $data['i-j-version'] . '-' . $data['i-j-build'];
            /* Update URL */
            $url = JYAML::getDownloadURL('updater') . '?version=' . rawurlencode($version) . '&full=1';
            $updateFiles = file_get_contents($url);
            $files = $this->getUpdateFiles($updateFiles);
        }
        $config =& JFactory::getConfig();
        $tmp_path = $config->getValue('config.tmp_path');
        jimport('joomla.filesystem.archive');
        $dataold = JYAML::getVersionInfo(true);
        /* Full Update */
        if (isset($files['full'])) {
            $extractPath = $tmp_path . DS . 'jyaml_update';
            $filename = basename($files['full']);
            /* Delete temp folder and create empty */
            if (JFolder::exists($extractPath)) {
                JFolder::delete($extractPath);
                JFolder::create($extractPath);
            }
            if (JFile::exists($tmp_path . DS . $filename)) {
                JFile::delete($tmp_path . DS . $filename);
            }
            $content = file_get_contents($files['full']);
            if (JFile::exists($tmp_path . DS . $filename)) {
                JFile::delete($tmp_path . DS . $filename);
            }
            if (!JFile::write($tmp_path . DS . $filename, $content)) {
                echo '<p class="off">' . JText::_('YAML CANT EXTRACT SAVE UPDATE FILE IN TMP') . '</p>';
            }
            if (!JArchive::extract($tmp_path . DS . $filename, $extractPath)) {
                echo '<p class="off">' . JText::_('YAML CANT EXTRACT UPDATE FILE') . '</p>';
            }
            // Call update script if available
            $update_script = $extractPath . DS . 'jyaml_update_script.php';
            if (JFile::exists($update_script)) {
                include_once $update_script;
                $update_result = new jyamlUpdateScript();
                // Delete update script
                JFile::delete($update_script);
                if (!$update_result) {
                    echo '<p class="off">' . JText::_('YAML RUN UPDATE SCRIPT FAIL') . '</p>';
                }
            }
            $files = array();
            $files = JFolder::files($extractPath, '.', true, true);
            $error_folders = array();
            $error_files = array();
            foreach ($files as $file) {
                $file_relative = str_replace($extractPath . DS, '', $file);
                $dest = JPATH_ROOT . DS . $file_relative;
                if (!JFolder::exists(dirname($dest))) {
                    if (!JFolder::create(dirname($dest))) {
                        $error_folders[] = dirname($dest);
                    }
                }
                if (!JFile::copy($file, $dest)) {
                    $error_files[] = DS . $file_relative;
                }
            }
            if ($error_folders) {
                echo '<p class="off">' . JText::_('YAML CANT CREATE DIRECTORY') . '</p>';
                echo '<ul>';
                foreach ($error_folders as $ef) {
                    echo '<li>' . $ef . '</li>';
                }
                echo '</ul>';
            }
            if ($error_files) {
                echo '<p class="off">' . JText::_('YAML CANT UPDATE-CREATE FILE') . '</p>';
                echo '<ul>';
                foreach ($error_files as $ef) {
                    echo '<li>' . $ef . '</li>';
                }
                echo '</ul>';
            }
            if (!$error_folders && !$error_files) {
                echo '<h2 class="on" style="text-align:center;">' . JText::_('YAML UPDATE SUCCESSFULLY') . '</h2>';
            }
            /* Delete temp file and folder */
            if (JFolder::exists($extractPath)) {
                JFolder::delete($extractPath);
            }
            if (JFile::exists($tmp_path . DS . $filename)) {
                JFile::delete($tmp_path . DS . $filename);
            }
            $data = JYAML::getVersionInfo(true);
            echo '<hr />';
            echo '<p class="off" style="font-weight:normal;">' . JText::_('YAML UPDATE OLD VERSION') . ': ' . $dataold['i-j-version'] . ' Build: ' . $dataold['i-j-build'] . '<p>';
            echo '<p class="on" style="font-weight:bold;">' . JText::_('YAML UPDATE NEW VERSION') . ': ' . $data['i-j-version'] . ' Build: ' . $data['i-j-build'] . '<p>';
            echo '<hr />';
            ?>
      <fieldset>
          <div align="center">
            <button onclick="window.parent.location.replace('index.php?option=<?php 
            echo $option;
            ?>
');" type="button"><?php 
            echo JText::_('YAML CLOSE UPDATE WINDOW');
            ?>
</button>
          </div>
      </fieldset>
      <?php 
        }
        $mainframe->close();
    }
Example #3
0
 /**
  * Satus of YAML Plugin
  * @param  ext
  * @return message in queue
  **/
 function getPluginStatus()
 {
     global $option, $mainframe;
     $html = '';
     //Get the database object
     $db =& JFactory::getDBO();
     $query = 'SELECT published FROM #__plugins' . ' WHERE element = \'jyaml\' and folder = \'system\'';
     $db->setQuery($query);
     $result = $db->loadResult();
     $plugin_file = JPATH_SITE . DS . 'plugins' . DS . 'system' . DS . 'jyaml.php';
     if (!JFile::exists($plugin_file)) {
         $result = 2;
     }
     $html .= '<p style="text-align:center;text-decoration:underline;">YAML Joomla! System Plugin:</p>';
     if ($result == '0') {
         $html .= '<p style="text-align:center;">' . JText::_('YAML PLUGIN DISABLED') . '</p>';
         $html .= '<p style="text-align:center"><a href="index.php?option=' . $option . '&amp;task=enablePlugin">[ ' . JText::_('YAML PLUGIN ENABLE BUTTON') . ' ]</a></p>';
     } elseif ($result == '1') {
         //$html .= '<p class="on">'.JText::_( 'YAML PLUGIN ENABLED' ).'</p>';
     } else {
         $html .= '<p style="text-align:center;">' . JText::_('YAML PLUGIN NOT INSTALLED') . '</p>';
         $allow_url_fopen = ini_get('allow_url_fopen');
         if (!$allow_url_fopen) {
             $html .= '<p style="text-align:center;"><a href="' . JYAML::getDownloadURL('plugin') . '" target="_blank">[ ' . JText::_('YAML PLUGIN DOWNLOAD HERE') . ' ]</a></p>';
         } else {
             $html .= '<form id="install_tpl_pgl" enctype="multipart/form-data" action="index.php" method="post" name="adminForm_pgl_install">';
             $html .= '<input type="hidden" id="install_url" name="install_url" class="input_box" size="70" value="' . JYAML::getDownloadURL('plugin') . '" />';
             $html .= '<p style="text-align:center;"><input type="submit" class="button" value="' . JText::_('YAML PLUGIN INSTALL') . '" /></p>';
             $html .= '<input type="hidden" name="type" value="" />';
             $html .= '<input type="hidden" name="installtype" value="url" />';
             $html .= '<input type="hidden" name="task" value="installPlugin" />';
             $html .= '<input type="hidden" name="option" value="' . $option . '" />';
             $html .= JHTML::_('form.token');
             $html .= '</form>';
             $html .= '<div id="installresult"></div>';
         }
     }
     if ($result != '1') {
         $mainframe->enqueueMessage($html, 'error');
     }
 }