本文整理汇总了PHP中Reg::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Reg::has方法的具体用法?PHP Reg::has怎么用?PHP Reg::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reg
的用法示例。
在下文中一共展示了Reg::has方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _designerFixCallback
/**
* Callback function for the designer fix preg_replace_callback
* Automatically adjusts paths if they have .. in them
*
* @access private
* @final
* @param array $match An array of the found items from the regular expression
* @return string
*/
private final function _designerFixCallback($match)
{
// if this isn't empty then it is a link
$link = !empty($match[2]);
// get the tag
$tag = $match[1];
// set the default to return the full string that was matched
$return = $match[0];
$custom = false;
// do the replacement
switch ($tag) {
case "[current]":
$return = Reg::get("Path.current");
break;
case "[site]":
$return = Reg::get("Path.site");
break;
case "[skin]":
$return = Reg::get("Path.skin");
break;
case "[root]":
$return = Reg::get("Path.root");
break;
case "[branch.site]":
$return = Reg::get("Path.branch");
break;
case "[branch.skin]":
$return = Reg::get("Path.branchSkin");
break;
case "[branch.root]":
$return = Reg::get("Path.branchRoot");
break;
default:
// see if it is a php variable. Quick way to echo variables from $this
if (strpos($tag, '$') === 1) {
$custom = true;
$var = str_replace(array('[', ']', '$', 'this->'), '', $tag);
// if it is in an object then we need to go down the objects pulling out the variables
// not pretty
if (strpos($var, '->') !== false) {
$parts = explode('->', $var);
$failed = false;
$var = $this->{array_shift($parts)};
foreach ($parts as $part) {
if (!isset($var->{$part})) {
// variable isn't set so it failed
$failed = true;
break;
}
$var = $var->{$part};
}
if ($failed === false) {
$return = $var;
}
} else {
// it is a variable that isn't an object
if (isset($this->{$var})) {
$return = $this->{$var};
}
}
// the variable didn't exist so send nothing back to the page
// don't want variable names to sneak in
if ($return == $tag) {
$return = '';
}
} else {
if (Reg::has(str_replace(array('[', ']'), '', $tag))) {
$custom = true;
// get the variable from the registry
$return = Reg::get(str_replace(array('[', ']'), '', $tag));
} else {
// look for the tag within the working URI
$working_uri = Reg::get("URI.working");
if (Reg::hasVal("Branch.name")) {
$working_uri = array_merge(array("branch" => Reg::get("Branch.name")), $working_uri);
}
foreach ($working_uri as $key => $item) {
$tmp_key = "[" . $key . "]";
if ($tag == $tmp_key && Reg::has('Path.' . $key)) {
$return = Reg::get('Path.' . $key);
break 1;
}
}
}
}
break;
}
// if it is a link then we need to do some more processing
if ($link === true && $custom === false) {
// remove any ../ from the url so that they are clean
$link_arr = explode("/", $match[2]);
//.........这里部分代码省略.........