Example #1
0
    function createDesign()
    {
        global $option;
        $source = JRequest::getVar('source', '');
        $template = JRequest::getVar('template', '');
        $source_files = array();
        if (!$source) {
            $source_files = JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'config', 'xml$', false, false, array('_global.xml'));
        }
        $templates = JYAML::getTemplates();
        ?>
    <form action="index.php" method="post" name="adminForm" autocomplete="off">
      <fieldset>
          <div style="float: right;">
            <button onclick="window.parent.document.getElementById('sbox-window').close();" type="button"><?php 
        echo JText::_('YAML CANCEL');
        ?>
</button>
          </div>
          <div class="configuration"><?php 
        echo JText::_('YAML CREATE DESIGN TITLE');
        ?>
</div>
      </fieldset>  
      <br /><br />
      <label class="bigform" for="new_design_name"><?php 
        echo JText::_('YAML ENTER DESIGN NAME');
        ?>
:</label><br />
      <input class="bigform" type="text" name="new_design_name" value="" />
      <br /><br />
      <?php 
        if ($source_files) {
            echo '<label for="basedesign">' . JText::_('YAML LABEL BASE DESIGN') . ':</label><br />';
            echo '<select name="basedesign">';
            echo '<option value="">' . JText::_('YAML SELECT BASE DESIGN') . '</option>';
            //echo '<option value="empty">'.JText::_( 'YAML CREATE EMPTY DESIGN' ).'</option>';
            foreach ($source_files as $file) {
                $file = JFile::stripExt($file);
                echo '<option value="' . $file . '">' . $file . '</option>';
            }
            echo '</select>';
        }
        echo '<br /><br />';
        echo '<label for="template_dest">' . JText::_('YAML LABEL TEMPLATE DESTINATION') . ':</label><br />';
        echo '<select name="template_dest">';
        echo '<option selected="selected" class="highlight" value="">->' . $template . ' <- ' . JText::_('YAML CURRENT SELECTED') . '</option>';
        foreach ($templates as $tmpl) {
            if ($tmpl->name != $template) {
                echo '<option value="' . $tmpl->name . '">' . $tmpl->name . '</option>';
            }
        }
        echo '</select>';
        ?>
      <br /><br /><br />
      <div align="center">
        <button class="bigform" onclick="create_design();" type="button"><?php 
        echo JText::_('YAML CREATE DESIGN');
        ?>
</button>
      </div>

      
      <input type="hidden" name="task" value="" />
      <input type="hidden" name="source" value="<?php 
        echo $source;
        ?>
" />
      <input type="hidden" name="template" value="<?php 
        echo $template;
        ?>
" />
      <input type="hidden" name="controller" value="fileControl" />    
      <input type="hidden" value="<?php 
        echo $option;
        ?>
" name="option"/>
    </form>
    
    <script type="text/javascript">
      function create_design() {
        var form = document.adminForm;
        <?php 
        if (!$source) {
            ?>
        var selIndex = form.basedesign.selectedIndex;
        <?php 
        } else {
            ?>
        var selIndex = 1;
        <?php 
        }
        ?>
                
        if (form.new_design_name.value=='') {
          alert('<?php 
        echo JText::_('YAML PLEASE ENTER DESIGN NAME', 1);
        ?>
');
          form.new_design_name.focus();
        } else if (selIndex < 1) {
          alert('<?php 
        echo JText::_('YAML PLEASE SELECT DESIGN SOURCE', 1);
        ?>
');
          form.basedesign.focus();
        } else {
          submitbutton('save_design');
          window.top.setTimeout('window.parent.location.replace(\'index.php?option=<?php 
        echo $option;
        ?>
\')', 2000);
        }
      }
    </script>
    <?php 
    }
Example #2
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);
 }