当前位置: 首页>>代码示例>>PHP>>正文


PHP Plugins::model方法代码示例

本文整理汇总了PHP中Plugins::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugins::model方法的具体用法?PHP Plugins::model怎么用?PHP Plugins::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugins的用法示例。


在下文中一共展示了Plugins::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHooks

 protected function getHooks()
 {
     $plugins = Plugins::model()->findAllByAttributes(array('enable' => 1));
     if (!$plugins) {
         return;
     }
     foreach ($plugins as $plugin) {
         foreach (unserialize($plugin->hooks) as $pos => $hook) {
             $this->hooks[$pos][] = array('identify' => $plugin->identify, 'path' => $plugin->path, 'hook' => $hook);
         }
     }
     return TRUE;
 }
开发者ID:zwq,项目名称:unpei,代码行数:13,代码来源:HookRender.php

示例2: actionIndex

 public function actionIndex()
 {
     if (!$_GET['id']) {
         $this->redirect(Yii::app()->homeUrl);
     }
     $id = $_GET['id'];
     $plugin = Plugins::model()->findbyAttributes(array('identify' => $id, 'enable' => 1));
     if (!$plugin) {
         $this->render('miss', array('name' => $id));
         exit;
     }
     if (!isset($_GET['action'])) {
         $action = strtolower($plugin->identify);
     } else {
         $action = strtolower($_GET['action']);
     }
     $class = $this->_loadPlugin($plugin);
     $method = 'action' . $action;
     if (method_exists($class, $method)) {
         $class->{$method}();
         Yii:
         app()->end();
     }
     $actions = array_change_key_case($class->Actions(), CASE_LOWER);
     if ($action) {
         if (isset($actions[$action])) {
             $actionClass = $this->_loadAction($actions[$action], $plugin);
             if ($actionClass) {
                 $actionClass->Owner($class);
                 $actionClass->run();
                 Yii::app()->end();
             }
         }
     }
     $this->redirect(Yii::app()->homeUrl);
 }
开发者ID:lhfcainiao,项目名称:basic,代码行数:36,代码来源:PluginController.php

示例3: processArchive

 public static function processArchive($dir, $file)
 {
     $_error = 'ok';
     $pluginName = substr($file, 0, -4);
     $destDir = Yii::getPathOfAlias('webroot') . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . $pluginName;
     $model = Plugins::model()->findByPk($pluginName);
     //remove plugin entry
     if ($model) {
         $model->delete();
     }
     //remove dir
     if (file_exists($destDir)) {
         Plugins::rrmdir($destDir);
     }
     //remove plugin table
     $connection = Yii::app()->db;
     try {
         $command = $connection->createCommand('DROP TABLE ' . $pluginName . ';')->execute();
     } catch (Exception $e) {
         $_error = $e;
     }
     $zip = zip_open($dir . $file);
     $dir = Plugins::extractZip($pluginName, $dir, $file, $destDir);
     if ($dir) {
         $version = $description = $changelog = $sql = '';
         //Open images directory
         $d = opendir($dir);
         //List files in images directory
         while (($file = readdir($d)) !== false) {
             if (strpos($file, '.info') !== false) {
                 $_in_file = fopen($dir . $file, 'r');
                 while ($line = fgets($_in_file)) {
                     if ($line === FALSE) {
                         //ERROR
                         echo 'error';
                         return;
                     }
                     if (preg_match('/^\\[[a-zA-Z0-9]{1,}\\]/', $line, $matches)) {
                         $section = str_replace(array('[', ']'), array('', ''), $matches[0]);
                         continue;
                     }
                     if ($section == 'version') {
                         $version .= $line;
                     }
                     if ($section == 'description') {
                         $description .= $line;
                     }
                     if ($section == 'changelog') {
                         $changelog .= $line;
                     }
                 }
                 //$version = file_get_contents($dir.$file);
                 //$description = '';
                 continue;
             }
             if (strpos($file, '.sql') !== false) {
                 $sql = file_get_contents($dir . $file);
                 continue;
             }
         }
         closedir($d);
         if ($sql) {
             $connection = Yii::app()->db;
             try {
                 $command = $connection->createCommand($sql)->execute();
             } catch (Exception $e) {
                 $_error = $e;
             }
         }
         $plugin = new Plugins();
         $plugin->name = 'Foo';
         $plugin->username = Yii::app()->user->id;
         $plugin->timestamp = date(Yii::app()->params['dateTimeFormatDB']);
         $plugin->version = $version;
         $plugin->description = $description;
         $plugin->changelog = $changelog;
         $plugin->priority = 0;
         $plugin->users = '*';
         $plugin->status = substr($_error, 0, 4000);
         //truncate to max length
         $plugin->enable = true;
         if ($plugin->save()) {
             return Yii::app()->createUrl($pluginName . '/' . $pluginName . '/index', array());
         }
     }
     return;
 }
开发者ID:Gnafu,项目名称:wiz,代码行数:87,代码来源:Plugins.php

示例4: actionIndex

 public function actionIndex()
 {
     $plugins = Plugins::model()->findAllByAttributes(array('status' => 'ok'));
     $this->render('index', array('plugins' => $plugins));
 }
开发者ID:Gnafu,项目名称:wiz,代码行数:5,代码来源:ExtraController.php


注:本文中的Plugins::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。