コード例 #1
0
 public function build($node, $matches, $options = array())
 {
     if (isset($options['interwiki'])) {
         preg_match('/(.*?):(.*)/', $matches[1][0], $m);
     }
     if (!isset($m[1]) || !isset($options['interwiki'][$m[1]])) {
         return parent::build($node, $matches, $options);
     }
     $format = $options['interwiki'][$m[1]];
     $link = new node('a');
     $link->set_attribute('href', $this->format_link(preg_replace('/~(.)/', '$1', $m[2]), $format));
     $this->apply($link, $matches[2][0], $options);
     $node->append($link);
 }
コード例 #2
0
 public function apply($node, $data, $options = array())
 {
     $tail = $data;
     if (!is_object($this->fallback)) {
         $this->fallback = $this->fallback ? new rule($this->fallback) : new defaultfallback();
     }
     while (true) {
         $best = false;
         $rule = false;
         for ($i = 0; $i < count($this->children); $i++) {
             if (!isset($matches[$i])) {
                 if (!is_object($this->children[$i])) {
                     $this->children[$i] = new rule($this->children[$i]);
                 }
                 $matches[$i] = $this->children[$i]->match($tail);
             }
             if ($matches[$i] && (!$best || $matches[$i][0][1] < $best[0][1])) {
                 $best = $matches[$i];
                 $rule = $this->children[$i];
                 if ($best[0][1] == 0) {
                     break;
                 }
             }
         }
         $pos = $best ? $best[0][1] : strlen($tail);
         if ($pos > 0) {
             $this->fallback->apply($node, substr($tail, 0, $pos), $options);
         }
         if (!$best) {
             break;
         }
         if (!is_object($rule)) {
             $rule = new rule($rule);
         }
         $rule->build($node, $best, $options);
         $chopped = $best[0][1] + strlen($best[0][0]);
         $tail = substr($tail, $chopped);
         for ($i = 0; $i < count($this->children); $i++) {
             if (isset($matches[$i])) {
                 if ($matches[$i][0][1] >= $chopped) {
                     $matches[$i][0][1] -= $chopped;
                 } else {
                     unset($matches[$i]);
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: category.php プロジェクト: unikent/moodle-tool_cat
 /**
  * Apply a rule to this category.
  *
  * @param rule $rule The rule to apply.
  */
 public function apply($rule)
 {
     $courses = $this->get_courses();
     $rule->apply($courses);
 }
コード例 #4
0
 public function __construct($params = array())
 {
     parent::__construct($params);
 }