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


PHP moodle_page::ensure_param_not_in_url方法代码示例

本文整理汇总了PHP中moodle_page::ensure_param_not_in_url方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_page::ensure_param_not_in_url方法的具体用法?PHP moodle_page::ensure_param_not_in_url怎么用?PHP moodle_page::ensure_param_not_in_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moodle_page的用法示例。


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

示例1: process_url_move

 /**
  * Handle showing/processing the submission from the block editing form.
  * @return boolean true if the form was submitted and the new config saved. Does not
  *      return if the editing form was displayed. False otherwise.
  */
 public function process_url_move()
 {
     global $CFG, $DB, $PAGE;
     $blockid = optional_param('bui_moveid', null, PARAM_INT);
     if (!$blockid) {
         return false;
     }
     require_sesskey();
     $block = $this->find_instance($blockid);
     if (!$this->page->user_can_edit_blocks()) {
         throw new moodle_exception('nopermissions', '', $this->page->url->out(), get_string('editblock'));
     }
     $newregion = optional_param('bui_newregion', '', PARAM_ALPHANUMEXT);
     $newweight = optional_param('bui_newweight', null, PARAM_FLOAT);
     if (!$newregion || is_null($newweight)) {
         // Don't have a valid target position yet, must be just starting the move.
         $this->movingblock = $blockid;
         $this->page->ensure_param_not_in_url('bui_moveid');
         return false;
     }
     if (!$this->is_known_region($newregion)) {
         throw new moodle_exception('unknownblockregion', '', $this->page->url, $newregion);
     }
     // Move this block. This may involve moving other nearby blocks.
     $blocks = $this->birecordsbyregion[$newregion];
     $maxweight = self::MAX_WEIGHT;
     $minweight = -self::MAX_WEIGHT;
     // Initialise the used weights and spareweights array with the default values
     $spareweights = array();
     $usedweights = array();
     for ($i = $minweight; $i <= $maxweight; $i++) {
         $spareweights[$i] = $i;
         $usedweights[$i] = array();
     }
     // Check each block and sort out where we have used weights
     foreach ($blocks as $bi) {
         if ($bi->weight > $maxweight) {
             // If this statement is true then the blocks weight is more than the
             // current maximum. To ensure that we can get the best block position
             // we will initialise elements within the usedweights and spareweights
             // arrays between the blocks weight (which will then be the new max) and
             // the current max
             $parseweight = $bi->weight;
             while (!array_key_exists($parseweight, $usedweights)) {
                 $usedweights[$parseweight] = array();
                 $spareweights[$parseweight] = $parseweight;
                 $parseweight--;
             }
             $maxweight = $bi->weight;
         } else {
             if ($bi->weight < $minweight) {
                 // As above except this time the blocks weight is LESS than the
                 // the current minimum, so we will initialise the array from the
                 // blocks weight (new minimum) to the current minimum
                 $parseweight = $bi->weight;
                 while (!array_key_exists($parseweight, $usedweights)) {
                     $usedweights[$parseweight] = array();
                     $spareweights[$parseweight] = $parseweight;
                     $parseweight++;
                 }
                 $minweight = $bi->weight;
             }
         }
         if ($bi->id != $block->instance->id) {
             unset($spareweights[$bi->weight]);
             $usedweights[$bi->weight][] = $bi->id;
         }
     }
     // First we find the nearest gap in the list of weights.
     $bestdistance = max(abs($newweight - self::MAX_WEIGHT), abs($newweight + self::MAX_WEIGHT)) + 1;
     $bestgap = null;
     foreach ($spareweights as $spareweight) {
         if (abs($newweight - $spareweight) < $bestdistance) {
             $bestdistance = abs($newweight - $spareweight);
             $bestgap = $spareweight;
         }
     }
     // If there is no gap, we have to go outside -self::MAX_WEIGHT .. self::MAX_WEIGHT.
     if (is_null($bestgap)) {
         $bestgap = self::MAX_WEIGHT + 1;
         while (!empty($usedweights[$bestgap])) {
             $bestgap++;
         }
     }
     // Now we know the gap we are aiming for, so move all the blocks along.
     if ($bestgap < $newweight) {
         $newweight = floor($newweight);
         for ($weight = $bestgap + 1; $weight <= $newweight; $weight++) {
             foreach ($usedweights[$weight] as $biid) {
                 $this->reposition_block($biid, $newregion, $weight - 1);
             }
         }
         $this->reposition_block($block->instance->id, $newregion, $newweight);
     } else {
         $newweight = ceil($newweight);
//.........这里部分代码省略.........
开发者ID:Burick,项目名称:moodle,代码行数:101,代码来源:blocklib.php


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