本文整理汇总了PHP中BlockInstance::set方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockInstance::set方法的具体用法?PHP BlockInstance::set怎么用?PHP BlockInstance::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockInstance
的用法示例。
在下文中一共展示了BlockInstance::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
$configdata = $instance->get('configdata');
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'file');
return array('artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('Files', 'blocktype.file/filedownload'), 'class' => 'last with-formgroup', 'elements' => array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null))));
}
示例2: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
$configdata = $instance->get('configdata');
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'file');
return array('artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('file', 'artefact.file'), 'class' => 'last select-file mtl', 'elements' => array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null))));
}
示例3: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
$configdata = $instance->get('configdata');
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'file');
return array('artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null));
}
示例4: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
$instance->set('artefactplugin', 'plans');
$configdata = $instance->get('configdata');
$form = array();
// Which resume field does the user want
$form[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null);
return $form;
}
示例5: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
$instance->set('artefactplugin', 'plans');
$configdata = $instance->get('configdata');
$form = array();
// Which resume field does the user want
$form[] = self::artefactchooser_element(isset($configdata['artefactid']) ? $configdata['artefactid'] : null);
$form['count'] = array('type' => 'text', 'title' => get_string('taskstodisplay', 'blocktype.plans/plans'), 'defaultvalue' => isset($configdata['count']) ? $configdata['count'] : 10, 'size' => 3);
return $form;
}
示例6: copy
/**
* Builds a new block instance as a copy of this one, taking into account
* the Views being copied from and to.
*
* Blocktypes can decide whether they want to be copied to the new View. The
* return value of this method should indicate whether the blocktype was
* copied or not.
*
* @param View $view The view that this new blockinstance is being created for
* @param View $template The view that this (the old) blockinstance comes from
* @param array $artefactcopies Correspondence between original artefact IDs and IDs of copies
* @return boolean Whether a new blockinstance was made or not.
*/
public function copy(View $view, View $template, &$artefactcopies)
{
$blocktypeclass = generate_class_name('blocktype', $this->get('blocktype'));
$configdata = $this->get('configdata');
if (isset($configdata['copytype'])) {
$copytype = $configdata['copytype'];
} else {
$copytype = call_static_method($blocktypeclass, 'default_copy_type');
}
$viewowner = $view->ownership();
$templateowner = $template->ownership();
$sameowner = $viewowner['type'] == $templateowner['type'] && $viewowner['id'] == $templateowner['id'];
// Check to see if the block is allowed to be copied into the new View
//
// Note for later: this is Blockinstance->allowed_in_view. This
// determines whether this blockinstance should be copied into a view.
// This could be a different question from BlockType::allowed_in_view!
// But for now they use the same method.
if (!call_static_method($blocktypeclass, 'allowed_in_view', $view)) {
return false;
}
if ($copytype == 'nocopy' && !$sameowner) {
return false;
}
$newblock = new BlockInstance(0, array('blocktype' => $this->get('blocktype'), 'title' => $this->get('title'), 'view' => $view->get('id'), 'view_obj' => $view, 'row' => $this->get('row'), 'column' => $this->get('column'), 'order' => $this->get('order')));
if ($sameowner || $copytype == 'reference') {
$newblock->set('configdata', $configdata);
$newblock->commit();
return true;
}
$artefactids = get_column('view_artefact', 'artefact', 'block', $this->get('id'));
if (!empty($artefactids) && $copytype == 'full') {
// Copy artefacts & put the new artefact ids into the new block.
// Artefacts may have children (defined using the parent column of the artefact table) and attachments (currently
// only for blogposts). If we copy an artefact we must copy all its descendents & attachments too.
$descendants = artefact_get_descendants($artefactids);
// We need the artefact instance before we can get its attachments
$tocopy = array();
$attachmentlists = array();
$embedlists = array();
foreach ($descendants as $d) {
if (!isset($artefactcopies[$d])) {
$tocopy[$d] = artefact_instance_from_id($d);
// Get attachments.
$attachmentlists[$d] = $tocopy[$d]->attachment_id_list();
foreach ($attachmentlists[$d] as $a) {
if (!isset($artefactcopies[$a]) && !isset($tocopy[$a])) {
$tocopy[$a] = artefact_instance_from_id($a);
}
}
// Get embedded file artefacts
$embedlists[$d] = $tocopy[$d]->embed_id_list();
foreach ($embedlists[$d] as $a) {
if (!isset($artefactcopies[$a]) && !isset($tocopy[$a])) {
$tocopy[$a] = artefact_instance_from_id($a);
}
}
}
}
// Copy all the artefacts we haven't copied yet
foreach ($tocopy as $aid => $a) {
// Save the id of the original artefact's parent
$artefactcopies[$aid] = (object) array('oldid' => $aid, 'oldparent' => $a->get('parent'));
if (!empty($attachmentlists[$aid])) {
$artefactcopies[$aid]->oldattachments = $attachmentlists[$aid];
}
if (!empty($embedlists[$aid])) {
$artefactcopies[$aid]->oldembeds = $embedlists[$aid];
}
$artefactcopies[$aid]->newid = $a->copy_for_new_owner($view->get('owner'), $view->get('group'), $view->get('institution'));
}
// Record new artefact ids in the new block
if (isset($configdata['artefactid'])) {
$configdata['artefactid'] = $artefactcopies[$configdata['artefactid']]->newid;
}
if (isset($configdata['artefactids'])) {
foreach ($configdata['artefactids'] as &$oldid) {
$oldid = $artefactcopies[$oldid]->newid;
}
}
} else {
$configdata = call_static_method($blocktypeclass, 'rewrite_blockinstance_config', $view, $configdata);
}
// Rewrite the extra configuration of block
$configdata = call_static_method($blocktypeclass, 'rewrite_blockinstance_extra_config', $view, $newblock, $configdata, $artefactcopies);
$newblock->set('configdata', $configdata);
$newblock->commit();
//.........这里部分代码省略.........
示例7: xmldb_blocktype_externalfeed_upgrade
function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
if ($oldversion < 2008042101) {
// We hit the 255 character limit for feed URLs
if (is_postgres()) {
execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
} else {
if (is_mysql()) {
// If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
// We have to remove then add the constraint again else the change will make MySQL cry
execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
}
}
}
if ($oldversion < 2009121600) {
if (is_mysql()) {
// Make content column wider (TEXT is only 65kb in mysql)
$table = new XMLDBTable('blocktype_externalfeed_data');
$field = new XMLDBField('content');
$field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
change_field_precision($table, $field);
}
}
if ($oldversion < 2010073000) {
execute_sql('
UPDATE {blocktype_cron}
SET minute = ?
WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
}
if ($oldversion < 2011091400) {
// Add columns for HTTP basic auth
$table = new XMLDBTable('blocktype_externalfeed_data');
$field1 = new XMLDBField('authuser');
$field1->setAttributes(XMLDB_TYPE_TEXT);
$field2 = new XMLDBField('authpassword');
$field2->setAttributes(XMLDB_TYPE_TEXT);
add_field($table, $field1);
add_field($table, $field2);
// Change unique constraint that's no longer valid
$table = new XMLDBTable('blocktype_externalfeed_data');
$index = new XMLDBIndex('url_uix');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('url'));
drop_index($table, $index);
if (is_postgres()) {
$index = new XMLDBIndex('urlautautix');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
add_index($table, $index);
} else {
if (is_mysql()) {
// MySQL needs size limits when indexing text fields
execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
{blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
}
}
}
if ($oldversion < 2011091401) {
// Add columns for insecure SSL mode
$table = new XMLDBTable('blocktype_externalfeed_data');
$field = new XMLDBField('insecuresslmode');
$field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
add_field($table, $field);
}
if ($oldversion < 2012090700) {
// Reset all feeds to reset themselves
set_field('blocktype_externalfeed_data', 'lastupdate', db_format_timestamp('0'));
safe_require('blocktype', 'externalfeed');
call_static_method('PluginBlocktypeExternalfeed', 'refresh_feeds');
}
if ($oldversion < 2014041500) {
log_debug('Cleaning up duplicate feeds in the externalfeed blocktype');
log_debug('1. Find the duplicate feed urls');
// Setting these to be empty strings instead of NULL will make our SQL a lot simpler in the next section
execute_sql("update {blocktype_externalfeed_data} set authuser='' where authuser is null");
execute_sql("update {blocktype_externalfeed_data} set authpassword='' where authpassword is null");
if ($duplicatefeeds = get_records_sql_array("SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_externalfeed_data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY url, authuser, authpassword", array())) {
log_debug('2. Get all feed ids for the duplicated feed urls');
// Use the 1st one found to be the feed id for the block instances that need updating
$feedstoupdate = array();
foreach ($duplicatefeeds as $feed) {
$feedids = get_column('blocktype_externalfeed_data', 'id', 'url', $feed->url, 'authuser', $feed->authuser, 'authpassword', $feed->authpassword);
$feedstoupdate[$feed->url] = $feedids;
}
log_debug('3. Updating blocks to use correct feed id');
// Find the block instances using external feeds. Check to see if they are not using the 'true' id and update them accordingly
require_once get_config('docroot') . 'blocktype/lib.php';
$blockids = get_records_array('block_instance', 'blocktype', 'externalfeed', 'id ASC', 'id');
foreach ($blockids as $blockid) {
$blockinstance = new BlockInstance($blockid->id);
$configdata = $blockinstance->get('configdata');
if (!empty($configdata['feedid'])) {
foreach ($feedstoupdate as $url => $ids) {
foreach ($ids as $key => $id) {
if ($id == $configdata['feedid'] && $key != '0') {
$configdata['feedid'] = $ids[0];
$blockinstance->set('configdata', $configdata);
$blockinstance->set('dirty', true);
$blockinstance->commit();
break;
//.........这里部分代码省略.........
示例8: render_instance
public static function render_instance(BlockInstance $instance, $editing = false)
{
global $THEME;
$configdata = $instance->get('configdata');
$width = !empty($configdata['width']) ? hsc($configdata['width']) : 0;
$height = !empty($configdata['height']) ? hsc($configdata['height']) : 0;
if (!isset($configdata['html'])) {
if (!isset($configdata['videoid'])) {
return '';
}
// This is a legacy block where videoid contains only a url, so generate embed/iframe code.
$url = $configdata['videoid'];
if (isset($configdata['type']) && $configdata['type'] == 'embed') {
$configdata['html'] = $configdata['videoid'] = self::embed_code($url, $width, $height);
unset($configdata['type']);
} else {
if (isset($configdata['type']) && $configdata['type'] == 'iframe') {
$configdata['html'] = $configdata['videoid'] = self::iframe_code($url, $width, $height);
unset($configdata['type']);
} else {
if ($urldata = self::process_url($url, $width, $height)) {
$configdata = $urldata;
} else {
$configdata['html'] = '';
// We can't do anything with this url
}
}
}
$instance->set('configdata', $configdata);
$instance->commit();
}
if (empty($configdata['html'])) {
return '';
}
$smarty = smarty_core();
// don't load html for auto retracted blocks to speed up page load time
if (!empty($configdata['retractedonload']) && !$editing) {
$smarty->assign('html', '<div id="block_' . $instance->get('id') . '_waiting">' . get_string('loading', 'mahara') . '</div>');
$is_src = preg_match('/src=\\"(.*?)\\"/', $configdata['html'], $src);
$is_width = preg_match('/ width=\\"(.*?)\\"/', $configdata['html'], $widthmatch);
$is_height = preg_match('/ height=\\"(.*?)\\"/', $configdata['html'], $heightmatch);
if ($is_src) {
$smarty->assign('jsurl', $src[1]);
// check if is embed rather than iframe
$is_flashvars = preg_match('/flashvars=\\"(.*?)\\"/', $configdata['html'], $flashvars);
if ($is_flashvars) {
$smarty->assign('jsflashvars', $flashvars[1]);
}
if (empty($width) && !empty($widthmatch)) {
$width = $widthmatch[1];
}
if (empty($height) && !empty($heightmatch)) {
$height = $heightmatch[1];
}
} else {
// need to fall back to handling this normally
$smarty->assign('html', $configdata['html']);
}
} else {
$smarty->assign('html', $configdata['html']);
}
$smarty->assign('width', $width);
$smarty->assign('height', $height);
$smarty->assign('blockid', $instance->get('id'));
return $smarty->fetch('blocktype:externalvideo:content.tpl');
}
示例9: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
global $USER;
require_once 'license.php';
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'internal');
$configdata = $instance->get('configdata');
if (!($height = get_config('blockeditorheight'))) {
$cfheight = param_integer('cfheight', 0);
$height = $cfheight ? $cfheight * 0.7 : 150;
}
$otherblockcount = 0;
$readonly = false;
$text = '';
$tags = '';
$view = $instance->get_view();
if (!empty($configdata['artefactid'])) {
$artefactid = $configdata['artefactid'];
try {
$artefact = $instance->get_artefact_instance($artefactid);
$readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
$text = $artefact->get('description');
$tags = $artefact->get('tags');
if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) {
$blocks = array_unique($blocks);
$otherblockcount = count($blocks) - 1;
}
} catch (ArtefactNotFoundException $e) {
unset($artefactid);
}
}
$otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>';
$otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg);
$manageurl = get_config('wwwroot') . 'artefact/internal/notes.php';
if ($group = $view->get('group')) {
$manageurl .= '?group=' . $group;
} else {
if ($institution = $view->get('institution')) {
$manageurl .= '?institution=' . $institution;
}
}
// Update the attached files in block configdata as
// it may change when attached files have been deleted
$attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false;
if ($attachmentids !== false && isset($configdata['artefactids']) && $configdata['artefactids'] != $attachmentids) {
$configdata['artefactids'] = $attachmentids;
$instance->set('configdata', $configdata);
$instance->commit();
}
$elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . $otherblocksmsg . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => '<p class="alert alert-info">' . get_string('readonlymessage', 'blocktype.internal/textbox') . ' <a class="copytextboxnote nojs-hidden-inline" href="">' . get_string('makeacopy', 'blocktype.internal/textbox') . '</a></p>', 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('blockcontent', 'blocktype.internal/textbox'), 'value' => '<div id="instconf_textreadonly_display" class="well text-midtone">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'value' => '<a id="chooseartefactlink" href="#" class="btn btn-default">' . get_string('usecontentfromanothertextbox1', 'blocktype.internal/textbox') . '</a>'), 'managenotes' => array('type' => 'html', 'class' => 'hidden text-right', 'value' => '<a href="' . $manageurl . '" target="_blank" class="pull-right">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' <span class="icon icon-arrow-right right"></span></a>'), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'license' => license_form_el_basic(isset($artefact) ? $artefact : null), 'license_advanced' => license_form_el_advanced(isset($artefact) ? $artefact : null), 'licensereadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('license'), 'value' => '<div id="instconf_licensereadonly_display">' . (isset($artefact) ? render_license($artefact) : get_string('licensenone')) . '</div>'), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'tags' => array('type' => 'tags', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $tags), 'tagsreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('tags'), 'value' => '<div id="instconf_tagsreadonly_display">' . (is_array($tags) ? hsc(join(', ', $tags)) : '') . '</div>'), 'artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('attachments', 'artefact.blog'), 'class' => 'last with-formgroup', 'elements' => array('artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null))));
if ($readonly) {
$elements['license']['class'] = 'hidden';
$elements['license_advanced']['class'] = 'hidden';
}
return $elements;
}
示例10: editnote_submit
function editnote_submit(Pieform $form, array $values)
{
global $SESSION, $artefact, $goto;
require_once 'embeddedimage.php';
db_begin();
$artefact->set('title', $values['title']);
$newdescription = EmbeddedImage::prepare_embedded_images($values['description'], 'textbox', $artefact->get('id'), $artefact->get('group'));
$artefact->set('description', $newdescription);
$artefact->set('tags', $values['tags']);
$artefact->set('allowcomments', (int) $values['allowcomments']);
if (isset($values['perms'])) {
$artefact->set('rolepermissions', $values['perms']);
$artefact->set('dirty', true);
}
if (get_config('licensemetadata')) {
$artefact->set('license', $values['license']);
$artefact->set('licensor', $values['licensor']);
$artefact->set('licensorurl', $values['licensorurl']);
}
$artefact->commit();
// Attachments
$old = $artefact->attachment_id_list();
$new = is_array($values['filebrowser']) ? $values['filebrowser'] : array();
if (!empty($new) || !empty($old)) {
foreach ($old as $o) {
if (!in_array($o, $new)) {
try {
$artefact->detach($o);
} catch (ArtefactNotFoundException $e) {
}
}
}
foreach ($new as $n) {
if (!in_array($n, $old)) {
try {
$artefact->attach($n);
} catch (ArtefactNotFoundException $e) {
}
}
}
}
// need to update the block_instances where this artefact is used - so they have
// the correct configuration artefactids
if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefact->get('id'))) {
require_once get_config('docroot') . 'blocktype/lib.php';
foreach ($blocks as $block) {
$bi = new BlockInstance($block);
$configdata = $bi->get('configdata');
$configdata['artefactids'] = $new;
$bi->set('configdata', $configdata);
$bi->commit();
}
}
db_commit();
$result = array('error' => false, 'message' => get_string('noteupdated', 'artefact.internal'), 'goto' => $goto);
if ($form->submitted_by_js()) {
// Redirect back to the note page from within the iframe
$SESSION->add_ok_msg($result['message']);
$form->json_reply(PIEFORM_OK, $result, false);
}
$form->reply(PIEFORM_OK, $result);
}
示例11: import_rewrite_blockinstance_relationships_leap
/**
* After a leap2a import, rewrite the block instance's collection ID to the collection's new ID.
* (If the collection was part of this import. If it's not, just remove it.)
*
* @param int $blockinstanceid
* @param PluginLeapImport $importer
*/
public static function import_rewrite_blockinstance_relationships_leap($blockinstanceid, $importer)
{
$bi = new BlockInstance($blockinstanceid);
$configdata = $bi->get('configdata');
// Rewrite the collection ID from the old one to the new one.
if (isset($configdata['collection'])) {
$oldcollectionid = $configdata['collection'];
// Backwards-compatibility for Leap2a files before we started rewriting the collection ID
if (strpos($oldcollectionid, 'portfolio:collection') !== 0) {
$oldcollectionid = 'portfolio:collection' . (int) $oldcollectionid;
}
if (isset($importer->collectionids[$oldcollectionid])) {
// If the collection was present in this import, point to its new ID
$configdata['collection'] = $importer->collectionids[$oldcollectionid];
} else {
// If the collection was not present, then deactivate this block
// TODO: Make some guesses about what it should point at?
unset($configdata['collection']);
}
}
$bi->set('configdata', $configdata);
$bi->commit();
}
示例12: install_profile_view
/**
* Installs a user's profile view.
*
* @return View
*/
private function install_profile_view()
{
static $systemprofileviewid = null;
db_begin();
if (is_null($systemprofileviewid)) {
$systemprofileviewid = get_field('view', 'id', 'owner', 0, 'type', 'profile');
}
require_once get_config('libroot') . 'view.php';
list($view) = View::create_from_template(array('owner' => $this->get('id'), 'title' => get_field('view', 'title', 'id', $systemprofileviewid), 'type' => 'profile'), $systemprofileviewid, $this->get('id'));
// Add about me block
$aboutme = new BlockInstance(0, array('blocktype' => 'profileinfo', 'title' => get_string('aboutme', 'blocktype.internal/profileinfo'), 'view' => $view->get('id'), 'column' => 1, 'order' => 1));
$configdata = array('artefactids' => array());
if ($intro = get_field('artefact', 'id', 'owner', $this->get('id'), 'artefacttype', 'introduction')) {
$configdata['artefactids'][] = $intro;
} else {
$configdata['introtext'] = get_string('thisistheprofilepagefor', 'mahara', display_name($this, null, true));
}
if ($this->get('profileicon')) {
$configdata['profileicon'] = $this->get('profileicon');
}
$aboutme->set('configdata', $configdata);
$view->addblockinstance($aboutme);
$view->set_access(array(array('type' => 'loggedin', 'startdate' => null, 'stopdate' => null)));
db_commit();
return $view;
}
示例13: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
global $USER;
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'internal');
$configdata = $instance->get('configdata');
if (!($height = get_config('blockeditorheight'))) {
$cfheight = param_integer('cfheight', 0);
$height = $cfheight ? $cfheight * 0.7 : 150;
}
$otherblockcount = 0;
$readonly = false;
$text = '';
$information = '';
$literature = $configdata['literature'];
$view = $instance->get_view();
if (!empty($configdata['artefactid'])) {
$artefactid = $configdata['artefactid'];
try {
$artefact = $instance->get_artefact_instance($artefactid);
$readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
$text = $artefact->get('note');
$information = $artefact->get('description');
if ($blocks = get_column('view_artefact', 'block', 'artefact', $artefactid)) {
$blocks = array_unique($blocks);
$otherblockcount = count($blocks) - 1;
}
} catch (ArtefactNotFoundException $e) {
unset($artefactid);
}
}
$otherblocksmsg = '<span id="textbox_blockcount">' . $otherblockcount . '</span>';
$otherblocksmsg = get_string('textusedinotherblocks', 'blocktype.internal/textbox', $otherblocksmsg);
$manageurl = get_config('wwwroot') . 'artefact/internal/notes.php';
if ($group = $view->get('group')) {
$manageurl .= '?group=' . $group;
} else {
if ($institution = $view->get('institution')) {
$manageurl .= '?institution=' . $institution;
}
}
// Update the attached files in block configdata as
// it may change when attached files have been deleted
$attachmentids = isset($artefact) ? $artefact->attachment_id_list() : false;
if ($attachmentids !== false && $configdata['artefactids'] != $attachmentids) {
$configdata['artefactids'] = $attachmentids;
$instance->set('configdata', $configdata);
$instance->commit();
}
$elements = array('otherblocksmsg' => array('type' => 'html', 'class' => 'message info' . ($otherblockcount && !$readonly ? '' : ' hidden'), 'value' => $otherblocksmsg, 'help' => true), 'readonlymsg' => array('type' => 'html', 'class' => 'message info' . ($readonly ? '' : ' hidden'), 'value' => get_string('readonlymessage', 'blocktype.internal/textbox'), 'help' => true), 'text' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('note', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'textreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'title' => get_string('note', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'value' => '<div id="instconf_textreadonly_display">' . $text . '</div>'), 'makecopy' => array('type' => 'checkbox', 'class' => 'hidden', 'defaultvalue' => false), 'chooseartefact' => array('type' => 'html', 'class' => 'nojs-hidden-block', 'value' => '<a id="chooseartefactlink" href=""></a>'), 'managenotes' => array('type' => 'html', 'class' => 'right hidden', 'value' => '<a href="' . $manageurl . '" target="_blank">' . get_string('managealltextboxcontent1', 'blocktype.internal/textbox') . ' »</a>'), 'selecttask' => array('type' => 'select', 'title' => get_string('selecttask', 'view'), 'description' => get_string('selecttaskdescription', 'view'), 'options' => PluginBlocktypeEselmagraduation::get_task(), 'defaultvalue' => $retractable + $retractedonload), 'artefactid' => self::artefactchooser_element(isset($artefactid) ? $artefactid : null), 'literature' => array('type' => 'text', 'title' => get_string('literature'), 'defaultvalue' => $literature), 'information' => array('type' => 'wysiwyg', 'class' => $readonly ? 'hidden' : '', 'title' => get_string('information', 'blocktype.internal/eselmagraduation'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $information, 'rules' => array('maxlength' => 65536)), 'allowcomments' => array('type' => 'switchbox', 'title' => get_string('allowcomments', 'artefact.comment'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'artefactids' => self::filebrowser_element($instance, isset($configdata['artefactids']) ? $configdata['artefactids'] : null));
return $elements;
}
示例14: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
global $USER;
$instance->set('artefactplugin', 'annotation');
// Get the saved configs in the artefact
$configdata = $instance->get('configdata');
if (!($height = get_config('blockeditorheight'))) {
$cfheight = param_integer('cfheight', 0);
$height = $cfheight ? $cfheight * 0.7 : 150;
}
// Default annotation text.
$text = '';
$tags = '';
$artefactid = '';
$readonly = false;
$textreadonly = false;
$view = $instance->get_view();
if (!empty($configdata['artefactid'])) {
$artefactid = $configdata['artefactid'];
try {
$artefact = $instance->get_artefact_instance($artefactid);
// Get the annotation record -> to get the artefact it's linked to.
$annotation = new ArtefactTypeAnnotation($artefactid);
// Get the total annotation feedback inserted so far by anyone.
$totalannotationfeedback = ArtefactTypeAnnotationfeedback::count_annotation_feedback($artefactid, array($view->get('id')), array($annotation->get('artefact')));
$readonly = $artefact->get('owner') !== $view->get('owner') || $artefact->get('group') !== $view->get('group') || $artefact->get('institution') !== $view->get('institution') || $artefact->get('locked') || !$USER->can_edit_artefact($artefact);
if (isset($totalannotationfeedback[$view->get('id')])) {
$textreadonly = $totalannotationfeedback[$view->get('id')]->total > 0;
}
$text = $artefact->get('description');
$tags = $artefact->get('tags');
} catch (ArtefactNotFoundException $e) {
unset($artefactid);
}
}
$elements = array('text' => array('type' => $textreadonly ? 'html' : 'wysiwyg', 'class' => '', 'title' => get_string('Annotation', 'artefact.annotation'), 'width' => '100%', 'height' => $height . 'px', 'defaultvalue' => $text, 'rules' => array('maxlength' => 65536)), 'annotationreadonlymsg' => array('type' => 'html', 'class' => 'message info' . ($textreadonly ? '' : ' hidden'), 'value' => get_string('annotationreadonlymessage', 'blocktype.annotation/annotation'), 'help' => true), 'allowfeedback' => array('type' => 'switchbox', 'title' => get_string('allowannotationfeedback', 'artefact.annotation'), 'defaultvalue' => !empty($artefact) ? $artefact->get('allowcomments') : 1), 'tags' => array('type' => 'tags', 'class' => $readonly ? 'hidden' : '', 'width' => '100%', 'title' => get_string('tags'), 'description' => get_string('tagsdescprofile'), 'defaultvalue' => $tags), 'tagsreadonly' => array('type' => 'html', 'class' => $readonly ? '' : 'hidden', 'width' => '100%', 'title' => get_string('tags'), 'value' => '<div id="instconf_tagsreadonly_display">' . (is_array($tags) ? hsc(join(', ', $tags)) : '') . '</div>'));
if ($textreadonly) {
// The annotation is displayed as html, need to populate its value.
$elements['text']['value'] = $text;
}
return $elements;
}
示例15: instance_config_form
public static function instance_config_form(BlockInstance $instance)
{
$configdata = $instance->get('configdata');
safe_require('artefact', 'file');
$instance->set('artefactplugin', 'file');
$elements = array('artefactfieldset' => array('type' => 'fieldset', 'collapsible' => true, 'collapsed' => true, 'legend' => get_string('Folders', 'artefact.file'), 'class' => 'last select-file mtl', 'elements' => array('artefactid' => self::filebrowser_element($instance, isset($configdata['artefactid']) ? array($configdata['artefactid']) : null))), 'sortorder' => array('type' => 'select', 'title' => get_string('sortorder'), 'defaultvalue' => isset($configdata['sortorder']) ? $configdata['sortorder'] : get_config_plugin('blocktype', 'folder', 'sortorder'), 'options' => array('asc' => get_string('ascending'), 'desc' => get_string('descending'))));
if (get_config_plugin('blocktype', 'folder', 'folderdownloadzip')) {
$elements['folderdownloadzip'] = array('type' => 'checkbox', 'labelhtml' => get_string('downloadfolderzipblock', 'artefact.file'), 'description' => get_string('downloadfolderzipdescriptionblock', 'artefact.file'), 'defaultvalue' => get_config_plugin('blocktype', 'folder', 'folderdownloadzip') ? isset($configdata['folderdownloadzip']) ? $configdata['folderdownloadzip'] : 0 : 0);
}
return $elements;
}