Dotclear

Changeset 2663:8dd9be9b33c1


Ignore:
Timestamp:
02/14/14 22:05:36 (11 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

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • locales/fr/plugins.po

    r2647 r2663  
    19921992msgstr "Du jeu de template :" 
    19931993 
     1994msgid "Reset" 
     1995msgstr "Réinitialiser" 
     1996 
     1997msgid "Are you sure you want to reset this file?" 
     1998msgstr "Êtes-vous sûr de vouloir réinitialiser ce fichier ?" 
     1999 
     2000msgid "The file has been reset." 
     2001msgstr "Le fichier a été réinitialisé." 
     2002 
    19942003#~ msgid "RSS or Atom feed subscription links" 
    19952004#~ msgstr "Liens d'abonnement aux flux RSS ou Atom" 
  • plugins/themeEditor/_define.php

    r2566 r2663  
    1616     /* Description*/         "Theme Editor", 
    1717     /* Author */             "Olivier Meunier", 
    18      /* Version */            '1.0', 
     18     /* Version */            '1.1', 
    1919     array( 
    2020          'type'         =>        'plugin' 
  • 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 
  • plugins/themeEditor/index.php

    r2566 r2663  
    5252          $o->writeFile($file['type'],$file['f'],$file['c']); 
    5353     } 
     54 
     55     # Delete file 
     56     if (!empty($_POST['delete'])) 
     57     { 
     58          $o->deleteFile($file['type'],$file['f']); 
     59          dcPage::addSuccessNotice(__('The file has been deleted.')); 
     60          http::redirect($p_url.'&'.$file['type'].'='.$file['f']); 
     61     } 
    5462} 
    5563catch (Exception $e) 
     
    6876  <?php echo dcPage::jsVar('dotclear.msg.document_saved',__("Document saved")); ?> 
    6977  <?php echo dcPage::jsVar('dotclear.msg.error_occurred',__("An error occurred:")); ?> 
     78  <?php echo dcPage::jsVar('dotclear.msg.confirm_reset_file',__("Are you sure you want to reset this file?")); ?> 
    7079  <?php echo dcPage::jsVar('dotclear.colorsyntax',$user_ui_colorsyntax); ?> 
    7180  //]]> 
     
    122131          echo 
    123132          '<p><input type="submit" name="write" value="'.__('Save').' (s)" accesskey="s" /> '. 
     133          ($o->deletableFile($file['type'],$file['f']) ? '<input type="submit" name="delete" class="delete" value="'.__('Reset').'" />' : ''). 
    124134          $core->formNonce(). 
    125135          ($file['type'] ? form::hidden(array($file['type']),$file['f']) : ''). 
  • plugins/themeEditor/script.js

    r2566 r2663  
    11$(function() { 
     2     // Cope with saving 
    23     var msg = false; 
    34     $('#file-form input[name="write"]').click(function() { 
     
    3132          return false; 
    3233     }); 
     34 
     35     // Confirm for deleting current file 
     36     $('#file-form input[name="delete"]').click(function() { 
     37          return window.confirm(dotclear.msg.confirm_reset_file); 
     38     }); 
     39 
    3340}); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map