當前位置: 首頁>>代碼示例>>PHP>>正文


PHP block_base類代碼示例

本文整理匯總了PHP中block_base的典型用法代碼示例。如果您正苦於以下問題:PHP block_base類的具體用法?PHP block_base怎麽用?PHP block_base使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了block_base類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: user_can_delete_block

 /**
  * @param block_base $block a block that appears on this page.
  * @return boolean boolean whether the currently logged in user is allowed to delete this block.
  */
 protected function user_can_delete_block($block)
 {
     return $this->page->user_can_edit_blocks() && $block->user_can_edit() && $block->user_can_addto($this->page) && !in_array($block->instance->blockname, self::get_undeletable_block_types());
 }
開發者ID:Burick,項目名稱:moodle,代碼行數:8,代碼來源:blocklib.php

示例2:

 function instance_config_save($data, $nolongerused = false)
 {
     if (empty($data->quizid)) {
         $data->quizid = $this->get_owning_quiz();
     }
     parent::instance_config_save($data);
 }
開發者ID:saurabh947,項目名稱:MoodleLearning,代碼行數:7,代碼來源:block_quiz_results.php

示例3:

 function get_required_javascript()
 {
     parent::get_required_javascript();
     $this->page->requires->jquery();
     $this->page->requires->jquery_plugin('ui');
     $this->page->requires->jquery_plugin('ui-css');
 }
開發者ID:jb-1980,項目名稱:ungraded_assignments,代碼行數:7,代碼來源:block_ungraded_assignments.php

示例4: array

 function after_install()
 {
     global $CFG;
     // initialize the global configuration
     $global_config = array("block_moodle_notifications_email_channel" => 1, "block_moodle_notifications_sms_channel" => 1, "block_moodle_notifications_rss_channel" => 1, "block_moodle_notifications_frequency" => 12, "block_moodle_notifications_email_notification_preset" => 1, "block_moodle_notifications_sms_notification_preset" => 1);
     return parent::config_save($global_config);
 }
開發者ID:nadavkav,項目名稱:Moodle2-Hebrew-plugins,代碼行數:7,代碼來源:block_moodle_notifications.php

示例5:

 function instance_config_save($data)
 {
     if (empty($data->quizid)) {
         $data->quizid = $this->get_owning_quiz();
     }
     parent::instance_config_save($data);
 }
開發者ID:raymondAntonio,項目名稱:moodle,代碼行數:7,代碼來源:block_quiz_results.php

