本文整理汇总了PHP中generate_artefact_class_name函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_artefact_class_name函数的具体用法?PHP generate_artefact_class_name怎么用?PHP generate_artefact_class_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_artefact_class_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
require_once get_config('docroot') . 'artefact/lib.php';
$configdata = $instance->get('configdata');
$viewid = $instance->get('view');
$wwwroot = get_config('wwwroot');
$files = array();
if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
foreach ($configdata['artefactids'] as $artefactid) {
try {
$artefact = $instance->get_artefact_instance($artefactid);
} catch (ArtefactNotFoundException $e) {
continue;
}
$file = array('id' => $artefactid, 'title' => $artefact->get('title'), 'description' => $artefact->get('description'), 'size' => $artefact->get('size'), 'ctime' => $artefact->get('ctime'), 'artefacttype' => $artefact->get('artefacttype'), 'iconsrc' => call_static_method(generate_artefact_class_name($artefact->get('artefacttype')), 'get_icon', array('id' => $artefactid, 'viewid' => $viewid)), 'downloadurl' => $wwwroot);
if ($artefact instanceof ArtefactTypeProfileIcon) {
$file['downloadurl'] .= 'thumb.php?type=profileiconbyid&id=' . $artefactid;
} else {
if ($artefact instanceof ArtefactTypeFile) {
$file['downloadurl'] .= 'artefact/file/download.php?file=' . $artefactid . '&view=' . $viewid;
}
}
$file['is_image'] = $artefact instanceof ArtefactTypeImage ? true : false;
$files[] = $file;
}
}
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('files', $files);
return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
}
示例2: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
}
$smarty = smarty_core();
// Get viewable views
$views = array();
if ($allviews = get_records_select_array('view', "\"owner\" = ? AND type NOT IN ('profile', 'dashboard')", array($userid))) {
foreach ($allviews as $view) {
if (can_view_view($view->id)) {
$views[$view->id] = $view;
$view->artefacts = array();
}
}
}
if ($views) {
$viewidlist = implode(', ', array_map(create_function('$a', 'return (int)$a->id;'), $views));
$artefacts = get_records_sql_array('SELECT va.view, va.artefact, a.title, a.artefacttype, t.plugin
FROM {view_artefact} va
INNER JOIN {artefact} a ON va.artefact = a.id
INNER JOIN {artefact_installed_type} t ON a.artefacttype = t.name
WHERE va.view IN (' . $viewidlist . ')
GROUP BY 1, 2, 3, 4, 5
ORDER BY a.title, va.artefact', '');
if ($artefacts) {
foreach ($artefacts as $artefactrec) {
safe_require('artefact', $artefactrec->plugin);
// Perhaps I shouldn't have to construct the entire
// artefact object to render the name properly.
$classname = generate_artefact_class_name($artefactrec->artefacttype);
$artefactobj = new $classname(0, array('title' => $artefactrec->title));
$artefactobj->set('dirty', false);
if (!$artefactobj->in_view_list()) {
continue;
}
$artname = $artefactobj->display_title(30);
if (strlen($artname)) {
$views[$artefactrec->view]->artefacts[] = array('id' => $artefactrec->artefact, 'title' => $artname);
}
}
}
$tags = get_records_select_array('view_tag', 'view IN (' . $viewidlist . ')');
if ($tags) {
foreach ($tags as &$tag) {
$views[$tag->view]->tags[] = $tag->tag;
}
}
}
$smarty->assign('VIEWS', $views);
return $smarty->fetch('blocktype:myviews:myviews.tpl');
}
示例3: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
require_once get_config('docroot') . 'artefact/lib.php';
$configdata = $instance->get('configdata');
$result = '';
if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
foreach ($configdata['artefactids'] as $artefactid) {
try {
$artefact = $instance->get_artefact_instance($artefactid);
} catch (ArtefactNotFoundException $e) {
continue;
}
$icondata = array('id' => $artefactid, 'viewid' => $instance->get('view'));
$detailsurl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $artefactid . '&view=' . $instance->get('view');
if ($artefact instanceof ArtefactTypeProfileIcon) {
require_once 'file.php';
$downloadurl = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $artefactid;
$size = filesize(get_dataroot_image_path('artefact/file/profileicons/', $artefactid));
} else {
if ($artefact instanceof ArtefactTypeFile) {
$downloadurl = get_config('wwwroot') . 'artefact/file/download.php?file=' . $artefactid . '&view=' . $icondata['viewid'];
$size = $artefact->get('size');
}
}
$result .= '<div title="' . hsc($artefact->get('title')) . '">';
$result .= '<div class="fl"><a href="' . hsc($downloadurl) . '">';
$result .= '<img src="' . hsc(call_static_method(generate_artefact_class_name($artefact->get('artefacttype')), 'get_icon', $icondata)) . '" alt=""></a></div>';
$result .= '<div style="margin-left: 30px;">';
$result .= '<h4><a href="' . hsc($detailsurl) . '">' . str_shorten_text($artefact->get('title'), 20) . '</a></h4>';
$description = $artefact->get('description');
if ($description) {
$result .= '<p style="margin: 0;"><strong>' . hsc($description) . '</strong></p>';
}
$result .= '' . display_size($size) . ' | ' . strftime(get_string('strftimedaydate'), $artefact->get('ctime'));
$result .= '</div>';
$result .= '</div>';
}
}
return $result;
}
示例4: set_profile_field
function set_profile_field($userid, $field, $value)
{
safe_require('artefact', 'internal');
// this is a special case that replaces the primary email address with the
// specified one
if ($field == 'email') {
try {
$email = artefact_instance_from_type('email', $userid);
} catch (ArtefactNotFoundException $e) {
$email = new ArtefactTypeEmail();
$email->set('owner', $userid);
}
$email->set('title', $value);
$email->commit();
} else {
$classname = generate_artefact_class_name($field);
$profile = new $classname(0, array('owner' => $userid));
$profile->set('title', $value);
$profile->commit();
}
}
示例5: copy_for_new_owner
public function copy_for_new_owner($user, $group, $institution)
{
$data = $this->copy_data();
$data->owner = $user;
$data->group = $group;
$data->institution = $institution;
$data->parent = null;
$classname = generate_artefact_class_name($data->artefacttype);
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $data->artefacttype));
$copy = new $classname(0, (object) $data);
$this->copy_extra($copy);
$copy->commit();
return $copy->get('id');
}
示例6: artefactchooser_get_element_data
/**
* Optional method. If specified, allows the blocktype class to munge the
* artefactchooser element data before it's templated
*/
public static function artefactchooser_get_element_data($artefact)
{
$folderdata = ArtefactTypeFileBase::artefactchooser_folder_data($artefact);
$artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
$artefact->hovertitle = $artefact->description;
$path = $artefact->parent ? ArtefactTypeFileBase::get_full_path($artefact->parent, $folderdata->data) : '';
$artefact->description = str_shorten_text($folderdata->ownername . $path . $artefact->title, 30);
return $artefact;
}
示例7: get_goals_and_skills
public function get_goals_and_skills($type = '')
{
global $USER;
switch ($type) {
case 'goals':
$artefacts = array('personalgoal', 'academicgoal', 'careergoal');
break;
case 'skills':
$artefacts = array('personalskill', 'academicskill', 'workskill');
break;
default:
$artefacts = array('personalgoal', 'academicgoal', 'careergoal', 'personalskill', 'academicskill', 'workskill');
}
$data = array();
foreach ($artefacts as $artefact) {
$record = get_record('artefact', 'artefacttype', $artefact, 'owner', $USER->get('id'));
if ($record) {
$record->exists = 1;
// Add attachments
$files = ArtefactType::attachments_from_id_list(array($record->id));
if ($files) {
safe_require('artefact', 'file');
foreach ($files as &$file) {
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', array('id' => $file->attachment));
$record->files[] = $file;
}
$record->count = count($files);
} else {
$record->count = 0;
}
} else {
$record = new stdClass();
$record->artefacttype = $artefact;
$record->exists = 0;
$record->count = 0;
}
$data[] = $record;
}
return $data;
}
示例8: artefactchooser_get_element_data
public static function artefactchooser_get_element_data($artefact)
{
$artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
return $artefact;
}
示例9: get_forms
static function get_forms(array $compositetypes)
{
require_once get_config('libroot') . 'pieforms/pieform.php';
$compositeforms = array();
foreach ($compositetypes as $compositetype) {
$elements = call_static_method(generate_artefact_class_name($compositetype), 'get_addform_elements');
$elements['submit'] = array('type' => 'submit', 'value' => get_string('save'));
$elements['compositetype'] = array('type' => 'hidden', 'value' => $compositetype);
$cform = array('name' => 'add' . $compositetype, 'plugintype' => 'artefact', 'pluginname' => 'resume', 'elements' => $elements, 'jsform' => true, 'successcallback' => 'compositeform_submit', 'jssuccesscallback' => 'compositeSaveCallback');
$compositeforms[$compositetype] = pieform($cform);
}
return $compositeforms;
}
示例10: get_posts
/**
* This function returns a list of posts in a given blog.
*
* @param integer
* @param integer
* @param integer
* @param array
*/
public static function get_posts($id, $limit, $offset, $viewoptions = null)
{
$results = array('limit' => $limit, 'offset' => $offset);
// If viewoptions is null, we're getting posts for the my blogs area,
// and we should get all posts & show drafts first. Otherwise it's a
// blog in a view, and we should only get published posts.
$from = "\n FROM {artefact} a LEFT JOIN {artefact_blog_blogpost} bp ON a.id = bp.blogpost\n WHERE a.artefacttype = 'blogpost' AND a.parent = ?";
if (!is_null($viewoptions)) {
if (isset($viewoptions['before'])) {
$from .= " AND a.ctime < '{$viewoptions['before']}'";
}
$from .= ' AND bp.published = 1';
}
$results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
$data = get_records_sql_assoc('
SELECT
a.id, a.title, a.description, a.author, a.authorname, ' . db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
a.locked, bp.published, a.allowcomments ' . $from . '
ORDER BY bp.published ASC, a.ctime DESC, a.id DESC', array($id), $offset, $limit);
if (!$data) {
$results['data'] = array();
return $results;
}
// Get the attached files.
$postids = array_map(create_function('$a', 'return $a->id;'), $data);
$files = ArtefactType::attachments_from_id_list($postids);
if ($files) {
safe_require('artefact', 'file');
foreach ($files as &$file) {
$params = array('id' => $file->attachment);
if (!empty($viewoptions['viewid'])) {
$params['viewid'] = $viewoptions['viewid'];
}
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', $params);
$data[$file->artefact]->files[] = $file;
}
}
if ($tags = ArtefactType::tags_from_id_list($postids)) {
foreach ($tags as &$at) {
$data[$at->artefact]->tags[] = $at->tag;
}
}
foreach ($data as &$post) {
// Format dates properly
if (is_null($viewoptions)) {
// My Blogs area: create forms for changing post status & deleting posts.
$post->changepoststatus = ArtefactTypeBlogpost::changepoststatus_form($post->id, $post->published);
$post->delete = ArtefactTypeBlogpost::delete_form($post->id, $post->title);
} else {
$by = $post->author ? display_default_name($post->author) : $post->authorname;
$post->postedby = get_string('postedbyon', 'artefact.blog', $by, format_date($post->ctime));
// Get comment counts
if (!empty($viewoptions['countcomments'])) {
safe_require('artefact', 'comment');
require_once get_config('docroot') . 'lib/view.php';
$view = new View($viewoptions['viewid']);
$artefact = artefact_instance_from_id($post->id);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false);
$post->commentcount = $commentcount;
$post->comments = $comments;
}
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
$post->mtime = format_date($post->mtime);
// Ensure images in the post have the right viewid associated with them
if (!empty($viewoptions['viewid'])) {
safe_require('artefact', 'file');
$post->description = ArtefactTypeFolder::append_view_url($post->description, $viewoptions['viewid']);
}
}
$results['data'] = array_values($data);
return $results;
}
示例11: artefact_instance_from_id
$a = artefact_instance_from_id($artefact);
$type = $a->get('artefacttype');
// Set correct redirect when user clicks Cancel button...
if ($type == 'languagediploma' || $type == 'languageexperience') {
// Find language diploma's or linguistic experience's parent for redirect...
$sql = 'SELECT aeo.id, aeo.artefact
FROM {artefact_europass_otherlanguage} aeo
JOIN {artefact_europass_' . $type . '} ar ON ar.languageid = aeo.id
WHERE ar.id = ? AND ar.artefact = ?';
$parent = get_record_sql($sql, array($id, $artefact));
$goto = 'viewcomposite.php?id=' . $parent->id . '&artefact=' . $parent->artefact;
} else {
$goto = 'languages.php';
}
$tabs = PluginArtefactEuropass::composite_tabs();
define('EUROPASS_SUBPAGE', $tabs[$type]);
if ($a->get('owner') != $USER->get('id')) {
throw new AccessDeniedException(get_string('notartefactowner', 'error'));
}
$elements = call_static_method(generate_artefact_class_name($type), 'get_addform_elements');
$elements['submit'] = array('type' => 'submitcancel', 'value' => array(get_string('save'), get_string('cancel')), 'goto' => get_config('wwwroot') . 'artefact/europass/' . $goto);
$elements['compositetype'] = array('type' => 'hidden', 'value' => $type);
$cform = array('name' => 'add' . $type, 'plugintype' => 'artefact', 'pluginname' => 'europass', 'elements' => $elements, 'successcallback' => 'langcompositeformedit_submit');
$a->populate_form($cform, $id, $type);
$compositeform = pieform($cform);
$smarty = smarty();
$smarty->assign('compositeform', $compositeform);
$smarty->assign('composite', $type);
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('SUBPAGENAV', PluginArtefactEuropass::submenu_items());
$smarty->display('artefact:europass:editcomposite.tpl');
示例12: foreach
}
}
foreach ($data as $id => $n) {
$n->deleteform = pieform(deletenote_form($id, $n));
}
}
// Get the attached files.
$noteids = array();
if ($data) {
$noteids = array_keys($data);
}
$files = ArtefactType::attachments_from_id_list($noteids);
if ($files) {
safe_require('artefact', 'file');
foreach ($files as $file) {
$file->icon = call_static_method(generate_artefact_class_name($file->artefacttype), 'get_icon', array('id' => $file->attachment));
$data[$file->artefact]->files[] = $file;
}
}
// Add Attachments count for each Note
if ($data) {
foreach ($data as $item) {
$item->count = isset($item->files) ? count($item->files) : 0;
}
}
$pagination = build_pagination(array('id' => 'notes_pagination', 'url' => $baseurl, 'datatable' => 'notes', 'count' => $count, 'limit' => $limit, 'offset' => $offset));
$js = '
jQuery(function($) {
$("a.notetitle").click(function(e) {
e.preventDefault();
$("#" + this.id + "_desc").toggleClass("hidden");
示例13: self_search_make_links
protected static function self_search_make_links($data)
{
$wwwroot = get_config('wwwroot');
if ($data['count']) {
foreach ($data['data'] as &$result) {
switch ($result['type']) {
case 'artefact':
safe_require('artefact', get_field('artefact_installed_type', 'plugin', 'name', $result['artefacttype']));
$result['links'] = call_static_method(generate_artefact_class_name($result['artefacttype']), 'get_links', $result['id']);
break;
case 'view':
$result['links'] = array('_default' => $wwwroot . 'view/view.php?id=' . $result['id'], get_string('editviewinformation') => $wwwroot . 'view/editmetadata.php?viewid=' . $result['id'], get_string('editview') => $wwwroot . 'view/edit.php?viewid=' . $result['id'], get_string('editaccess') => $wwwroot . 'view/editaccess.php?viewid=' . $result['id']);
break;
default:
break;
}
}
}
}
示例14: get_forms
static function get_forms(array $compositetypes, $languageid = 0)
{
require_once get_config('libroot') . 'pieforms/pieform.php';
$compositeforms = array();
foreach ($compositetypes as $compositetype) {
$elements = call_static_method(generate_artefact_class_name($compositetype), 'get_addform_elements');
$elements['submit'] = array('type' => 'submit', 'value' => get_string('save'));
$elements['compositetype'] = array('type' => 'hidden', 'value' => $compositetype);
// Set language for language diploma(s) or linguistic experience(s)...
if ($languageid > 0) {
$elements['languageid'] = array('type' => 'hidden', 'value' => $languageid);
}
$cform = array('name' => 'add' . $compositetype, 'plugintype' => 'artefact', 'pluginname' => 'europass', 'elements' => $elements, 'jsform' => true, 'successcallback' => 'langcompositeform_submit', 'jssuccesscallback' => 'compositeSaveCallback');
$compositeforms[$compositetype] = pieform($cform);
}
return $compositeforms;
}
示例15: add_import_entry_request
/**
* Add an import request of an interactive import entry as an Mahara view+collection or artefact.
* For view import
* If the entry is for Profile or Dashboard page, the decision is APPEND(default), IGNORE or REPLACE
* If there is a duplicated view (same title and description), the decision is APPEND(default), IGNORE, REPLACE, or ADDNEW
* If else, the decision is IGNORE, or ADDNEW(default)
* For artefact import
* If there are duplicated artefacts, the decision is IGNORE
* If ELSE If there is $entrytype NOT is_singular, e.g. an user may have up to 5 email addresses
* the decision is ADDNEW(default) or IGNORE
* If there is $entrytype is_singular,
* the decision is REPLACE(default) or APPEND
* Also update the list of
* - duplicated artefacts which have same artefacttype and content
* - existing artefacts which have same artefacttype but the content may be different to the entry data
*
* @param string $importid ID of the import
* @param string $entryid ID of the entry
* @param string $strategy Strategy of entry import
* @param string $plugin
* @param array $entrydata Data the entry including the following fields:
* owner ID of the user who imports the entry (required)
* type (required)
* parent ID of the parent entry (e.g. the blog entryid of the blogpost entry).
* content (required)
* - title (required)
* @return updated DB table 'import_entry_requests'
*/
public static function add_import_entry_request($importid, $entryid, $strategy, $plugin, $entrydata)
{
$duplicatedartefactids = array();
$existingartefactids = array();
$title = $entrydata['content']['title'];
if ($plugin === 'core') {
// For view import
$decision = PluginImport::DECISION_ADDNEW;
} else {
safe_require('artefact', $plugin);
$classname = generate_artefact_class_name($entrydata['type']);
if ($duplicatedartefactids = call_static_method($classname, 'get_duplicated_artefacts', $entrydata)) {
$decision = PluginImport::DECISION_IGNORE;
} else {
if (isset($entrydata['defaultdecision'])) {
$decision = $entrydata['defaultdecision'];
} else {
$existingartefactids = call_static_method($classname, 'get_existing_artefacts', $entrydata);
if (call_static_method($classname, 'is_singular') && !empty($existingartefactids)) {
if ($entrydata['type'] == 'email') {
$decision = PluginImport::DECISION_ADDNEW;
} else {
$decision = PluginImport::DECISION_REPLACE;
}
} else {
$decision = PluginImport::DECISION_ADDNEW;
}
}
}
}
// Update DB table
if (!record_exists_select('import_entry_requests', 'importid = ? AND entryid = ? AND ownerid = ? AND entrytype = ? AND entrytitle = ?', array($importid, $entryid, $entrydata['owner'], $entrydata['type'], $title))) {
return insert_record('import_entry_requests', (object) array('importid' => $importid, 'entryid' => $entryid, 'strategy' => $strategy, 'plugin' => $plugin, 'ownerid' => $entrydata['owner'], 'entrytype' => $entrydata['type'], 'entryparent' => isset($entrydata['parent']) ? $entrydata['parent'] : null, 'entrytitle' => $title, 'entrycontent' => serialize($entrydata['content']), 'duplicateditemids' => serialize($duplicatedartefactids), 'existingitemids' => serialize($existingartefactids), 'decision' => $decision));
}
return false;
}