本文整理汇总了PHP中Modules::parseIni方法的典型用法代码示例。如果您正苦于以下问题:PHP Modules::parseIni方法的具体用法?PHP Modules::parseIni怎么用?PHP Modules::parseIni使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Modules
的用法示例。
在下文中一共展示了Modules::parseIni方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
function indexAction()
{
$modules_table = new Modules("nuts");
$request = new Bolts_Request($this->getRequest());
if ($request->has("id") and $request->has("perform")) {
switch ($request->perform) {
case "enable":
if (!$modules_table->isEnabled($request->id)) {
if ($modules_table->enable($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" enabled.";
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is already enabled.";
}
break;
case "disable":
if ($modules_table->isEnabled($request->id)) {
if ($modules_table->disable($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" disabled.";
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is already disabled.";
}
break;
case "install":
if (!$modules_table->exists($request->id)) {
if ($modules_table->install($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" installed.";
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is already installed.";
}
break;
case "uninstall":
if ($modules_table->exists($request->id)) {
if ($modules_table->disable($request->id)) {
if ($modules_table->uninstall($request->id)) {
if (!is_null($modules_table->success)) {
$this->view->success = $modules_table->success;
} else {
$this->view->success = "Module \"" . $request->id . "\" disabled and uninstalled.";
}
}
}
} else {
$this->view->notice = "Module \"" . $request->id . "\" is not installed.";
}
break;
}
if (count($modules_table->errors) > 0) {
$this->view->errors = $modules_table->errors;
}
if (!is_null($modules_table->notice)) {
$this->view->notice = $modules_table->notice;
}
}
$basepath = Zend_Registry::get('basepath');
$module_dir = $basepath . "/nuts";
$o_module_dir = dir($module_dir);
$available_modules = array();
while (false !== ($entry = $o_module_dir->read())) {
if (substr($entry, 0, 1) != ".") {
if ($entry != "default") {
$full_dir = $module_dir . "/" . $entry;
if (file_exists($full_dir . "/module.ini") and !$modules_table->exists($entry)) {
$tmp_module = $modules_table->parseIni($entry);
$tmp_module['id'] = $entry;
$tmp_module['available'] = true;
$available_modules[] = $tmp_module;
}
}
}
}
$o_module_dir->close();
$tmp_modules = array();
$modules = $modules_table->fetchAll(null, "id");
if (count($modules) > 0) {
$tmp_modules = array();
foreach ($modules as $module) {
$module = $module->toArray();
try {
$config = $modules_table->parseIni($module['id']);
foreach ($config as $key => $val) {
$module[$key] = $val;
}
$module['available'] = false;
$tmp_modules[] = $module;
} catch (Exception $e) {
//.........这里部分代码省略.........
示例2: editAction
//.........这里部分代码省略.........
$resources[$resource->module][$resource->controller] = array();
}
$resources[$resource->module][$resource->controller][] = $resource->action;
}
/*
* This is a poor man's introspector. The reflection API needs the classes actually available,
* which creates naming conflicts between modules. What I do instead is read the physical files,
* line by line, find the lines with "function fooAction" and determine that the action name is
* "foo". It's a hack, but it works.
*/
$all_actions = array();
$modules = array();
$controllerdirs = array();
$enabled_modules = $modules_table->getEnabledModules();
foreach ($enabled_modules as $enabled_module)
{
$module_dir = 'modules';
if ($enabled_module == 'default') $module_dir = 'core';
$controllerdirs[$enabled_module] = Zend_Registry::get("basepath") . DIRECTORY_SEPARATOR . $module_dir . DIRECTORY_SEPARATOR . $enabled_module . DIRECTORY_SEPARATOR . "controllers";
}
$controllerdir = $controllerdirs[$module_id];
$d = dir($controllerdir);
$modules[] = $module_id;
while (($entry = $d->read()) !== false)
{
if ($entry != '.' and $entry != '..' and $entry != '.svn')
{
$controller_name = substr($entry, 0, stripos($entry, 'Controller.php'));
if ($module_id != "default" && substr($controller_name, 0, 1) == "_")
{
$controller_name = substr($controller_name, stripos($controller_name, '_') + 1);
}
$lines = file($controllerdir . DIRECTORY_SEPARATOR . $entry);
foreach ($lines as $line)
{
if (preg_match('/function.*Action.*\(.*\).*\{?/', $line))
{
$action_name = trim(preg_replace('/Action.*/', '', preg_replace('/^.*function/', '', $line)));
$allowed = false;
if (array_key_exists($module_id, $resources))
{
if (array_key_exists($controller_name, $resources[$module_id]))
{
if (in_array($action_name, $resources[$module_id][$controller_name]))
{
$allowed = true;
}
}
}
$inherited = false;
if (count($roles_table->getInheritedRoles($role_id)) > 0)
{
$inherited = $this->isResourceInherited($module_id, $controller_name, $action_name, $role_id);
}
$all_actions[$module_id][$controller_name][$action_name] = array(
'allowed' => $allowed,
'inherited' => $inherited,
);
}
}
}
}
$d->close();
$this->view->modid = $module_id;
if ($module_id == 'default') $mod_cfg = $modules_table_core->parseIni($module_id);
else $mod_cfg = $modules_table->parseIni($module_id);
$this->view->module_title = $mod_cfg['general']['name'];
$this->view->actions = $all_actions;
$this->view->modules = $enabled_modules;
// get "extra" resources
$extra_resources = array();
if (array_key_exists('resources', $mod_cfg))
{
foreach ($mod_cfg['resources'] as $resource_name => $nicename)
{
$extra_resources[$resource_name]['nicename'] = $nicename;
$extra_resources[$resource_name]['inherited'] = $this->isExtraResourceInherited($module_id, $resource_name, $role_id);
$extra_resources[$resource_name]['allowed'] = $roles_res_extra_table->isAllowed($role_id, $module_id, $resource_name);
}
}
$this->view->extra_resources = $extra_resources;
$this->view->breadcrumbs = array(
'Roles' => '/default/role/index',
$role['shortname'] => '/default/role/edit/id/' . $role['id'],
'Resources' => null,
);
}
示例3: indexAction
function indexAction()
{
$config_table = new Config();
// $modules_table = new Modules('core');
$modules_table = new Modules('modules');
$modules_table_core = new Modules('core');
$request = new RivetyCore_Request($this->getRequest());
$modid = $request->has('modid') ? $request->modid : 'default';
if ($this->_request->isPost())
{
$config_params = $this->_request->getParams();
foreach ($config_params as $ckey => $value)
{
$data = array('value' => $value);
$config_table->update($data, "ckey = '" . $ckey . "' and module = '" . $modid . "'");
}
$this->view->success = $this->_T('Configuration Updated.');
$config_table->cache();
$params = array();
$this->_rivety_plugin->doAction($this->_mca . '_post_save', $params); // ACTION HOOK
}
$config = $config_table->fetchAll($config_table->select()->where('module = ?', $modid));
if (count($config) > 0)
{
$config = $config->toArray();
sort($config);
$this->view->config = $config;
}
$modules = $modules_table_core->getEnabledModules();
sort($modules);
$this->view->modules = $modules;
$this->view->current = $modid;
$this->view->modid = $modid;
if ($modid == 'default') $mod_cfg = $modules_table_core->parseIni($modid);
else $mod_cfg = $modules_table->parseIni($modid);
$this->view->module_title = $mod_cfg['general']['name'];
$this->view->breadcrumbs = array('Module Config' => null);
}