本文整理汇总了PHP中modX::makeUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::makeUrl方法的具体用法?PHP modX::makeUrl怎么用?PHP modX::makeUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::makeUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBaseUrl
/**
* Returns current base url for pagination
*
* @return string $url
*/
public function getBaseUrl()
{
if ($this->modx->getOption('friendly_urls')) {
$q_var = $this->modx->getOption('request_param_alias', null, 'q');
$q_val = isset($_REQUEST[$q_var]) ? $_REQUEST[$q_var] : '';
$this->req_var = $q_var;
$host = '';
switch ($this->pdoTools->config['scheme']) {
case 'full':
$host = $this->modx->getOption('site_url');
break;
case 'abs':
case 'absolute':
$host = $this->modx->getOption('base_url');
break;
case 'https':
case 'http':
$host = $this->pdoTools->config['scheme'] . '://' . $this->modx->getOption('http_host') . $this->modx->getOption('base_url');
break;
}
$url = $host . $q_val;
} else {
$id_var = $this->modx->getOption('request_param_id', null, 'id');
$id_val = isset($_GET[$id_var]) ? $_GET[$id_var] : $this->modx->getOption('site_start');
$this->req_var = $id_var;
$url = $this->modx->makeUrl($id_val, '', '', $this->pdoTools->config['scheme']);
}
return $url;
}
示例2: formatResourceUrl
/**
* @param int $resource
*
* @return string
*/
public function formatResourceUrl($resource = 0)
{
$url = '';
$args = array();
if (!empty($resource)) {
$url = $this->modx->makeUrl($resource, '', $args, 'full', array('xhtml_urls' => false));
}
return $url;
}
示例3: showList
/**
* Show the remembered list
*
* @param array $options Template options
* @return string
*/
public function showList($options)
{
$output = array();
// Generate the list
$list = array();
foreach ($_SESSION['rememberThis'] as $element) {
$list[] = $element['element']['identifier'];
}
$output['list'] = $list;
// Generate the result
if (!count($_SESSION['rememberThis'])) {
if (!$this->getOption('notRememberRedirect')) {
$output['result'] = $this->modx->getChunk($options['outerTpl'], array('wrapper' => $this->modx->getChunk($options['noResultsTpl']), 'count' => $this->getOption('showZeroCount') ? '0' : ''));
} else {
$this->modx->sendRedirect($this->modx->makeUrl($this->getOption('notRememberRedirect')));
}
} else {
$output['result'] = $this->modx->getChunk($options['outerTpl'], array('wrapper' => $this->showElements($options['rowTpl']), 'count' => (string) count($_SESSION['rememberThis'])));
}
// Generate count
$output['count'] = count($_SESSION['rememberThis']);
// Generate debug informations
if ($this->getOption('debug')) {
$output['debug'] = '<pre>DEBUG: $_SESSION["rememberThis"] = ' . print_r($_SESSION['rememberThis'], TRUE) . '</pre>';
}
return $output;
}
示例4: makeUrl
/**
* @param $id
* @param array $options
* @param array $args
*
* @return mixed|string
*/
public function makeUrl($id, $options = array(), $args = array())
{
$scheme = !empty($options['scheme']) ? $options['scheme'] : $this->config['scheme'];
if (strtolower($scheme) == 'uri' && !empty($options['uri'])) {
$url = $options['uri'];
if (!empty($args)) {
if (is_array($args)) {
$args = rtrim(modX::toQueryString($args), '?&');
}
$url .= strpos($url, '?') !== false ? '&' : '?';
$url .= ltrim(trim($args), '?&');
}
} else {
if (!empty($options['context_key'])) {
$context = $options['context_key'];
} elseif (!empty($options['context'])) {
$context = $options['context'];
} else {
$context = '';
}
if (strtolower($scheme) == 'uri') {
$scheme = -1;
}
$url = $this->modx->makeUrl($id, $context, $args, $scheme, $options);
}
return $url;
}
示例5: _cleanResourceIdentifier
/**
* Cleans the resource identifier from the request params.
*
* @param string $identifier The raw identifier.
* @return string|integer The cleansed identifier.
*/
public function _cleanResourceIdentifier($identifier)
{
if (empty($identifier)) {
$identifier = $this->modx->getOption('site_start', null, 1);
$this->modx->resourceMethod = 'id';
} elseif ($this->modx->getOption('friendly_urls', null, false) && ($this->modx->resourceMethod = 'alias')) {
$containerSuffix = trim($this->modx->getOption('container_suffix', null, ''));
if (!isset($this->modx->aliasMap[$identifier])) {
if (!empty($containerSuffix)) {
$suffixPos = strpos($identifier, $containerSuffix);
$suffixLen = strlen($containerSuffix);
$identifierLen = strlen($identifier);
if (substr($identifier, $identifierLen - $suffixLen) === $containerSuffix) {
$identifier = substr($identifier, 0, $identifierLen - $suffixLen);
} elseif (isset($this->modx->aliasMap["{$identifier}{$containerSuffix}"])) {
$identifier = "{$identifier}{$containerSuffix}";
}
if (isset($this->modx->aliasMap[$identifier])) {
$url = $this->modx->makeUrl($this->modx->aliasMap[$identifier], '', '', 'full');
$this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
$this->modx->resourceMethod = 'alias';
}
} elseif ($this->modx->getOption('site_start', null, 1) == $this->modx->aliasMap[$identifier]) {
$this->modx->sendRedirect($this->modx->getOption('site_url', null, MODX_SITE_URL), array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
} else {
$this->modx->resourceMethod = 'alias';
}
} else {
$this->modx->resourceMethod = 'id';
}
return $identifier;
}
示例6: makeUrl
/**
* @param $id
* @param string $context
* @param string $args
* @param int $scheme
* @param array $options
*
* @return string
*/
public function makeUrl($id, $context = '', $args = '', $scheme = -1, array $options = array())
{
$this->debugParser('makeUrl', $id, $args);
$result = $this->modx->makeUrl($id, $context, $args, $scheme, $options);
$this->debugParser('makeUrl', $id, $args);
return $result;
}
示例7: redirect
/**
* Redirect to a specified URL.
*
* Properties needed:
* - redirectTo - the ID of the Resource to redirect to.
*
* @param array $fields An array of cleaned POST fields
* @return boolean False if unsuccessful.
*/
public function redirect(array $fields = array())
{
if (empty($this->formit->config['redirectTo'])) {
return false;
}
$redirectParams = !empty($this->formit->config['redirectParams']) ? $this->formit->config['redirectParams'] : '';
if (!empty($redirectParams)) {
$prefix = $this->modx->getOption('placeholderPrefix', $this->formit->config, 'fi.');
$this->modx->setPlaceholders($fields, $prefix);
$this->modx->parser->processElementTags('', $redirectParams, true, true);
$redirectParams = $this->modx->fromJSON($redirectParams);
if (empty($redirectParams)) {
$redirectParams = '';
}
}
$contextKey = $this->modx->context->get('key');
$resource = $this->modx->getObject('modResource', $this->formit->config['redirectTo']);
if ($resource) {
$contextKey = $resource->get('context_key');
}
if (!is_numeric($this->formit->config['redirectTo']) && isset($fields[$this->formit->config['redirectTo']]) && is_numeric($fields[$this->formit->config['redirectTo']])) {
$url = $this->modx->makeUrl($fields[$this->formit->config['redirectTo']], $contextKey, $redirectParams, 'full');
} elseif (!is_numeric($this->formit->config['redirectTo']) && substr($this->formit->config['redirectTo'], 0, 4) === "http") {
$url = $this->formit->config['redirectTo'];
} else {
$url = $this->modx->makeUrl($this->formit->config['redirectTo'], $contextKey, $redirectParams, 'full');
}
$this->setRedirectUrl($url);
return true;
}
示例8: redirect
/**
* Redirect to a specified URL.
*
* Properties needed:
* - redirectTo - the ID of the Resource to redirect to.
*
* @param array $fields An array of cleaned POST fields
* @return boolean False if unsuccessful.
*/
public function redirect(array $fields = array())
{
if (empty($this->login->config['redirectTo'])) {
return false;
}
$url = $this->modx->makeUrl($this->login->config['redirectTo'], '', '', 'abs');
return $this->modx->sendRedirect($url);
}
示例9: _cleanResourceIdentifier
/**
* Cleans the resource identifier from the request params.
*
* @param string $identifier The raw identifier.
* @return string|integer The cleansed identifier.
*/
public function _cleanResourceIdentifier($identifier)
{
if (empty($identifier)) {
if ($this->modx->getOption('base_url', null, MODX_BASE_URL) !== strtok($_SERVER["REQUEST_URI"], '?')) {
$this->modx->sendRedirect($this->modx->getOption('site_url', null, MODX_SITE_URL), array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
$identifier = $this->modx->getOption('site_start', null, 1);
$this->modx->resourceMethod = 'id';
} elseif ($this->modx->getOption('friendly_urls', null, false) && $this->modx->resourceMethod == 'alias') {
$containerSuffix = trim($this->modx->getOption('container_suffix', null, ''));
$found = $this->modx->findResource($identifier);
if ($found === false && !empty($containerSuffix)) {
$suffixLen = strlen($containerSuffix);
$identifierLen = strlen($identifier);
if (substr($identifier, $identifierLen - $suffixLen) === $containerSuffix) {
$identifier = substr($identifier, 0, $identifierLen - $suffixLen);
$found = $this->modx->findResource($identifier);
} else {
$identifier = "{$identifier}{$containerSuffix}";
$found = $this->modx->findResource("{$identifier}{$containerSuffix}");
}
if ($found) {
$parameters = $this->getParameters();
unset($parameters[$this->modx->getOption('request_param_alias')]);
$url = $this->modx->makeUrl($found, $this->modx->context->get('key'), $parameters, 'full');
$this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
$this->modx->resourceMethod = 'alias';
} elseif ((int) $this->modx->getOption('site_start', null, 1) === $found) {
$parameters = $this->getParameters();
unset($parameters[$this->modx->getOption('request_param_alias')]);
$url = $this->modx->makeUrl($this->modx->getOption('site_start', null, 1), $this->modx->context->get('key'), $parameters, 'full');
$this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
} else {
if ($this->modx->getOption('friendly_urls_strict', null, false)) {
$requestUri = $_SERVER['REQUEST_URI'];
$qsPos = strpos($requestUri, '?');
if ($qsPos !== false) {
$requestUri = substr($requestUri, 0, $qsPos);
}
$fullId = $this->modx->getOption('base_url', null, MODX_BASE_URL) . $identifier;
$requestUri = urldecode($requestUri);
if ($fullId !== $requestUri && strpos($requestUri, $fullId) !== 0) {
$parameters = $this->getParameters();
unset($parameters[$this->modx->getOption('request_param_alias')]);
$url = $this->modx->makeUrl($found, $this->modx->context->get('key'), $parameters, 'full');
$this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
}
$this->modx->resourceMethod = 'alias';
}
} else {
$this->modx->resourceMethod = 'id';
}
return $identifier;
}
示例10: templateBranch
/**
* Recursive template of branch of menu
*
* @param array $row
*
* @return mixed|string
*/
public function templateBranch($row = array())
{
$children = '';
$row['level'] = $this->level;
if (!empty($row['children']) && ($this->isHere($row['id']) || empty($this->pdoTools->config['hideSubMenus'])) && $this->checkResource($row['id'])) {
$idx = 1;
$this->level++;
$count = count($row['children']);
foreach ($row['children'] as $v) {
$v['idx'] = $idx++;
$v['last'] = (int) $v['idx'] == $count;
$children .= $this->templateBranch($v);
}
$this->level--;
$row['children'] = $count;
} else {
$row['children'] = isset($row['children']) ? count($row['children']) : 0;
}
if (!empty($this->pdoTools->config['countChildren'])) {
if ($ids = $this->modx->getChildIds($row['id'])) {
$tstart = microtime(true);
$count = $this->modx->getCount('modResource', array('id:IN' => $ids, 'published' => true, 'deleted' => false));
$this->modx->queryTime += microtime(true) - $tstart;
$this->modx->executedQueries++;
$this->pdoTools->addTime('Got the number of active children for resource "' . $row['id'] . '": ' . $count);
} else {
$count = 0;
}
$row['children'] = $count;
}
if (!empty($children)) {
$pls = $this->addWayFinderPlaceholders(array('wrapper' => $children, 'classes' => ' class="' . $this->pdoTools->config['innerClass'] . '"', 'classNames' => $this->pdoTools->config['innerClass'], 'classnames' => $this->pdoTools->config['innerClass'], 'level' => $this->level));
$row['wrapper'] = $this->pdoTools->parseChunk($this->pdoTools->config['tplInner'], $pls);
} else {
$row['wrapper'] = '';
}
if (empty($row['menutitle']) && !empty($row['pagetitle'])) {
$row['menutitle'] = $row['pagetitle'];
}
$classes = $this->getClasses($row);
if (!empty($classes)) {
$row['classNames'] = $row['classnames'] = $classes;
$row['classes'] = ' class="' . $classes . '"';
} else {
$row['classNames'] = $row['classnames'] = $row['classes'] = '';
}
if (!empty($this->pdoTools->config['useWeblinkUrl']) && $row['class_key'] == 'modWebLink') {
$row['link'] = is_numeric(trim($row['content'], '[]~ ')) ? $this->modx->makeUrl(intval(trim($row['content'], '[]~ ')), '', '', $this->pdoTools->config['scheme']) : $row['content'];
} else {
$row['link'] = $this->modx->makeUrl($row['id'], $row['context_key'], '', $this->pdoTools->config['scheme']);
}
$row['title'] = !empty($this->pdoTools->config['titleOfLinks']) ? $row[$this->pdoTools->config['titleOfLinks']] : '';
$tpl = $this->getTpl($row);
$row = $this->addWayFinderPlaceholders($row);
return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']);
}
示例11: formatUrlReferrer
/** @inheritdoc} */
public function formatUrlReferrer($id = 0)
{
$clientKey = $this->MlmSystem->getOption('client_key', null, 'rclient');
$referrerKey = $this->MlmSystem->getOption('referrer_key', null, 'rhash');
$contextKey = $this->MlmSystem->getOption('ctx', null, $this->MlmSystem->getOption('referrer_context'), true);
$referrerPage = $this->MlmSystem->getOption('referrer_page', null, $this->modx->getOption('site_start'));
if (empty($referrerPage)) {
$referrerPage = $this->modx->getOption('site_start');
}
$params = array($clientKey => $id, $referrerKey => $this->formatHashReferrer($id));
$url = $this->modx->makeUrl($referrerPage, $contextKey, $params, 'full');
return $url;
}
示例12: initialize
/**
* Load all config files and prepare the values.
*
* @access public
* @return void
*/
public function initialize()
{
// TODO: Caching of these calculated values.
$configFiles = glob($this->config['configsPath'] . '*.config.inc.php');
// import config files
foreach ($configFiles as $configFile) {
// $settings will be defined in each config file
$settings = array();
include $configFile;
foreach ($settings as $setting) {
// fill urlParams if defined
$urlParams = isset($setting['urlParams']) && is_array($setting['urlParams']) ? $setting['urlParams'] : array();
$regEx = isset($setting['regEx']) && is_array($setting['regEx']) ? $setting['regEx'] : FALSE;
if (isset($setting['alias'])) {
// if alias is defined, calculate the other values
if (isset($setting['resourceId'])) {
$resourceId = $setting['resourceId'];
} elseif ($res = $this->modx->getObject('modResource', array('uri' => $setting['alias']))) {
$resourceId = $res->get('id');
} else {
// if resourceId could not be calculated, don't use that setting
if ($this->config['debug']) {
$modx->log(modX::LOG_LEVEL_INFO, 'CustomRequest Plugin: Could not calculate the resourceId for the given alias');
}
break;
}
$alias = $setting['alias'];
} elseif (isset($setting['resourceId'])) {
// else if resourceId is defined, calculate the other values
$resourceId = $setting['resourceId'];
if (isset($setting['alias'])) {
$alias = $setting['alias'];
} elseif ($url = $this->modx->makeUrl($setting['resourceId'])) {
$alias = $url;
} else {
// if alias could not be calculated, don't use that setting
if ($this->config['debug']) {
$modx->log(modX::LOG_LEVEL_INFO, 'CustomRequest Plugin: Could not calculate the alias for the given resourceId');
}
break;
}
}
$this->requests[$alias] = array('resourceId' => $resourceId, 'alias' => $alias, 'urlParams' => $urlParams, 'regEx' => $regEx);
}
}
return;
}
示例13: templateBranch
/**
* Recursive template of branch of menu
*
* @param array $row
*
* @return mixed|string
*/
public function templateBranch($row = array())
{
$children = '';
$row['level'] = $this->level;
if (!empty($row['children']) && ($this->isHere($row['id']) || empty($this->pdoTools->config['hideSubMenus'])) && $this->checkResource($row['id'])) {
$idx = 1;
$this->level++;
$count = count($row['children']);
foreach ($row['children'] as $v) {
$v['idx'] = $idx++;
$v['last'] = (int) $v['idx'] == $count;
$children .= $this->templateBranch($v);
}
$this->level--;
$row['children'] = $count;
} else {
$row['children'] = 0;
}
if (!empty($children)) {
$pls = $this->addWayFinderPlaceholders(array('wrapper' => $children, 'classes' => ' class="' . $this->pdoTools->config['innerClass'] . '"', 'classNames' => $this->pdoTools->config['innerClass'], 'classnames' => $this->pdoTools->config['innerClass']));
$row['wrapper'] = $this->pdoTools->parseChunk($this->pdoTools->config['tplInner'], $pls);
} else {
$row['wrapper'] = '';
}
if (empty($row['menutitle']) && !empty($row['pagetitle'])) {
$row['menutitle'] = $row['pagetitle'];
}
$classes = $this->getClasses($row);
if (!empty($classes)) {
$row['classNames'] = $row['classnames'] = $classes;
$row['classes'] = ' class="' . $classes . '"';
} else {
$row['classNames'] = $row['classnames'] = $row['classes'] = '';
}
if (!empty($this->pdoTools->config['useWeblinkUrl']) && $row['class_key'] == 'modWebLink') {
$row['link'] = is_numeric(trim($row['content'], '[]~ ')) ? $this->modx->makeUrl(intval(trim($row['content'], '[]~ ')), $row['context_key'], '', $this->pdoTools->config['scheme']) : $row['content'];
} else {
$row['link'] = $this->modx->makeUrl($row['id'], $row['context_key'], '', $this->pdoTools->config['scheme']);
}
$row['title'] = !empty($this->pdoTools->config['titleOfLinks']) ? $row[$this->pdoTools->config['titleOfLinks']] : '';
$tpl = $this->getTpl($row);
$row = $this->addWayFinderPlaceholders($row);
return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']);
}
示例14: redirect
/**
* Redirect to a specified URL.
*
* Properties needed:
* - redirectTo - the ID of the Resource to redirect to.
*
* @param array $fields An array of cleaned POST fields
* @return boolean False if unsuccessful.
*/
public function redirect(array $fields = array())
{
if (empty($this->quip->config['redirectTo'])) {
return false;
}
$redirectParams = !empty($this->quip->config['redirectParams']) ? $this->quip->config['redirectParams'] : '';
if (!empty($redirectParams)) {
$prefix = $this->modx->getOption('placeholderPrefix', $this->quip->config, 'fi.');
$this->modx->setPlaceholders($fields, $prefix);
$this->modx->parser->processElementTags('', $redirectParams, true, true);
$redirectParams = $this->modx->fromJSON($redirectParams);
if (empty($redirectParams)) {
$redirectParams = '';
}
}
$url = $this->modx->makeUrl($this->quip->config['redirectTo'], '', $redirectParams, 'abs');
$this->setRedirectUrl($url);
return true;
}
示例15: fenomFunction
/**
* @param $method
* @param array $params
*
* @return string
*/
public function fenomFunction($method, array $params)
{
if (empty($params[0])) {
return '';
}
$result = '';
switch ($method) {
case 'lexicon':
$key = array_shift($params);
if (!empty($params[0]) && is_array($params[0])) {
$properties = $params[0];
$topic = !empty($properties['topic']) ? $properties['topic'] : 'default';
$namespace = !empty($properties['namespace']) ? $properties['namespace'] : 'core';
$language = !empty($properties['language']) ? $properties['language'] : $this->modx->getOption('cultureKey', null, 'en');
$this->modx->lexicon->load($language . ':' . $namespace . ':' . $topic);
}
$placeholders = !empty($params[1]) && is_array($params[1]) ? $params[1] : array();
$result = $this->modx->lexicon($key, $placeholders);
break;
case 'url':
$id = trim(array_shift($params), '[]~');
if (is_numeric($id)) {
$context = $this->modx->context->get('key');
$scheme = $this->modx->getOption('link_tag_scheme', null, -1);
$options = array();
if (!empty($params[0]) && is_array($params[0])) {
$options = $params[0];
if (isset($options['context'])) {
$context = $options['context'];
unset($options['context']);
}
if (isset($options['scheme'])) {
$scheme = $options['scheme'];
unset($options['scheme']);
}
}
$args = !empty($params[1]) && is_array($params[1]) ? $params[1] : array();
$result = $this->modx->makeUrl($id, $context, $args, $scheme, $options);
}
break;
}
return $result;
}