本文整理汇总了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;
}
示例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);
}
示例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;
}
示例4: actionIndex
public function actionIndex()
{
$plugins = Plugins::model()->findAllByAttributes(array('status' => 'ok'));
$this->render('index', array('plugins' => $plugins));
}