Source for file view.html.php

Documentation is available at view.html.php

  1. <?php
  2. /**
  3. @package     Joomla.Administrator
  4. @subpackage  com_templates
  5. *
  6. @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7. @license     GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13. * View to edit a template style.
  14. *
  15. @package     Joomla.Administrator
  16. @subpackage  com_templates
  17. @since       1.6
  18. */
  19. {
  20.     /**
  21.      * For loading extension state
  22.      */
  23.     protected $state;
  24.  
  25.     /**
  26.      * For loading template details
  27.      */
  28.     protected $template;
  29.  
  30.     /**
  31.      * For loading the source form
  32.      */
  33.     protected $form;
  34.  
  35.     /**
  36.      * For loading source file contents
  37.      */
  38.     protected $source;
  39.  
  40.     /**
  41.      * Extension id
  42.      */
  43.     protected $id;
  44.  
  45.     /**
  46.      * Encrypted file path
  47.      */
  48.     protected $file;
  49.  
  50.     /**
  51.      * List of available overrides
  52.      */
  53.     protected $overridesList;
  54.  
  55.     /**
  56.      * Name of the present file
  57.      */
  58.     protected $fileName;
  59.  
  60.     /**
  61.      * Type of the file - image, source, font
  62.      */
  63.     protected $type;
  64.  
  65.     /**
  66.      * For loading image information
  67.      */
  68.     protected $image;
  69.  
  70.     /**
  71.      * Template id for showing preview button
  72.      */
  73.     protected $preview;
  74.  
  75.     /**
  76.      * For loading font information
  77.      */
  78.     protected $font;
  79.  
  80.     /**
  81.      * For checking if the template is hathor
  82.      */
  83.     protected $hathor;
  84.  
  85.     /**
  86.      * A nested array containing lst of files and folders
  87.      */
  88.     protected $files;
  89.  
  90.     /**
  91.      * An array containing a list of compressed files
  92.      */
  93.     protected $archive;
  94.  
  95.     /**
  96.      * Execute and display a template script.
  97.      *
  98.      * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  99.      *
  100.      * @return  mixed  A string if successful, otherwise a Error object.
  101.      */
  102.     public function display($tpl null)
  103.     {
  104.         $app            JFactory::getApplication();
  105.         $this->file     = $app->input->get('file');
  106.         $this->fileName = base64_decode($this->file);
  107.         $explodeArray   explode('.'$this->fileName);
  108.         $ext            end($explodeArray);
  109.         $this->files    = $this->get('Files');
  110.         $this->state    = $this->get('State');
  111.         $this->template = $this->get('Template');
  112.         $this->preview  = $this->get('Preview');
  113.         $this->hathor   = $this->get('Hathor');
  114.  
  115.         $params       JComponentHelper::getParams('com_templates');
  116.         $imageTypes   explode(','$params->get('image_formats'));
  117.         $sourceTypes  explode(','$params->get('source_formats'));
  118.         $fontTypes    explode(','$params->get('font_formats'));
  119.         $archiveTypes explode(','$params->get('compressed_formats'));
  120.  
  121.         if (in_array($ext$sourceTypes))
  122.         {
  123.             $this->form   = $this->get('Form');
  124.             $this->form->setFieldAttribute('source''syntax'$ext);
  125.             $this->source = $this->get('Source');
  126.             $this->type   = 'file';
  127.         }
  128.         elseif (in_array($ext$imageTypes))
  129.         {
  130.             $this->image = $this->get('Image');
  131.             $this->type  = 'image';
  132.         }
  133.         elseif (in_array($ext$fontTypes))
  134.         {
  135.             $this->font = $this->get('Font');
  136.             $this->type = 'font';
  137.         }
  138.         elseif (in_array($ext$archiveTypes))
  139.         {
  140.             $this->archive = $this->get('Archive');
  141.             $this->type    = 'archive';
  142.         }
  143.         else
  144.         {
  145.             $this->type = 'home';
  146.         }
  147.  
  148.         $this->overridesList = $this->get('OverridesList');
  149.         $this->id            = $this->state->get('extension.id');
  150.  
  151.         // Check for errors.
  152.         if (count($errors $this->get('Errors')))
  153.         {
  154.             $app->enqueueMessage(implode("\n"$errors));
  155.  
  156.             return false;
  157.         }
  158.  
  159.         $this->addToolbar();
  160.  
  161.         return parent::display($tpl);
  162.     }
  163.  
  164.     /**
  165.      * Add the page title and toolbar.
  166.      *
  167.      * @since   1.6
  168.      *
  169.      * @return  void 
  170.      */
  171.     protected function addToolbar()
  172.     {
  173.         JFactory::getApplication()->input->set('hidemainmenu'true);
  174.         $canDo TemplatesHelper::getActions();
  175.  
  176.         if ($canDo->get('core.edit'&& $canDo->get('core.create'&& $canDo->get('core.admin'))
  177.         {
  178.             $showButton true;
  179.         }
  180.         else
  181.         {
  182.             $showButton false;
  183.         }
  184.  
  185.         // Get the toolbar object instance
  186.         $bar JToolBar::getInstance('toolbar');
  187.         $explodeArray explode('.'$this->fileName);
  188.         $ext end($explodeArray);
  189.  
  190.         JToolbarHelper::title(JText::_('COM_TEMPLATES_MANAGER_VIEW_TEMPLATE')'eye thememanager');
  191.  
  192.         // Add a Apply and save button
  193.         if ($this->type == 'file')
  194.         {
  195.             if ($showButton)
  196.             {
  197.                 JToolbarHelper::apply('template.apply');
  198.                 JToolbarHelper::save('template.save');
  199.             }
  200.         }
  201.         // Add a Crop and Resize button
  202.         elseif ($this->type == 'image')
  203.         {
  204.             if ($showButton)
  205.             {
  206.                 JToolbarHelper::custom('template.cropImage''move''move''COM_TEMPLATES_BUTTON_CROP'falsefalse);
  207.  
  208.                 JToolbarHelper::modal('resizeModal''icon-refresh''COM_TEMPLATES_BUTTON_RESIZE');
  209.             }
  210.         }
  211.         // Add an extract button
  212.         elseif ($this->type == 'archive')
  213.         {
  214.             if ($showButton)
  215.             {
  216.                 JToolbarHelper::custom('template.extractArchive''arrow-down''arrow-down''COM_TEMPLATES_BUTTON_EXTRACT_ARCHIVE'falsefalse);
  217.             }
  218.         }
  219.  
  220.         // Add a copy template button
  221.         if ($this->hathor->home == 0)
  222.         {
  223.             if ($showButton)
  224.             {
  225.                 JToolbarHelper::modal('collapseModal''icon-copy''COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
  226.             }
  227.         }
  228.  
  229.         // Add a Template preview button
  230.         if ($this->preview->client_id == 0)
  231.         {
  232.             $bar->appendButton('Link''picture''COM_TEMPLATES_BUTTON_PREVIEW'JUri::root('index.php?tp=1&templateStyle=' $this->preview->id);
  233.         }
  234.  
  235.         // Add Manage folders button
  236.         if ($showButton)
  237.         {
  238.             JToolbarHelper::modal('folderModal''icon-folder icon white''COM_TEMPLATES_BUTTON_FOLDERS');
  239.         }
  240.  
  241.         // Add a new file button
  242.         if ($showButton)
  243.         {
  244.             JToolbarHelper::modal('fileModal''icon-file''COM_TEMPLATES_BUTTON_FILE');
  245.         }
  246.  
  247.         // Add a Rename file Button
  248.         if ($this->hathor->home == 0)
  249.         {
  250.             if ($showButton && $this->type != 'home')
  251.             {
  252.                 JToolbarHelper::modal('renameModal''icon-refresh''COM_TEMPLATES_BUTTON_RENAME_FILE');
  253.             }
  254.         }
  255.  
  256.         // Add a Delete file Button
  257.         if ($showButton && $this->type != 'home')
  258.         {
  259.             JToolbarHelper::modal('deleteModal''icon-remove''COM_TEMPLATES_BUTTON_DELETE_FILE');
  260.         }
  261.  
  262.         // Add a Compile Button
  263.         if ($showButton)
  264.         {
  265.             if ($ext == 'less')
  266.             {
  267.                 JToolbarHelper::custom('template.less''play''play''COM_TEMPLATES_BUTTON_LESS'falsefalse);
  268.             }
  269.         }
  270.  
  271.         if ($this->type == 'home')
  272.         {
  273.             JToolbarHelper::cancel('template.cancel''JTOOLBAR_CLOSE');
  274.         }
  275.         else
  276.         {
  277.             JToolbarHelper::cancel('template.close''COM_TEMPLATES_BUTTON_CLOSE_FILE');
  278.         }
  279.  
  280.         JToolbarHelper::divider();
  281.         JToolbarHelper::help('JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT');
  282.     }
  283.  
  284.     /**
  285.      * Method for creating the collapsible tree.
  286.      *
  287.      * @param   array  $array  The value of the present node for recursion
  288.      *
  289.      * @return  string 
  290.      *
  291.      * @note    Uses recursion
  292.      * @since   3.2
  293.      */
  294.     protected function directoryTree($array)
  295.     {
  296.         $temp        $this->files;
  297.         $this->files = $array;
  298.         $txt         $this->loadTemplate('tree');
  299.         $this->files = $temp;
  300.  
  301.         return $txt;
  302.     }
  303.  
  304.     /**
  305.      * Method for listing the folder tree in modals.
  306.      *
  307.      * @param   array  $array  The value of the present node for recursion
  308.      *
  309.      * @return  string 
  310.      *
  311.      * @note    Uses recursion
  312.      * @since   3.2
  313.      */
  314.     protected function folderTree($array)
  315.     {
  316.         $temp        $this->files;
  317.         $this->files = $array;
  318.         $txt         $this->loadTemplate('folders');
  319.         $this->files = $temp;
  320.  
  321.         return $txt;
  322.     }
  323. }

Documentation generated on Tue, 19 Nov 2013 15:17:26 +0100 by phpDocumentor 1.4.3