Returns human readable context identifier.

@param boolean $withprefix whether to prefix the name of the context with Course
@param boolean $short whether to use the short name of the thing.
@return string the human readable context name.
512256
public function get_context_name($withprefix = true, $short = false) {
        global $DB;

        $name = '';
        if ($this->_instanceid == SITEID) {
            $name = get_string('frontpage', 'admin');
        } else {
            if ($course = $DB->get_record('course', array('id'=>$this->_instanceid))) {
                if ($withprefix){
                    $name = get_string('course').': ';
                }
                if ($short){
                    $name .= format_string($course->shortname, true, array('context' => $this));
                } else {
                    $name .= format_string(get_course_display_name_for_list($course));
               }
            }
        }
        return $name;
    }
588921
public function shortName($name = null)
    {
        if ($name === null) {
            return $this->_nameShort;
        }
        $this->_nameShort = $name;

        return $this;
    }
916750
public static function getPrepositionName( $prep ) {
		$names = [
			TreeBuilder::BEFORE => 'before',
			TreeBuilder::UNDER => 'under',
			TreeBuilder::ROOT => 'under root'
		];
		return isset( $names[$prep] ) ? $names[$prep] : '???';
	}
1130691
private function getUriPrefix()
	{
		$mode = strtolower($this->getMode());
		switch ($mode) {
			case 'live':
				$prefix = CheckoutApi_Client_Constant::APIGW3_URI_PREFIX_LIVE.CheckoutApi_Client_Constant::VERSION.'/';
				break;
            default :
                $prefix = CheckoutApi_Client_Constant::APIGW3_URI_PREFIX_SANDBOX.CheckoutApi_Client_Constant::VERSION.'/';
                break;    
		}
		return $prefix;
	}
331949
protected static function getWithPrefix($table)
    {
        $prefix = static::$prefix;

        if (is_null($prefix) || empty($prefix)) {
            // If prefix is null, then no need to prepend a redundant _
            return $table;
        }

        return sprintf('%s_%s', $prefix, $table);
    }
619388
public static function getRawTableName($name, $tablePrefix = '')
    {
        if (false !== strpos($name, '{{')) {
            $name = preg_replace('/\\{\\{(.*?)\\}\\}/', '\1', $name);

            return str_replace('%', $tablePrefix, $name);
        }

        return $name;
    }
1168515
public static function getClassName($extension, $shortName) {
        $url = _url('index', $shortName, $extension);
        return self::getClassNameByUrl($url);
    }
742118
public function getLabel($short = false)
    {
        if (!$this->label) {
            $this->label = $this->generateLabel();
            if ($this->hasShortLabel()) {
                $this->label_short = $this->generateLabelShort();
            }
        }

        return $short ? $this->label_short : $this->label;
    }
13504
public function getEventPrefix() {
    static $prefix;
    if (!$prefix) {
      if (defined(static::class.'::EVENT_PREFIX'))
        $prefix = static::EVENT_PREFIX;
      else
        $prefix = strtolower(array_slice(explode('\\', static::class), -1)[0]);
    }
    return $prefix;
  }
1138102
public function get_context_name($withprefix = true, $short = false) {
        global $DB, $CFG;

        $name = '';
        if ($blockinstance = $DB->get_record('block_instances', array('id'=>$this->_instanceid))) {
            global $CFG;
            require_once("$CFG->dirroot/blocks/moodleblock.class.php");
            require_once("$CFG->dirroot/blocks/$blockinstance->blockname/block_$blockinstance->blockname.php");
            $blockname = "block_$blockinstance->blockname";
            if ($blockobject = new $blockname()) {
                if ($withprefix){
                    $name = get_string('block').': ';
                }
                $name .= $blockobject->title;
            }
        }

        return $name;
    }
1116897
public function getDomain(bool $withSuffix = true)
    {
        if (!isset($this->uri['host'])) {
            return null;
        }

        $manager = new Manager(new Cache(sys_get_temp_dir() . '/publicsuffix/'), new CurlHttpClient());
        $rules = $manager->getRules();
        $domain = $rules->resolve($this->uri['host']);

        if (!$domain->isKnown()) {
            return $this->uri['host'];
        }

        if ($withSuffix) {
            return $domain->getRegistrableDomain();
        } else {
            return substr($domain->getRegistrableDomain(), 0, -strlen($domain->getPublicSuffix()) - 1);
        }
    }
1022300
protected static function getClassMethodsByPrefix($prefix = null)
    {
        //
        $attribute = 'MethodsByPrefix:'.$prefix;

        if (!static::hasClassAttribute($attribute)) {
            $class = static::getClass();
            $allMethods = get_class_methods($class);
            $methods = [];

            if (count($allMethods) > 0) {
                foreach ($allMethods as $method) {
                    if (preg_match('/^'.$prefix.'/i', $method)) {
                        $methods[] = $method;
                    }
                }
            }
            asort($methods);

            static::setClassAttribute($attribute, $methods);
        }

        //
        return static::getClassAttribute($attribute);
    }
424971
public function get_coursename() {
        return format_string($this->course->shortname, true, array(
            'context' => \context_course::instance($this->course->id),
        ));
    }
1052430
public static function getServerNameOrIp($withProtocol = false)
    {
        $host = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'HTTP_HOST');

        /*
         * Unknown host / server?
         * Nothing to do
         */
        if (empty($host)) {
            return '';
        }

        /*
         * With protocol?
         * Let's include the protocol
         */
        if ($withProtocol) {
            return sprintf('%s://%s', self::getProtocolName(), $host);
        }

        return $host;
    }
1234515
public function getPrefix()
    {
        if (!$this->prefix) {
            if (ctype_lower($this->getName())) {
                $this->prefix = $this->getName();
            } else {
                $this->prefix = mb_strtolower(preg_replace('/(.)([A-Z])/', '$1_$2', $this->getName()));
            }
        }

        return $this->prefix;
    }
1005646
public function getQueryFields($usePrefix = false, $prefix = '')
    {
        $fields = $this->fields;

        if ($usePrefix) {
            $prefix = (empty($prefix) ? $this->getTable() : $prefix);
            $fields = array();
            foreach ($this->fields as $field) {
                $fields[] = $prefix . '.' . $field;
            }
        }

        return implode(', ', $fields);
    }
661326
public function shortName()
    {
        $id = $this->getModuleId();
        $p  = strrpos($id, '.');

        return $p ? substr($id, $p + 1) : $id;
    }