Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/blocks/settings/block_settings.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00037 class block_settings extends block_base {
00038 
00040     public static $navcount;
00041     public $blockname = null;
00043     protected $contentgenerated = false;
00045     protected $docked = null;
00046 
00050     function init() {
00051         $this->blockname = get_class($this);
00052         $this->title = get_string('pluginname', $this->blockname);
00053     }
00054 
00059     function instance_allow_multiple() {
00060         return false;
00061     }
00062 
00069     function  instance_can_be_hidden() {
00070         return false;
00071     }
00072 
00077     function applicable_formats() {
00078         return array('all' => true);
00079     }
00080 
00085     function instance_allow_config() {
00086         return true;
00087     }
00088 
00089     function instance_can_be_docked() {
00090         return (parent::instance_can_be_docked() && (empty($this->config->enabledock) || $this->config->enabledock=='yes'));
00091     }
00092 
00093     function get_required_javascript() {
00094         global $CFG;
00095         $arguments = array('id' => $this->instance->id, 'instance' => $this->instance->id, 'candock' => $this->instance_can_be_docked());
00096         $this->page->requires->yui_module(array('core_dock', 'moodle-block_navigation-navigation'), 'M.block_navigation.init_add_tree', array($arguments));
00097         user_preference_allow_ajax_update('docked_block_instance_'.$this->instance->id, PARAM_INT);
00098     }
00099 
00103     function get_content() {
00104         global $CFG, $OUTPUT;
00105         // First check if we have already generated, don't waste cycles
00106         if ($this->contentgenerated === true) {
00107             return true;
00108         }
00109         // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
00110         // $this->page->requires->js('/lib/javascript-navigation.js');
00111         block_settings::$navcount++;
00112 
00113         // Check if this block has been docked
00114         if ($this->docked === null) {
00115             $this->docked = get_user_preferences('nav_in_tab_panel_settingsnav'.block_settings::$navcount, 0);
00116         }
00117 
00118         // Check if there is a param to change the docked state
00119         if ($this->docked && optional_param('undock', null, PARAM_INT)==$this->instance->id) {
00120             unset_user_preference('nav_in_tab_panel_settingsnav'.block_settings::$navcount, 0);
00121             $url = $this->page->url;
00122             $url->remove_params(array('undock'));
00123             redirect($url);
00124         } else if (!$this->docked && optional_param('dock', null, PARAM_INT)==$this->instance->id) {
00125             set_user_preferences(array('nav_in_tab_panel_settingsnav'.block_settings::$navcount=>1));
00126             $url = $this->page->url;
00127             $url->remove_params(array('dock'));
00128             redirect($url);
00129         }
00130 
00131         $renderer = $this->page->get_renderer('block_settings');
00132         $this->content = new stdClass();
00133         $this->content->text = $renderer->settings_tree($this->page->settingsnav);
00134 
00135         // only do search if you have moodle/site:config
00136         if (!empty($this->content->text)) {
00137             if (has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) ) {
00138                 $this->content->footer = $renderer->search_form(new moodle_url("$CFG->wwwroot/$CFG->admin/search.php"), optional_param('query', '', PARAM_RAW));
00139             } else {
00140                 $this->content->footer = '';
00141             }
00142 
00143             if (!empty($this->config->enabledock) && $this->config->enabledock == 'yes') {
00144                 user_preference_allow_ajax_update('nav_in_tab_panel_settingsnav'.block_settings::$navcount, PARAM_INT);
00145             }
00146         }
00147 
00148         $this->contentgenerated = true;
00149         return true;
00150     }
00151 }
 All Data Structures Namespaces Files Functions Variables Enumerations