Changeset 3730:5c45a5df9a59 for plugins/buildtools
- Timestamp:
- 03/08/18 17:58:39 (7 years ago)
- Branch:
- default
- Location:
- plugins/buildtools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/buildtools/_admin.php
r2566 r3730 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 13 $core->addBehavior('dcMaintenanceInit', array('dcBuildTools', 'maintenanceAdmin')); 14 14 15 15 class dcBuildTools 16 16 { 17 public static function maintenanceAdmin($maintenance) { 18 $maintenance->addTask('dcMaintenanceBuildtools'); 19 } 17 public static function maintenanceAdmin($maintenance) 18 { 19 $maintenance->addTask('dcMaintenanceBuildtools'); 20 } 20 21 } -
plugins/buildtools/_define.php
r2566 r3730 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_RC_PATH')) { return;}12 if (!defined('DC_RC_PATH')) {return;} 13 13 14 14 $this->registerModule( 15 /* Name */ "buildtools", 16 /* Description*/ "Internal build tools for dotclear team", 17 /* Author */ "dcTeam", 18 /* Version */ '1.0', 19 20 'permissions' =>'admin'21 15 "buildtools", // Name 16 "Internal build tools for dotclear team", // Description 17 "dcTeam", // Author 18 '1.0', // Version 19 array( 20 'permissions' => 'admin' 21 ) 22 22 ); -
plugins/buildtools/_prepend.php
r2095 r3730 1 1 <?php 2 2 3 $__autoload['dcMaintenanceBuildtools'] = dirname(__FILE__) .'/class.dc.maintenance.buildtools.php';3 $__autoload['dcMaintenanceBuildtools'] = dirname(__FILE__) . '/class.dc.maintenance.buildtools.php'; -
plugins/buildtools/class.dc.maintenance.buildtools.php
r2566 r3730 1 1 <?php 2 3 2 4 3 class dcMaintenanceBuildtools extends dcMaintenanceTask 5 4 { 6 protected $tab= 'dev';7 5 protected $tab = 'dev'; 6 protected $group = 'l10n'; 8 7 9 10 11 $this->task= __('Generate fake l10n');12 $this->success= __('fake l10n file generated.');13 $this->error= __('Failed to generate fake l10n file.');14 $this->description= __('Generate a php file that contents strings to translate that are not be done with core tools.');15 8 protected function init() 9 { 10 $this->task = __('Generate fake l10n'); 11 $this->success = __('fake l10n file generated.'); 12 $this->error = __('Failed to generate fake l10n file.'); 13 $this->description = __('Generate a php file that contents strings to translate that are not be done with core tools.'); 14 } 16 15 17 18 19 20 21 include $widget['root'].'/_default_widgets.php';16 public function execute() 17 { 18 global $core; 19 $widget = $this->core->plugins->getModules("widgets"); 20 include $widget['root'] . '/_default_widgets.php'; 22 21 23 24 25 26 22 $faker = new l10nFaker($GLOBALS['core']); 23 $faker->generate_file(); 24 return true; 25 } 27 26 } 28 27 29 class l10nFaker { 30 protected $core; 31 protected $bundled_plugins; 28 class l10nFaker 29 { 30 protected $core; 31 protected $bundled_plugins; 32 32 33 public function __construct($core) { 34 $this->core = $core; 35 $this->bundled_plugins = explode(',', DC_DISTRIB_PLUGINS); 36 $this->core->media = new dcMedia($this->core); 37 } 33 public function __construct($core) 34 { 35 $this->core = $core; 36 $this->bundled_plugins = explode(',', DC_DISTRIB_PLUGINS); 37 $this->core->media = new dcMedia($this->core); 38 } 38 39 39 protected function fake_l10n($str) { 40 return sprintf('__("%s");'."\n",str_replace('"','\\"',$str)); 41 } 42 public function generate_file() { 43 global $__widgets; 44 global $__autoload; 40 protected function fake_l10n($str) 41 { 42 return sprintf('__("%s");' . "\n", str_replace('"', '\\"', $str)); 43 } 44 public function generate_file() 45 { 46 global $__widgets; 47 global $__autoload; 45 48 46 $main= "<?php\n";47 48 49 foreach ($this->core->media->thumb_sizes as $k=> $v) {50 51 52 53 54 55 56 57 $ws = $this->core->auth->user_prefs->favorites;// Favs old school !58 59 60 61 62 63 64 65 file_put_contents(dirname($__autoload['dcCore']).'/_fake_l10n.php', $main);66 67 68 69 70 71 72 73 74 75 76 mkdir(dirname(__FILE__)."/../_fake_plugin");77 file_put_contents(dirname(__FILE__).'/../_fake_plugin/_fake_l10n.php', $plugin);78 49 $main = "<?php\n"; 50 $plugin = "<?php\n"; 51 $main .= "# Media sizes\n\n"; 52 foreach ($this->core->media->thumb_sizes as $k => $v) { 53 $main .= $this->fake_l10n($v[2]); 54 } 55 $post_types = $this->core->getPostTypes(); 56 $main .= "\n# Post types \n\n"; 57 foreach ($post_types as $k => $v) { 58 $main .= $this->fake_l10n($v['label']); 59 } 60 $ws = $this->core->auth->user_prefs->favorites; // Favs old school ! 61 if ($ws) { 62 $main .= "\n# Favorites \n\n"; 63 foreach ($ws->dumpPrefs() as $k => $v) { 64 $fav = unserialize($v['value']); 65 $main .= $this->fake_l10n($fav['title']); 66 } 67 } 68 file_put_contents(dirname($__autoload['dcCore']) . '/_fake_l10n.php', $main); 69 $plugin .= "\n# Plugin names \n\n"; 70 foreach ($this->bundled_plugins as $id) { 71 $p = $this->core->plugins->getModules($id); 72 $plugin .= $this->fake_l10n($p['desc']); 73 } 74 $plugin .= "\n# Widget settings names \n\n"; 75 $widgets = $__widgets->elements(); 76 foreach ($widgets as $w) { 77 $plugin .= $this->fake_l10n($w->desc()); 78 } 79 mkdir(dirname(__FILE__) . "/../_fake_plugin"); 80 file_put_contents(dirname(__FILE__) . '/../_fake_plugin/_fake_l10n.php', $plugin); 81 } 79 82 }
Note: See TracChangeset
for help on using the changeset viewer.