1 <?php
2
3 4 5 6 7 8 9 10
11
12 13 14 15 16 17 18 19
20 class P3BootstrapCommand extends CConsoleCommand
21 {
22 public $themePath = 'application.themes';
23 public $publicThemePath = 'application.www.themes';
24
25 public function getHelp()
26 {
27 echo <<<EOS
28 n/a
29 EOS;
30 }
31
32 33 34 35
36 public function run($args)
37 {
38 $srcPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
39
40 $themePath = realpath(Yii::getPathOfAlias($this->themePath));
41 $publicThemePath = realpath(Yii::getPathOfAlias($this->publicThemePath));
42
43 if (!is_dir($themePath)) {
44 echo "\nInvalid 'themePath', aborting.";
45 return;
46 }
47 if (!is_dir($publicThemePath)) {
48 echo "\nInvalid 'publicThemePath', aborting.";
49 return;
50 }
51
52 echo "\nCopying p3bootstrap package to theme folders ...\n";
53
54 $backendViews = $this->buildFileList(
55 $srcPath . 'views/layouts', $themePath . DIRECTORY_SEPARATOR . 'backend/views/layouts');
56 $backendSkins = $this->buildFileList(
57 $srcPath . 'views/skins', $themePath . DIRECTORY_SEPARATOR . 'backend/views/skins');
58 unset($backendViews['_menu.php']);
59
60 $backendCss = $this->buildFileList(
61 $srcPath . 'css', $publicThemePath . DIRECTORY_SEPARATOR . 'backend/css');
62 $backendLess = $this->buildFileList(
63 $srcPath . 'less', $publicThemePath . DIRECTORY_SEPARATOR . 'backend/less');
64
65 $frontendViews = $this->buildFileList(
66 $srcPath . 'views',
67 $themePath . DIRECTORY_SEPARATOR . 'frontend/views',
68 '',
69 array('skins'));
70 $frontendCss = $this->buildFileList(
71 $srcPath . 'css', $publicThemePath . DIRECTORY_SEPARATOR . 'frontend/css');
72 $frontendLess = $this->buildFileList(
73 $srcPath . 'less', $publicThemePath . DIRECTORY_SEPARATOR . 'frontend/less');
74 $frontendCkeditor = $this->buildFileList(
75 $srcPath . 'ckeditor', $publicThemePath . DIRECTORY_SEPARATOR . 'frontend/ckeditor');
76
77 echo "\nCopying theme files for 'backend' theme...\n";
78 $this->copyFiles($backendViews);
79 $this->copyFiles($backendSkins);
80 $this->copyFiles($backendCss);
81 $this->copyFiles($backendLess);
82
83 echo "\nCopying theme files for 'frontend' theme...\n";
84 $this->copyFiles($frontendViews);
85 $this->copyFiles($frontendCss);
86 $this->copyFiles($frontendLess);
87 $this->copyFiles($frontendCkeditor);
88 }
89
90 }
91
92 ?>