Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

Location:
plugins/themeEditor
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/themeEditor/_admin.php

    r2370 r2566  
    3838          try { 
    3939               $core->auth->user_prefs->interface->put('colorsyntax',!empty($_POST['colorsyntax']),'boolean'); 
    40           }  
     40          } 
    4141          catch (Exception $e) 
    4242          { 
     
    4444          } 
    4545     } 
    46       
     46 
    4747     public static function adminPreferencesForm($core) 
    4848     { 
     
    5050          $core->auth->user_prefs->addWorkspace('interface'); 
    5151 
    52           echo       
     52          echo 
    5353          '<p><label for="colorsyntax" class="classic">'. 
    5454          form::checkbox('colorsyntax',1,$core->auth->user_prefs->interface->colorsyntax).'</label>'. 
     
    5757     } 
    5858} 
    59 ?> 
  • plugins/themeEditor/_define.php

    r2257 r2566  
    2121     ) 
    2222); 
    23 ?> 
  • plugins/themeEditor/class.themeEditor.php

    r1179 r2566  
    1515{ 
    1616     protected $core; 
    17       
     17 
    1818     protected $default_theme; 
    1919     protected $user_theme; 
    2020     protected $parent_theme; 
    21       
     21 
    2222     protected $default_tpl = array(); 
    2323     public $tpl = array(); 
     
    2525     public $js  = array(); 
    2626     public $po  = array(); 
    27       
     27 
    2828     public function __construct($core) 
    2929     { 
     
    4242          $this->findLocales(); 
    4343     } 
    44       
     44 
    4545     public function filesList($type,$item='%1$s') 
    4646     { 
    4747          $files = $this->getFilesFromType($type); 
    48            
     48 
    4949          if (empty($files)) { 
    5050               return '<p>'.__('No file').'</p>'; 
    5151          } 
    52            
     52 
    5353          $list = ''; 
    5454          foreach ($files as $k => $v) 
     
    6363               $list .= sprintf($li,$k,html::escapeHTML($k)); 
    6464          } 
    65            
     65 
    6666          return sprintf('<ul>%s</ul>',$list); 
    6767     } 
    68       
     68 
    6969     public function getFileContent($type,$f) 
    7070     { 
    7171          $files = $this->getFilesFromType($type); 
    72            
     72 
    7373          if (!isset($files[$f])) { 
    7474               throw new Exception(__('File does not exist.')); 
    7575          } 
    76            
     76 
    7777          $F = $files[$f]; 
    7878          if (!is_readable($F)) { 
    7979               throw new Exception(sprintf(__('File %s is not readable'),$f)); 
    8080          } 
    81            
     81 
    8282          return array( 
    8383               'c' => file_get_contents($F), 
     
    8787          ); 
    8888     } 
    89       
     89 
    9090     public function writeFile($type,$f,$content) 
    9191     { 
    9292          $files = $this->getFilesFromType($type); 
    93            
     93 
    9494          if (!isset($files[$f])) { 
    9595               throw new Exception(__('File does not exist.')); 
    9696          } 
    97            
     97 
    9898          try 
    9999          { 
    100100               $dest = $this->getDestinationFile($type,$f); 
    101                 
     101 
    102102               if ($dest == false) { 
    103103                    throw new Exception(); 
    104104               } 
    105                 
     105 
    106106               if ($type == 'tpl' && !is_dir(dirname($dest))) { 
    107107                    files::makeDir(dirname($dest)); 
    108108               } 
    109                 
     109 
    110110               if ($type == 'po' && !is_dir(dirname($dest))) { 
    111111                    files::makeDir(dirname($dest)); 
    112112               } 
    113                 
     113 
    114114               $fp = @fopen($dest,'wb'); 
    115115               if (!$fp) { 
    116116                    throw new Exception('tocatch'); 
    117117               } 
    118                 
     118 
    119119               $content = preg_replace('/(\r?\n)/m',"\n",$content); 
    120120               $content = preg_replace('/\r/m',"\n",$content); 
    121                 
     121 
    122122               fwrite($fp,$content); 
    123123               fclose($fp); 
    124                 
     124 
    125125               # Updating inner files list 
    126126               $this->updateFileInList($type,$f,$dest); 
     
    131131          } 
    132132     } 
    133       
     133 
    134134     protected function getDestinationFile($type,$f) 
    135135     { 
     
    141141               $dest = $this->user_theme.'/'.$f; 
    142142          } 
    143            
     143 
    144144          if (file_exists($dest) && is_writable($dest)) { 
    145145               return $dest; 
    146146          } 
    147            
     147 
    148148          if ($type == 'tpl' && !is_dir(dirname($dest))) { 
    149149               if (is_writable($this->user_theme)) { 
     
    161161               return $dest; 
    162162          } 
    163            
     163 
    164164          return false; 
    165165     } 
    166       
     166 
    167167     protected function getFilesFromType($type) 
    168168     { 
     
    181181          } 
    182182     } 
    183       
     183 
    184184     protected function updateFileInList($type,$f,$file) 
    185185     { 
     
    201201                    return; 
    202202          } 
    203            
     203 
    204204          $list[$f] = $file; 
    205205     } 
    206       
     206 
    207207     protected function findTemplates() 
    208208     { 
    209209          # First, we look in template paths 
    210210          $this->default_tpl = $this->getFilesInDir($this->default_theme.'/tpl'); 
    211            
     211 
    212212          $this->tpl = array_merge( 
    213213               $this->default_tpl, 
     
    216216               ); 
    217217          $this->tpl = array_merge($this->getFilesInDir(DC_ROOT.'/inc/public/default-templates'),$this->tpl); 
    218            
     218 
    219219          # Then we look in 'default-templates' plugins directory 
    220220          $plugins = $this->core->plugins->getModules(); 
     
    222222               $this->tpl = array_merge($this->getFilesInDir($p['root'].'/default-templates'),$this->tpl); 
    223223          } 
    224            
     224 
    225225          uksort($this->tpl,array($this,'sortFilesHelper')); 
    226226     } 
    227       
     227 
    228228     protected function findStyles() 
    229229     { 
     
    231231          $this->css= array_merge($this->css,$this->getFilesInDir($this->user_theme.'/style','css','style/')); 
    232232     } 
    233       
     233 
    234234     protected function findScripts() 
    235235     { 
     
    237237          $this->js = array_merge($this->js,$this->getFilesInDir($this->user_theme.'/js','js','js/')); 
    238238     } 
    239       
     239 
    240240     protected function findLocales() 
    241241     { 
     
    248248          } 
    249249     } 
    250       
     250 
    251251     protected function getFilesInDir($dir,$ext=null,$prefix='',$model=null) 
    252252     { 
     
    255255               return array(); 
    256256          } 
    257            
     257 
    258258          $d = dir($dir); 
    259259          $res = array(); 
     
    266266               } 
    267267          } 
    268            
     268 
    269269          return $res; 
    270270     } 
    271       
     271 
    272272     protected function sortFilesHelper($a,$b) 
    273273     { 
     
    275275               return 0; 
    276276          } 
    277            
     277 
    278278          $ext_a = files::getExtension($a); 
    279279          $ext_b = files::getExtension($b); 
    280            
     280 
    281281          return strcmp($ext_a.'.'.$a,$ext_b.'.'.$b); 
    282282     } 
    283283} 
    284 ?> 
  • plugins/themeEditor/index.php

    r2256 r2566  
    4545          throw $e; 
    4646     } 
    47       
     47 
    4848     # Write file 
    4949     if (!empty($_POST['write'])) 
     
    117117     '<p><label for="file_content">'.sprintf(__('Editing file %s'),'<strong>'.$file['f']).'</strong></label></p>'. 
    118118     '<p>'.form::textarea('file_content',72,25,html::escapeHTML($file['c']),'maximal','',!$file['w']).'</p>'; 
    119       
     119 
    120120     if ($file['w']) 
    121121     { 
     
    130130          echo '<p>'.__('This file is not writable. Please check your theme files permissions.').'</p>'; 
    131131     } 
    132       
     132 
    133133     echo 
    134134     '</fieldset></form>'; 
    135135 
    136136     if ($user_ui_colorsyntax) { 
    137           $editorMode =  
     137          $editorMode = 
    138138               (!empty($_REQUEST['css']) ? "css" : 
    139139               (!empty($_REQUEST['js']) ? "javascript" : 
    140140               (!empty($_REQUEST['po']) ? "text/plain" : "text/html"))); 
    141           echo  
     141          echo 
    142142          '<script> 
    143143               window.CodeMirror.defineMode("dotclear", function(config) { 
  • plugins/themeEditor/script.js

    r948 r2566  
    33     $('#file-form input[name="write"]').click(function() { 
    44          var f = this.form; 
    5            
     5 
    66          var data = { 
    77               file_content: (!dotclear.colorsyntax ? $(f).find('#file_content').get(0).value : editor.getValue()), 
     
    99               write: 1 
    1010          }; 
    11            
     11 
    1212          if (msg == false) { 
    1313               msg = $('<p style="font-weight:bold; color:red;"></p>'); 
    1414               $('#file_content').parent().after(msg); 
    1515          } 
    16            
     16 
    1717          msg.text(dotclear.msg.saving_document); 
    18            
     18 
    1919          $.post(document.location.href,data,function(res,status) { 
    2020               var err = $(res).find('div.error li:first'); 
     
    2828               } 
    2929          }); 
    30            
     30 
    3131          return false; 
    3232     }); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map