本文整理汇总了PHP中dmString::getDataFromUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP dmString::getDataFromUrl方法的具体用法?PHP dmString::getDataFromUrl怎么用?PHP dmString::getDataFromUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dmString
的用法示例。
在下文中一共展示了dmString::getDataFromUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareAttributesForHtml
protected function prepareAttributesForHtml(array $attributes)
{
$attributes = parent::prepareAttributesForHtml($attributes);
list($attributes['href'], $attributes['params']) = $this->getBaseHref(true);
if (array_key_exists('params', $attributes)) {
if (!empty($attributes['params'])) {
$attributes['href'] = $this->buildUrl(dmString::getBaseFromUrl($attributes['href']), array_merge(dmString::getDataFromUrl($attributes['href']), $attributes['params']));
/*
* if last href char is a =, remove it
* fixes http://github.com/diem-project/diem/issues/#issue/6
*/
if ('=' === substr($attributes['href'], -1)) {
$attributes['href'] = substr($attributes['href'], 0, strlen($attributes['href']) - 1);
}
}
unset($attributes['params']);
}
if (isset($attributes['anchor'])) {
$attributes['href'] .= '#' . $attributes['anchor'];
}
// makes unit testing easier
ksort($attributes);
return $attributes;
}
示例2: initialize
public function initialize($source)
{
$this->source = $source;
$this->params = false;
if (empty($source)) {
$this->type = 'page';
$this->subject = dmDb::table('DmPage')->findOneBySource(null);
} elseif (is_string($source)) {
/*
* If a blank space is found in the source,
* remove characters after it
* because they are just a comment
* i.e. page:1?var=val Home
*/
if ($blankSpacePos = strpos($source, ' ')) {
$source = substr($source, 0, $blankSpacePos);
}
/*
* Extract url parameters from source string
*/
$this->params = dmString::getDataFromUrl($source);
$source = dmString::getBaseFromUrl($source);
if ('@homepage' === $source) {
$source = 'main/root';
}
if (strncmp($source, 'page:', 5) === 0) {
if ($page = dmDb::table('DmPage')->findOneBySource($source)) {
$this->type = 'page';
$this->subject = $page;
} else {
throw new dmException(sprintf('%s is not a valid link resource', $source));
}
} elseif (strncmp($source, 'media:', 6) === 0) {
if ($media = dmDb::table('DmMedia')->findOneByIdWithFolder(substr($source, 6))) {
$this->type = 'media';
$this->subject = $media;
} else {
throw new dmException(sprintf('%s is not a valid link resource', $source));
}
} elseif (strncmp($source, 'app:', 4) === 0) {
$app = substr($source, 4);
/*
* A slug may be added to the app name, extract it
*/
if ($slashPos = strpos($app, '/')) {
$slug = substr($app, $slashPos);
$app = substr($app, 0, $slashPos);
} else {
$slug = '';
}
$this->type = 'uri';
$this->subject = dmContext::hasInstance() ? dmContext::getInstance()->get('script_name_resolver')->get($app) . $slug : $slug;
} elseif (strncmp($source, '@', 1) === 0) {
$this->type = 'route';
$this->subject = $source;
} elseif (strncmp($source, 'http://', 7) === 0 || strncmp($source, 'https://', 7) === 0 || strncmp($source, 'ftp://', 6) === 0 || strncmp($source, 'mailto:', 7) === 0 || strncmp($source, '#', 1) === 0) {
$this->type = 'uri';
$this->subject = $source;
} elseif (strncmp($source, '/', 1) === 0) {
$this->type = 'uri';
$this->subject = $source;
} elseif (strncmp($source, '+/', 2) === 0) {
$this->type = 'action';
$this->subject = substr($source, 2);
} elseif (substr_count($source, '/') === 1) {
if ($page = dmDb::table('DmPage')->findOneBySource($source)) {
$this->type = 'page';
$this->subject = $page;
} else {
throw new dmException(sprintf('%s is not a valid link resource', $source));
}
} else {
throw new dmException(sprintf('%s is not a valid link resource', $source));
}
} elseif (is_object($source)) {
if ($source instanceof DmPage) {
$this->type = 'page';
$this->subject = $source;
} elseif ($source instanceof DmMedia) {
$this->type = 'media';
$this->subject = $source;
} elseif ($source instanceof dmDoctrineRecord) {
if ($module = $source->getDmModule()) {
if ($module->hasPage()) {
$this->type = 'record';
$this->subject = $source;
} else {
throw new dmException(sprintf('%s module has no page', $module));
}
} else {
throw new dmException(sprintf('%s object can not be associated to a page', get_class($source)));
}
} elseif ($source instanceof Exception) {
$this->type = 'error';
$this->subject = $source;
}
} elseif (is_array($source)) {
if (isset($source[1])) {
if (is_object($source[1])) {
$this->type = 'action';
//.........这里部分代码省略.........