本文整理汇总了PHP中plugin_types函数的典型用法代码示例。如果您正苦于以下问题:PHP plugin_types函数的具体用法?PHP plugin_types怎么用?PHP plugin_types使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plugin_types函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Convert a Mahara plugin template file path into a normal template file path with extra search paths.
*
* @param string $pluginfile The plugintype, name, and name of file, e.g. "blocktype:clippy:index.tpl"
* @param int $cacheTime Not used.
* @param int $cacheId Not used.
* @param int $compileId Not used.
* @param array $includePath The paths to look in.
* @throws MaharaException
*/
public function __construct($file, $cacheTime = null, $cacheId = null, $compileId = null, $includePath = null)
{
global $THEME;
$parts = explode(':', $file, 3);
if (count($parts) !== 3) {
throw new SystemException("Invalid template path \"{$file}\"");
}
// Keep the original string for logging purposes
$dwooref = $file;
list($plugintype, $pluginname, $file) = $parts;
// Since we use $plugintype as part of a file path, we should whitelist it
$plugintype = strtolower($plugintype);
if (!in_array($plugintype, plugin_types())) {
throw new SystemException("Invalid plugintype in Dwoo template \"{$dwooref}\"");
}
// Get the relative path for this particular plugin
require_once get_config('docroot') . $plugintype . '/lib.php';
$pluginpath = call_static_method(generate_class_name($plugintype), 'get_theme_path', $pluginname);
// Because this is a plugin template file, we don't want to include any accidental matches against
// core template files with the same name.
$includePath = array();
// First look for a local override.
$includePath[] = get_config('docroot') . "local/theme/{$pluginpath}/templates";
// Then look for files in a custom theme
foreach ($THEME->inheritance as $theme) {
$includePath[] = get_config('docroot') . "theme/{$theme}/{$pluginpath}/templates";
}
// Lastly look for files in the plugin itself
foreach ($THEME->inheritance as $theme) {
$includePath[] = get_config('docroot') . "{$pluginpath}/theme/{$theme}/templates";
// For legacy purposes also look for the template file loose under the theme directory.
$includePath[] = get_config('docroot') . "{$pluginpath}/theme/{$theme}";
}
// Now, we instantiate this as a standard Dwoo_Template_File class.
// We're passing in $file, which is the relative path to the file, and
// $includePath, which is an array of directories to search for $file in.
// We let Dwoo figure out which one actually has it.
parent::__construct($file, null, null, null, $includePath);
}
示例2: get_config
require_once get_config('docroot') . 'import/lib.php';
require_once get_config('docroot') . 'export/lib.php';
require_once get_config('docroot') . 'lib/activity.php';
require_once get_config('docroot') . 'lib/file.php';
// This is here for debugging purposes, it allows us to fake the time to test
// cron behaviour
$realstart = time();
$fake = isset($argv[1]);
$start = $fake ? strtotime($argv[1]) : $realstart;
log_info('---------- cron running ' . date('r', $start) . ' ----------');
raise_memory_limit('128M');
if (!is_writable(get_config('dataroot'))) {
log_warn("Unable to write to dataroot directory.");
}
// for each plugin type
foreach (plugin_types() as $plugintype) {
$table = $plugintype . '_cron';
// get list of cron jobs to run for this plugin type
$now = $fake ? time() - ($realstart - $start) : time();
$jobs = get_records_select_array($table, 'nextrun < ? OR nextrun IS NULL', array(db_format_timestamp($now)), '', 'plugin,callfunction,minute,hour,day,month,dayofweek,' . db_format_tsfield('nextrun'));
if ($jobs) {
// for each cron entry
foreach ($jobs as $job) {
if (!cron_lock($job, $start, $plugintype)) {
continue;
}
// If some other cron instance ran the job while we were messing around,
// skip it.
$nextrun = get_field_sql('
SELECT ' . db_format_tsfield('nextrun') . '
FROM {' . $table . '}
示例3: i_trigger_cron
/**
* This step triggers the cron, through the web interface.
*
* It resets the "nextrun" on every cron task, so every cron task will run
* every time this step is used.
*
* @Given /^I trigger (the )?cron$/
*/
public function i_trigger_cron()
{
set_field('cron', 'nextrun', null);
foreach (plugin_types() as $plugintype) {
set_field($plugintype . '_cron', 'nextrun', null);
}
$this->getSession()->visit($this->locate_path('/lib/cron.php'));
}
示例4: sort_upgrades
function sort_upgrades($k1, $k2)
{
if ($k1 == 'core') {
return -1;
} else {
if ($k2 == 'core') {
return 1;
} else {
if ($k1 == 'firstcoredata') {
return -1;
} else {
if ($k2 == 'firstcoredata') {
return 1;
} else {
if ($k1 == 'lastcoredata') {
return 1;
} else {
if ($k2 == 'lastcoredata') {
return -1;
}
}
}
}
}
}
// else obey the order plugin types returns (strip off plugintype. from the start)
$weight1 = array_search(substr($k1, 0, strpos($k1, '.')), plugin_types());
$weight2 = array_search(substr($k2, 0, strpos($k2, '.')), plugin_types());
return $weight1 > $weight2;
}
示例5: has_page_help
function has_page_help()
{
$pt = defined('SECTION_PLUGINTYPE') ? SECTION_PLUGINTYPE : null;
$pn = defined('SECTION_PLUGINNAME') ? SECTION_PLUGINNAME : null;
$sp = defined('SECTION_PAGE') ? SECTION_PAGE : null;
if (empty($pt) || $pt != 'core' && empty($pn)) {
// we can't have a plugin type but no plugin name
return false;
}
if (in_array($pt, plugin_types())) {
$pagehelp = get_config('docroot') . $pt . '/' . $pn . '/lang/en.utf8/help/pages/' . $sp . '.html';
} else {
$pagehelp = get_config('docroot') . 'lang/en.utf8/help/pages/' . $pn . '/' . $sp . '.html';
}
if (is_readable($pagehelp)) {
return array($sp, get_help_icon($pt, $pn, '', '', $sp));
}
return false;
}
示例6: plugin_types_installed
/**
* Returns plugin types that are actually installed
*/
function plugin_types_installed()
{
static $plugins = array();
if (empty($plugins)) {
require_once 'ddl.php';
foreach (plugin_types() as $plugin) {
if (table_exists(new XMLDBTable("{$plugin}_installed"))) {
$plugins[] = $plugin;
}
}
}
return $plugins;
}
示例7: check_installed_plugins
function check_installed_plugins()
{
$missing = array();
foreach (plugin_types() as $plugintype) {
if ($installed = plugins_installed($plugintype, true)) {
foreach ($installed as $i) {
$key = $i->name;
if ($plugintype == 'blocktype') {
$key = blocktype_single_to_namespaced($i->name, $i->artefactplugin);
}
try {
safe_require($plugintype, $key);
} catch (SystemException $e) {
$missing[] = "{$plugintype}:{$key}";
}
}
}
}
return $missing;
}
示例8: registration_data
/**
* Builds the data that will be sent by the "register your site" feature
*/
function registration_data()
{
foreach (array('wwwroot', 'installation_key', 'sitename', 'dbtype', 'lang', 'theme', 'enablenetworking', 'allowpublicviews', 'allowpublicprofiles', 'version', 'release') as $key) {
$data_to_send[$key] = get_config($key);
}
// System information
$data_to_send['phpversion'] = phpversion();
$data_to_send['dbversion'] = get_field_sql('SELECT VERSION()');
$osversion = php_uname('s');
if ($osversion == 'Linux') {
$lsbversion = exec('lsb_release -d', $execout, $return_val);
if ($return_val === 0) {
$osversion = $lsbversion;
} else {
$osversion = php_uname();
}
}
$data_to_send['osversion'] = $osversion;
$data_to_send['phpsapi'] = php_sapi_name();
if (!empty($_SERVER) && !empty($_SERVER['SERVER_SOFTWARE'])) {
$data_to_send['webserver'] = $_SERVER['SERVER_SOFTWARE'];
}
$modules = get_loaded_extensions();
natcasesort($modules);
$data_to_send['phpmodules'] = '; ' . implode('; ', $modules) . ';';
foreach (array('usr_friend', 'usr_institution', 'group_member', 'block_instance', 'institution', 'blocktype_wall_post', 'institution') as $key) {
$data_to_send['count_' . $key] = count_records($key);
}
foreach (array('usr', 'group', 'host') as $key) {
$data_to_send['count_' . $key] = count_records_select($key, 'deleted = 0');
}
// Don't include the root user
$data_to_send['count_usr']--;
// Slightly more drilled down information
if ($data = get_records_sql_array('SELECT artefacttype, COUNT(*) AS count
FROM {artefact}
GROUP BY artefacttype', array())) {
foreach ($data as $artefacttypeinfo) {
$data_to_send['artefact_type_' . $artefacttypeinfo->artefacttype] = $artefacttypeinfo->count;
}
}
if ($data = get_records_sql_array('SELECT type, COUNT(*) AS count
FROM {view}
GROUP BY type', array())) {
foreach ($data as $viewtypeinfo) {
$data_to_send['view_type_' . $viewtypeinfo->type] = $viewtypeinfo->count;
}
}
// Plugin versions
foreach (plugin_types() as $type) {
foreach (plugins_installed($type) as $plugin) {
$data_to_send['plugin_' . $type . '_' . $plugin->name . '_version'] = $plugin->version;
}
}
$data_to_send['newstats'] = 1;
return $data_to_send;
}
示例9: drop_database
/**
* Drop the whole test database
* @static
* @param bool $displayprogress
*/
protected static function drop_database($displayprogress = false)
{
// Drop triggers
try {
db_drop_trigger('update_unread_insert', 'notification_internal_activity');
db_drop_trigger('update_unread_update', 'notification_internal_activity');
db_drop_trigger('update_unread_delete', 'notification_internal_activity');
db_drop_trigger('update_unread_insert2', 'module_multirecipient_userrelation');
db_drop_trigger('update_unread_update2', 'module_multirecipient_userrelation');
db_drop_trigger('update_unread_delete2', 'module_multirecipient_userrelation');
db_drop_trigger('unmark_quota_exceed_upd_usr_set', 'usr');
} catch (Exception $e) {
exit(1);
}
// Drop plugins' tables
// Find all plugins from the code base
// and drop their tables from database if exists
$plugins = array();
$pluginstocheck = plugin_types();
foreach ($pluginstocheck as $plugin) {
$dirhandle = opendir(get_config('docroot') . $plugin);
while (false !== ($dir = readdir($dirhandle))) {
if (strpos($dir, '.') === 0 or 'CVS' == $dir) {
continue;
}
if (!is_dir(get_config('docroot') . $plugin . '/' . $dir)) {
continue;
}
$plugins[] = array($plugin, $dir);
if ($plugin == 'artefact') {
// go check it for blocks as well
$btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
if (!is_dir($btlocation)) {
continue;
}
$btdirhandle = opendir($btlocation);
while (false !== ($btdir = readdir($btdirhandle))) {
if (strpos($btdir, '.') === 0 or 'CVS' == $btdir) {
continue;
}
if (!is_dir(get_config('docroot') . $plugin . '/' . $dir . '/blocktype/' . $btdir)) {
continue;
}
$plugins[] = array('blocktype', $dir . '/' . $btdir);
}
}
}
}
foreach ($plugins as $plugin) {
$plugintype = $plugin[0];
$pluginname = $plugin[1];
$pluginpath = "{$plugin['0']}/{$plugin['1']}";
$pluginkey = "{$plugin['0']}.{$plugin['1']}";
if ($plugintype == 'blocktype' && strpos($pluginname, '/') !== false) {
// sigh.. we're a bit special...
$bits = explode('/', $pluginname);
$pluginpath = 'artefact/' . $bits[0] . '/blocktype/' . $bits[1];
}
log_info("Uninstalling {$plugintype}.{$pluginname}");
$location = get_config('docroot') . $pluginpath . '/db';
if (is_readable($location . '/install.xml')) {
uninstall_from_xmldb_file($location . '/install.xml');
}
}
// These constraints must be dropped manually as they cannot be
// created with xmldb due to ordering issues
try {
if (is_postgres()) {
execute_sql('ALTER TABLE {usr} DROP CONSTRAINT {usr_pro_fk}');
execute_sql('ALTER TABLE {institution} DROP CONSTRAINT {inst_log_fk}');
}
} catch (Exception $e) {
exit(1);
}
// now uninstall core
if (is_mysql()) {
execute_sql('SET foreign_key_checks = 0');
}
log_info('Uninstalling core');
uninstall_from_xmldb_file(get_config('docroot') . 'lib/db/install.xml');
if (is_mysql()) {
execute_sql('SET foreign_key_checks = 1');
}
}
示例10: validate_version
// Check the core database version
validate_version('htdocs/lib/version.php', 'htdocs/lib/db/upgrade.php');
// Check versions of plugins. Pull the list of changed files, and then check each of them
// to see if it's a version.php or an upgrade.php file. Make a list of those, then
// validate each one found.
require_once 'htdocs/lib/mahara.php';
$p = popen("git diff-tree --no-commit-id --name-only -r {$GITREV}", 'r');
$updates = array();
$localupdated = false;
while (!feof($p)) {
$buffer = trim(fgets($p));
if (preg_match('#htdocs/([a-z]+)/([a-z]+)/version.php#', $buffer, $matches) && in_array($matches[1], plugin_types())) {
$updates["htdocs/{$matches[1]}/{$matches[2]}"] = true;
continue;
}
if (preg_match('#htdocs/([a-z]+)/([a-z]+)/db/upgrade.php#', $buffer, $matches) && in_array($matches[1], plugin_types())) {
$updates["htdocs/{$matches[1]}/{$matches[2]}"] = true;
continue;
}
if (preg_match('#htdocs/artefact/([a-z]+)/blocktype/([a-z]+)/version.php#', $buffer, $matches)) {
$updates["htdocs/artefact/{$matches[1]}/blocktype/{$matches[2]}"] = true;
continue;
}
if (preg_match('#htdocs/artefact/([a-z]+)/blocktype/([a-z]+)/db/upgrade.php#', $buffer, $matches)) {
$updates["htdocs/artefact/{$matches[1]}/blocktype/{$matches[2]}"] = true;
continue;
}
if (preg_match('#htdocs/local/version.php#', $buffer, $matches)) {
$localconfig = get_mahara_version($GITREV, $buffer);
if ($localconfig->version !== 0) {
echo "ERROR: You should not update the version number in htdocs/local/version.php.\n";
示例11: registration_data
/**
* Builds the data that will be sent by the "register your site" feature
*/
function registration_data()
{
foreach (array('wwwroot', 'installation_key', 'sitename', 'dbtype', 'lang', 'theme', 'enablenetworking', 'allowpublicviews', 'allowpublicprofiles', 'version', 'release') as $key) {
$data_to_send[$key] = get_config($key);
}
foreach (array('usr_friend', 'usr_institution', 'group_member', 'block_instance', 'institution', 'blocktype_wall_post', 'institution') as $key) {
$data_to_send['count_' . $key] = count_records($key);
}
foreach (array('usr', 'group', 'host') as $key) {
$data_to_send['count_' . $key] = count_records_select($key, 'deleted = 0');
}
// Don't include the root user
$data_to_send['count_usr']--;
// Slightly more drilled down information
if ($data = get_records_sql_array('SELECT artefacttype, COUNT(*) AS count
FROM {artefact}
GROUP BY artefacttype', array())) {
foreach ($data as $artefacttypeinfo) {
$data_to_send['artefact_type_' . $artefacttypeinfo->artefacttype] = $artefacttypeinfo->count;
}
}
if ($data = get_records_sql_array('SELECT type, COUNT(*) AS count
FROM {view}
GROUP BY type', array())) {
foreach ($data as $viewtypeinfo) {
$data_to_send['view_type_' . $viewtypeinfo->type] = $viewtypeinfo->count;
}
}
// Plugin versions
foreach (plugin_types() as $type) {
foreach (plugins_installed($type) as $plugin) {
$data_to_send['plugin_' . $type . '_' . $plugin->name . '_version'] = $plugin->version;
}
}
$data_to_send['newstats'] = 1;
return $data_to_send;
}