本文整理汇总了PHP中generate_class_name函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_class_name函数的具体用法?PHP generate_class_name怎么用?PHP generate_class_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_class_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: release_submitted_view
/**
* Releases a submission to a remote host.
* @param int $id A view or collection id
* @param mixed $assessmentdata Assessment data from the remote host, for this assignment
* @param string $teacherusername The username of the teacher who is releasing the assignment
* @param boolean $iscollection Whether the $id is a view or a collection
*/
function release_submitted_view($id, $assessmentdata, $teacherusername, $iscollection = false)
{
global $REMOTEWWWROOT, $USER;
list($teacher, $authinstance) = find_remote_user($teacherusername, $REMOTEWWWROOT);
require_once 'view.php';
db_begin();
if ($iscollection) {
require_once 'collection.php';
$collection = new Collection($id);
$collection->release($teacher);
} else {
$view = new View($id);
View::_db_release(array($id), $view->get('owner'));
}
// Provide each artefact plugin the opportunity to handle the remote submission release
foreach (plugins_installed('artefact') as $plugin) {
safe_require('artefact', $plugin->name);
$classname = generate_class_name('artefact', $plugin->name);
if (is_callable($classname . '::view_release_external_data')) {
call_static_method($classname, 'view_release_external_data', $id, $assessmentdata, $teacher ? $teacher->id : 0, $iscollection);
}
}
// Release the view for editing
db_commit();
}
示例3: get_search_plugins
function get_search_plugins()
{
$searchpluginoptions = array();
if ($searchplugins = plugins_installed('search')) {
foreach ($searchplugins as $plugin) {
safe_require_plugin('search', $plugin->name, 'lib.php');
if (!call_static_method(generate_class_name('search', $plugin->name), 'is_available_for_site_setting')) {
continue;
}
$searchpluginoptions[$plugin->name] = $plugin->name;
$config_path = get_config('docroot') . 'search/' . $plugin->name . '/version.php';
if (is_readable($config_path)) {
$config = new stdClass();
require_once $config_path;
if (isset($config->name)) {
$searchpluginoptions[$plugin->name] = $config->name;
}
}
}
}
return $searchpluginoptions;
}
示例4: build_artefactchooser_data
/**
* Builds data for the artefact chooser.
*
* This builds three pieces of information:
*
* - HTML containing table rows
* - Pagination HTML and Javascript
* - The total number of artefacts found
* - Artefact fields to return
*/
public static function build_artefactchooser_data($data, $group = null, $institution = null)
{
global $USER;
// If lazyload is set, immediately return an empty resultset
// In the case of forms using lazyload, lazyload is set to false by subsequent requests via ajax,
// for example in views/artefactchooser.json.php, at which time the full resultset is returned.
if (isset($data['lazyload']) && $data['lazyload']) {
$result = '';
$pagination = build_pagination(array('id' => $data['name'] . '_pagination', 'class' => 'ac-pagination', 'url' => View::make_base_url() . (param_boolean('s') ? '&s=1' : ''), 'count' => 0, 'limit' => 0, 'offset' => 0, 'datatable' => $data['name'] . '_data', 'jsonscript' => 'view/artefactchooser.json.php', 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'numbersincludefirstlast' => false, 'extradata' => array('value' => $data['defaultvalue'], 'blocktype' => $data['blocktype'], 'group' => $group, 'institution' => $institution)));
return array($result, $pagination, 0, 0, array());
}
$search = '';
if (!empty($data['search']) && param_boolean('s')) {
$search = param_variable('search', '');
// Maybe later, depending on performance - don't search if there's
// not enough characters. Prompts should be added to the UI too.
//if (strlen($search) < 3) {
// $search = '';
//}
}
$data['search'] = $search;
$data['offset'] -= $data['offset'] % $data['limit'];
safe_require('blocktype', $data['blocktype']);
$blocktypeclass = generate_class_name('blocktype', $data['blocktype']);
$data['sortorder'] = array(array('fieldname' => 'title', 'order' => 'ASC'));
if (method_exists($blocktypeclass, 'artefactchooser_get_sort_order')) {
$data['sortorder'] = call_static_method($blocktypeclass, 'artefactchooser_get_sort_order');
}
list($artefacts, $totalartefacts) = self::get_artefactchooser_artefacts($data, $USER, $group, $institution);
$selectone = $data['selectone'];
$value = $data['defaultvalue'];
$elementname = $data['name'];
$template = $data['template'];
$returnfields = isset($data['returnfields']) ? $data['returnfields'] : null;
$returnartefacts = array();
$result = '';
if ($artefacts) {
if (!empty($data['ownerinfo'])) {
require_once get_config('docroot') . 'artefact/lib.php';
$userid = $group || $institution ? null : $USER->get('id');
foreach (artefact_get_owner_info(array_keys($artefacts)) as $k => $v) {
if ($artefacts[$k]->owner !== $userid || $artefacts[$k]->group !== $group || $artefacts[$k]->institution !== $institution) {
$artefacts[$k]->ownername = $v->name;
$artefacts[$k]->ownerurl = $v->url;
}
}
}
foreach ($artefacts as &$artefact) {
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $artefact->artefacttype));
if (method_exists($blocktypeclass, 'artefactchooser_get_element_data')) {
$artefact = call_static_method($blocktypeclass, 'artefactchooser_get_element_data', $artefact);
}
// Build the radio button or checkbox for the artefact
$formcontrols = '';
if ($selectone) {
$formcontrols .= '<input type="radio" class="radio" id="' . hsc($elementname . '_' . $artefact->id) . '" name="' . hsc($elementname) . '" value="' . hsc($artefact->id) . '"';
if ($value == $artefact->id) {
$formcontrols .= ' checked="checked"';
}
$formcontrols .= '>';
} else {
$formcontrols .= '<input type="checkbox" id="' . hsc($elementname . '_' . $artefact->id) . '" name="' . hsc($elementname) . '[' . hsc($artefact->id) . ']"';
if ($value && in_array($artefact->id, $value)) {
$formcontrols .= ' checked="checked"';
}
$formcontrols .= ' class="artefactid-checkbox checkbox">';
$formcontrols .= '<input type="hidden" name="' . hsc($elementname) . '_onpage[]" value="' . hsc($artefact->id) . '" class="artefactid-onpage">';
}
$smarty = smarty_core();
$smarty->assign('artefact', $artefact);
$smarty->assign('elementname', $elementname);
$smarty->assign('formcontrols', $formcontrols);
$result .= $smarty->fetch($template) . "\n";
if ($returnfields) {
$returnartefacts[$artefact->id] = array();
foreach ($returnfields as $f) {
if ($f == 'safedescription') {
$returnartefacts[$artefact->id]['safedescription'] = clean_html($artefact->description);
continue;
}
if ($f == 'attachments') {
// Check if the artefact has attachments - we need to update the instance config form
// to have those attachments selected.
$attachment_ids = get_column('artefact_attachment', 'attachment', 'artefact', $artefact->id);
$returnartefacts[$artefact->id]['attachments'] = $attachment_ids;
continue;
}
$returnartefacts[$artefact->id][$f] = $artefact->{$f};
}
}
//.........这里部分代码省略.........
示例5: install_blocktype_viewtypes_for_plugin
function install_blocktype_viewtypes_for_plugin($blocktype)
{
safe_require('blocktype', $blocktype);
$blocktype = blocktype_namespaced_to_single($blocktype);
db_begin();
delete_records('blocktype_installed_viewtype', 'blocktype', $blocktype);
if ($viewtypes = call_static_method(generate_class_name('blocktype', $blocktype), 'get_viewtypes')) {
foreach ($viewtypes as $vt) {
insert_record('blocktype_installed_viewtype', (object) array('blocktype' => $blocktype, 'viewtype' => $vt));
}
}
db_commit();
}
示例6: artefact_get_progressbar_metaartefacts
/**
* Dealing with things to count in progressbar that are not true artefacts
* and therefore are not countable by adding up how many instances exist in
* the artefact table. Or if you want to count an artefact differently.
* For example: Social -> Make a friend
*
* @param string $plugin name of artefact plugin
* @param array $onlythese (optional) An array of items from artefact_get_progressbar_items, indicating which to include
* @return array of objects each containing artefacttype, completed
* (where completed represents the number completed)
*/
function artefact_get_progressbar_metaartefacts($plugin, $onlythese = false)
{
$results = array();
$classname = generate_class_name('artefact', $plugin);
// Check the artefacttypes to see if they have a special metaartefact count
$names = call_static_method($classname, 'get_artefact_types');
foreach ($names as $name) {
if (!array_key_exists($name, $onlythese)) {
continue;
}
$is_metaartefact = call_static_method('ArtefactType' . ucfirst($name), 'is_metaartefact');
if ($is_metaartefact) {
$meta = call_user_func($classname . '::progressbar_metaartefact_count', $name);
if (is_object($meta)) {
array_push($results, $meta);
}
}
}
// Also check the special artefacts
if (is_array($specials = call_static_method($classname, 'progressbar_additional_items'))) {
foreach ($specials as $special) {
if (!array_key_exists($special->name, $onlythese)) {
continue;
}
if (empty($special->is_metaartefact)) {
// check to see if it can have mataartefact count
$special->is_metaartefact = call_static_method('ArtefactType' . ucfirst($special->name), 'is_metaartefact');
}
if (!empty($special->is_metaartefact)) {
// Now check if they have a special metaartefact count
$meta = call_user_func($classname . '::progressbar_metaartefact_count', $special->name);
if (is_object($meta)) {
array_push($results, $meta);
}
}
}
}
return $results;
}
示例7: header_search_form
/**
* Builds the pieform for the search field in the page header
*/
function header_search_form()
{
$plugin = get_config('searchplugin');
safe_require('search', $plugin);
return call_static_method(generate_class_name('search', $plugin), 'header_search_form');
}
示例8: param_integer
$enable = param_integer('enable', 0);
$disable = param_integer('disable', 0);
if ($disable && !call_static_method(generate_class_name($plugintype, $pluginname), 'can_be_disabled')) {
throw new UserException("Plugin {$plugintype} {$pluginname} cannot be disabled");
}
if ($enable || $disable) {
require_once get_config('libroot') . 'upgrade.php';
clear_menu_cache();
activate_plugin_form($plugintype, get_record($plugintype . '_installed', 'name', $pluginname));
}
if ($plugintype == 'artefact') {
$type = param_alpha('type');
$classname = generate_artefact_class_name($type);
} else {
$type = '';
$classname = generate_class_name($plugintype, $pluginname);
}
if (!call_static_method($classname, 'has_config')) {
throw new InvalidArgumentException("{$classname} doesn't have config options available");
}
$form = call_static_method($classname, 'get_config_options');
$form['plugintype'] = $plugintype;
$form['pluginname'] = $pluginname;
$form['name'] = 'pluginconfig';
$form['class'] = 'panel panel-body';
$form['pluginconfigform'] = true;
$form['jsform'] = true;
$form['successcallback'] = 'pluginconfig_submit';
$form['validatecallback'] = 'pluginconfig_validate';
$form['elements']['plugintype'] = array('type' => 'hidden', 'value' => $plugintype);
$form['elements']['pluginname'] = array('type' => 'hidden', 'value' => $pluginname);
示例9: class_from_format
public static function class_from_format($format)
{
$format = trim($format);
if ($format == 'files') {
$format = 'file';
}
safe_require('import', $format);
return generate_class_name('import', $format);
}
示例10: get_portfolio_items_by_tag
function get_portfolio_items_by_tag($tag, $owner, $limit, $offset, $sort = 'name', $type = null, $returntags = true)
{
// For now, can only be used to search a user's portfolio
if (empty($owner->id) || empty($owner->type)) {
throw new SystemException('get_views_and_artefacts_by_tag: invalid owner');
}
if ($owner->type != 'user') {
throw new SystemException('get_views_and_artefacts_by_tag only implemented for users');
}
$types = get_portfolio_types_from_param($type);
$plugin = 'internal';
safe_require('search', $plugin);
$result = call_static_method(generate_class_name('search', $plugin), 'portfolio_search_by_tag', $tag, $owner, $limit, $offset, $sort, $types, $returntags);
$result->filter = $result->type = $type ? $type : 'all';
return $result;
}
示例11: db_begin
$count = 0;
db_begin();
try {
foreach ($_GET as $k => $v) {
if (preg_match('/^delete\\-(\\d+)$/', $k, $m)) {
delete_records('notification_internal_activity', 'id', $m[1], 'usr', $USER->get('id'));
$count++;
}
}
} catch (Exception $e) {
db_rollback();
json_reply('local', get_string('failedtodeletenotifications', 'activity') . ': ' . $e->getMessage());
}
db_commit();
safe_require('notification', 'internal');
json_reply(false, array('message' => get_string('deletednotifications', 'activity', $count), 'count' => $count, 'newunreadcount' => call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'))));
}
}
// normal processing
$type = param_alphanum('type', 'all');
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$userid = $USER->get('id');
if ($type == 'all') {
$count = count_records('notification_internal_activity', 'usr', $userid);
$sql = 'SELECT a.*, at.name AS type,at.plugintype, at.pluginname FROM {notification_internal_activity} a
JOIN {activity_type} at ON a.type = at.id
WHERE a.usr = ? ORDER BY ctime DESC';
$records = get_records_sql_array($sql, array($userid), $offset, $limit);
} else {
if ($type == 'adminmessages' && $USER->get('admin')) {
示例12: plugin_institution_prefs_submit
/**
* Submit plugin institution form values.
*
* @param Pieform $form
* @param array $values
* @param Institution $institution
* @return bool is page need to be refreshed
*/
function plugin_institution_prefs_submit(Pieform $form, $values, Institution $institution)
{
$elements = array();
$installed = plugin_all_installed();
foreach ($installed as $i) {
if (!safe_require_plugin($i->plugintype, $i->name)) {
continue;
}
call_static_method(generate_class_name($i->plugintype, $i->name), 'institutionprefs_submit', $form, $values, $institution);
}
}
示例13: build_artefactchooser_data
/**
* Builds data for the artefact chooser.
*
* This builds three pieces of information:
*
* - HTML containing table rows
* - Pagination HTML and Javascript
* - The total number of artefacts found
*/
public static function build_artefactchooser_data($data, $group = null, $institution = null)
{
global $USER;
$search = '';
if (!empty($data['search']) && param_boolean('s')) {
$search = param_variable('search', '');
// Maybe later, depending on performance - don't search if there's
// not enough characters. Prompts should be added to the UI too.
//if (strlen($search) < 3) {
// $search = '';
//}
}
$data['search'] = $search;
$data['offset'] -= $data['offset'] % $data['limit'];
safe_require('blocktype', $data['blocktype']);
$blocktypeclass = generate_class_name('blocktype', $data['blocktype']);
$data['sortorder'] = array(array('fieldname' => 'title', 'order' => 'ASC'));
if (method_exists($blocktypeclass, 'artefactchooser_get_sort_order')) {
$data['sortorder'] = call_static_method($blocktypeclass, 'artefactchooser_get_sort_order');
}
list($artefacts, $totalartefacts) = self::get_artefactchooser_artefacts($data, $USER, $group, $institution);
$selectone = $data['selectone'];
$value = $data['defaultvalue'];
$elementname = $data['name'];
$template = $data['template'];
$result = '';
if ($artefacts) {
foreach ($artefacts as &$artefact) {
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $artefact->artefacttype));
if (method_exists($blocktypeclass, 'artefactchooser_get_element_data')) {
$artefact = call_static_method($blocktypeclass, 'artefactchooser_get_element_data', $artefact);
}
// Build the radio button or checkbox for the artefact
$formcontrols = '';
if ($selectone) {
$formcontrols .= '<input type="radio" class="radio" id="' . hsc($elementname . '_' . $artefact->id) . '" name="' . hsc($elementname) . '" value="' . hsc($artefact->id) . '"';
if ($value == $artefact->id) {
$formcontrols .= ' checked="checked"';
}
$formcontrols .= '>';
} else {
$formcontrols .= '<input type="checkbox" id="' . hsc($elementname . '_' . $artefact->id) . '" name="' . hsc($elementname) . '[' . hsc($artefact->id) . ']"';
if ($value && in_array($artefact->id, $value)) {
$formcontrols .= ' checked="checked"';
}
$formcontrols .= ' class="artefactid-checkbox checkbox">';
$formcontrols .= '<input type="hidden" name="' . hsc($elementname) . '_onpage[]" value="' . hsc($artefact->id) . '" class="artefactid-onpage">';
}
$smarty = smarty_core();
$smarty->assign('artefact', $artefact);
$smarty->assign('elementname', $elementname);
$smarty->assign('formcontrols', $formcontrols);
$result .= $smarty->fetch($template) . "\n";
}
}
$pagination = build_pagination(array('id' => $elementname . '_pagination', 'class' => 'ac-pagination', 'url' => View::make_base_url() . (param_boolean('s') ? '&s=1' : ''), 'count' => $totalartefacts, 'limit' => $data['limit'], 'offset' => $data['offset'], 'datatable' => $elementname . '_data', 'jsonscript' => 'view/artefactchooser.json.php', 'firsttext' => '', 'previoustext' => '', 'nexttext' => '', 'lasttext' => '', 'numbersincludefirstlast' => false, 'extradata' => array('value' => $value, 'blocktype' => $data['blocktype'], 'group' => $group, 'institution' => $institution)));
return array($result, $pagination, $totalartefacts, $data['offset']);
}
示例14: set_field_select
if ($ids) {
set_field_select('notification_internal_activity', 'read', 1, 'id IN (' . join(',', $ids) . ') AND usr = ?', array($USER->get('id')));
}
$message = get_string('markedasread', 'activity');
} else {
if ($delete) {
$ids = array();
foreach ($_GET as $k => $v) {
if (preg_match('/^delete\\-(\\d+)$/', $k, $m)) {
$ids[] = $m[1];
}
}
if ($ids) {
$strids = join(',', $ids);
$userid = $USER->get('id');
db_begin();
// Remove parent pointers to messages we're about to delete
// Use temp table in subselect for Mysql compat.
execute_sql("\n UPDATE {notification_internal_activity}\n SET parent = NULL\n WHERE parent IN (\n SELECT id\n FROM (\n SELECT id FROM {notification_internal_activity} WHERE id IN ({$strids}) AND usr = ?\n ) AS temp\n )", array($userid));
delete_records_select('notification_internal_activity', "id IN ({$strids}) AND usr = ?", array($userid));
db_commit();
}
$message = get_string('deletednotifications', 'activity', count($ids));
}
}
$newhtml = activitylist_html($type, $limit, $offset);
if ($message) {
safe_require('notification', 'internal');
$newhtml['newunreadcount'] = call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'));
}
json_reply(false, (object) array('message' => $message, 'data' => $newhtml));
示例15: rewrite_blockinstance_relationships
/**
* This method is called late in the import process, after views, collections, and artefacts have been set up, to give collections the opportunity
* to rewrite any references they have to old view, collection, or artefact IDs.
*
* Blocktypes that use this API should define an "import_rewrite_blockinstance_relationships_leap" method.
*/
private function rewrite_blockinstance_relationships()
{
foreach ($this->viewids as $entryid => $viewid) {
$records = get_records_array('block_instance', 'view', $viewid, 'view, id');
if ($records) {
foreach ($records as $blockrec) {
// Let blocktype plugin rewrite relationships now that all views and collections are set up
safe_require('blocktype', $blockrec->blocktype);
$classname = generate_class_name('blocktype', $blockrec->blocktype);
$method = 'import_rewrite_blockinstance_relationships_leap';
$blockinstance['config'] = call_static_method($classname, $method, $blockrec->id, $this);
}
}
}
}