Dotclear


Ignore:
Timestamp:
02/14/14 22:05:36 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add reset button in theme editor (available only on template file and if there is a model, from parent or from template set), addresses #1703

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/themeEditor/class.themeEditor.php

    r2651 r2663  
    158158     } 
    159159 
     160     public function deletableFile($type,$f) 
     161     { 
     162          if ($type != 'tpl') { 
     163               // Only tpl files may be deleted 
     164               return false; 
     165          } 
     166 
     167          $files = $this->getFilesFromType($type); 
     168          if (isset($files[$f])) { 
     169               $dest = $this->getDestinationFile($type,$f); 
     170               if ($dest) { 
     171                    if (file_exists($dest) && is_writable($dest)) { 
     172                         // Is there a model (parent theme or template set) ? 
     173                         if (isset($this->tpl_model[$f])) { 
     174                              return true; 
     175                         } 
     176                    } 
     177               } 
     178          } 
     179          return false; 
     180     } 
     181 
     182     public function deleteFile($type,$f) 
     183     { 
     184          if ($type != 'tpl') { 
     185               // Only tpl files may be deleted 
     186               return; 
     187          } 
     188 
     189          $files = $this->getFilesFromType($type); 
     190          if (!isset($files[$f])) { 
     191               throw new Exception(__('File does not exist.')); 
     192          } 
     193 
     194          try 
     195          { 
     196               $dest = $this->getDestinationFile($type,$f); 
     197               if ($dest) { 
     198                    // File exists and may be deleted 
     199                    unlink($dest); 
     200 
     201                    // Updating template files list 
     202                    $this->findTemplates(); 
     203               } 
     204          } 
     205          catch (Exception $e) 
     206          { 
     207               throw new Exception(sprintf(__('Unable to delete file %s. Please check your theme files and folders permissions.'),$f)); 
     208          } 
     209     } 
     210 
    160211     protected function getDestinationFile($type,$f) 
    161212     { 
     
    235286          $this->tpl = array_merge( 
    236287               $this->getFilesInDir($this->tplset_theme), 
    237                $this->getFilesInDir($this->parent_theme.'/tpl'), 
    238                $this->getFilesInDir($this->user_theme.'/tpl') 
     288               $this->getFilesInDir($this->parent_theme.'/tpl') 
    239289               ); 
     290          $this->tpl_model = $this->tpl; 
     291 
     292          $this->tpl = array_merge($this->tpl,$this->getFilesInDir($this->user_theme.'/tpl')); 
    240293 
    241294          # Then we look in 'default-templates' plugins directory 
     
    243296          foreach ($plugins as $p) { 
    244297               $this->tpl = array_merge($this->getFilesInDir($p['root'].'/default-templates'),$this->tpl); 
     298               $this->tpl_model = array_merge($this->getFilesInDir($p['root'].'/default-templates'),$this->tpl_model); 
    245299          } 
    246300 
Note: See TracChangeset for help on using the changeset viewer.

Sites map