本文整理汇总了PHP中Mapper::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapper::url方法的具体用法?PHP Mapper::url怎么用?PHP Mapper::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: link
public function link($text, $url = null, $attr = array(), $full = false)
{
if (is_null($url)) {
$url = $text;
}
$attr['href'] = Mapper::url($url, $full);
return $this->tag('a', $text, $attr);
}
示例2: create
public function create($action = null, $options = array())
{
$options += array('method' => 'post', 'action' => Mapper::url($action));
if ($options['method'] == 'file') {
$options['method'] = 'post';
$options['enctype'] = 'multipart/form-data';
}
return $this->html->openTag('form', $options);
}
示例3: asset
public function asset($url, $name, $extension = null)
{
if (!Mapper::isExternal($url)) {
if (!is_null($extension)) {
$url = $this->extension($url, $extension);
}
$url = Mapper::url($url, false, self::$assets[$name]);
}
return $url;
}
示例4: asset
public function asset($url, $type, $extension = null)
{
if (!$this->external($url)) {
if (!is_null($extension)) {
$url = $this->extension($url, $extension);
}
$url = Mapper::url(self::$assets[$type] . $url);
}
return $url;
}
示例5: submit
/**
* Cria um botão de envio dos dados do formulário.
*
* @param string $submit Nome do botão de envio
* @param array $attributes Atributos e opções da tag
* @return string Botão de envio do formulário
*/
public function submit($text, $attributes = array())
{
$attributes = array_merge(array("type" => "submit", "tag" => "button"), $attributes);
switch (array_unset($attributes, "tag")) {
case "image":
$attributes["alt"] = $text;
$attributes["type"] = "image";
if (!$this->external($attributes["src"])) {
$attributes["src"] = Mapper::url("/images/" . $attributes["src"]);
}
case "input":
$attributes["value"] = $text;
$button = $this->tag("input", null, $attributes, false);
break;
default:
$button = $this->tag("button", $text, $attributes);
}
return $this->output($button);
}
示例6: menu
public function menu($array = array())
{
$html = '<ul>' . PHP_EOL;
foreach ($array as $label => $link) {
$class = trim(Mapper::here(), '/') == trim($link, '/') ? ' class="selected" ' : '';
$class = Mapper::match($link) ? ' class="selected" ' : '';
$listclass = $this->applyClassOn == 'list' ? $class : '';
$html .= '<li' . $listclass . '>';
if (is_array($link)) {
$html .= $label;
$html .= $this->menu($link);
} else {
$linkclass = $this->applyClassOn == 'link' ? $class : '';
$html .= '<a href="' . Mapper::url($link) . $linkclass . '" >' . $label . '</a>';
}
$html .= '</li>' . PHP_EOL;
}
$html .= '</ul>' . PHP_EOL;
return $html;
}
示例7: __construct
/**
* @param string $blogURL The URL of your blog.
* @param string $wordPressAPIKey WordPress API key.
*/
public function __construct()
{
$this->blogURL = Mapper::url("", true);
//$this->wordPressAPIKey = $wordPressAPIKey;
// Set some default values
$this->apiPort = 80;
$this->akismetServer = 'rest.akismet.com';
$this->akismetVersion = '1.1';
// Start to populate the comment data
$this->comment['blog'] = $blogURL;
$this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
if (isset($_SERVER['HTTP_REFERER'])) {
$this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
}
/*
* This is necessary if the server PHP5 is running on has been set up to run PHP4 and
* PHP5 concurently and is actually running through a separate proxy al a these instructions:
* http://www.schlitt.info/applications/blog/archives/83_How_to_run_PHP4_and_PHP_5_parallel.html
* and http://wiki.coggeshall.org/37.html
* Otherwise the user_ip appears as the IP address of the PHP4 server passing the requests to the
* PHP5 one...
*/
$this->comment['user_ip'] = $_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR') ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
}
示例8: request
/**
* Centraliza o envio das requisições http
*
* @param string $url A url que receberá a requisição
* @param string $method O tipo de requisição. Ex.: POST, GET, etc
* @return mixed O resultado da requisição
*/
public static function request($url, $method)
{
$self = self::instance();
//Tipos de requisições e seus correspondentes no cURL
$methods = array('GET' => CURLOPT_HTTPGET, 'POST' => CURLOPT_POST);
//Existe no array $methods
if (array_key_exists($method, $methods)) {
$self->curlOptions[$methods[$method]] = true;
//Não existe, envia uma requisição customizada
} else {
$self->curlOptions[CURLOPT_CUSTOMREQUEST] = $method;
}
//Inicia a sessão curl
$ch = curl_init(Mapper::url($url, true));
//Traz o resultado como string, ao invés de jogá-lo diretamente na saída
$self->curlOptions[CURLOPT_RETURNTRANSFER] = true;
//Coloca os arrays como opções do curl
curl_setopt_array($ch, $self->curlOptions);
//Executa
$self->result = curl_exec($ch);
//Pega o código de cabeçalho retornado
$self->statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//Tipo do conteúdo retornado.
$self->contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
//info
$self->info = curl_getinfo($ch);
//Fecha a sessão curl
curl_close($ch);
//Retorna
return $self->result;
}
示例9: action
/**
* Adiciona a action tratada com o Mapper::url()
* $fluent->form()->action('/formularios')
*
* @return $this
*/
public function action($url)
{
$this->attr('action', Mapper::url($url));
return $this;
}
示例10: redirect
public function redirect($url, $status = null, $exit = true)
{
$this->render = false;
$codes = array(100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out');
if (!is_null($status) && isset($codes[$status])) {
header('HTTP/1.1 ' . $status . ' ' . $codes[$status]);
}
header('Location: ' . Mapper::url($url, true));
if ($exit) {
$this->stop();
}
}
示例11: internalUrl
public function internalUrl($path = "", $url = "", $full = false)
{
if (preg_match("/^[a-z]+:/", $url)) {
return $url;
} else {
return Mapper::url("{$path}/{$url}", $full);
}
}
示例12: testUrlWithFullReturn
public function testUrlWithFullReturn()
{
$results = Mapper::url("controller/action", true);
$expected = "/^http:\\/\\/(.*)\\/controller\\/action\$/";
$this->assertPattern($expected, $results);
}
示例13: aa
public function aa($text)
{
$pattern = '/(?<patten>\\[(?<function>img|url)(?:="(?<url>.*?)")?(?<attrs>.*?)\\](?<value>.*?)\\[\\/(?<retrovisor>(\\2))\\])/';
preg_match($pattern, $text, $output);
pr($output);
pr($output['function']);
if ($output['function'] == 'img') {
$url = Mapper::url($output['value']);
$replace = '<img src="' . $url . '" ' . $output['attrs'] . ' />';
} elseif ($output['function'] == 'url') {
$url = Mapper::url($output['url']);
if (empty($output['value'])) {
$output['value'] = $url;
}
$replace = '<a href="' . $url . '" ' . $output['attrs'] . '>' . $output['value'] . '</a>';
} else {
return $text;
}
return $this->aa(preg_replace($pattern, $replace, $text));
}
示例14: mapSmiles
private function mapSmiles($key, $smile)
{
return "<img src='" . Mapper::url($this->emoticons_path) . "/" . $smile . "' alt='" . $key . "'>";
}
示例15: script
/**
* Cria um elemento de script para ser usado no HTML.
*
* @param string $src Caminho do script a ser inseido no HTML
* @param array $attr Atributos da tag
* @param boolean $inline Verdadeiro para imprimir o script inline
* @param boolean $full Verdadeiro para gerar uma URL completa
* @return string Elemento de script a ser utilizado
*/
public function script($src = "", $attr = array(), $inline = true, $full = false)
{
if (is_array($src)) {
$output = "";
foreach ($src as $tag) {
$output .= $this->script($tag, $attr, true, $full) . PHP_EOL;
}
} else {
if (!$this->external($src)) {
$src = Mapper::url("/scripts/" . $this->extension($src, "js"), $full);
}
$attr = array_merge(array("src" => $src, "type" => "text/javascript"), $attr);
$output = $this->output($this->tag("script", null, $attr));
}
if ($inline) {
return $output;
} else {
$this->view->scriptsForLayout .= $output;
return true;
}
}