当前位置: 首页>>代码示例>>PHP>>正文


PHP during_initial_install函数代码示例

本文整理汇总了PHP中during_initial_install函数的典型用法代码示例。如果您正苦于以下问题:PHP during_initial_install函数的具体用法?PHP during_initial_install怎么用?PHP during_initial_install使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了during_initial_install函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_keypair

 function get_keypair()
 {
     global $DB, $CFG;
     // We don't generate keys on install/upgrade because we want the USER
     // record to have an email address, city and country already.
     if (during_initial_install()) {
         return true;
     }
     if ($CFG->mnet_dispatcher_mode == 'off') {
         return true;
     }
     if (!extension_loaded("openssl")) {
         return true;
     }
     if (!empty($this->keypair)) {
         return true;
     }
     $this->keypair = array();
     $keypair = get_config('mnet', 'openssl');
     if (!empty($keypair)) {
         // Explode/Implode is faster than Unserialize/Serialize
         list($this->keypair['certificate'], $this->keypair['keypair_PEM']) = explode('@@@@@@@@', $keypair);
     }
     if ($this->public_key_expires > time()) {
         $this->keypair['privatekey'] = openssl_pkey_get_private($this->keypair['keypair_PEM']);
         $this->keypair['publickey'] = openssl_pkey_get_public($this->keypair['certificate']);
     } else {
         // Key generation/rotation
         // 1. Archive the current key (if there is one).
         $result = get_config('mnet', 'openssl_history');
         if (empty($result)) {
             set_config('openssl_history', serialize(array()), 'mnet');
             $openssl_history = array();
         } else {
             $openssl_history = unserialize($result);
         }
         if (count($this->keypair)) {
             $this->keypair['expires'] = $this->public_key_expires;
             array_unshift($openssl_history, $this->keypair);
         }
         // 2. How many old keys do we want to keep? Use array_slice to get
         // rid of any we don't want
         $openssl_generations = get_config('mnet', 'openssl_generations');
         if (empty($openssl_generations)) {
             set_config('openssl_generations', 3, 'mnet');
             $openssl_generations = 3;
         }
         if (count($openssl_history) > $openssl_generations) {
             $openssl_history = array_slice($openssl_history, 0, $openssl_generations);
         }
         set_config('openssl_history', serialize($openssl_history), 'mnet');
         // 3. Generate fresh keys
         $this->replace_keys();
     }
     return true;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:56,代码来源:environment.php

示例2: xmldb_block_iomad_approve_access_install

function xmldb_block_iomad_approve_access_install()
{
    global $USER, $DB;
    // Only do this when we are not installing for the first time,
    // that is handled elsewhere.
    if (!during_initial_install()) {
        // Add this block to the dashboard.
        // (yes, I know this isn't really what this is for!!)
        $reportblock = $DB->get_record('block_instances', array('blockname' => 'iomad_reports', 'pagetypepattern' => 'local-iomad-dashboard-index'));
        $approveblock = $reportblock;
        $approveblock->blockname = 'iomad_approve_access';
        $approveblock->id = null;
        $DB->insert_record('block_instances', $approveblock);
        $reportblock = $DB->get_record('block_instances', array('blockname' => 'iomad_reports', 'pagetypepattern' => 'local-iomad-dashboard-index'));
        $reportblock->defaultweight = $reportblock->defaultweight + 1;
        $DB->update_record('block_instances', $reportblock);
    }
    return true;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:19,代码来源:install.php

示例3: login_info

 /**
  * Return the standard string that says whether you are logged in (and switched
  * roles/logged in as another user).
  *
  * @return string HTML fragment.
  */
 public function login_info()
 {
     global $USER, $CFG, $DB, $SESSION;
     if (during_initial_install()) {
         return '';
     }
     $loginpage = (string) $this->page->url === get_login_url();
     $course = $this->page->course;
     if (session_is_loggedinas()) {
         $realuser = session_get_realuser();
         $fullname = fullname($realuser, true);
         $realuserinfo = " [<a href=\"{$CFG->wwwroot}/course/loginas.php?id={$course->id}&amp;sesskey=" . sesskey() . "\">{$fullname}</a>] ";
     } else {
         $realuserinfo = '';
     }
     $loginurl = get_login_url();
     if (empty($course->id)) {
         // $course->id is not defined during installation
         return '';
     } else {
         if (isloggedin()) {
             $context = get_context_instance(CONTEXT_COURSE, $course->id);
             $fullname = fullname($USER, true);
             // Since Moodle 2.0 this link always goes to the public profile page (not the course profile page)
             $username = "<a href=\"{$CFG->wwwroot}/user/profile.php?id={$USER->id}\">{$fullname}</a>";
             if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id' => $USER->mnethostid))) {
                 $username .= " from <a href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
             }
             if (isguestuser()) {
                 $loggedinas = $realuserinfo . get_string('loggedinasguest');
                 if (!$loginpage) {
                     $loggedinas .= " (<a href=\"{$loginurl}\">" . get_string('login') . '</a>)';
                 }
             } else {
                 if (is_role_switched($course->id)) {
                     // Has switched roles
                     $rolename = '';
                     if ($role = $DB->get_record('role', array('id' => $USER->access['rsw'][$context->path]))) {
                         $rolename = ': ' . format_string($role->name);
                     }
                     $loggedinas = get_string('loggedinas', 'moodle', $username) . $rolename . " (<a href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}&amp;switchrole=0&amp;sesskey=" . sesskey() . "\">" . get_string('switchrolereturn') . '</a>)';
                 } else {
                     $loggedinas = $realuserinfo . get_string('loggedinas', 'moodle', $username) . ' ' . " (<a href=\"{$CFG->wwwroot}/login/logout.php?sesskey=" . sesskey() . "\">" . get_string('logout') . '</a>)';
                 }
             }
         } else {
             $loggedinas = get_string('loggedinnot', 'moodle');
             if (!$loginpage) {
                 $loggedinas .= " (<a href=\"{$loginurl}\">" . get_string('login') . '</a>)';
             }
         }
     }
     $loggedinas = '<div class="logininfo">' . $loggedinas . '</div>';
     if (isset($SESSION->justloggedin)) {
         unset($SESSION->justloggedin);
         if (!empty($CFG->displayloginfailures)) {
             if (!isguestuser()) {
                 if ($count = count_login_failures($CFG->displayloginfailures, $USER->username, $USER->lastlogin)) {
                     $loggedinas .= '&nbsp;<div class="loginfailures">';
                     if (empty($count->accounts)) {
                         $loggedinas .= get_string('failedloginattempts', '', $count);
                     } else {
                         $loggedinas .= get_string('failedloginattemptsall', '', $count);
                     }
                     if (file_exists("{$CFG->dirroot}/report/log/index.php") and has_capability('report/log:view', get_context_instance(CONTEXT_SYSTEM))) {
                         $loggedinas .= ' (<a href="' . $CFG->wwwroot . '/report/log/index.php' . '?chooselog=1&amp;id=1&amp;modid=site_errors">' . get_string('logs') . '</a>)';
                     }
                     $loggedinas .= '</div>';
                 }
             }
         }
     }
     return $loggedinas;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:80,代码来源:outputrenderers.php

示例4: check_unoconv_version

/**
 * Method used to check the installed unoconv version.
 *
 * @param environment_results $result object to update, if relevant.
 * @return environment_results|null updated results or null if unoconv path is not executable.
 */
function check_unoconv_version(environment_results $result)
{
    global $CFG;
    if (!during_initial_install() && !empty($CFG->pathtounoconv) && file_is_executable(trim($CFG->pathtounoconv))) {
        $currentversion = 0;
        $supportedversion = 0.7;
        $unoconvbin = \escapeshellarg($CFG->pathtounoconv);
        $command = "{$unoconvbin} --version";
        exec($command, $output);
        // If the command execution returned some output, then get the unoconv version.
        if ($output) {
            foreach ($output as $response) {
                if (preg_match('/unoconv (\\d+\\.\\d+)/', $response, $matches)) {
                    $currentversion = (double) $matches[1];
                }
            }
        }
        if ($currentversion < $supportedversion) {
            $result->setInfo('unoconv version not supported');
            $result->setStatus(false);
            return $result;
        }
    }
    return null;
}
开发者ID:dg711,项目名称:moodle,代码行数:31,代码来源:upgradelib.php

示例5: load_available_updates_for_plugin

 /**
  * Returns list of available updates for the given component.
  *
  * This method should be considered as internal API and is supposed to be
  * called by {@link \core\plugininfo\base::available_updates()} only
  * to lazy load the data once they are first requested.
  *
  * @param string $component frankenstyle name of the plugin
  * @return null|array array of \core\update\info objects or null
  */
 public function load_available_updates_for_plugin($component)
 {
     global $CFG;
     $provider = \core\update\checker::instance();
     if (!$provider->enabled() or during_initial_install()) {
         return null;
     }
     if (isset($CFG->updateminmaturity)) {
         $minmaturity = $CFG->updateminmaturity;
     } else {
         // This can happen during the very first upgrade to 2.3.
         $minmaturity = MATURITY_STABLE;
     }
     return $provider->get_update_info($component, array('minmaturity' => $minmaturity));
 }
开发者ID:bewanyk,项目名称:moodle,代码行数:25,代码来源:plugin_manager.php

示例6: login_info

 /**
  * Return the standard string that says whether you are logged in (and switched
  * roles/logged in as another user).
  * @param bool $withlinks if false, then don't include any links in the HTML produced.
  * If not set, the default is the nologinlinks option from the theme config.php file,
  * and if that is not set, then links are included.
  * @return string HTML fragment.
  */
 public function login_info($withlinks = null)
 {
     global $USER, $CFG, $DB, $SESSION;
     if (during_initial_install()) {
         return '';
     }
     if (is_null($withlinks)) {
         $withlinks = empty($this->page->layout_options['nologinlinks']);
     }
     $loginpage = (string) $this->page->url === get_login_url();
     $course = $this->page->course;
     if (\core\session\manager::is_loggedinas()) {
         $realuser = \core\session\manager::get_realuser();
         $fullname = fullname($realuser, true);
         if ($withlinks) {
             $loginastitle = get_string('loginas');
             $realuserinfo = " [<a href=\"{$CFG->wwwroot}/course/loginas.php?id={$course->id}&amp;sesskey=" . sesskey() . "\"";
             $realuserinfo .= "title =\"" . $loginastitle . "\">{$fullname}</a>] ";
         } else {
             $realuserinfo = " [{$fullname}] ";
         }
     } else {
         $realuserinfo = '';
     }
     $loginurl = get_login_url();
     if (empty($course->id)) {
         // $course->id is not defined during installation
         return '';
     } else {
         if (isloggedin()) {
             $context = context_course::instance($course->id);
             $fullname = fullname($USER, true);
             // Since Moodle 2.0 this link always goes to the public profile page (not the course profile page)
             if ($withlinks) {
                 $linktitle = get_string('viewprofile');
                 $username = "<a href=\"{$CFG->wwwroot}/user/profile.php?id={$USER->id}\" title=\"{$linktitle}\">{$fullname}</a>";
             } else {
                 $username = $fullname;
             }
             if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id' => $USER->mnethostid))) {
                 if ($withlinks) {
                     $username .= " from <a href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
                 } else {
                     $username .= " from {$idprovider->name}";
                 }
             }
             if (isguestuser()) {
                 $loggedinas = $realuserinfo . get_string('loggedinasguest');
                 if (!$loginpage && $withlinks) {
                     $loggedinas .= " (<a href=\"{$loginurl}\">" . get_string('login') . '</a>)';
                 }
             } else {
                 if (is_role_switched($course->id)) {
                     // Has switched roles
                     $rolename = '';
                     if ($role = $DB->get_record('role', array('id' => $USER->access['rsw'][$context->path]))) {
                         $rolename = ': ' . role_get_name($role, $context);
                     }
                     $loggedinas = get_string('loggedinas', 'moodle', $username) . $rolename;
                     if ($withlinks) {
                         $url = new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => 0, 'returnurl' => $this->page->url->out_as_local_url(false)));
                         $loggedinas .= '(' . html_writer::tag('a', get_string('switchrolereturn'), array('href' => $url)) . ')';
                     }
                 } else {
                     $loggedinas = $realuserinfo . get_string('loggedinas', 'moodle', $username);
                     if ($withlinks) {
                         echo "<i class='fa fa-user hide979 mywhite'></i> ";
                         //****************$loggedinas .= " (<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
                         $loggedinas .= " <span class=\"line-trans\">|</span><a class=\"logtop\" href=\"{$CFG->wwwroot}/login/logout.php?sesskey=" . sesskey() . "\"> " . get_string('logout') . '</a><span class="line-trans"> |</span>';
                     }
                 }
             }
         } else {
             $loggedinas = get_string('loggedinnot', 'moodle');
             if (!$loginpage && $withlinks) {
                 //****************$loggedinas $loggedinas .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
                 echo "<i class='fa fa-lock hide979 mywhite'></i> ";
                 $loggedinas .= " | <a href=\"{$loginurl}\">" . get_string('login') . '</a> |';
             }
         }
     }
     $loggedinas = '<div class="logininfo">' . $loggedinas . '</div>';
     if (isset($SESSION->justloggedin)) {
         unset($SESSION->justloggedin);
         if (!empty($CFG->displayloginfailures)) {
             if (!isguestuser()) {
                 if ($count = count_login_failures($CFG->displayloginfailures, $USER->username, $USER->lastlogin)) {
                     $loggedinas .= '&nbsp;<div class="loginfailures">';
                     if (empty($count->accounts)) {
                         $loggedinas .= get_string('failedloginattempts', '', $count);
                     } else {
                         $loggedinas .= get_string('failedloginattemptsall', '', $count);
//.........这里部分代码省略.........
开发者ID:digitalquest,项目名称:moodle_themex,代码行数:101,代码来源:core_renderer_back020714.php

示例7: instance

 /**
  * Returns system context instance.
  *
  * @static
  * @param int $instanceid
  * @param int $strictness
  * @param bool $cache
  * @return context_system context instance
  */
 public static function instance($instanceid = 0, $strictness = MUST_EXIST, $cache = true)
 {
     global $DB;
     if ($instanceid != 0) {
         debugging('context_system::instance(): invalid $id parameter detected, should be 0');
     }
     if (defined('SYSCONTEXTID') and $cache) {
         // dangerous: define this in config.php to eliminate 1 query/page
         if (!isset(context::$systemcontext)) {
             $record = new stdClass();
             $record->id = SYSCONTEXTID;
             $record->contextlevel = CONTEXT_SYSTEM;
             $record->instanceid = 0;
             $record->path = '/' . SYSCONTEXTID;
             $record->depth = 1;
             context::$systemcontext = new context_system($record);
         }
         return context::$systemcontext;
     }
     try {
         // we ignore the strictness completely because system context must except except during install
         $record = $DB->get_record('context', array('contextlevel' => CONTEXT_SYSTEM), '*', MUST_EXIST);
     } catch (dml_exception $e) {
         //table or record does not exist
         if (!during_initial_install()) {
             // do not mess with system context after install, it simply must exist
             throw $e;
         }
         $record = null;
     }
     if (!$record) {
         $record = new stdClass();
         $record->contextlevel = CONTEXT_SYSTEM;
         $record->instanceid = 0;
         $record->depth = 1;
         $record->path = null;
         //not known before insert
         try {
             if ($DB->count_records('context')) {
                 // contexts already exist, this is very weird, system must be first!!!
                 return null;
             }
             if (defined('SYSCONTEXTID')) {
                 // this would happen only in unittest on sites that went through weird 1.7 upgrade
                 $record->id = SYSCONTEXTID;
                 $DB->import_record('context', $record);
                 $DB->get_manager()->reset_sequence('context');
             } else {
                 $record->id = $DB->insert_record('context', $record);
             }
         } catch (dml_exception $e) {
             // can not create context - table does not exist yet, sorry
             return null;
         }
     }
     if ($record->instanceid != 0) {
         // this is very weird, somebody must be messing with context table
         debugging('Invalid system context detected');
     }
     if ($record->depth != 1 or $record->path != '/' . $record->id) {
         // fix path if necessary, initial install or path reset
         $record->depth = 1;
         $record->path = '/' . $record->id;
         $DB->update_record('context', $record);
     }
     if (!defined('SYSCONTEXTID')) {
         define('SYSCONTEXTID', $record->id);
     }
     context::$systemcontext = new context_system($record);
     return context::$systemcontext;
 }
开发者ID:rolandovanegas,项目名称:moodle,代码行数:80,代码来源:accesslib.php

示例8: initialise_standard_body_classes

    protected function initialise_standard_body_classes() {
        global $CFG, $USER;

        $pagetype = $this->pagetype;
        if ($pagetype == 'site-index') {
            $this->_legacyclass = 'course';
        } else if (substr($pagetype, 0, 6) == 'admin-') {
            $this->_legacyclass = 'admin';
        }
        $this->add_body_class($this->_legacyclass);

        $pathbits = explode('-', trim($pagetype));
        for ($i=1;$i<count($pathbits);$i++) {
            $this->add_body_class('path-'.join('-',array_slice($pathbits, 0, $i)));
        }

        $this->add_body_classes(get_browser_version_classes());
        $this->add_body_class('dir-' . get_string('thisdirection', 'langconfig'));
        $this->add_body_class('lang-' . current_language());
        $this->add_body_class('yui-skin-sam'); // Make YUI happy, if it is used.
        $this->add_body_class('yui3-skin-sam'); // Make YUI3 happy, if it is used.
        $this->add_body_class($this->url_to_class_name($CFG->wwwroot));

        $this->add_body_class('pagelayout-' . $this->_pagelayout); // extra class describing current page layout

        if (!during_initial_install()) {
            $this->add_body_class('course-' . $this->_course->id);
            $this->add_body_class('context-' . $this->_context->id);
        }

        if (!empty($this->_cm)) {
            $this->add_body_class('cmid-' . $this->_cm->id);
        }

        if (!empty($CFG->allowcategorythemes)) {
            $this->ensure_category_loaded();
            foreach ($this->_categories as $catid => $notused) {
                $this->add_body_class('category-' . $catid);
            }
        } else {
            $catid = 0;
            if (is_array($this->_categories)) {
                $catids = array_keys($this->_categories);
                $catid = reset($catids);
            } else if (!empty($this->_course->category)) {
                $catid = $this->_course->category;
            }
            if ($catid) {
                $this->add_body_class('category-' . $catid);
            }
        }

        if (!isloggedin()) {
            $this->add_body_class('notloggedin');
        }

        if (!empty($USER->editing)) {
            $this->add_body_class('editing');
            if (optional_param('bui_moveid', false, PARAM_INT)) {
               $this->add_body_class('blocks-moving');
        }
        }

        if (!empty($CFG->blocksdrag)) {
            $this->add_body_class('drag');
        }

        if ($this->_devicetypeinuse != 'default') {
            $this->add_body_class($this->_devicetypeinuse . 'theme');
        }
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:71,代码来源:pagelib.php

示例9: get_plugins

 /**
  * Returns a tree of known plugins and information about them
  *
  * @param bool $disablecache force reload, cache can be used otherwise
  * @return array 2D array. The first keys are plugin type names (e.g. qtype);
  *      the second keys are the plugin local name (e.g. multichoice); and
  *      the values are the corresponding objects extending {@link plugininfo_base}
  */
 public function get_plugins($disablecache = false)
 {
     if ($disablecache or is_null($this->pluginsinfo)) {
         $this->pluginsinfo = array();
         $plugintypes = get_plugin_types();
         $plugintypes = $this->reorder_plugin_types($plugintypes);
         foreach ($plugintypes as $plugintype => $plugintyperootdir) {
             if (in_array($plugintype, array('base', 'general'))) {
                 throw new coding_exception('Illegal usage of reserved word for plugin type');
             }
             if (class_exists('plugininfo_' . $plugintype)) {
                 $plugintypeclass = 'plugininfo_' . $plugintype;
             } else {
                 $plugintypeclass = 'plugininfo_general';
             }
             if (!in_array('plugininfo_base', class_parents($plugintypeclass))) {
                 throw new coding_exception('Class ' . $plugintypeclass . ' must extend plugininfo_base');
             }
             $plugins = call_user_func(array($plugintypeclass, 'get_plugins'), $plugintype, $plugintyperootdir, $plugintypeclass);
             $this->pluginsinfo[$plugintype] = $plugins;
         }
         // TODO: MDL-20438 verify this is the correct solution/replace
         if (!during_initial_install()) {
             // append the information about available updates provided by {@link available_update_checker()}
             $provider = available_update_checker::instance();
             foreach ($this->pluginsinfo as $plugintype => $plugins) {
                 foreach ($plugins as $plugininfoholder) {
                     $plugininfoholder->check_available_updates($provider);
                 }
             }
         }
     }
     return $this->pluginsinfo;
 }
开发者ID:robadobdob,项目名称:moodle,代码行数:42,代码来源:pluginlib.php

示例10: add_to_config_log

/**
* Add an entry to the config log table.
*
* These are "action" focussed rather than web server hits,
* and provide a way to easily reconstruct changes to Moodle configuration.
*
* @package core
* @category log
* @global moodle_database $DB
* @global stdClass $USER
* @param    string  $name     The name of the configuration change action
                              For example 'filter_active' when activating or deactivating a filter
* @param    string  $oldvalue The config setting's previous value
* @param    string  $value    The config setting's new value
* @param    string  $plugin   Plugin name, for example a filter name when changing filter configuration
* @return void
*/
function add_to_config_log($name, $oldvalue, $value, $plugin)
{
    global $USER, $DB;
    $log = new stdClass();
    $log->userid = during_initial_install() ? 0 : $USER->id;
    // 0 as user id during install
    $log->timemodified = time();
    $log->name = $name;
    $log->oldvalue = $oldvalue;
    $log->value = $value;
    $log->plugin = $plugin;
    $DB->insert_record('config_log', $log);
}
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:datalib.php

示例11: toHtml


//.........这里部分代码省略.........
            $media_options->maxbytes  = $this->_options['maxbytes'];
            $media_options->areamaxbytes  = $this->_options['areamaxbytes'];
            $media_options->env = 'editor';
            $media_options->itemid = $draftitemid;

            // advlink plugin
            $args->accepted_types = '*';
            $link_options = initialise_filepicker($args);
            $link_options->context = $ctx;
            $link_options->client_id = uniqid();
            $link_options->maxbytes  = $this->_options['maxbytes'];
            $link_options->areamaxbytes  = $this->_options['areamaxbytes'];
            $link_options->env = 'editor';
            $link_options->itemid = $draftitemid;

            $args->accepted_types = array('.vtt');
            $subtitle_options = initialise_filepicker($args);
            $subtitle_options->context = $ctx;
            $subtitle_options->client_id = uniqid();
            $subtitle_options->maxbytes  = $this->_options['maxbytes'];
            $subtitle_options->areamaxbytes  = $this->_options['areamaxbytes'];
            $subtitle_options->env = 'editor';
            $subtitle_options->itemid = $draftitemid;

            $fpoptions['image'] = $image_options;
            $fpoptions['media'] = $media_options;
            $fpoptions['link'] = $link_options;
            $fpoptions['subtitle'] = $subtitle_options;
        }

        //If editor is required and tinymce, then set required_tinymce option to initalize tinymce validation.
        if (($editor instanceof tinymce_texteditor)  && !is_null($this->getAttribute('onchange'))) {
            $this->_options['required'] = true;
        }

        // print text area - TODO: add on-the-fly switching, size configuration, etc.
        $editor->set_text($text);
        $editor->use_editor($id, $this->_options, $fpoptions);

        $rows = empty($this->_attributes['rows']) ? 15 : $this->_attributes['rows'];
        $cols = empty($this->_attributes['cols']) ? 80 : $this->_attributes['cols'];

        //Apply editor validation if required field
        $context = [];
        $context['rows'] = $rows;
        $context['cols'] = $cols;
        $context['frozen'] = $this->_flagFrozen;
        foreach ($this->getAttributes() as $name => $value) {
            $context[$name] = $value;
        }
        $context['hasformats'] = count($formats) > 1;
        $context['formats'] = [];
        if (($format === '' || $format === null) && count($formats)) {
            $format = key($formats);
        }
        foreach ($formats as $formatvalue => $formattext) {
            $context['formats'][] = ['value' => $formatvalue, 'text' => $formattext, 'selected' => ($formatvalue == $format)];
        }
        $context['id'] = $id;
        $context['value'] = $text;
        $context['format'] = $format;

        if (!is_null($this->getAttribute('onblur')) && !is_null($this->getAttribute('onchange'))) {
            $context['changelistener'] = true;
        }

        $str .= $OUTPUT->render_from_template('core_form/editor_textarea', $context);

        // during moodle installation, user area doesn't exist
        // so we need to disable filepicker here.
        if (!during_initial_install() && empty($CFG->adminsetuppending)) {
            // 0 means no files, -1 unlimited
            if ($maxfiles != 0 ) {
                $str .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $elname.'[itemid]',
                        'value' => $draftitemid));

                // used by non js editor only
                $editorurl = new moodle_url("$CFG->wwwroot/repository/draftfiles_manager.php", array(
                    'action'=>'browse',
                    'env'=>'editor',
                    'itemid'=>$draftitemid,
                    'subdirs'=>$subdirs,
                    'maxbytes'=>$maxbytes,
                    'areamaxbytes' => $areamaxbytes,
                    'maxfiles'=>$maxfiles,
                    'ctx_id'=>$ctx->id,
                    'course'=>$PAGE->course->id,
                    'sesskey'=>sesskey(),
                    ));
                $str .= '<noscript>';
                $str .= "<div><object type='text/html' data='$editorurl' height='160' width='600' style='border:1px solid #000'></object></div>";
                $str .= '</noscript>';
            }
        }


        $str .= '</div>';

        return $str;
    }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:101,代码来源:editor.php

示例12: initialise

 /**
  * Initialise the navigation given the type and id for the branch to expand.
  *
  * @param int $branchtype One of navigation_node::TYPE_*
  * @param int $id
  * @return array The expandable nodes
  */
 public function initialise()
 {
     global $CFG, $DB, $SITE;
     if ($this->initialised || during_initial_install()) {
         return $this->expandable;
     }
     $this->initialised = true;
     $this->rootnodes = array();
     $this->rootnodes['site'] = $this->add_course($SITE);
     $this->rootnodes['mycourses'] = $this->add(get_string('mycourses'), new moodle_url('/my'), self::TYPE_ROOTNODE, null, 'mycourses');
     $this->rootnodes['courses'] = $this->add(get_string('courses'), null, self::TYPE_ROOTNODE, null, 'courses');
     if (function_exists('enrol_user_sees_own_courses')) {
         // Determine if the user is enrolled in any course.
         $enrolledinanycourse = enrol_user_sees_own_courses();
         if ($enrolledinanycourse) {
             $this->rootnodes['mycourses']->isexpandable = true;
             if ($CFG->navshowallcourses) {
                 // When we show all courses we need to show both the my courses and the regular courses branch.
                 $this->rootnodes['courses']->isexpandable = true;
             }
         } else {
             $this->rootnodes['courses']->isexpandable = true;
         }
     }
     $this->expand($this->branchtype, $this->instanceid);
 }
开发者ID:CourseBit,项目名称:moodle-theme_social,代码行数:33,代码来源:lib.php

示例13: get_defaultsetting

 /**
  * Return the default setting for this control
  *
  * @return array Array of default settings
  */
 public function get_defaultsetting()
 {
     global $CFG;
     if (during_initial_install()) {
         return null;
     }
     $result = array();
     foreach ($this->types as $capability) {
         if ($caproles = get_roles_with_capability($capability, CAP_ALLOW)) {
             foreach ($caproles as $caprole) {
                 $result[$caprole->id] = 1;
             }
         }
     }
     return $result;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:21,代码来源:adminlib.php

示例14: initialise

    /**
     * Initialise the navigation given the type and id for the branch to expand.
     *
     * @param int $branchtype One of navigation_node::TYPE_*
     * @param int $id
     * @return array The expandable nodes
     */
    public function initialise($branchtype, $id) {
        global $CFG, $DB, $SITE, $PAGE;

        if ($this->initialised || during_initial_install()) {
            return $this->expandable;
        }
        $this->initialised = true;

        $this->rootnodes = array();
        $this->rootnodes['site']      = $this->add_course($SITE);
        $this->rootnodes['courses'] = $this->add(get_string('courses'), null, self::TYPE_ROOTNODE, null, 'courses');

        // Branchtype will be one of navigation_node::TYPE_*
        switch ($branchtype) {
            case self::TYPE_CATEGORY :
                $this->load_all_categories($id);
                $limit = 20;
                if (!empty($CFG->navcourselimit)) {
                    $limit = (int)$CFG->navcourselimit;
                }
                $courses = $DB->get_records('course', array('category' => $id), 'sortorder','*', 0, $limit);
                foreach ($courses as $course) {
                    $this->add_course($course);
                }
                break;
            case self::TYPE_COURSE :
                $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
                try {
                    krystle2_require_course_login($course);
                    //$this->page = $PAGE;
                    $this->page->set_context(get_context_instance(CONTEXT_COURSE, $course->id));
                    $coursenode = $this->add_course($course);
                    $this->add_course_essentials($coursenode, $course);
                    if ($this->format_display_course_content($course->format) && $PAGE->course->id == $course->id) {
                        $this->load_course_sections($course, $coursenode);
                    }
                } catch(require_login_exception $rle) {
                   $coursenode = $this->add_course($course);
                }
                break;
            case self::TYPE_SECTION :
                $sql = 'SELECT c.*, cs.section AS sectionnumber
                        FROM {course} c
                        LEFT JOIN {course_sections} cs ON cs.course = c.id
                        WHERE cs.id = ?';
                $course = $DB->get_record_sql($sql, array($id), MUST_EXIST);
                try {
                    krystle2_require_course_login($course);
                    //$this->page = $PAGE;
                    $this->page->set_context(get_context_instance(CONTEXT_COURSE, $course->id));
                    $coursenode = $this->add_course($course);
                    $this->add_course_essentials($coursenode, $course);
                    $sections = $this->load_course_sections($course, $coursenode);
                    if(method_exists($this,'generate_sections_and_activities')) {
                        list($sectionarray, $activities) = $this->generate_sections_and_activities($course);
                        $this->load_section_activities($sections[$course->sectionnumber]->sectionnode, $course->sectionnumber, $activities);
                    } else {
                        // pre-Moodle 2.1
                        $this->load_section_activities($sections[$course->sectionnumber]->sectionnode, $course->sectionnumber, get_fast_modinfo($course));
                    }
                } catch(require_login_exception $rle) {
                    $coursenode = $this->add_course($course);
                }
                break;
            case self::TYPE_ACTIVITY :
                if(method_exists($this,'generate_sections_and_activities')) {
                    $sql = "SELECT c.*
                              FROM {course} c
                              JOIN {course_modules} cm ON cm.course = c.id
                             WHERE cm.id = :cmid";
                    $params = array('cmid' => $id);
                    $course = $DB->get_record_sql($sql, $params, MUST_EXIST);
                    $modinfo = get_fast_modinfo($course);
                    $cm = $modinfo->get_cm($id);
                } else {
                    // pre-Moodle 2.1
                    $cm = get_coursemodule_from_id(false, $id, 0, false, MUST_EXIST);
                    $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
                }
                try {
                    krystle2_require_course_login($course, true, $cm);
                    //$this->page = $PAGE;
                    $this->page->set_context(get_context_instance(CONTEXT_MODULE, $cm->id));
                    $coursenode = $this->load_course($course);
                    if(!method_exists($this,'generate_sections_and_activities')) {
                        // pre-Moodle 2.1
                        $sections = $this->load_course_sections($course, $coursenode);
                        foreach ($sections as $section) {
                            if ($section->id == $cm->section) {
                                $cm->sectionnumber = $section->section;
                                break;
                            }
                        }
//.........这里部分代码省略.........
开发者ID:roelmann,项目名称:krystle2,代码行数:101,代码来源:lib.php

示例15: toHtml

 function toHtml()
 {
     global $CFG, $PAGE;
     require_once $CFG->dirroot . '/repository/lib.php';
     if ($this->_flagFrozen) {
         return $this->getFrozenHtml();
     }
     $ctx = $this->_options['context'];
     $id = $this->_attributes['id'];
     $elname = $this->_attributes['name'];
     $subdirs = $this->_options['subdirs'];
     $maxbytes = $this->_options['maxbytes'];
     $maxfiles = $this->_options['maxfiles'];
     $changeformat = $this->_options['changeformat'];
     // TO DO: implement as ajax calls
     $text = $this->_values['text'];
     $format = $this->_values['format'];
     $draftitemid = $this->_values['itemid'];
     // security - never ever allow guest/not logged in user to upload anything
     if (isguestuser() or !isloggedin()) {
         $maxfiles = 0;
     }
     $str = $this->_getTabs();
     $str .= '<div>';
     $editor = editors_get_preferred_editor($format);
     $strformats = format_text_menu();
     $formats = $editor->get_supported_formats();
     foreach ($formats as $fid) {
         $formats[$fid] = $strformats[$fid];
     }
     // get filepicker info
     //
     $fpoptions = array();
     if ($maxfiles != 0) {
         if (empty($draftitemid)) {
             // no existing area info provided - let's use fresh new draft area
             require_once "{$CFG->libdir}/filelib.php";
             $this->setValue(array('itemid' => file_get_unused_draft_itemid()));
             $draftitemid = $this->_values['itemid'];
         }
         $args = new stdClass();
         // need these three to filter repositories list
         $args->accepted_types = array('image');
         $args->return_types = FILE_INTERNAL | FILE_EXTERNAL;
         $args->context = $ctx;
         $args->env = 'filepicker';
         // advimage plugin
         $image_options = initialise_filepicker($args);
         $image_options->context = $ctx;
         $image_options->client_id = uniqid();
         $image_options->maxbytes = $this->_options['maxbytes'];
         $image_options->env = 'editor';
         $image_options->itemid = $draftitemid;
         // moodlemedia plugin
         $args->accepted_types = array('video', 'audio');
         $media_options = initialise_filepicker($args);
         $media_options->context = $ctx;
         $media_options->client_id = uniqid();
         $media_options->maxbytes = $this->_options['maxbytes'];
         $media_options->env = 'editor';
         $media_options->itemid = $draftitemid;
         // advlink plugin
         $args->accepted_types = '*';
         $link_options = initialise_filepicker($args);
         $link_options->context = $ctx;
         $link_options->client_id = uniqid();
         $link_options->maxbytes = $this->_options['maxbytes'];
         $link_options->env = 'editor';
         $link_options->itemid = $draftitemid;
         $fpoptions['image'] = $image_options;
         $fpoptions['media'] = $media_options;
         $fpoptions['link'] = $link_options;
     }
     //If editor is required and tinymce, then set required_tinymce option to initalize tinymce validation.
     if ($editor instanceof tinymce_texteditor && !is_null($this->getAttribute('onchange'))) {
         $this->_options['required'] = true;
     }
     /// print text area - TODO: add on-the-fly switching, size configuration, etc.
     $editor->use_editor($id, $this->_options, $fpoptions);
     $rows = empty($this->_attributes['rows']) ? 15 : $this->_attributes['rows'];
     $cols = empty($this->_attributes['cols']) ? 80 : $this->_attributes['cols'];
     //Apply editor validation if required field
     $editorrules = '';
     if (!is_null($this->getAttribute('onblur')) && !is_null($this->getAttribute('onchange'))) {
         $editorrules = 'onblur="' . htmlspecialchars($this->getAttribute('onblur')) . '" onchange="' . htmlspecialchars($this->getAttribute('onchange')) . '"';
     }
     $str .= '<div><textarea id="' . $id . '" name="' . $elname . '[text]" rows="' . $rows . '" cols="' . $cols . '"' . $editorrules . '>';
     $str .= s($text);
     $str .= '</textarea></div>';
     $str .= '<div>';
     if (count($formats) > 1) {
         $str .= html_writer::select($formats, $elname . '[format]', $format, false);
     } else {
         $str .= html_writer::empty_tag('input', array('name' => $elname . '[format]', 'type' => 'hidden', 'value' => array_pop(array_keys($formats))));
     }
     $str .= '</div>';
     // during moodle installation, user area doesn't exist
     // so we need to disable filepicker here.
     if (!during_initial_install() && empty($CFG->adminsetuppending)) {
         // 0 means no files, -1 unlimited
//.........这里部分代码省略.........
开发者ID:nigeldaley,项目名称:moodle,代码行数:101,代码来源:editor.php


注:本文中的during_initial_install函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。