本文整理汇总了PHP中ModUtil::getAllMods方法的典型用法代码示例。如果您正苦于以下问题:PHP ModUtil::getAllMods方法的具体用法?PHP ModUtil::getAllMods怎么用?PHP ModUtil::getAllMods使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModUtil
的用法示例。
在下文中一共展示了ModUtil::getAllMods方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_html_select_modules
/**
* Zikula_View function to display a list box with a list of active modules.
*
* Either user or admin capable or all modules.
*
* Available parameters:
* - name: Name for the control (optional) if not present then only the option tags are output
* - id: ID for the control
* - selected: Selected value
* - capability: Show modules with this capability, all or $capability.
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
*
* Example
*
* {html_select_modules name=mod selected=$mymod}
*
* <select name="mod">
* <option value="">&bsp;</option>
* {html_select_modules selected=$mythemechoice}
* </select>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see function.html_select_modules.php::smarty_function_html_select_modules()
* @return string A drop down containing a list of modules.
*/
function smarty_function_html_select_modules($params, Zikula_View $view)
{
// we'll make use of the html_options plugin to simplfiy this plugin
require_once $view->_get_plugin_filepath('function', 'html_options');
// set some defaults
if (isset($params['type'])) {
// bc
$params['capability'] = $params['type'];
}
if (!isset($params['capability'])) {
$params['capability'] = 'all';
}
// get the modules
switch ($params['capability']) {
case 'all':
$modules = ModUtil::getAllMods();
break;
default:
$modules = ModUtil::getModulesCapableOf($params['capability']);
break;
}
// process our list of modules for input to the html_options plugin
$moduleslist = array();
$installerArray = array('ZikulaBlocksModule', 'ZikulaErrorsModule', 'ZikulaPermissionsModule', 'ZikulaCategoriesModule', 'ZikulaGroupsModule', 'ZikulaThemeModule', 'ZikulaUsersModule', 'ZikulaSearchModule');
if (!empty($modules)) {
foreach ($modules as $module) {
if (!(System::isInstalling() && in_array($module['name'], $installerArray))) {
$moduleslist[$module['name']] = $module['displayname'];
}
}
}
natcasesort($moduleslist);
// get the formatted list
$output = smarty_function_html_options(array('options' => $moduleslist, 'selected' => isset($params['selected']) ? $params['selected'] : null, 'name' => isset($params['name']) ? $params['name'] : null, 'id' => isset($params['id']) ? $params['id'] : null), $view);
if (isset($params['assign']) && !empty($params['assign'])) {
$view->assign($params['assign'], $output);
} else {
return $output;
}
}
示例2: getallplugins
/**
* Get all search plugins.
*
* @return array array of items, or false on failure.
*/
public function getallplugins($args)
{
// defaults
if (!isset($args['loadall'])) {
$args['loadall'] = false;
}
// initialize the search plugins array
$search_modules = array();
// Attempt to load the search API for each user module
// The modules should be determined by a select of the modules table or something like that in the future
$usermods = ModUtil::getAllMods();
foreach ($usermods as $usermod) {
if ($args['loadall'] || (!$this->getVar("disable_$usermod[name]") && SecurityUtil::checkPermission('Search::Item', "$usermod[name]::", ACCESS_READ))) {
$info = ModUtil::apiFunc($usermod['name'], 'search', 'info');
if ($info) {
$info['name'] = $usermod['name'];
$search_modules[] = $info;
$plugins_found = 'yes';
}
}
}
return $search_modules;
}
示例3: getallschemas
/**
* Get all security permissions schemas.
*
* @return array array if permission schema values.
*/
public function getallschemas()
{
// Security check
if (!SecurityUtil::checkPermission('Permissions::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
$schemas = SecurityUtil::getSchemas();
BlockUtil::loadAll();
$modinfos = ModUtil::getAllMods();
foreach ($modinfos as $modinfo) {
if (!empty($modinfo['securityschema'])) {
$schemas = array_merge($schemas, $modinfo['securityschema']);
}
}
uksort($schemas, 'strnatcasecmp');
SecurityUtil::setSchemas($schemas);
return $schemas;
}
示例4: countitems
/**
* Utility function to count the number of items held by this module
*
* Credits to Lee Eason from http://pnflashgames.com for giving the idea
* to allow a module to find the number of comments that have been added
* to the module as a whole or to an individual item.
*
* @param $args['mod'] name of the module to get the number of comments for
* @param $args['objectid'] the objectid to get the number of comments for
* @param $args['status'] Status of the comments to get (default: all)
* @param $args['owneruid'] (optional) UID of owner
* @param $args['uid'] (optional) UID of poster
* @param $args['admin'] (optional) set to 1 if called from admin mode
* @return integer number of items held by this module
*/
public function countitems($args = array())
{
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_OVERVIEW)) {
return false;
}
// get parameters
$owneruid = isset($args['owneruid']) ? (int)$args['owneruid'] : 0;
$uid = isset($args['uid']) ? (int)$args['uid'] : 0;
// Get database column names
$tables = DBUtil::getTables();
$columns = $tables['EZComments_column'];
// build the where clause
$queryargs = array();
if (isset($args['addwhere'])) {
$queryargs[] = $args['addwhere'];
}
if ($owneruid > 1 && $uid > 1) {
$queryargs[] = "$columns[owneruid] = '$args[owneruid]' OR $columns[uid] = '$args[uid]'";
} else if ($uid > 1) {
$queryargs[] = "$columns[uid] = '$args[uid]'";
} else if ($owneruid > 1) {
$queryargs[] = "$columns[owneruid] = '$args[owneruid]'";
}
if (isset($args['mod'])) {
// Count comments for a specific module
$mod = DataUtil::formatForStore($args['mod']);
$queryargs[] = "$columns[modname] = '$mod'";
if (isset($args['objectid'])) {
// Count comments for a specific item in a specific mod
$objectid = DataUtil::formatForStore($args['objectid']);
$queryargs[] = "$columns[objectid] = '$objectid'";
}
}
if (isset($args['status']) && is_numeric($args['status']) && $args['status'] >= 0 && $args['status'] <= 2) {
$queryargs[] = $columns['status'] . ' = \'' . DataUtil::formatForStore($args['status']) . '\'';
}
// admin mode: only count comments for modules considering permission checks
$admin = isset($args['admin']) ? (bool)$args['admin'] : false;
if ($admin) {
// get list of modules
$modlist = ModUtil::getAllMods();
$permclause = array();
foreach ($modlist as $module) {
// simple permission check
$inst = "$module[name]:".(isset($args['objectid']) ? $args['objectid'] : '').":";
if (SecurityUtil::checkPermission('EZComments::', $inst, ACCESS_EDIT)) {
$permclause[] = "$columns[modname] = '$module[name]'";
}
}
$queryargs[] = implode(' OR ', $permclause);
}
$where = '';
if (!empty($queryargs)) {
$where = implode(' AND ', $queryargs);
}
return DBUtil::selectObjectCount('EZComments', $where);
}
示例5: loadAll
/**
* Load all blocks.
*
* @return array Array of blocks.
*/
public static function loadAll()
{
static $blockdirs = array();
// Load new-style blocks from system and modules tree
$mods = ModUtil::getAllMods();
foreach ($mods as $mod) {
$modname = $mod['name'];
$moddir = DataUtil::formatForOS($mod['directory']);
if (!isset($blockdirs[$modname])) {
$blockdirs[$modname] = array();
$blockdirs[$modname][] = "system/$moddir/lib/$moddir/Block";
$blockdirs[$modname][] = "modules/$moddir/lib/$moddir/Block";
$blockdirs[$modname][] = "modules/$moddir/pnblocks";
foreach ($blockdirs[$modname] as $dir) {
if (is_dir($dir) && is_readable($dir)) {
$dh = opendir($dir);
while (($f = readdir($dh)) !== false) {
if (substr($f, -4) == '.php') {
$block = substr($f, 0, -4);
self::load($modname, $block);
}
}
closedir($dh);
}
}
}
}
// Return information gathered
return $GLOBALS['blocks_modules'];
}
示例6: modify
/**
* Modify a block.
*
* @param int $bid block id.
*
* @return string HTML output string.
*/
public function modify()
{
// Get parameters
$bid = FormUtil::getPassedValue('bid');
// Get details on current block
$blockinfo = BlockUtil::getBlockInfo($bid);
// Security check
if (!SecurityUtil::checkPermission('Blocks::', "{$blockinfo['bkey']}:{$blockinfo['title']}:{$blockinfo['bid']}", ACCESS_EDIT)) {
return LogUtil::registerPermissionError();
}
// check the blockinfo array
if (empty($blockinfo)) {
return LogUtil::registerError($this->__('Sorry! No such block found.'), 404);
}
// get the block placements
$where = "WHERE bid = '" . DataUtil::formatForStore($bid) . "'";
$placements = DBUtil::selectObjectArray('block_placements', $where, 'sortorder', -1, -1, '', null);
$blockinfo['placements'] = array();
foreach ($placements as $placement) {
$blockinfo['placements'][] = $placement['pid'];
}
// Load block
$modinfo = ModUtil::getInfo($blockinfo['mid']);
$blockObj = BlockUtil::load($modinfo['name'], $blockinfo['bkey']);
if (!$blockObj) {
return LogUtil::registerError($this->__('Sorry! No such block found.'), 404);
}
// Title - putting a title ad the head of each page reminds the user what
// they are doing
if (!empty($modinfo['name'])) {
$this->view->assign('modtitle', "{$modinfo['name']}/{$blockinfo['bkey']}");
}
// Add hidden block id to form
$this->view->assign('bid', $bid);
// assign the block
$this->view->assign($blockinfo);
// build and assign the list of modules
$homepage = array('_homepage_' => $this->__('Homepage'));
$modules = ModUtil::getAllMods();
unset($modules['zikula']);
foreach ($modules as $name => $module) {
$modules[$name] = $module['displayname'];
}
asort($modules);
$this->view->assign('mods', array_merge($homepage, $modules));
// assign block positions
$positions = ModUtil::apiFunc('Blocks', 'user', 'getallpositions');
$block_positions = array();
foreach ($positions as $position) {
$block_positions[$position['pid']] = $position['name'];
}
$this->view->assign('block_positions', $block_positions);
// Block-specific
$blockoutput = '';
if ($blockObj instanceof Zikula_Controller_AbstractBlock) {
$blockoutput = call_user_func(array($blockObj, 'modify'), $blockinfo);
} else {
$usname = preg_replace('/ /', '_', $modinfo['name']);
$updatefunc = $usname . '_' . $blockinfo['bkey'] . 'block_modify';
if (function_exists($updatefunc)) {
$blockoutput = $updatefunc($blockinfo);
}
}
// Block output
$this->view->assign('blockoutput', $blockoutput);
// Tableless for blockoutput
if (!isset($GLOBALS['blocks_modules'][$blockinfo['mid']][$blockinfo['bkey']]['admin_tableless'])) {
$GLOBALS['blocks_modules'][$blockinfo['mid']][$blockinfo['bkey']]['admin_tableless'] = false;
}
// Requirement for the block
if (!isset($GLOBALS['blocks_modules'][$blockinfo['mid']][$blockinfo['bkey']]['requirement'])) {
$GLOBALS['blocks_modules'][$blockinfo['mid']][$blockinfo['bkey']]['requirement'] = '';
}
// Assign blockinfo to the template
$this->view->assign($GLOBALS['blocks_modules'][$blockinfo['mid']][$blockinfo['bkey']]);
// Refresh
$refreshtimes = array(60 => $this->__('One minute'), 120 => $this->__('Two minutes'), 300 => $this->__('Five minutes'), 600 => $this->__('Ten minutes'), 900 => $this->__('Fifteen minutes'), 1800 => $this->__('Half an hour'), 3600 => $this->__('One hour'), 7200 => $this->__('Two hours'), 14400 => $this->__('Four hours'), 43200 => $this->__('Twelve hours'), 86400 => $this->__('One day'), 172800 => $this->__('Two days'), 259200 => $this->__('Three days'), 345600 => $this->__('Four days'), 432000 => $this->__('Five days'), 518400 => $this->__('Six days'), 604800 => $this->__('Seven days'));
$this->view->assign('blockrefreshtimes', $refreshtimes);
// Return the output that has been generated by this function
return $this->view->fetch('blocks_admin_modify.tpl');
}
示例7: modifypageconfigurationassignment
/**
* Modify a theme page configuration
*
*/
public function modifypageconfigurationassignment($args)
{
// get our input
$themename = FormUtil::getPassedValue('themename', isset($args['themename']) ? $args['themename'] : null, 'GET');
$pcname = FormUtil::getPassedValue('pcname', isset($args['pcname']) ? $args['pcname'] : null, 'GET');
// check our input
if (!isset($themename) || empty($themename)) {
return LogUtil::registerArgsError(ModUtil::url('Theme', 'admin', 'view'));
}
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($themename));
if (!file_exists('themes/'.DataUtil::formatForOS($themeinfo['directory']).'/version.php')) {
return LogUtil::registerArgsError(ModUtil::url('Theme', 'admin', 'view'));
}
// Security check
if (!SecurityUtil::checkPermission('Theme::', "$themename::pageconfigurations", ACCESS_EDIT)) {
return LogUtil::registerPermissionError();
}
// assign all modules
$allmods = ModUtil::getAllMods();
$mods = array();
foreach ($allmods as $mod) {
$mods[$mod['name']] = $mod['name'];
}
// get all pageconfigurations
$pageconfigurations = ModUtil::apiFunc('Theme', 'user', 'getpageconfigurations', array('theme' => $themename));
if (!isset($pageconfigurations[$pcname])) {
LogUtil::registerError($this->__('Error! No such page configuration assignment found.'));
$this->redirect(ModUtil::url('Theme', 'admin', 'view'));
}
// defines the default types and master
$pagetypes = array(
'master' => $this->__('Master'),
'*home' => $this->__('Homepage'),
'*admin' => $this->__('Admin panel pages'),
'*editor' => $this->__('Editor panel pages')
);
// checks for non-standard pagetypes
foreach ($pageconfigurations as $name => $pageconfiguration) {
if (strpos($name, '*') === 0 && !isset($pagetypes[$name])) {
//! Pages inside a specific Controller type (editor, moderator, user)
$pagetypes[$name] = $this->__f('%s type pages', ucfirst(substr($name, 1)));
}
}
// form the page config assignment array setting some useful key names
$pageconfigassignment = array('pagemodule' => null, 'pagetype' => null, 'pagefunc' => null, 'pagecustomargs' => null);
$pageconfigparts = explode('/', $pcname);
$pageconfigassignment['pagemodule'] = $pageconfigparts[0];
if (isset($pageconfigparts[1])) {
$pageconfigassignment['pagetype'] = $pageconfigparts[1];
}
if (isset($pageconfigparts[2])) {
$pageconfigassignment['pagefunc'] = $pageconfigparts[2];
}
if (isset($pageconfigparts[3])) {
$pageconfigassignment['pagecustomargs'] = $pageconfigparts[3];
}
if (isset($pageconfigurations[$pcname]['important']) && $pageconfigurations[$pcname]['important']) {
$pageconfigassignment['important'] = 1;
}
// gets the available page configurations on the theme
$existingconfigs = ModUtil::apiFunc('Theme', 'user', 'getconfigurations', array('theme' => $themename));
// assign the page config assignment name, theme name and theme info
$this->view->assign($pageconfigassignment)
->assign('existingconfigs', $existingconfigs)
->assign('pcname', $pcname)
->assign('themename', $themename)
->assign('themeinfo', $themeinfo)
->assign('pagetypes', $pagetypes)
->assign('modules', $mods)
->assign('filename', $pageconfigurations[$pcname]['file']);
// Return the output that has been generated by this function
return $this->view->fetch('theme_admin_modifypageconfigurationassignment.tpl');
}
示例8: modifymodule
public function modifymodule($args)
{
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Scribite::', '::', ACCESS_ADMIN), LogUtil::getErrorMsgPermission());
// get passed args
$mid = FormUtil::getPassedValue('mid', null, 'GET');
// get config for current module
$modconfig = ModUtil::apiFunc('Scribite', 'admin', 'getModuleConfigfromID', array('mid' => $mid));
$modules = ModUtil::getAllMods();
// get all editors
$this->view->assign('editor_list', ModUtil::apiFunc('Scribite', 'user', 'getEditors', array('editorname' => 'list')));
$this->view->assign('mid', $modconfig['mid']);
$this->view->assign('modulename', $modconfig['modname']);
$this->view->assign('modfuncs', implode(',', unserialize($modconfig['modfuncs'])));
$this->view->assign('modareas', implode(',', unserialize($modconfig['modareas'])));
$this->view->assign('modeditor', $modconfig['modeditor']);
return $this->view->fetch('admin/modifymodule.tpl');
}
示例9: cleanup
/**
* Cleanup functionality
*
* This is the interface to the Cleanup functionality.
* When a Module is deleted, EZComments doesn't know about
* this. Thus, any comments for this module stay in the database.
* With this functionality you can delete these comments.
*
* @return output the cleanup interface
*/
public function cleanup()
{
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// build a simple array of all available modules
$mods = ModUtil::getAllMods();
$allmods = array();
foreach ($mods as $mod) {
$allmods[] = $mod['name'];
}
$usedmods = ModUtil::apiFunc('EZComments', 'admin', 'getUsedModules');
$orphanedmods = array_diff($usedmods, $allmods);
if (!$orphanedmods) {
LogUtil::registerStatus($this->__('No orphaned comments.'));
return System::redirect(ModUtil::url('EZComments', 'admin', 'main'));
}
$selectitems = array();
foreach ($orphanedmods as $mod) {
$selectitems[$mod] = $mod;
}
$this->view->assign('selectitems', $selectitems);
return $this->view->fetch('ezcomments_admin_cleanup.tpl');
}
示例10: pnModGetAllMods
/**
* The pnModGetAllMods function gets a list of all modules.
*
* @deprecated
* @see ModUtil::getAllMods()
*
* @return array An array of module information arrays.
*/
function pnModGetAllMods()
{
LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'ModUtil::getAllMods()')), E_USER_DEPRECATED);
return ModUtil::getAllMods();
}
示例11: modifypageconfigurationassignmentAction
/**
* @Route("/modifypageconfigurationassignment/{themename}/{pcname}")
* @Method("GET")
*
* Modify a theme page configuration
*
* @param Request $request
* @param string $themename name of the theme
* @param string $pcname name of the page configuration to edit
*
* @return Response symfony response object
*
* @throws \Exception if required files not found
* @throws AccessDeniedException Thrown if the user doesn't have edit permissions over the theme
*/
public function modifypageconfigurationassignmentAction(Request $request, $themename, $pcname = null)
{
$themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($themename));
$this->checkIfMainThemeFileExists($themeinfo);
// Security check
if (!SecurityUtil::checkPermission('ZikulaThemeModule::', "{$themename}::pageconfigurations", ACCESS_EDIT)) {
throw new AccessDeniedException();
}
// assign all modules
$allmods = ModUtil::getAllMods();
$mods = array();
foreach ($allmods as $mod) {
$mods[$mod['name']] = $mod['name'];
}
// get all pageconfigurations
$pageconfigurations = ModUtil::apiFunc('ZikulaThemeModule', 'user', 'getpageconfigurations', array('theme' => $themename));
if (!isset($pageconfigurations[$pcname])) {
throw new \InvalidArgumentException();
}
// defines the default types and master
$pagetypes = array('master' => $this->__('Master'), '*home' => $this->__('Homepage'), '*admin' => $this->__('Admin panel pages'), '*editor' => $this->__('Editor panel pages'));
// checks for non-standard pagetypes
foreach ($pageconfigurations as $name => $pageconfiguration) {
if (strpos($name, '*') === 0 && !isset($pagetypes[$name])) {
//! Pages inside a specific Controller type (editor, moderator, user)
$pagetypes[$name] = $this->__f('%s type pages', ucfirst(substr($name, 1)));
}
}
// form the page config assignment array setting some useful key names
$pageconfigassignment = array('pagemodule' => null, 'pagetype' => null, 'pagefunc' => null, 'pagecustomargs' => null);
$pageconfigparts = explode('/', $pcname);
$pageconfigassignment['pagemodule'] = $pageconfigparts[0];
if (isset($pageconfigparts[1])) {
$pageconfigassignment['pagetype'] = $pageconfigparts[1];
}
if (isset($pageconfigparts[2])) {
$pageconfigassignment['pagefunc'] = $pageconfigparts[2];
}
if (isset($pageconfigparts[3])) {
$pageconfigassignment['pagecustomargs'] = $pageconfigparts[3];
}
if (isset($pageconfigurations[$pcname]['important']) && $pageconfigurations[$pcname]['important']) {
$pageconfigassignment['important'] = 1;
}
// gets the available page configurations on the theme
$existingconfigs = ModUtil::apiFunc('ZikulaThemeModule', 'user', 'getconfigurations', array('theme' => $themename));
// assign the page config assignment name, theme name and theme info
$this->view->assign($pageconfigassignment)->assign('existingconfigs', $existingconfigs)->assign('pcname', $pcname)->assign('themename', $themename)->assign('themeinfo', $themeinfo)->assign('pagetypes', $pagetypes)->assign('modules', $mods)->assign('filename', $pageconfigurations[$pcname]['file']);
return new Response($this->view->fetch('Admin/modifypageconfigurationassignment.tpl'));
}
示例12: accountLinks
/**
* Retrieve the account links for each user module.
*
* @return array An array of links for the user account page.
*/
public function accountLinks()
{
// Get all user modules
$mods = ModUtil::getAllMods();
if ($mods == false) {
return false;
}
$accountlinks = array();
foreach ($mods as $mod) {
// saves 17 system checks
if ($mod['type'] == 3 && !in_array($mod['name'], array('Admin', 'Categories', 'Groups', 'Theme', $this->name))) {
continue;
}
$modpath = ($mod['type'] == ModUtil::TYPE_SYSTEM) ? 'system' : 'modules';
$ooAccountApiFile = DataUtil::formatForOS("{$modpath}/{$mod['directory']}/lib/{$mod['directory']}/Api/Account.php");
$legacyAccountApiFile = DataUtil::formatForOS("{$modpath}/{$mod['directory']}/pnaccountapi.php");
if (file_exists($ooAccountApiFile) || file_exists($legacyAccountApiFile)) {
$items = ModUtil::apiFunc($mod['name'], 'account', 'getAll');
if ($items) {
foreach ($items as $k => $item) {
// check every retured link for permissions
if (SecurityUtil::checkPermission('Users::', "$mod[name]::$item[title]", ACCESS_READ)) {
if (!isset($item['module'])) {
$item['module'] = $mod['name'];
}
// insert the indexed item
$accountlinks["$mod[name]{$k}"] = $item;
}
}
}
} else {
$items = false;
}
}
return $accountlinks;
}