Strip inline directive prefix

@param  string $rule
@return string
9112
protected function stripInlineDirective($rule)
    {
        $directive = $this->isInlineDirective($rule);
        if ($directive !== false) {
            $rule = trim(str_ireplace($directive . ':', '', $rule));
        }
        return $rule;
    }
477258
protected function getRuleName($rule)
    {
        /* Retire le caractère de négation de la fonction. */
        $function = $rule[ 0 ] == '!'
            ? substr($rule, 1)
            : $rule;

        /* Sépare le nom de la fonction si elle a des arguments. */
        if (($name = strstr($function, ':', true)) !== false) {
            return strtolower($name);
        }

        return strtolower($function);
    }
948893
protected function compileTransposeModulo(array $rule)
    {
        return array(
            'regexp' => '([' .
                preg_quote(
                    $this->getModuloCharRange(
                        $this->compileCharacter($rule['data']['srcStart']),
                        $this->compileCharacter($rule['data']['srcEnd']),
                        $rule['data']['modulo']
                    )
                ) .
                '])us',
            'callback' => $this->getTransposeClosure($rule['data']['op'], $rule['data']['dest']),
        );
    }
1273334
public function setRule($rule)
    {
        if ('$' == substr($rule, -1, 1)) {
            // 是否完整匹配
            $rule = substr($rule, 0, -1);

            $this->option['complete_match'] = true;
        }

        $rule = '/' != $rule ? ltrim($rule, '/') : '';

        if ($this->parent && $prefix = $this->parent->getFullName()) {
            $rule = $prefix . ($rule ? '/' . ltrim($rule, '/') : '');
        }

        if (false !== strpos($rule, ':')) {
            $this->rule = preg_replace(['/\[\:(\w+)\]/', '/\:(\w+)/'], ['<\1?>', '<\1>'], $rule);
        } else {
            $this->rule = $rule;
        }

        // 生成路由标识的快捷访问
        $this->setRuleName();
    }
887981
protected static function replaceWithRule($rule, $output)
    {
        foreach ($rule as $data) {

            $from_json = $data["from"];

            //search line break.
            //if line break include , need to fix the line
            if (strpos($from_json, chr(13)) !== false) {
                $from_json = self::parseline($from_json);
            }

            $from = "~".json_decode('"'.$from_json.'"')."~u";
            $to = json_decode('"'.$data["to"].'"');
            $output = preg_replace($from, $to, $output);
        }

        return $output;
    }
1095056
protected function convertPattern($pattern)
    {
        $prefix = 0 === strpos($pattern, '!') ? '!' : '';
        $searchPattern = trim(ltrim($pattern, '!'), '/');
        $pattern = $prefix.$searchPattern;

        if (\in_array($searchPattern, array('*', '*.*'), true)) {
            $this->doAddPattern($prefix.'.*');
        } elseif (0 === strpos($searchPattern, '**/')) {
            $this->doAddPattern($prefix.'**/'.$searchPattern);
            $this->doAddPattern($prefix.substr($searchPattern, 3));
        } else {
            $this->convertPatternStep2($prefix, $searchPattern, $pattern);
        }

        return $pattern;
    }
242188
private function checkHostRule($rule)
    {
        if (!isset($this->url)) {
            $error_msg = 'Inline host directive detected. URL not set, result may be inaccurate.';
            $this->log[] = $error_msg;
            trigger_error("robots.txt: $error_msg", E_USER_NOTICE);
            return false;
        }
        $url = $this->parseURL($this->url);
        $host = trim(str_ireplace(self::DIRECTIVE_HOST . ':', '', mb_strtolower($rule)));
        if (in_array(
            $host, array(
                $url['host'],
                $url['host'] . ':' . $url['port'],
                $url['scheme'] . '://' . $url['host'],
                $url['scheme'] . '://' . $url['host'] . ':' . $url['port']
            )
        )) {
            $this->log[] = 'Rule match: ' . self::DIRECTIVE_HOST . ' directive';
            return true;
        }
        return false;
    }
358585
private function extractNeededProperties($rule)
    {
        if (\in_array($rule['operation'], ['AND', 'OR'])) {
            $properties = [];
            foreach ($rule['children'] as $childRule) {
                $properties[] = $this->extractNeededProperties($childRule);
            }
            return $properties;
        }

        // Local is child property name.
        if (isset($rule['local'])) {
            return $rule['local'];
        }

        // Remote is parent property name.
        if (isset($rule['property'])) {
            return $rule['property'];
        }

        throw new \RuntimeException('Unexpected filter rule ' . \var_export($rule, true));
    }
512641
private function prefix()
    {
        $result = $this->lineBreak() . $this->directive . ':';
        if ($this->level === 0) {
            return $result;
        }
        return ucwords($result) . ' ';
    }
927714
protected function getRuleArgs($rule)
    {
        if (($arg = substr(strstr($rule, ':'), 1)) !== false) {
            /* Si l'argument fait référence à un autre champ. */
            if ($arg[ 0 ] == '@') {
                $keyArg = substr($arg, 1);
                $arg    = $this->inputs[ $keyArg ];
            }
        }

        return $arg;
    }
532148
protected function explodeExplicitRule($rule)
    {
        if (is_string($rule)) {
            return explode('|', $rule);
        } elseif (is_object($rule)) {
            return [$this->prepareRule($rule)];
        }

        return array_map([$this, 'prepareRule'], $rule);
    }
246441
protected function getRuleType($rule)
    {
        if ( ! is_string($rule)) {
            return '';
        }

        if (false === ($pos = strpos($rule, ':'))) {
            return $rule;
        }

        return substr($rule, 0, $pos);
    }
687893
public function getFilterForRule(Rule $rule)
    {
        $filterIdentifier = $rule->getFilter();

        if ($this->container === null || !$this->container->has($filterIdentifier)) {
            return parent::getFilterForRule($rule);
        }

        return $this->container->get($filterIdentifier);
    }
313925
protected function parseValidationRule($rule)
    {
        $ruleArray = array();

        $explodedRule = explode(':', $rule, 2);
        $ruleArray['name'] = array_shift($explodedRule);

        if (empty($explodedRule) || !in_array(strtolower($ruleArray['name']), static::$multiParamRules)) {
            $ruleArray['parameters'] = $explodedRule;
        } else {
            $ruleArray['parameters'] = str_getcsv($explodedRule[0]);
        }

        return $ruleArray;
    }
124542
public function revokeRule($rule)
    {
        if ($this->hasRule($rule)) {
            unset($this->rules[$rule]);
            return true;
        } else {
            return false;
        }
    }
165713
protected function _getRule($rule)
    {
        if ($rule instanceof FilterInterface) {
            return $rule;
        }

        $rule = (string) $rule;
        return $this->getPluginManager()->get($rule);
    }
1122865
public function col_course(\tool_monitor\rule $rule) {
        $coursename = $rule->get_course_name($this->context);

        $courseid = $rule->courseid;
        if (empty($courseid)) {
            return $coursename;
        } else {
            return \html_writer::link(new \moodle_url('/course/view.php', array('id' => $this->courseid)), $coursename);
        }
    }