Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

новая плюшка: в папку install можно положить файлы install.sql и unin…

…stall.sql которые выполнятся в нужный момент. теперь модули можно удалять совсем. включена мультиязычность. включенны flash messages
  • Loading branch information...
commit d9efd00001e9c3279e2743aef2e9f60a31ad9d8a 1 parent 11ca9c7
@horechek authored
View
11 README.markdown
@@ -12,4 +12,13 @@
## Внимание!
-После установки нужно ограничить доступ к приложению
+После установки нужно ограничить доступ к приложению
+
+## Обновления
+
+### 13.06.2012
+
+* Новая плюшка: в папку install можно положить файлы install.sql и uninstall.sql которые выполнятся в нужный момент.
+* Теперь модули можно удалять совсем.
+* Включена мультиязычность.
+* Включенны flash messages
View
11 index.php
@@ -1,14 +1,13 @@
-<?php
-// include Yii bootstrap file
-$yii=(dirname(__FILE__).'/../framework/system/yii.php');
+<?php
+// change the following paths if necessary
+$yii=dirname(__FILE__).'/../../framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
-// remove the following line when in production mode
+
+// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
-
-// create a Web application instance and run
Yii::createWebApplication($config)->run();
View
0  protected/.htaccess 100644 → 100755
File mode changed
View
22 protected/config/main.php 100644 → 100755
@@ -5,9 +5,13 @@
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
-return array(
+$mainConfig = include dirname(__FILE__).'/../../../protected/config/main.php';
+return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
- 'name'=>'Yii Blog Demo',
+
+ 'sourceLanguage' => 'en',
+
+ 'language' => 'ru',
// preloading 'log' component
'preload'=>array('log'),
@@ -33,16 +37,9 @@
'tablePrefix' => 'tbl_',
),*/
// uncomment the following to use a MySQL database
- /*
- 'db'=>array(
- 'connectionString' => 'mysql:host=localhost;dbname=blog',
- 'emulatePrepare' => true,
- 'username' => 'root',
- 'password' => '',
- 'charset' => 'utf8',
- 'tablePrefix' => 'tbl_',
- ),
- */
+
+ 'db'=>$mainConfig['components']['db'],
+
/*'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
@@ -55,6 +52,7 @@
'posts/<tag:.*?>'=>'post/index',
*/
'install/build/<moduleName:\w+>'=>'install/build',
+ 'install/uninstall/<moduleName:\w+>'=>'install/uninstall',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
View
0  protected/config/params.php 100644 → 100755
File mode changed
View
65 protected/controllers/InstallController.php 100644 → 100755
@@ -17,9 +17,10 @@ public function actionIndex()
$form->archive = CUploadedFile::getInstance($form,'archive');
$form->archive->saveAs(Yii::app()->params['uploadsFolder'] . '/' . $form->archive);
- $this->_unpack($form->archive);
+ $moduleFolder = $this->_unpack($form->archive);
+ $this->_executeSql($moduleFolder);
+ Yii::app()->user->setFlash('success', Yii::t("install", "Modue installed"));
}
-
$this->render('index', array(
'form' => $form
));
@@ -28,11 +29,61 @@ public function actionIndex()
public function actionBuild($moduleName)
{
$this->_pack($moduleName);
-
+ Yii::app()->user->setFlash('success', Yii::t("install", "Modue builded"));
$this->redirect( Yii::app()->baseUrl . '/uploads/' . $moduleName. '.zip');
}
+ public function actionUninstall($moduleName)
+ {
+ if (!is_dir(Yii::app()->params['modulesFolder'] . '/' . $moduleName))
+ {
+ Yii::app()->user->setFlash('error', Yii::t("install", "Not removed"));
+ $this->redirect(Yii::app()->baseUrl);
+ }
+
+ $this->_executeSql($moduleName, 'uninstall');
+
+ $this->_removeDir(Yii::app()->params['modulesFolder'] . '/' . $moduleName);
+
+ Yii::app()->user->setFlash('success', Yii::t("install", "Modue removed"));
+ $this->redirect(Yii::app()->baseUrl);
+ }
+
+ private function _executeSql($moduleName, $type = 'install')
+ {
+
+ if (file_exists(Yii::app()->params['modulesFolder'] . '/' . $moduleName . "/install/" . $type . ".sql"))
+ {
+ $fileName = Yii::app()->params['modulesFolder'] . '/' . $moduleName . "/install/".$type.".sql";
+ $fh = fopen($fileName, "r");
+ $content = fread($fh, filesize($fileName));
+
+ $sqls = explode(';\n', $content);
+
+ if(count($sqls))
+ {
+ foreach ($sqls as $sql)
+ {
+ $command=Yii::app()->db->createCommand($sql);
+ $command->execute();
+ }
+ }
+ }
+ }
+
+ private function _removeDir($path)
+ {
+ if ($objs = glob($path."/*"))
+ {
+ foreach($objs as $obj)
+ {
+ is_dir($obj) ? $this->_removeDir($obj) : unlink($obj);
+ }
+ }
+ rmdir($path);
+ }
+
private function _unpack($archiveName)
{
$archive = new ZipArchive();
@@ -49,6 +100,7 @@ private function _unpack($archiveName)
}
$archive->close();
+ return $moduleName;
}
private function _pack($moduleName)
@@ -58,13 +110,14 @@ private function _pack($moduleName)
private function _zip($source, $destination)
{
-
+
$zip = new ZipArchive();
- if (!$zip->open($destination, ZIPARCHIVE::CREATE)) {
+ if (!$zip->open($destination, ZIPARCHIVE::CREATE))
+ {
return false;
}
-
+
if (is_dir($source) === true)
{
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
View
0  protected/controllers/SiteController.php 100644 → 100755
File mode changed
View
0  protected/models/UploadForm.php 100644 → 100755
File mode changed
View
15,394 protected/runtime/application.log 100644 → 100755
5,343 additions, 10,051 deletions not shown
View
0  protected/vendors/Archive/ArchiveTar.php 100644 → 100755
File mode changed
View
0  protected/vendors/Archive/PEAR.php 100644 → 100755
File mode changed
View
0  protected/widgets/menu/MenuWidget.php 100644 → 100755
File mode changed
View
0  protected/widgets/menu/views/menu.php 100644 → 100755
File mode changed
View
8 themes/bootstrap/views/layouts/main.php
@@ -39,6 +39,14 @@
</div>
<div class="container">
+ <?php
+ foreach(Yii::app()->user->getFlashes() as $key => $message): ?>
+ <div class="alert alert-<?php echo $key?>">
+ <a class="close" data-dismiss="alert" href="#">×</a>
+ <?php echo $message; ?>
+ </div>
+
+ <?php endforeach;?>
<?php echo $content; ?>
</div> <!-- /container -->
View
5 themes/bootstrap/views/site/index.php
@@ -15,10 +15,11 @@
<tr>
<td>
<h3><?php echo $module['title'] ?></h3>
- <p><?php echo $module['description'] ?></p>
+ <p><?php echo $module['description'] ?><b><?php echo $module['version'] ?></b></p>
</td>
- <td>
+ <td style="width: 250px;">
<?php echo CHtml::link('Упаковать', Yii::app()->baseUrl.'/install/build/'.$key, array('class' => 'btn btn-primary')) ?>
+ <?php echo CHtml::link(Yii::t('install', 'Uninstall'), Yii::app()->baseUrl.'/install/uninstall/'.$key, array('class' => 'btn btn-primary')) ?>
</td>
</tr>
<?php endforeach; ?>
View
BIN  uploads/raiting.zip
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.