Dotclear


Ignore:
Timestamp:
11/26/12 13:27:11 (13 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Add capability to edit locales files for theme editor plugin

File:
1 edited

Legend:

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

    r270 r1036  
    2424     public $css = array(); 
    2525     public $js  = array(); 
     26     public $po  = array(); 
    2627      
    2728     public function __construct($core) 
     
    3940          $this->findStyles(); 
    4041          $this->findScripts(); 
     42          $this->findLocales(); 
    4143     } 
    4244      
     
    106108               } 
    107109                
     110               if ($type == 'po' && !is_dir(dirname($dest))) { 
     111                    files::makeDir(dirname($dest)); 
     112               } 
     113                
    108114               $fp = @fopen($dest,'wb'); 
    109115               if (!$fp) { 
     
    130136          if ($type == 'tpl') { 
    131137               $dest = $this->user_theme.'/tpl/'.$f; 
     138          } elseif ($type == 'po') { 
     139               $dest = $this->user_theme.'/locales/'.$f; 
    132140          } else { 
    133141               $dest = $this->user_theme.'/'.$f; 
     
    143151               } 
    144152          } 
    145            
     153 
     154          if ($type == 'po' && !is_dir(dirname($dest))) { 
     155               if (is_writable($this->user_theme)) { 
     156                    return $dest; 
     157               } 
     158          } 
     159 
    146160          if (is_writable(dirname($dest))) { 
    147161               return $dest; 
     
    161175               case 'js': 
    162176                    return $this->js; 
     177               case 'po': 
     178                    return $this->po; 
    163179               default: 
    164180                    return array(); 
     
    178194               case 'js': 
    179195                    $list =& $this->js; 
     196                    break; 
     197               case 'po': 
     198                    $list =& $this->po; 
    180199                    break; 
    181200               default: 
     
    219238     } 
    220239      
     240     protected function findLocales() 
     241     { 
     242          $langs = l10n::getISOcodes(1,1); 
     243          foreach ($langs as $k => $v) { 
     244               if ($this->parent_theme) { 
     245                    $this->po = array_merge($this->po,$this->getFilesInDir($this->parent_theme.'/locales/'.$v,'po',$v.'/')); 
     246               } 
     247               $this->po = array_merge($this->po,$this->getFilesInDir($this->user_theme.'/locales/'.$v,'po',$v.'/')); 
     248          } 
     249     } 
     250      
    221251     protected function getFilesInDir($dir,$ext=null,$prefix='') 
    222252     { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map