本文整理汇总了PHP中moodle_page::user_is_editing方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_page::user_is_editing方法的具体用法?PHP moodle_page::user_is_editing怎么用?PHP moodle_page::user_is_editing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodle_page
的用法示例。
在下文中一共展示了moodle_page::user_is_editing方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_url_actions
/**
* Process any block actions that were specified in the URL.
*
* @return boolean true if anything was done. False if not.
*/
public function process_url_actions()
{
if (!$this->page->user_is_editing()) {
return false;
}
return $this->process_url_add() || $this->process_url_delete() || $this->process_url_show_hide() || $this->process_url_edit() || $this->process_url_move();
}
示例2: get_content_for_output
/**
* Return a block_contents object representing the full contents of this block.
*
* This internally calls ->get_content(), and then adds the editing controls etc.
*
* You probably should not override this method, but instead override
* {@link html_attributes()}, {@link formatted_contents()} or {@link get_content()},
* {@link hide_header()}, {@link (get_edit_controls)}, etc.
*
* @return block_contents a representation of the block, for rendering.
* @since Moodle 2.0.
*/
public function get_content_for_output($output)
{
global $CFG;
$bc = new block_contents($this->html_attributes());
$bc->attributes['data-block'] = $this->name();
$bc->blockinstanceid = $this->instance->id;
$bc->blockpositionid = $this->instance->blockpositionid;
if ($this->instance->visible) {
$bc->content = $this->formatted_contents($output);
if (!empty($this->content->footer)) {
$bc->footer = $this->content->footer;
}
} else {
$bc->add_class('invisible');
}
if (!$this->hide_header()) {
$bc->title = $this->title;
}
if (empty($bc->title)) {
$bc->arialabel = new lang_string('pluginname', get_class($this));
$this->arialabel = $bc->arialabel;
}
if ($this->page->user_is_editing()) {
$bc->controls = $this->page->blocks->edit_controls($this);
} else {
// we must not use is_empty on hidden blocks
if ($this->is_empty() && !$bc->controls) {
return null;
}
}
if (empty($CFG->allowuserblockhiding) || empty($bc->content) && empty($bc->footer) || !$this->instance_can_be_collapsed()) {
$bc->collapsible = block_contents::NOT_HIDEABLE;
} else {
if (get_user_preferences('block' . $bc->blockinstanceid . 'hidden', false)) {
$bc->collapsible = block_contents::HIDDEN;
} else {
$bc->collapsible = block_contents::VISIBLE;
}
}
if ($this->instance_can_be_docked() && !$this->hide_header()) {
$bc->dockable = true;
}
$bc->annotation = '';
// TODO MDL-19398 need to work out what to say here.
return $bc;
}
示例3: get_content_for_output
/**
* Return a block_contents oject representing the full contents of this block.
*
* This internally calls ->get_content(), and then adds the editing controls etc.
*
* You probably should not override this method, but instead override
* {@link html_attributes()}, {@link formatted_contents()} or {@link get_content()},
* {@link hide_header()}, {@link (get_edit_controls)}, etc.
*
* @return block_contents a represntation of the block, for rendering.
* @since Moodle 2.0.
*/
public function get_content_for_output($output)
{
global $CFG;
$bc = new block_contents();
$bc->blockinstanceid = $this->instance->id;
$bc->blockpositionid = $this->instance->blockpositionid;
if ($this->instance->visible) {
$bc->content = $this->formatted_contents($output);
if (!empty($this->content->footer)) {
$bc->footer = $this->content->footer;
}
} else {
$bc->add_class('invisible');
}
$attributes = $this->html_attributes();
if (isset($attributes['id'])) {
$bc->id = $attributes['id'];
unset($attributes['id']);
}
if (isset($attributes['class'])) {
$bc->set_classes($attributes['class']);
unset($attributes['class']);
}
$bc->attributes = $attributes;
if (!$this->hide_header()) {
$bc->title = $this->title;
}
if ($this->page->user_is_editing()) {
$bc->controls = $this->page->blocks->edit_controls($this);
}
if ($this->is_empty() && !$bc->controls) {
return null;
}
if (empty($CFG->allowuserblockhiding) || empty($bc->content) && empty($bc->footer)) {
$bc->collapsible = block_contents::NOT_HIDEABLE;
} else {
if (get_user_preferences('block' . $bc->blockinstanceid . 'hidden', false)) {
$bc->collapsible = block_contents::HIDDEN;
} else {
$bc->collapsible = block_contents::VISIBLE;
}
}
$bc->annotation = '';
// TODO MDL-19398 need to work out what to say here.
return $bc;
}
示例4: load_front_page_settings
/**
* This function loads all of the front page settings into the settings navigation.
* This function is called when the user is on the front page, or $COURSE==$SITE
* @return navigation_node
*/
protected function load_front_page_settings($forceopen = false)
{
global $SITE, $CFG;
$course = clone $SITE;
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
// Course context
$frontpage = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
if ($forceopen) {
$frontpage->force_open();
}
$frontpage->id = 'frontpagesettings';
if (has_capability('moodle/course:update', $coursecontext)) {
// Add the turn on/off settings
$url = new moodle_url('/course/view.php', array('id' => $course->id, 'sesskey' => sesskey()));
if ($this->page->user_is_editing()) {
$url->param('edit', 'off');
$editstring = get_string('turneditingoff');
} else {
$url->param('edit', 'on');
$editstring = get_string('turneditingon');
}
$frontpage->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
// Add the course settings link
$url = new moodle_url('/admin/settings.php', array('section' => 'frontpagesettings'));
$frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
}
// add enrol nodes
enrol_add_course_navigation($frontpage, $course);
// Manage filters
if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
$url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
}
// Backup this course
if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
$url = new moodle_url('/backup/backup.php', array('id' => $course->id));
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
}
// Restore to this course
if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
$url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
}
// Manage questions
$questioncaps = array('moodle/question:add', 'moodle/question:editmine', 'moodle/question:editall', 'moodle/question:viewmine', 'moodle/question:viewall', 'moodle/question:movemine', 'moodle/question:moveall');
if (has_any_capability($questioncaps, $this->context)) {
$questionlink = $CFG->wwwroot . '/question/edit.php';
} else {
if (has_capability('moodle/question:managecategory', $this->context)) {
$questionlink = $CFG->wwwroot . '/question/category.php';
}
}
if (isset($questionlink)) {
$url = new moodle_url($questionlink, array('courseid' => $course->id));
$frontpage->add(get_string('questions', 'quiz'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/questions', ''));
}
// Manage files
if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $this->context)) {
//hiden in new installs
$url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id, 'itemid' => 0, 'component' => 'course', 'filearea' => 'legacy'));
$frontpage->add(get_string('sitelegacyfiles'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/files', ''));
}
return $frontpage;
}
示例5: init_requirements_data
/**
* Initialise with the bits of JavaScript that every Moodle page should have.
*
* @param moodle_page $page
* @param core_renderer $renderer
*/
protected function init_requirements_data(moodle_page $page, core_renderer $renderer)
{
global $CFG;
// JavaScript should always work with $CFG->httpswwwroot rather than $CFG->wwwroot.
// Otherwise, in some situations, users will get warnings about insecure content
// on secure pages from their web browser.
$this->M_cfg = array('wwwroot' => $CFG->httpswwwroot, 'sesskey' => sesskey(), 'loadingicon' => $renderer->pix_url('i/loading_small', 'moodle')->out(false), 'themerev' => theme_get_revision(), 'slasharguments' => (int) (!empty($CFG->slasharguments)), 'theme' => $page->theme->name, 'jsrev' => (empty($CFG->cachejs) or empty($CFG->jsrev)) ? -1 : $CFG->jsrev, 'svgicons' => $page->theme->use_svg_icons());
if (debugging('', DEBUG_DEVELOPER)) {
$this->M_cfg['developerdebug'] = true;
}
if (defined('BEHAT_SITE_RUNNING')) {
$this->M_cfg['behatsiterunning'] = true;
}
// Accessibility stuff.
$this->skip_link_to('maincontent', get_string('tocontent', 'access'));
// Add strings used on many pages.
$this->string_for_js('confirmation', 'admin');
$this->string_for_js('cancel', 'moodle');
$this->string_for_js('yes', 'moodle');
// Alter links in top frame to break out of frames.
if ($page->pagelayout === 'frametop') {
$this->js_init_call('M.util.init_frametop');
}
// Include block drag/drop if editing is on
if ($page->user_is_editing()) {
$params = array('courseid' => $page->course->id, 'pagetype' => $page->pagetype, 'pagelayout' => $page->pagelayout, 'subpage' => $page->subpage, 'regions' => $page->blocks->get_regions(), 'contextid' => $page->context->id);
if (!empty($page->cm->id)) {
$params['cmid'] = $page->cm->id;
}
$page->requires->yui_module('moodle-core-blocks', 'M.core_blocks.init_dragdrop', array($params), null, true);
}
}