本文整理汇总了PHP中plugin_manager类的典型用法代码示例。如果您正苦于以下问题:PHP plugin_manager类的具体用法?PHP plugin_manager怎么用?PHP plugin_manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了plugin_manager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: definition
protected function definition()
{
global $CFG, $OUTPUT;
$mform =& $this->_form;
$indicators = $this->_customdata['indicators'];
$mform->addElement('hidden', 'id', $this->_customdata['id']);
// TODO: general course-level report settings.
$mform->addElement('header', 'general', get_string('pluginname', 'coursereport_engagement'));
$mform->addElement('header', 'weightings', get_string('weighting', 'coursereport_engagement'));
$mform->addElement('static', 'weightings_desc', get_string('indicator', 'coursereport_engagement'));
foreach ($indicators as $name => $path) {
$grouparray = array();
$grouparray[] =& $mform->createElement('text', "weighting_{$name}", '', array('size' => 3));
$grouparray[] =& $mform->createElement('static', '', '', '%');
$mform->addGroup($grouparray, "weight_group_{$name}", get_string('pluginname', "engagementindicator_{$name}"), ' ', false);
}
$pluginman = plugin_manager::instance();
$instances = get_plugin_list('engagementindicator');
foreach ($indicators as $name => $path) {
$plugin = coursereport_engagement_get_plugin_info($pluginman, 'engagementindicator_' . $name);
$file = "{$CFG->dirroot}/mod/engagement/indicator/{$name}/thresholds_form.php";
if (file_exists($file) && $plugin->is_enabled()) {
require_once $file;
$class = "engagementindicator_{$name}_thresholds_form";
$subform = new $class();
$mform->addElement('header', 'general', get_string('pluginname', "engagementindicator_{$name}"));
$subform->definition_inner($mform);
}
}
$this->add_action_buttons();
}
示例2: mnetadmin_rpc_get_plugins_info
/**
* Get role capabilities of a virtual platform.
* @param mixed $user The calling user.
* @param string $role The role to read capabilities.
* @param mixed $capabilities The capabilities to read (optional / may be string or array).
*/
function mnetadmin_rpc_get_plugins_info($user, $plugintype, $json_response = true)
{
global $CFG, $USER, $DB;
// Invoke local user and check his rights
if ($auth_response = invoke_local_user((array) $user, 'local/vmoodle:execute')) {
if ($json_response) {
return $auth_response;
} else {
return json_decode($auth_response);
}
}
$response = new StdClass();
$response->errors = array();
$response->error = '';
// Creating response.
$response->status = RPC_SUCCESS;
// Getting role.
$pm = plugin_manager::instance();
$allplugins = $pm->get_plugins();
if (!array_key_exists($plugintype, $allplugins)) {
$response->status = RPC_FAILURE_RECORD;
$response->errors[] = "Non existant plugin type {$plugintype}.";
$response->error = "Non existant plugin type {$plugintype}.";
if ($json_response) {
return json_encode($response);
} else {
return $response;
}
}
// Setting result value.
$response->value = (array) $allplugins[$plugintype];
$actionclass = $plugintype . '_remote_control';
// Get activation status.
foreach ($response->value as $pluginname => $foobar) {
// Ignore non implemented.
if (!class_exists($actionclass)) {
debug_trace("failing running remote action on {$actionclass}. Class not found");
continue;
}
$control = new $actionclass($pluginname);
$response->value[$pluginname]->enabled = $control->is_enabled();
}
// Returning response.
if ($json_response) {
return json_encode($response);
} else {
return $response;
}
}
示例3: coursereport_engagement_get_course_summary
function coursereport_engagement_get_course_summary($courseid)
{
global $CFG, $DB;
$risks = array();
// TODO: We want this to rely on enabled indicators in the course...
require_once $CFG->libdir . '/pluginlib.php';
require_once $CFG->dirroot . '/course/report/engagement/locallib.php';
$pluginman = plugin_manager::instance();
$instances = get_plugin_list('engagementindicator');
if (!($weightings = $DB->get_records_menu('coursereport_engagement', array('course' => $courseid), '', 'indicator, weight'))) {
// Setup default weightings, all equal.
$weight = sprintf('%.2f', 1 / count($instances));
foreach ($instances as $name => $path) {
$record = new stdClass();
$record->course = $courseid;
$record->indicator = $name;
$record->weight = $weight;
$record->configdata = null;
$wid = $DB->insert_record('coursereport_engagement', $record);
$weightings[$name] = $weight;
}
}
foreach ($instances as $name => $path) {
$plugin = coursereport_engagement_get_plugin_info($pluginman, 'engagementindicator_' . $name);
if ($plugin->is_enabled() && file_exists("{$path}/indicator.class.php")) {
require_once "{$path}/indicator.class.php";
$classname = "indicator_{$name}";
$indicator = new $classname($courseid);
$indicatorrisks = $indicator->get_course_risks();
$weight = isset($weightings[$name]) ? $weightings[$name] : 0;
foreach ($indicatorrisks as $userid => $risk) {
if (!isset($risks[$userid])) {
$risks[$userid] = 0;
}
$risks[$userid] += $risk->risk * $weight;
}
}
}
return $risks;
}
示例4: required_param
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/pluginlib.php';
$action = required_param('action', PARAM_ALPHANUMEXT);
$formatname = required_param('format', PARAM_PLUGIN);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$syscontext = context_system::instance();
$PAGE->set_url('/admin/courseformats.php');
$PAGE->set_context($syscontext);
require_login();
require_capability('moodle/site:config', $syscontext);
require_sesskey();
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
$allplugins = plugin_manager::instance()->get_plugins();
$formatplugins = $allplugins['format'];
$sortorder = array_flip(array_keys($formatplugins));
if (!isset($formatplugins[$formatname])) {
print_error('courseformatnotfound', 'error', $return, $formatname);
}
switch ($action) {
case 'disable':
if ($formatplugins[$formatname]->is_enabled()) {
if (get_config('moodlecourse', 'format') === $formatname) {
print_error('cannotdisableformat', 'error', $return);
}
set_config('disabled', 1, 'format_' . $formatname);
}
break;
case 'enable':
示例5: deploy_ingredients
/**
* Adds and upgrades the selected plugins
*
* @param array $ingredients
* @param string $path Path to the ingredient type file system
* @param SimpleXMLElement $xml
* @return array Problems during the ingredients deployment
*/
public function deploy_ingredients($ingredients, $path, SimpleXMLElement $xml)
{
// Using the $ingredients array keys to maintain coherence with the main deployment method
$problems = array();
$pluginman = plugin_manager::instance();
$plugintypespaths = get_plugin_types();
$this->get_flavour_info($xml);
foreach ($ingredients as $selection) {
// [0] => ingredienttype, [1] => ingredientname
$ingredientdata = explode('/', $selection);
$type = $ingredientdata[0];
$ingredient = $ingredientdata[1];
if (empty($this->branches[$type]->branches[$ingredient])) {
$problems[$selection]['pluginnotfound'] = $selection;
continue;
}
$ingredientdata = $this->branches[$type]->branches[$ingredient];
// Adapter to the restrictions array
if (!empty($ingredientdata->restrictions)) {
$problems[$selection] = $ingredientdata->restrictions;
continue;
}
if (empty($xml->{$type}) || empty($xml->{$type}->{$ingredient})) {
$problems[$selection]['pluginnotfound'] = $selection;
continue;
}
// Deploy then
$ingredientpath = $plugintypespaths[$type] . '/' . $ingredient;
// Remove old dir if present
if (file_exists($ingredientpath)) {
// Report if the old plugin directory can't be removed
if (!$this->unlink($ingredientpath)) {
$problems[$selection]['plugincantremove'] = $selection;
continue;
}
}
// Copy the new contents where the flavour says
$tmppath = $path . '/' . $xml->{$type}->{$ingredient}->path;
if (!$this->copy($tmppath, $ingredientpath)) {
debugging('From : ' . $tmppath . ' To: ' . $ingredientpath);
$problems[$selection]['plugincopyerror'] = $selection;
}
}
// Execute the moodle upgrade process
try {
foreach ($plugintypespaths as $type => $location) {
upgrade_plugins($type, 'flavours_print_upgrade_void', 'flavours_print_upgrade_void', false);
}
} catch (Exception $ex) {
abort_all_db_transactions();
$info = get_exception_info($ex);
upgrade_log(UPGRADE_LOG_ERROR, $ex->module, 'Exception: ' . get_class($ex), $info->message, $info->backtrace);
}
return $problems;
}
示例6: output_html
/**
* Return XHTML to display control
*
* @param mixed $data Unused
* @param string $query
* @return string highlight
*/
public function output_html($data, $query = '')
{
global $CFG, $OUTPUT;
$return = '';
$return = $OUTPUT->heading(new lang_string('courseformats'), 3, 'main');
$return .= $OUTPUT->box_start('generalbox formatsui');
$formats = plugin_manager::instance()->get_plugins_of_type('format');
// display strings
$txt = get_strings(array('settings', 'name', 'enable', 'disable', 'up', 'down', 'default', 'delete'));
$txt->updown = "{$txt->up}/{$txt->down}";
$table = new html_table();
$table->head = array($txt->name, $txt->enable, $txt->updown, $txt->delete, $txt->settings);
$table->align = array('left', 'center', 'center', 'center', 'center');
$table->width = '90%';
$table->attributes['class'] = 'manageformattable generaltable';
$table->data = array();
$cnt = 0;
$defaultformat = get_config('moodlecourse', 'format');
$spacer = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'iconsmall'));
foreach ($formats as $format) {
$url = new moodle_url('/admin/courseformats.php', array('sesskey' => sesskey(), 'format' => $format->name));
$isdefault = '';
if ($format->is_enabled()) {
$strformatname = html_writer::tag('span', $format->displayname);
if ($defaultformat === $format->name) {
$hideshow = $txt->default;
} else {
$hideshow = html_writer::link($url->out(false, array('action' => 'disable')), $OUTPUT->pix_icon('t/hide', $txt->disable, 'moodle', array('class' => 'iconsmall')));
}
} else {
$strformatname = html_writer::tag('span', $format->displayname, array('class' => 'dimmed_text'));
$hideshow = html_writer::link($url->out(false, array('action' => 'enable')), $OUTPUT->pix_icon('t/show', $txt->enable, 'moodle', array('class' => 'iconsmall')));
}
$updown = '';
if ($cnt) {
$updown .= html_writer::link($url->out(false, array('action' => 'up')), $OUTPUT->pix_icon('t/up', $txt->up, 'moodle', array('class' => 'iconsmall'))) . '';
} else {
$updown .= $spacer;
}
if ($cnt < count($formats) - 1) {
$updown .= ' ' . html_writer::link($url->out(false, array('action' => 'down')), $OUTPUT->pix_icon('t/down', $txt->down, 'moodle', array('class' => 'iconsmall')));
} else {
$updown .= $spacer;
}
$cnt++;
$settings = '';
if ($format->get_settings_url()) {
$settings = html_writer::link($format->get_settings_url(), $txt->settings);
}
$uninstall = '';
if ($defaultformat !== $format->name) {
$uninstall = html_writer::link($format->get_uninstall_url(), $txt->delete);
}
$table->data[] = array($strformatname, $hideshow, $updown, $uninstall, $settings);
}
$return .= html_writer::table($table);
$link = html_writer::link(new moodle_url('/admin/settings.php', array('section' => 'coursesettings')), new lang_string('coursesettings'));
$return .= html_writer::tag('p', get_string('manageformatsgotosettings', 'admin', $link));
$return .= $OUTPUT->box_end();
return highlight($query, $return);
}
示例7: get_status
/**
* Returns the status of the plugin
*
* @return string one of plugin_manager::PLUGIN_STATUS_xxx constants
*/
public function get_status() {
if (is_null($this->versiondb) and is_null($this->versiondisk)) {
return plugin_manager::PLUGIN_STATUS_NODB;
} else if (is_null($this->versiondb) and !is_null($this->versiondisk)) {
return plugin_manager::PLUGIN_STATUS_NEW;
} else if (!is_null($this->versiondb) and is_null($this->versiondisk)) {
if (plugin_manager::is_deleted_standard_plugin($this->type, $this->name)) {
return plugin_manager::PLUGIN_STATUS_DELETE;
} else {
return plugin_manager::PLUGIN_STATUS_MISSING;
}
} else if ((string)$this->versiondb === (string)$this->versiondisk) {
return plugin_manager::PLUGIN_STATUS_UPTODATE;
} else if ($this->versiondb < $this->versiondisk) {
return plugin_manager::PLUGIN_STATUS_UPGRADE;
} else if ($this->versiondb > $this->versiondisk) {
return plugin_manager::PLUGIN_STATUS_DOWNGRADE;
} else {
// $version = pi(); and similar funny jokes - hopefully Donald E. Knuth will never contribute to Moodle ;-)
throw new coding_exception('Unable to determine plugin state, check the plugin versions');
}
}
示例8: plugins_control_panel
/**
* Displays all known plugins and links to manage them
*
* This default implementation renders all plugins into one big table.
*
* @param plugin_manager $pluginman provides information about the plugins.
* @return string HTML code
*/
public function plugins_control_panel(plugin_manager $pluginman)
{
global $CFG;
$plugininfo = $pluginman->get_plugins();
if (empty($plugininfo)) {
return '';
}
$table = new html_table();
$table->id = 'plugins-control-panel';
$table->head = array(get_string('displayname', 'core_plugin'), get_string('source', 'core_plugin'), get_string('version', 'core_plugin'), get_string('availability', 'core_plugin'), get_string('actions', 'core_plugin'), get_string('notes', 'core_plugin'));
$table->colclasses = array('pluginname', 'source', 'version', 'availability', 'actions', 'notes');
foreach ($plugininfo as $type => $plugins) {
$header = new html_table_cell($pluginman->plugintype_name_plural($type));
$header->header = true;
$header->colspan = count($table->head);
$header = new html_table_row(array($header));
$header->attributes['class'] = 'plugintypeheader type-' . $type;
$table->data[] = $header;
if (empty($plugins)) {
$msg = new html_table_cell(get_string('noneinstalled', 'core_plugin'));
$msg->colspan = count($table->head);
$row = new html_table_row(array($msg));
$row->attributes['class'] .= 'msg msg-noneinstalled';
$table->data[] = $row;
continue;
}
foreach ($plugins as $name => $plugin) {
$row = new html_table_row();
$row->attributes['class'] = 'type-' . $plugin->type . ' name-' . $plugin->type . '_' . $plugin->name;
if ($this->page->theme->resolve_image_location('icon', $plugin->type . '_' . $plugin->name)) {
$icon = $this->output->pix_icon('icon', '', $plugin->type . '_' . $plugin->name, array('class' => 'smallicon pluginicon'));
} else {
$icon = $this->output->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
}
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
$msg = html_writer::tag('span', get_string('status_missing', 'core_plugin'), array('class' => 'notifyproblem'));
$row->attributes['class'] .= ' missingfromdisk';
} else {
$msg = '';
}
$pluginname = html_writer::tag('div', $icon . ' ' . $plugin->displayname . ' ' . $msg, array('class' => 'displayname')) . html_writer::tag('div', $plugin->component, array('class' => 'componentname'));
$pluginname = new html_table_cell($pluginname);
if ($plugin->is_standard()) {
$row->attributes['class'] .= ' standard';
$source = new html_table_cell(get_string('sourcestd', 'core_plugin'));
} else {
$row->attributes['class'] .= ' extension';
$source = new html_table_cell(get_string('sourceext', 'core_plugin'));
}
$version = new html_table_cell($plugin->versiondb);
$isenabled = $plugin->is_enabled();
if (is_null($isenabled)) {
$availability = new html_table_cell('');
} else {
if ($isenabled) {
$row->attributes['class'] .= ' enabled';
$icon = $this->output->pix_icon('i/hide', get_string('pluginenabled', 'core_plugin'));
$availability = new html_table_cell($icon . ' ' . get_string('pluginenabled', 'core_plugin'));
} else {
$row->attributes['class'] .= ' disabled';
$icon = $this->output->pix_icon('i/show', get_string('plugindisabled', 'core_plugin'));
$availability = new html_table_cell($icon . ' ' . get_string('plugindisabled', 'core_plugin'));
}
}
$actions = array();
$settingsurl = $plugin->get_settings_url();
if (!is_null($settingsurl)) {
$actions[] = html_writer::link($settingsurl, get_string('settings', 'core_plugin'), array('class' => 'settings'));
}
$uninstallurl = $plugin->get_uninstall_url();
if (!is_null($uninstallurl)) {
$actions[] = html_writer::link($uninstallurl, get_string('uninstall', 'core_plugin'), array('class' => 'uninstall'));
}
$actions = new html_table_cell(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $actions));
$requriedby = $pluginman->other_plugins_that_require($plugin->component);
if ($requriedby) {
$requiredby = html_writer::tag('div', get_string('requiredby', 'core_plugin', implode(', ', $requriedby)), array('class' => 'requiredby'));
} else {
$requiredby = '';
}
$updateinfo = '';
if (empty($CFG->disableupdatenotifications) and is_array($plugin->available_updates())) {
foreach ($plugin->available_updates() as $availableupdate) {
$updateinfo .= $this->plugin_available_update_info($availableupdate);
}
}
$notes = new html_table_cell($requiredby . $updateinfo);
$row->cells = array($pluginname, $source, $version, $availability, $actions, $notes);
$table->data[] = $row;
}
}
return html_writer::table($table);
//.........这里部分代码省略.........
示例9: get_message_providers
/**
* Get all message providers, validate their plugin existance and
* system configuration
*
* @return mixed $processors array of objects containing information on message processors
*/
function get_message_providers() {
global $CFG, $DB;
require_once($CFG->libdir . '/pluginlib.php');
$pluginman = plugin_manager::instance();
$providers = $DB->get_records('message_providers', null, 'name');
// Remove all the providers whose plugins are disabled or don't exist
foreach ($providers as $providerid => $provider) {
$plugin = $pluginman->get_plugin_info($provider->component);
if ($plugin) {
if ($plugin->get_status() === plugin_manager::PLUGIN_STATUS_MISSING) {
unset($providers[$providerid]); // Plugins does not exist
continue;
}
if ($plugin->is_enabled() === false) {
unset($providers[$providerid]); // Plugin disabled
continue;
}
}
}
return $providers;
}
示例10: action
function action($action)
{
$allplugins = plugin_manager::instance()->get_plugins();
$formatplugins = $allplugins['format'];
if (!isset($formatplugins[$this->plugin])) {
return get_string('courseformatnotfound', 'error', $this->plugin);
}
switch ($action) {
case 'enable':
if (!$formatplugins[$this->plugin]->is_enabled()) {
unset_config('disabled', 'format_' . $this->plugin);
}
break;
case 'disable':
if ($formatplugins[$this->plugin]->is_enabled()) {
if (get_config('moodlecourse', 'format') === $this->plugin) {
return get_string('cannotdisableformat', 'error');
}
set_config('disabled', 1, 'format_' . $formatname);
}
break;
}
return 0;
}
示例11: mnetadmin_rpc_upgrade
function mnetadmin_rpc_upgrade($user, $json_response = true)
{
global $CFG, $USER;
// Invoke local user and check his rights
if ($auth_response = invoke_local_user((array) $user)) {
if ($json_response) {
return $auth_response;
} else {
return json_decode($auth_response);
}
}
// Creating response
$response = new stdclass();
$response->status = RPC_SUCCESS;
require "{$CFG->dirroot}/version.php";
// defines $version, $release, $branch and $maturity
$CFG->target_release = $release;
// used during installation and upgrades
if ($version < $CFG->version) {
$response->status = RPC_FAILURE_RUN;
$response->error = get_string('downgradedcore', 'error');
$response->errors[] = get_string('downgradedcore', 'error');
if ($json_response) {
return json_encode($response);
} else {
return $response;
}
}
$oldversion = "{$CFG->release} ({$CFG->version})";
$newversion = "{$release} ({$version})";
if (!moodle_needs_upgrading()) {
$response->message = get_string('cliupgradenoneed', 'core_admin', $newversion);
if ($json_response) {
return json_encode($response);
} else {
return $response;
}
}
// debug_trace('Remote Upgrade : Environment check');
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_NEWER);
if (!$envstatus) {
$response->status = RPC_FAILURE_RUN;
$response->error = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade');
$response->errors[] = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade');
$response->detail = $environment_results;
if ($json_response) {
return json_encode($response);
} else {
return $response;
}
}
// Test plugin dependencies.
// debug_trace('Remote Upgrade : Plugins check');
$failed = array();
if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
$response->status = RPC_FAILURE_RUN;
$response->error = get_string('pluginschecktodo', 'admin');
$response->errors[] = get_string('pluginschecktodo', 'admin');
if ($json_response) {
return json_encode($response);
} else {
return $response;
}
}
ob_start();
// debug_trace('Remote Upgrade : Upgrade core');
if ($version > $CFG->version) {
upgrade_core($version, false);
}
set_config('release', $release);
set_config('branch', $branch);
// unconditionally upgrade
// debug_trace('Remote Upgrade : Upgrade other');
upgrade_noncore(false);
// log in as admin - we need doanything permission when applying defaults
// debug_trace('Remote Upgrade : Turning ADMIN ');
session_set_user(get_admin());
// apply all default settings, just in case do it twice to fill all defaults
// debug_trace('Remote Upgrade : Applying settings ');
admin_apply_default_settings(NULL, false);
admin_apply_default_settings(NULL, false);
ob_end_clean();
$response->message = vmoodle_get_string('upgradecomplete', 'vmoodleadminset_upgrade', $newversion);
if ($json_response) {
return json_encode($response);
} else {
return $response;
}
}
示例12: defined
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* TinyMCE admin settings
*
* @package editor_tinymce
* @copyright 2009 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('editorsettings', new admin_category('editortinymce', $editor->displayname, $editor->is_enabled() === false));
$settings = new admin_settingpage('editorsettingstinymce', new lang_string('settings', 'editor_tinymce'));
if ($ADMIN->fulltree) {
require_once __DIR__ . '/adminlib.php';
$settings->add(new tiynce_subplugins_settings());
$settings->add(new admin_setting_heading('tinymcegeneralheader', new lang_string('settings'), ''));
$default = "fontselect,fontsizeselect,formatselect,|,undo,redo,|,search,replace,|,fullscreen\n\nbold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl\n\nbullist,numlist,outdent,indent,|,link,unlink,|,image,nonbreaking,charmap,table,|,code";
$settings->add(new admin_setting_configtextarea('editor_tinymce/customtoolbar', get_string('customtoolbar', 'editor_tinymce'), get_string('customtoolbar_desc', 'editor_tinymce', 'http://www.tinymce.com/wiki.php/Buttons/controls'), $default, PARAM_RAW, 100, 8));
$settings->add(new admin_setting_configtextarea('editor_tinymce/fontselectlist', get_string('fontselectlist', 'editor_tinymce'), '', 'Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings', PARAM_RAW, 100, 8));
$settings->add(new editor_tinymce_json_setting_textarea('editor_tinymce/customconfig', get_string('customconfig', 'editor_tinymce'), get_string('customconfig_desc', 'editor_tinymce'), '', PARAM_RAW, 100, 8));
}
$ADMIN->add('editortinymce', $settings);
unset($settings);
require_once "{$CFG->libdir}/pluginlib.php";
foreach (plugin_manager::instance()->get_plugins_of_type('tinymce') as $plugin) {
$plugin->load_settings($ADMIN, 'editortinymce', $hassiteconfig);
}
// TinyMCE does not have standard settings page.
$settings = null;
示例13: run
/**
* Execute the command.
* @param $hosts mixed The host where run the command (may be wwwroot or an array).
* @throws Command_Exception.
*/
public function run($hosts)
{
global $CFG, $USER;
// Adding constants.
require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
// Checking capability to run.
if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
throw new Command_Exception('insuffisantcapabilities');
}
// Getting plugin.
list($type, $plugin) = explode('/', $this->getParameter('plugin')->getValue());
// Getting the state.
$state = $this->getParameter('state')->getValue();
$pm = \plugin_manager::instance();
$plugininfo = $pm->get_plugin_info($plugin);
if (empty($plugininfo->type)) {
if (empty($plugininfo)) {
$plugininfo = new \StdClass();
}
$plugininfo->type = $type;
}
$plugininfo->action = $state;
$plugininfos[$plugin] = (array) $plugininfo;
// Creating XMLRPC client to change remote configuration.
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/plugins/rpclib.php/mnetadmin_rpc_set_plugins_states');
$rpc_client->add_param($plugininfos, 'array');
// Initializing responses.
$responses = array();
// Creating peers.
$mnet_hosts = array();
if (!empty($hosts)) {
foreach ($hosts as $host => $name) {
$mnet_host = new \mnet_peer();
if ($mnet_host->bootstrap($host, null, 'moodle')) {
$mnet_hosts[] = $mnet_host;
} else {
$responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
}
}
}
// Sending requests.
foreach ($mnet_hosts as $mnet_host) {
// Sending request.
if (!$rpc_client->send($mnet_host)) {
$response = new \StdClass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
echo '</pre>';
}
} else {
$response = json_decode($rpc_client->response);
}
// Recording response.
$responses[$mnet_host->wwwroot] = $response;
// Recording plugin descriptors.
if ($response->status == RPC_SUCCESS) {
$this->plugins[$mnet_host->wwwroot] = @$response->value;
}
}
// Saving results
$this->results = $responses + $this->results;
}
示例14: required_param
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once '../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->libdir . '/pluginlib.php';
$action = required_param('action', PARAM_ALPHANUMEXT);
$formatname = required_param('format', PARAM_PLUGIN);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$syscontext = context_system::instance();
$PAGE->set_url('/admin/courseformats.php');
$PAGE->set_context($syscontext);
require_login();
require_capability('moodle/site:config', $syscontext);
require_sesskey();
$return = new moodle_url('/admin/settings.php', array('section' => 'manageformats'));
$formatplugins = plugin_manager::instance()->get_plugins_of_type('format');
$sortorder = array_flip(array_keys($formatplugins));
if (!isset($formatplugins[$formatname])) {
print_error('courseformatnotfound', 'error', $return, $formatname);
}
switch ($action) {
case 'disable':
if ($formatplugins[$formatname]->is_enabled()) {
if (get_config('moodlecourse', 'format') === $formatname) {
print_error('cannotdisableformat', 'error', $return);
}
set_config('disabled', 1, 'format_' . $formatname);
}
break;
case 'enable':
if (!$formatplugins[$formatname]->is_enabled()) {
示例15: output_html
/**
* Builds the XHTML to display the control.
*
* @param string $data Unused
* @param string $query
* @return string
*/
public function output_html($data, $query = '')
{
global $CFG, $OUTPUT, $PAGE;
require_once "{$CFG->libdir}/editorlib.php";
require_once "{$CFG->libdir}/pluginlib.php";
require_once __DIR__ . '/lib.php';
$tinymce = new tinymce_texteditor();
$pluginmanager = plugin_manager::instance();
// display strings
$strbuttons = get_string('availablebuttons', 'editor_tinymce');
$strdisable = get_string('disable');
$strenable = get_string('enable');
$strname = get_string('name');
$strsettings = get_string('settings');
$struninstall = get_string('uninstallplugin', 'admin');
$strversion = get_string('version');
$subplugins = get_plugin_list('tinymce');
$return = $OUTPUT->heading(get_string('subplugintype_tinymce_plural', 'editor_tinymce'), 3, 'main', true);
$return .= $OUTPUT->box_start('generalbox tinymcesubplugins');
$table = new html_table();
$table->head = array($strname, $strbuttons, $strversion, $strenable, $strsettings, $struninstall);
$table->align = array('left', 'left', 'center', 'center', 'center', 'center');
$table->data = array();
$table->width = '100%';
// Iterate through subplugins.
foreach ($subplugins as $name => $dir) {
$namestr = get_string('pluginname', 'tinymce_' . $name);
$version = get_config('tinymce_' . $name, 'version');
if ($version === false) {
$version = '';
}
$plugin = $tinymce->get_plugin($name);
$plugininfo = $pluginmanager->get_plugin_info('tinymce_' . $name);
// Add hide/show link.
if (!$version) {
$hideshow = '';
$displayname = html_writer::tag('span', $name, array('class' => 'error'));
} else {
if ($plugininfo->is_enabled()) {
$url = new moodle_url('/lib/editor/tinymce/subplugins.php', array('sesskey' => sesskey(), 'return' => 'settings', 'disable' => $name));
$hideshow = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/hide'), 'class' => 'icon', 'alt' => $strdisable));
$hideshow = html_writer::link($url, $hideshow);
$displayname = html_writer::tag('span', $namestr);
} else {
$url = new moodle_url('/lib/editor/tinymce/subplugins.php', array('sesskey' => sesskey(), 'return' => 'settings', 'enable' => $name));
$hideshow = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/show'), 'class' => 'icon', 'alt' => $strenable));
$hideshow = html_writer::link($url, $hideshow);
$displayname = html_writer::tag('span', $namestr, array('class' => 'dimmed_text'));
}
}
if ($PAGE->theme->resolve_image_location('icon', 'tinymce_' . $name)) {
$icon = $OUTPUT->pix_icon('icon', '', 'tinymce_' . $name, array('class' => 'smallicon pluginicon'));
} else {
$icon = $OUTPUT->pix_icon('spacer', '', 'moodle', array('class' => 'smallicon pluginicon noicon'));
}
$displayname = $icon . ' ' . $displayname;
// Add available buttons.
$buttons = implode(', ', $plugin->get_buttons());
$buttons = html_writer::tag('span', $buttons, array('class' => 'tinymcebuttons'));
// Add settings link.
if (!$version) {
$settings = '';
} else {
if ($url = $plugininfo->get_settings_url()) {
$settings = html_writer::link($url, $strsettings);
} else {
$settings = '';
}
}
// Add uninstall info.
if ($version) {
$url = new moodle_url($plugininfo->get_uninstall_url(), array('return' => 'settings'));
$uninstall = html_writer::link($url, $struninstall);
} else {
$uninstall = '';
}
// Add a row to the table.
$table->data[] = array($displayname, $buttons, $version, $hideshow, $settings, $uninstall);
}
$return .= html_writer::table($table);
$return .= html_writer::tag('p', get_string('tablenosave', 'admin'));
$return .= $OUTPUT->box_end();
return highlight($query, $return);
}