本文整理汇总了PHP中Plugins::runHook方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugins::runHook方法的具体用法?PHP Plugins::runHook怎么用?PHP Plugins::runHook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugins
的用法示例。
在下文中一共展示了Plugins::runHook方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'add':
$this->doView("plugins/add.php");
break;
case 'add_post':
$package = Params::getFiles("package");
$path = osc_plugins_path();
(int) ($status = osc_unzip_file($package['tmp_name'], $path));
switch ($status) {
case 0:
$msg = _m('The plugin folder is not writable');
break;
case 1:
$msg = _m('The plugin has been uploaded correctly');
break;
case 2:
$msg = _m('The zip file is not valid');
break;
case -1:
default:
$msg = _m('There was a problem adding the plugin');
break;
}
osc_add_flash_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'install':
$pn = Params::getParam("plugin");
Plugins::activate($pn);
//run this after installing the plugin
Plugins::runHook('install_' . $pn);
osc_add_flash_message(_m('Plugin installed'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'uninstall':
$pn = Params::getParam("plugin");
Plugins::runHook($pn . '_uninstall');
Plugins::deactivate($pn);
osc_add_flash_message(_m('Plugin uninstalled'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'admin':
global $active_plugins;
$plugin = Params::getParam("plugin");
if ($plugin != "") {
Plugins::runHook($plugin . '_configure');
}
break;
case 'admin_post':
Plugins::runHook('admin_post');
case 'renderplugin':
global $active_plugins;
$file = Params::getParam("file");
if ($file != "") {
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
//$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
//$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
}
}
} else {
$file = $_REQUEST['file'];
}
$this->_exportVariableToView("file", osc_plugins_path() . $file);
//osc_renderPluginView($file);
$this->doView("plugins/view.php");
}
break;
case 'configure':
$plugin = Params::getParam("plugin");
if ($plugin != '') {
$plugin_data = Plugins::getInfo($plugin);
$this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
$this->_exportVariableToView("selected", PluginCategory::newInstance()->listSelected($plugin_data['short_name']));
$this->_exportVariableToView("plugin_data", $plugin_data);
$this->doView("plugins/configuration.php");
} else {
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
}
break;
case 'configure_post':
$plugin_short_name = Params::getParam("plugin_short_name");
$categories = Params::getParam("categories");
if ($plugin_short_name != "") {
Plugins::cleanCategoryFromPlugin($plugin_short_name);
if (isset($categories)) {
Plugins::addToCategoryPlugin($categories, $plugin_short_name);
}
} else {
osc_add_flash_message(_m('No plugin selected'), 'admin');
$this->doView("plugins/index.php");
}
//.........这里部分代码省略.........
示例2: doModel
function doModel()
{
parent::doModel();
//specific things for this class
switch ($this->action) {
case 'add':
$this->doView("plugins/add.php");
break;
case 'add_post':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
$package = Params::getFiles("package");
if (isset($package['size']) && $package['size'] != 0) {
$path = osc_plugins_path();
(int) ($status = osc_unzip_file($package['tmp_name'], $path));
} else {
$status = 3;
}
switch ($status) {
case 0:
$msg = _m('The plugin folder is not writable');
osc_add_flash_error_message($msg, 'admin');
break;
case 1:
$msg = _m('The plugin has been uploaded correctly');
osc_add_flash_ok_message($msg, 'admin');
break;
case 2:
$msg = _m('The zip file is not valid');
osc_add_flash_error_message($msg, 'admin');
break;
case 3:
$msg = _m('No file was uploaded');
osc_add_flash_error_message($msg, 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins&action=add");
break;
case -1:
default:
$msg = _m('There was a problem adding the plugin');
osc_add_flash_error_message($msg, 'admin');
break;
}
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'install':
$pn = Params::getParam("plugin");
// CATCH FATAL ERRORS
$old_value = error_reporting(0);
register_shutdown_function(array($this, 'errorHandler'), $pn);
$installed = Plugins::install($pn);
if ($installed) {
//run this after installing the plugin
Plugins::runHook('install_' . $pn);
osc_add_flash_ok_message(_m('Plugin installed'), 'admin');
} else {
osc_add_flash_error_message(_m('Error: Plugin already installed'), 'admin');
}
error_reporting($old_value);
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'uninstall':
$pn = Params::getParam("plugin");
Plugins::runHook($pn . '_uninstall');
Plugins::uninstall($pn);
osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'enable':
$pn = Params::getParam("plugin");
// CATCH FATAL ERRORS
$old_value = error_reporting(0);
register_shutdown_function(array($this, 'errorHandler'), $pn);
$enabled = Plugins::activate($pn);
if ($enabled) {
Plugins::runHook($pn . '_enable');
osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Error: Plugin already enabled'), 'admin');
}
error_reporting($old_value);
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'disable':
$pn = Params::getParam("plugin");
Plugins::runHook($pn . '_disable');
Plugins::deactivate($pn);
osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
$this->redirectTo(osc_admin_base_url(true) . "?page=plugins");
break;
case 'admin':
global $active_plugins;
$plugin = Params::getParam("plugin");
if ($plugin != "") {
Plugins::runHook($plugin . '_configure');
}
break;
case 'admin_post':
Plugins::runHook('admin_post');
//.........这里部分代码省略.........
示例3: doModel
//.........这里部分代码省略.........
$data = array();
/************************
*** CHECK VALID CODE ***
************************/
if ($code != '' && $section != '') {
if (stripos($code, "http://") === FALSE) {
// OSCLASS OFFICIAL REPOSITORY
$url = osc_market_url($section, $code);
$data = json_decode(osc_file_get_contents($url), true);
} else {
// THIRD PARTY REPOSITORY
if (osc_market_external_sources()) {
$data = json_decode(osc_file_get_contents($code), true);
} else {
echo json_encode(array('error' => 8, 'error_msg' => __('No external sources are allowed')));
break;
}
}
/***********************
**** DOWNLOAD FILE ****
***********************/
if (isset($data['s_update_url']) && isset($data['s_source_file']) && isset($data['e_type'])) {
if ($data['e_type'] == 'THEME') {
$folder = 'themes/';
} else {
if ($data['e_type'] == 'LANGUAGE') {
$folder = 'languages/';
} else {
// PLUGINS
$folder = 'plugins/';
$plugin = Plugins::findByUpdateURI($data['s_update_url']);
if ($plugin != false) {
if (Plugins::isEnabled($plugin)) {
Plugins::runHook($plugin . '_disable');
Plugins::deactivate($plugin);
$re_enable = true;
}
}
}
}
$filename = $data['s_update_url'] . "_" . $data['s_version'] . ".zip";
$url_source_file = $data['s_source_file'];
// error_log('Source file: ' . $url_source_file);
// error_log('Filename: ' . $filename);
$result = osc_downloadFile($url_source_file, $filename);
if ($result) {
// Everything is OK, continue
/**********************
***** UNZIP FILE *****
**********************/
@mkdir(ABS_PATH . 'oc-temp', 0777);
$res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, osc_content_path() . 'downloads/oc-temp/');
if ($res == 1) {
// Everything is OK, continue
/**********************
***** COPY FILES *****
**********************/
$fail = -1;
if ($handle = opendir(osc_content_path() . 'downloads/oc-temp')) {
$folder_dest = ABS_PATH . "oc-content/" . $folder;
if (function_exists('posix_getpwuid')) {
$current_user = posix_getpwuid(posix_geteuid());
$ownerFolder = posix_getpwuid(fileowner($folder_dest));
}
$fail = 0;
while (false !== ($_file = readdir($handle))) {
示例4: doModel
//.........这里部分代码省略.........
osc_add_flash_ok_message(_m('Plugin uninstalled'), 'admin');
} else {
osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'enable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
if (Plugins::activate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'disable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action cannot be done because is a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
if (Plugins::deactivate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'admin':
$plugin = Params::getParam("plugin");
if ($plugin != "") {
Plugins::runHook($plugin . '_configure');
}
break;
case 'admin_post':
Plugins::runHook('admin_post');
case 'renderplugin':
$file = Params::getParam("file");
if ($file != "") {
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
//$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
//$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
}
}
} else {
$file = $_REQUEST['file'];
}
$this->_exportVariableToView("file", osc_plugins_path() . $file);
//osc_renderPluginView($file);
$this->doView("plugins/view.php");
}
break;
case 'render':
$file = Params::getParam("file");
if ($file != "") {
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
示例5: elseif
</p>
<?php
if (EMAILS == "on") {
?>
<p class="email">
<input type="text" name="email" autocomplete="off" />
<label for="email">E-mail</label>
</p>
<?php
}
?>
<p class="submit">
<input type="submit" name="submit" value="Register" />
</p>
</form>
<?php
} elseif ($finalize == true) {
?>
<center>Thank you for activating your serial, you can now use your application with the credentials you provided here.</center>
<?php
}
?>
</div>
</div>
</div>
</div>
<?php
}
echo $plugin->runHook("miscHook", $content);
示例6: osc_market
function osc_market($section, $code)
{
$plugin = false;
$re_enable = false;
$message = "";
$data = array();
$download_post_data = array('api_key' => osc_market_api_connect());
/************************
*** CHECK VALID CODE ***
************************/
if ($code != '' && $section != '') {
if (stripos($code, "http://") === FALSE) {
// OSCLASS OFFICIAL REPOSITORY
$url = osc_market_url($section, $code);
$data = osc_file_get_contents($url, array('api_key' => osc_market_api_connect()));
$data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);
} else {
// THIRD PARTY REPOSITORY
if (osc_market_external_sources()) {
$download_post_data = array();
$data = json_decode(osc_file_get_contents($code), true);
} else {
return array('error' => 9, 'message' => __('No external sources are allowed'), 'data' => $data);
}
}
/***********************
**** DOWNLOAD FILE ****
***********************/
if (isset($data['s_update_url']) && isset($data['s_source_file']) && isset($data['e_type'])) {
if ($data['e_type'] == 'THEME') {
$folder = 'themes/';
} else {
if ($data['e_type'] == 'LANGUAGE') {
$folder = 'languages/';
} else {
// PLUGINS
$folder = 'plugins/';
$plugin = Plugins::findByUpdateURI($data['s_update_url']);
if ($plugin != false) {
if (Plugins::isEnabled($plugin)) {
Plugins::runHook($plugin . '_disable');
Plugins::deactivate($plugin);
$re_enable = true;
}
}
}
}
$filename = date('YmdHis') . "_" . osc_sanitize_string($data['s_title']) . "_" . $data['s_version'] . ".zip";
$url_source_file = $data['s_source_file'];
$result = osc_downloadFile($url_source_file, $filename, $download_post_data);
if ($result) {
// Everything is OK, continue
/**********************
***** UNZIP FILE *****
**********************/
@mkdir(osc_content_path() . 'downloads/oc-temp/');
$res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, osc_content_path() . 'downloads/oc-temp/');
if ($res == 1) {
// Everything is OK, continue
/**********************
***** COPY FILES *****
**********************/
$fail = -1;
if ($handle = opendir(osc_content_path() . 'downloads/oc-temp')) {
$folder_dest = ABS_PATH . "oc-content/" . $folder;
if (function_exists('posix_getpwuid')) {
$current_user = posix_getpwuid(posix_geteuid());
$ownerFolder = posix_getpwuid(fileowner($folder_dest));
}
$fail = 0;
while (false !== ($_file = readdir($handle))) {
if ($_file != '.' && $_file != '..') {
$copyprocess = osc_copy(osc_content_path() . "downloads/oc-temp/" . $_file, $folder_dest . $_file);
if ($copyprocess == false) {
$fail = 1;
}
}
}
closedir($handle);
// Additional actions is not important for the rest of the proccess
// We will inform the user of the problems but the upgrade could continue
// Also remove the zip package
/****************************
** REMOVE TEMPORARY FILES **
****************************/
@unlink(osc_content_path() . 'downloads/' . $filename);
$path = osc_content_path() . 'downloads/oc-temp';
$rm_errors = 0;
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
for ($dir->rewind(); $dir->valid(); $dir->next()) {
if ($dir->isDir()) {
if ($dir->getFilename() != '.' && $dir->getFilename() != '..') {
if (!rmdir($dir->getPathname())) {
$rm_errors++;
}
}
} else {
if (!unlink($dir->getPathname())) {
$rm_errors++;
}
//.........这里部分代码省略.........
示例7: doModel
//.........这里部分代码省略.........
osc_add_flash_error_message(_m("Plugin couldn't be uninstalled"), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'enable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::activate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin enabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already enabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'disable':
if (defined('DEMO')) {
osc_add_flash_warning_message(_m("This action can't be done because it's a demo site"), 'admin');
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
}
osc_csrf_check();
if (Plugins::deactivate(Params::getParam('plugin'))) {
osc_add_flash_ok_message(_m('Plugin disabled'), 'admin');
} else {
osc_add_flash_error_message(_m('Plugin is already disabled'), 'admin');
}
$this->redirectTo(osc_admin_base_url(true) . '?page=plugins');
break;
case 'admin':
$plugin = Params::getParam("plugin");
if ($plugin != "") {
Plugins::runHook($plugin . '_configure');
}
break;
case 'admin_post':
Plugins::runHook('admin_post');
break;
case 'renderplugin':
$file = Params::getParam("file");
if ($file != "") {
// We pass the GET variables (in case we have somes)
if (preg_match('|(.+?)\\?(.*)|', $file, $match)) {
$file = $match[1];
if (preg_match_all('|&([^=]+)=([^&]*)|', urldecode('&' . $match[2] . '&'), $get_vars)) {
for ($var_k = 0; $var_k < count($get_vars[1]); $var_k++) {
//$_GET[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
//$_REQUEST[$get_vars[1][$var_k]] = $get_vars[2][$var_k];
Params::setParam($get_vars[1][$var_k], $get_vars[2][$var_k]);
}
}
} else {
$file = $_REQUEST['file'];
}
$this->_exportVariableToView("file", osc_plugins_path() . $file);
//osc_renderPluginView($file);
$this->doView("plugins/view.php");
}
break;
case 'configure':
$plugin = Params::getParam("plugin");
if ($plugin != '') {
$plugin_data = Plugins::getInfo($plugin);
$this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
$this->_exportVariableToView("selected", PluginCategory::newInstance()->listSelected($plugin_data['short_name']));