示例6: definition

 function definition()
 {
     $mform =& $this->_form;
     // First show fields specific to this type of block.
     $this->specific_definition($mform);
     // Then show the fields about where this block appears.
     $mform->addElement('header', 'whereheader', get_string('wherethisblockappears', 'block'));
     // If the current weight of the block is out-of-range, add that option in.
     $blockweight = $this->block->instance->weight;
     $weightoptions = array();
     if ($blockweight < -block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     for ($i = -block_manager::MAX_WEIGHT; $i <= block_manager::MAX_WEIGHT; $i++) {
         $weightoptions[$i] = $i;
     }
     if ($blockweight > block_manager::MAX_WEIGHT) {
         $weightoptions[$blockweight] = $blockweight;
     }
     $first = reset($weightoptions);
     $weightoptions[$first] = get_string('bracketfirst', 'block', $first);
     $last = end($weightoptions);
     $weightoptions[$last] = get_string('bracketlast', 'block', $last);
     $regionoptions = $this->page->theme->get_all_block_regions();
     $parentcontext = get_context_instance_by_id($this->block->instance->parentcontextid);
     $mform->addElement('static', 'contextname', get_string('thisblockbelongsto', 'block'), print_context_name($parentcontext));
     $mform->addElement('selectyesno', 'bui_showinsubcontexts', get_string('appearsinsubcontexts', 'block'));
     $pagetypeoptions = matching_page_type_patterns($this->page->pagetype);
     $pagetypeoptions = array_combine($pagetypeoptions, $pagetypeoptions);
     $mform->addElement('select', 'bui_pagetypepattern', get_string('pagetypes', 'block'), $pagetypeoptions);
     if ($this->page->subpage) {
         $subpageoptions = array('%@NULL@%' => get_string('anypagematchingtheabove', 'block'), $this->page->subpage => get_string('thisspecificpage', 'block', $this->page->subpage));
         $mform->addElement('select', 'bui_subpagepattern', get_string('subpages', 'block'), $subpageoptions);
     }
     $defaultregionoptions = $regionoptions;
     $defaultregion = $this->block->instance->defaultregion;
     if (!array_key_exists($defaultregion, $defaultregionoptions)) {
         $defaultregionoptions[$defaultregion] = $defaultregion;
     }
     $mform->addElement('select', 'bui_defaultregion', get_string('defaultregion', 'block'), $defaultregionoptions);
     $mform->addElement('select', 'bui_defaultweight', get_string('defaultweight', 'block'), $weightoptions);
     // Where this block is positioned on this page.
     $mform->addElement('header', 'whereheader', get_string('onthispage', 'block'));
     $mform->addElement('selectyesno', 'bui_visible', get_string('visible', 'block'));
     $blockregion = $this->block->instance->region;
     if (!array_key_exists($blockregion, $regionoptions)) {
         $regionoptions[$blockregion] = $blockregion;
     }
     $mform->addElement('select', 'bui_region', get_string('region', 'block'), $regionoptions);
     $mform->addElement('select', 'bui_weight', get_string('weight', 'block'), $weightoptions);
     $pagefields = array('bui_visible', 'bui_region', 'bui_weight');
     if (!$this->block->user_can_edit()) {
         $mform->hardFreezeAllVisibleExcept($pagefields);
     }
     if (!$this->page->user_can_edit_blocks()) {
         $mform->hardFreeze($pagefields);
     }
     $this->add_action_buttons();
 }
開發者ID:ajv,項目名稱:Offline-Caching,代碼行數:59,代碼來源:edit_form.php

示例7: get_required_javascript

 public function get_required_javascript()
 {
     global $PAGE;
     $PAGE->requires->yui_module('moodle-block_databasebookmarks-bookmark', 'M.block_databasebookmarks.bookmark.init');
     $PAGE->requires->strings_for_js(array('deletebookmark', 'bookmark', 'bookmarkname', 'bookmarkheader'), 'block_databasebookmarks');
     $PAGE->requires->strings_for_js(array('buttons'), 'mod_data');
     return parent::get_required_javascript();
 }
開發者ID:andrewhancox,項目名稱:block_databasebookmarks,代碼行數:8,代碼來源:block_databasebookmarks.php

示例8: html_attributes

 /**
  * Returns the attributes to set for this block
  *
  * This function returns an array of HTML attributes for this block including
  * the defaults.
  * {@link block_tree::html_attributes()} is used to get the default arguments
  * and then we check whether the user has enabled hover expansion and add the
  * appropriate hover class if it has.
  *
  * @return array An array of HTML attributes
  */
 public function html_attributes()
 {
     $attributes = parent::html_attributes();
     if (!empty($this->config->enablehoverexpansion) && $this->config->enablehoverexpansion == 'yes') {
         $attributes['class'] .= ' block_js_expansion';
     }
     $attributes['class'] .= ' block_uai';
     return $attributes;
 }
開發者ID:jorgecabane93,項目名稱:block_uai,代碼行數:20,代碼來源:block_uai.php

示例9: array

 /**
  * Serialize and store config data
  */
 function instance_config_save($data, $nolongerused = false)
 {
     global $DB;
     $config = clone $data;
     // Move embedded files into a proper filearea and adjust HTML links to match
     $config->text = file_save_draft_area_files($data->text['itemid'], $this->context->id, 'block_html', 'content', 0, array('subdirs' => true), $data->text['text']);
     $config->format = $data->text['format'];
     parent::instance_config_save($config, $nolongerused);
 }
開發者ID:sebastiansanio,項目名稱:tallerdeprogramacion2fiuba,代碼行數:12,代碼來源:block_html.php

示例10:

 function instance_config_save($data)
 {
     $savedata = null;
     if (isset($data->general['moduleUrl'])) {
         $savedata->moduleUrl = $data->general['moduleUrl'];
     }
     $savedata->configuration = $data->configuration;
     $savedata->preferences = $data->preferences;
     return parent::instance_config_save($savedata);
 }
開發者ID:nagyistoce,項目名稱:moodle-Teach-Pilot,代碼行數:10,代碼來源:block_uwa_widget.php

示例11:

 function _print_block()
 {
     global $USER;
     // make sure they are looged in or they cant see it
     if (isloggedin() && isset($USER) && $USER->username != 'guest') {
         return parent::_print_block();
     } else {
         return "";
     }
 }
開發者ID:nadavkav,項目名稱:MoodleTAO,代碼行數:10,代碼來源:block_site_forum.php

示例12:

 /**
  * Will be called before an instance of this block is backed up, so that any links in
  * any links in any HTML fields on config can be encoded.
  * @return string
  */
 function get_backup_encoded_config()
 {
     /// Prevent clone for non configured block instance. Delegate to parent as fallback.
     if (empty($this->config)) {
         return parent::get_backup_encoded_config();
     }
     $data = clone $this->config;
     $data->text = backup_encode_absolute_links($data->text);
     return base64_encode(serialize($data));
 }
開發者ID:r007,項目名稱:PMoodle,代碼行數:15,代碼來源:block_incrementalclient.php

示例13: get_required_javascript

 /**
  * The block depends upon a React app (which should only be loaded once).
  * Unfortunately, it is necessary to use the Moodle page requirements manager.
  * It is also necessary to hide RequireJS from the React app.
  */
 public function get_required_javascript()
 {
     parent::get_required_javascript();
     // if debugging, load unminified script
     $script_src = 'build/activity_tree.min.js';
     if (debugging()) {
         $script_src = str_replace('.min.js', '.js', $script_src);
     }
     /** @var page_requirements_manager $prm */
     $prm = $this->page->requires;
     $prm->js('/blocks/activity_tree/static/js/other/requirejs_hide.js');
     $prm->js(new moodle_url('/blocks/activity_tree/static/js/' . $script_src));
     $prm->js('/blocks/activity_tree/static/js/other/requirejs_show.js');
 }
開發者ID:robologo3000,項目名稱:block-activity-tree,代碼行數:19,代碼來源:block_activity_tree.php

示例14:

 function instance_config($instance)
 {
     parent::instance_config($instance);
     $course = get_record('course', 'id', $this->instance->pageid);
     if (isset($course->format)) {
         if ($course->format == 'topics') {
             $this->title = get_string('topics', 'block_section_links');
         } else {
             if ($course->format == 'weeks') {
                 $this->title = get_string('weeks', 'block_section_links');
             } else {
                 $this->title = get_string('blockname', 'block_section_links');
             }
         }
     }
 }
開發者ID:kai707,項目名稱:ITSA-backup,代碼行數:16,代碼來源:block_section_links.php

示例15:

 function instance_config($instance)
 {
     global $DB;
     parent::instance_config($instance);
     $course = $this->page->course;
     if (isset($course->format)) {
         if ($course->format == 'topics') {
             $this->title = get_string('topics', 'block_section_links');
         } else {
             if ($course->format == 'weeks') {
                 $this->title = get_string('weeks', 'block_section_links');
             } else {
                 $this->title = get_string('pluginname', 'block_section_links');
             }
         }
     }
 }
開發者ID:numbas,項目名稱:moodle,代碼行數:17,代碼來源:block_section_links.php


注:本文中的block_base類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。