本文整理汇总了PHP中UrlHelper类的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper类的具体用法?PHP UrlHelper怎么用?PHP UrlHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UrlHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthorizationUserForm
private function getAuthorizationUserForm()
{
$urlHelper = new UrlHelper();
$this->form = '';
$this->form .= '<form class="AuthorizationForm" name="AuthorizationForm" action="' . $urlHelper->getThisPage() . '"
method="post" accept-charset="UTF-8" autocomplete="on">';
$this->form .= '<center>';
$this->form .= "<div class='AuthorizationFormBlock'>";
$this->form .= '<table class="AuthorizationFormTable" >';
$this->form .= '<tr>';
$this->form .= '<td>';
$this->form .= "<div class='AuthorizationFormLogin'></div>";
$this->form .= '</td>';
$this->form .= '<td>';
$this->form .= $this->inputHelper->paternTextBox("login", "login", "login", 25, true, $this->localization->getText("login"), "[A-Za-z0-9]{3,20}", null);
$this->form .= '</td>';
//$this->form .= '<td rowspan="2">';
//$this->form .= '</td>';
$this->form .= '</tr>';
$this->form .= '<tr>';
$this->form .= '<td>';
$this->form .= "<div class='AuthorizationFormPassword'></div>";
$this->form .= '</td>';
$this->form .= '<td>';
$this->form .= $this->inputHelper->paternPasswordBox("password", "password", "password", 25, true, $this->localization->getText("password"), "[A-Za-z0-9]{3,20}", null);
$this->form .= '</td>';
$this->form .= '</tr>';
$this->form .= '</tr>';
$this->form .= '</table>';
$this->form .= '<input class="AuthorizationFormButton" type="submit" name="AuthorizationFormSubmit" value="in" title="' . $this->localization->getText("authorizationFormText") . '">';
$this->form .= "</div>";
$this->form .= '</center>';
$this->form .= '</form>';
}
示例2: testAbsoluteLinkShouldCreateRequestFormGlobalsWhenNoRequestIsGiven
public function testAbsoluteLinkShouldCreateRequestFormGlobalsWhenNoRequestIsGiven()
{
$helper = new UrlHelper();
$_SERVER['HTTPS'] = 'on';
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['REQUEST_URI'] = '/webroot/test';
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['SCRIPT_NAME'] = '/webroot';
$this->assertEquals('https://localhost/webroot/page', $helper->absoluteLink('/page'));
}
示例3: generateHTML
private function generateHTML()
{
$this->getSliderData();
$out = '<div class="border_box">';
$out .= '<div class="box_skitter box_skitter_large ' . $this->name . '">';
$out .= '<ul>';
foreach ($this->data['slides'] as $slide) {
$html = "<li>";
// echo $this->sliderDir.$this->name.'/'.strtolower($this->thisLang).'/'.$slide['fileName']."<br>";
$img = '<img src="' . $this->sliderDir . $this->name . '/' . strtolower($this->thisLang) . '/' . $slide['fileName'] . '" class="' . $slide['animation'] . '" />';
$imgFile = $this->sliderDir . $this->name . '/' . strtolower($this->thisLang) . '/' . $slide['fileName'];
if (!file_exists($imgFile)) {
$imgFile = $this->sliderDir . $this->name . '/' . strtolower($this->defaultLang) . '/' . $slide['fileName'];
}
$img = '<img src="' . $imgFile . '" class="' . $slide['animation'] . '" />';
if (isset($slide['url']) && $slide['url'] != null && $slide['url'] != "") {
$urlHelper = new UrlHelper();
$target = "";
if (substr($slide['url'], 0, 1) == "#") {
$url = $urlHelper->getThisPage() . $slide['url'];
} else {
if (substr($slide['url'], 0, 1) == "\$") {
$url = $urlHelper->pageUrl(substr($slide['url'], 1), null);
} else {
if (substr($slide['url'], 0, 7) == "http://") {
$target = 'target="_blank"';
}
$url = $slide['url'];
}
}
$html .= '<a href="' . $url . ' ' . $target . '">';
$html .= $img;
$html .= '</a>';
} else {
$html .= $img;
}
if (isset($slide['text']) && $slide['text'] != null && $slide['text'] != "") {
$html .= '<div class="label_text">';
$html .= $slide['text'];
$html .= '</div>';
}
$html .= "</li>";
$out .= $html;
}
$out .= '</ul>';
$out .= '</div>';
$out .= '</div>';
$out .= $this->generateParams();
$this->html = $out;
}
示例4: generateMenuLevelHtml
private function generateMenuLevelHtml($parent)
{
$out = "";
if (isset($this->menuItems[$parent]) && count($this->menuItems[$parent]) > 0) {
if ($parent != 0) {
$javaID = $this->menuName . "_child_" . $parent;
$out .= "<ul id='" . $javaID . "' style='display: none;' ";
$out .= "class='menu child_menu " . $this->menuType . " ";
$out .= $this->menuCssClass . " " . $this->menuName . "' ";
$out .= "onmouseover=\"showChildMenu('{$javaID}');\" ";
$out .= "onmouseout=\"hideChildMenu('{$javaID}');\">";
} else {
$out .= "<ul id='" . $this->menuName . "' class='menu ";
$out .= $this->menuType . " " . $this->menuCssClass . " ";
$out .= $this->menuName . "'>";
}
foreach ($this->menuItems[$parent] as $menuItem) {
if ($this->checkValue($menuItem['url'])) {
$url = $menuItem['url'];
} else {
$urlHelper = new UrlHelper();
if ($menuItem['postfix'][0] == "/") {
$menuItem['postfix'] = substr($menuItem['postfix'], 1);
}
$url = $urlHelper->pageUrl($menuItem['page'], null) . $menuItem['postfix'];
}
global $_URL_PARAMS;
$thisPageClass = "";
if ($menuItem['page'] == $_URL_PARAMS['page']) {
$thisPageClass = "thisPage";
}
$javaChildID = $this->menuName . "_child_" . $menuItem['menuItem'];
// $out .= "<a href='$url' target='".$menuItem['target']."'>";
$out .= "<li onmouseover=\"showChildMenu('{$javaChildID}');\" onmouseout=\"hideChildMenu('{$javaChildID}');\" ";
$out .= "class='{$thisPageClass}'>";
$out .= "<a href='{$url}' target='" . $menuItem['target'] . "'>";
$out .= "<span text='text'>";
$out .= $menuItem['title'];
$out .= "</span>";
$out .= "</a>";
$out .= "</li>";
// $out .= "</a>";
$out .= $this->generateMenuLevelHtml($menuItem['menuItem']);
}
$out .= "</ul>";
}
return $out;
}
示例5: getInputHtml
/**
* Returns the field's input HTML.
*
* @param string $name
* @param mixed $value
* @return string
*/
public function getInputHtml($name, $value)
{
$id = craft()->templates->formatInputId($name);
craft()->templates->includeCssResource('twitter/css/tweet.css');
craft()->templates->includeJsResource('twitter/js/TweetInput.js');
craft()->templates->includeJs('new TweetInput("' . craft()->templates->namespaceInputId($id) . '");');
$tweet = $value;
$html = "";
if ($tweet && isset($tweet['id_str'])) {
$url = 'https://twitter.com/' . $tweet['user']['screen_name'] . '/status/' . $tweet['id_str'];
if (craft()->request->isSecureConnection()) {
$profileImageUrl = $tweet['user']['profile_image_url_https'];
} else {
$profileImageUrl = $tweet['user']['profile_image_url'];
}
if (craft()->twitter_plugin->checkDependencies()) {
$html .= '<div class="tweet-preview">' . '<div class="tweet-image" style="background-image: url(' . $profileImageUrl . ');"></div> ' . '<div class="tweet-user">' . '<span class="tweet-user-name">' . $tweet['user']['name'] . '</span> ' . '<a class="tweet-user-screenname light" href="http://twitter.com/' . $tweet['user']['screen_name'] . '" target="_blank">@' . $tweet['user']['screen_name'] . '</a>' . '</div>' . '<div class="tweet-text">' . $tweet['text'] . '</div>' . '</div>';
}
} else {
$url = $value;
$preview = '';
}
if (!craft()->twitter_plugin->checkDependencies()) {
$html .= '<p class="light">' . Craft::t("Twitter plugin is not configured properly. Please check {url} for more informations.", array('url' => Craft::t('<a href="' . UrlHelper::getUrl('twitter/settings') . '">{title}</a>', array('title' => 'Twitter plugin settings')))) . '</p>';
}
return '<div class="tweet">' . craft()->templates->render('_includes/forms/text', array('id' => $id, 'name' => $name, 'value' => $url, 'placeholder' => Craft::t('Enter a tweet URL or ID'))) . '<div class="spinner hidden"></div>' . $html . '</div>';
}
示例6: getCpEditUrl
public function getCpEditUrl()
{
$form = $this->getForm();
if ($form) {
return UrlHelper::getCpUrl('formerly/' . $form->handle . '/' . $this->id);
}
}
示例7: addResources
protected function addResources()
{
// Get revision manifest
$manifestPath = dirname(__FILE__) . '/resources/rev-manifest.json';
$manifest = file_exists($manifestPath) && ($manifest = file_get_contents($manifestPath)) ? json_decode($manifest) : false;
// Get data
$data = ['fields' => [], 'entryTypeIds' => [], 'baseEditFieldUrl' => rtrim(UrlHelper::getCpUrl('settings/fields/edit'), '/'), 'baseEditEntryTypeUrl' => rtrim(UrlHelper::getCpUrl('settings/sections/sectionId/entrytypes'), '/'), 'baseEditGlobalSetUrl' => rtrim(UrlHelper::getCpUrl('settings/globals'), '/'), 'baseEditCategoryGroupUrl' => rtrim(UrlHelper::getCpUrl('settings/categories'), '/')];
$sectionIds = craft()->sections->allSectionIds;
foreach ($sectionIds as $sectionId) {
$entryTypes = craft()->sections->getEntryTypesBySectionId($sectionId);
$data['entryTypeIds']['' . $sectionId] = [];
foreach ($entryTypes as $entryType) {
$data['entryTypeIds']['' . $sectionId][] = $entryType->id;
}
}
$fields = craft()->fields->allFields;
foreach ($fields as $field) {
$data['fields'][$field->handle] = ['id' => $field->id, 'handle' => $field->handle, 'type' => $field->type];
}
$data = json_encode($data);
craft()->templates->includeJs('window._CpFieldLinksData=' . $data . ';');
// Include resources
$cssFile = 'stylesheets/CpFieldLinks.css';
$jsFile = 'javascripts/CpFieldLinks.js';
craft()->templates->includeCssResource('cpfieldlinks/' . ($manifest ? $manifest->{$cssFile} : $cssFile));
craft()->templates->includeJsResource('cpfieldlinks/' . ($manifest ? $manifest->{$jsFile} : $jsFile));
}
示例8: post
function post()
{
$blog_post_id = $this->node->arg('blog_post_id');
$values = array();
$form = $this->components->add('form', array('back' => $this->db->from('blog_post')->select('title')));
$author_id = $this->db->from('blog_author')->select('blog_author_id')->where('user_id', $this->plugin->Auth->get('user_id'))->fetchScalar();
$blog_post = $form->addTable('blog_post', array('title' => array('validator' => $this->valid->get('required', 'no_html')), 'content' => array('validator' => $this->valid->required), 'blog_author_id' => array('value' => $author_id), 'blog_id' => array('value' => $this->node->arg('blog_id')), 'pub_date' => array('value' => date('Y-m-d H:i:s')), 'summary' => array('validator' => $this->valid->required), 'status' => array('validator' => $this->valid->required), 'blog_category_id' => array('type' => 'dropdown', 'validator' => $this->valid->required)));
$plugins = $blog_post->content->getConfigOption('plugins');
$blog_post->content->setConfigOption('plugins', $plugins . ',table,pagebreak,markettoimages');
$blog_post->content->setConfigOption('pagebreak_separator', '<!-- Break -->');
$blog_post->content->setConfigOption('height', 600);
$blog_post->content->setConfigOption('theme_advanced_blockformats', "p,pre,h1,h2,h3,h4,blockquote,code");
$blog_post->content->setConfigOption('content_css', UrlHelper::resource('/blog/tinymce.css'));
$blog_post->content->setConfigOption('theme_advanced_buttons1_add', 'pagebreak,markettoimages');
$blog_post->content->setConfigOption('theme_advanced_buttons2', 'tablecontrols');
$blog_post->content->setConfigOption('valid_elements', '*[*]');
$blog_post->content->filter_html = false;
$blog_post->blog_category_id->setDataSource($this->db->from('blog_category')->select('blog_category_id', 'name')->where('blog_id', $this->node->arg('blog_id'))->orderby('name', 'asc'));
$blog_post->blog_category_id->add('', $this->lang->categories['select']);
$blog_post->status->setDataSource($this->lang->status);
$blog_post_tag = $form->addTable('blog_post_tag', array('blog_tag_id' => array('type' => '/blog/taglist')), array('keys' => array('blog_post_id' => $blog_post), 'delete' => array('blog_post_id' => $blog_post), 'multirow' => true, 'multicolumn' => true));
$blog_post_tag->blog_post_id->setReference($blog_post->blog_post_id, true);
$blog_post_tag->blog_tag_id->setNote($this->lang->fields['separated']);
if ($blog_post_id) {
$values = $this->db->from('blog_post')->where('blog_post_id', $blog_post_id)->fetchRow();
$form->setValues($blog_post, $values);
$values = $this->db->from('blog_post_tag')->select('blog_tag_id')->where('blog_post_id', $blog_post_id)->fetchArray();
$form->setValues($blog_post_tag, array('blog_tag_id' => $values));
}
}
示例9: actionEditSource
/**
* Edit an asset source.
*
* @param array $variables
*
* @throws HttpException
* @return null
*/
public function actionEditSource(array $variables = array())
{
if (empty($variables['source'])) {
if (!empty($variables['sourceId'])) {
$variables['source'] = craft()->assetSources->getSourceById($variables['sourceId']);
if (!$variables['source']) {
throw new HttpException(404);
}
$variables['sourceType'] = craft()->assetSources->populateSourceType($variables['source']);
} else {
$variables['source'] = new AssetSourceModel();
$variables['sourceType'] = craft()->assetSources->getSourceType('Local');
}
}
if (empty($variables['sourceType'])) {
$variables['sourceType'] = craft()->assetSources->populateSourceType($variables['source']);
}
if (craft()->getEdition() == Craft::Pro) {
$sourceTypes = craft()->assetSources->getAllSourceTypes();
$variables['sourceTypes'] = AssetSourceTypeVariable::populateVariables($sourceTypes);
}
$variables['isNewSource'] = !$variables['source']->id;
if ($variables['isNewSource']) {
$variables['title'] = Craft::t('Create a new asset source');
} else {
$variables['title'] = $variables['source']->name;
}
$variables['crumbs'] = array(array('label' => Craft::t('Settings'), 'url' => UrlHelper::getUrl('settings')), array('label' => Craft::t('Assets'), 'url' => UrlHelper::getUrl('settings/assets')), array('label' => Craft::t('Asset Sources'), 'url' => UrlHelper::getUrl('settings/assets')));
$variables['tabs'] = array('settings' => array('label' => Craft::t('Settings'), 'url' => '#assetsource-settings'), 'fieldlayout' => array('label' => Craft::t('Field Layout'), 'url' => '#assetsource-fieldlayout'));
$this->renderTemplate('settings/assets/sources/_edit', $variables);
}
示例10: includeCpResources
/**
* Includes the plugin's resources for the Control Panel.
*/
protected function includeCpResources()
{
// Prepare config
$config = [];
$config['iconMapping'] = craft()->config->get('iconMapping', 'redactoriconbuttons');
$iconAdminPath = craft()->path->getConfigPath() . 'redactoriconbuttons/icons.svg';
$iconPublicPath = craft()->config->get('iconFile', 'redactoriconbuttons');
if (IOHelper::fileExists($iconAdminPath)) {
$config['iconFile'] = UrlHelper::getResourceUrl('config/redactoriconbuttons/icons.svg');
} elseif ($iconPublicPath) {
$config['iconFile'] = craft()->config->parseEnvironmentString($iconPublicPath);
} else {
$config['iconFile'] = UrlHelper::getResourceUrl('redactoriconbuttons/icons/redactor-i.svg');
}
// Include JS
$config = JsonHelper::encode($config);
$js = "var RedactorIconButtons = {}; RedactorIconButtons.config = {$config};";
craft()->templates->includeJs($js);
craft()->templates->includeJsResource('redactoriconbuttons/redactoriconbuttons.js');
// Include CSS
craft()->templates->includeCssResource('redactoriconbuttons/redactoriconbuttons.css');
// Add external spritemap support for IE9+ and Edge 12
$ieShim = craft()->config->get('ieShim', 'redactoriconbuttons');
if (filter_var($ieShim, FILTER_VALIDATE_BOOLEAN)) {
craft()->templates->includeJsResource('redactoriconbuttons/lib/svg4everybody.min.js');
craft()->templates->includeJs('svg4everybody();');
}
}
示例11: getPageUrl
/**
* Returns the URL to a specific page
*
* @param int $page
*
* @return string|null
*/
public function getPageUrl($page)
{
if ($page >= 1 && $page <= $this->totalPages) {
$path = craft()->request->getPath();
$params = array();
if ($page != 1) {
$pageTrigger = craft()->config->get('pageTrigger');
if (!is_string($pageTrigger) || !strlen($pageTrigger)) {
$pageTrigger = 'p';
}
// Is this query string-based pagination?
if ($pageTrigger[0] === '?') {
$pageTrigger = trim($pageTrigger, '?=');
if ($pageTrigger === 'p') {
// Avoid conflict with the main 'p' param
$pageTrigger = 'pg';
}
$params = array($pageTrigger => $page);
} else {
if ($path) {
$path .= '/';
}
$path .= $pageTrigger . $page;
}
}
return UrlHelper::getUrl($path, $params);
}
}
示例12: getInputHtml
public function getInputHtml($name, $value)
{
// Include JavaScript & CSS
craft()->templates->includeJsResource('simplemeta/simple.meta.js');
craft()->templates->includeCssResource('simplemeta/simple.meta.css');
// Whether any assets sources exist
$sources = craft()->assets->findFolders();
$variables['assetsSourceExists'] = count($sources);
// URL to create a new assets source
$variables['newAssetsSourceUrl'] = UrlHelper::getUrl('settings/assets/sources/new');
if (!empty($value)) {
$simpleMetaModel = SimpleMeta_SimpleMetaModel::populateModel($value);
} else {
$simpleMetaModel = new SimpleMeta_SimpleMetaModel();
$simpleMetaModel->handle = $name;
}
// Set assets
$simplemetaAssets = array('socialOGImage' => $simpleMetaModel->socialOGImageId, 'socialTwitterGalleryImages' => $simpleMetaModel->socialTwitterGalleryImagesId, 'socialTwitterPhoto' => $simpleMetaModel->socialTwitterPhotoId, 'socialTwitterProductImage' => $simpleMetaModel->socialTwitterProductImageId, 'socialTwitterSummaryImage' => $simpleMetaModel->socialTwitterSummaryImageId, 'socialTwitterSummaryLargeImage' => $simpleMetaModel->socialTwitterSummaryLargeImageId);
foreach ($simplemetaAssets as $key => $value) {
if ($value) {
$asset = craft()->elements->getElementById($value);
$variables[$key . 'Elements'] = array($asset);
$variables[$key . 'Id'] = $asset->id;
} else {
$variables[$key . 'Elements'] = array();
$variables[$key . 'Id'] = "";
}
}
// Set element type
$variables['elementType'] = craft()->elements->getElementType(ElementType::Asset);
$data = array_merge($simpleMetaModel->getAttributes(), $variables);
return craft()->templates->render('simplemeta/input', $data);
}
示例13: runStep
/**
* @inheritDoc ITask::runStep()
*
* @param int $step
*
* @return bool
*/
public function runStep($step)
{
// NOTE: Perhaps much of this should be moved into a service
$batch = \Guzzle\Batch\BatchBuilder::factory()->transferRequests(20)->bufferExceptions()->build();
// Make the client
$client = new \Guzzle\Http\Client();
// Set the Accept header
$client->setDefaultOption('headers/Accept', '*/*');
// Loop the paths in this step
foreach ($this->_paths[$step] as $path) {
// Make the url, stripping 'site:' from the path if it exists
$newPath = preg_replace('/site:/', '', $path, 1);
$url = UrlHelper::getSiteUrl($newPath);
// Create the GET request
$request = $client->get($url);
// Add it to the batch
$batch->add($request);
}
// Flush the queue and retrieve the flushed items
$requests = $batch->flush();
// Log any exceptions
foreach ($batch->getExceptions() as $e) {
Craft::log('CacheMonster: an exception occurred: ' . $e->getMessage(), LogLevel::Error);
}
// Clear any exceptions
$batch->clearExceptions();
return true;
}
示例14: admin_setup
function admin_setup()
{
if ($this->layout) {
$this->layout = $this->load->layout('admin');
}
$default_utility = '/' . DEFAULT_MODULE . '/admin/' . DEFAULT_MODULE . 'admin';
if (!file_exists(APPD_APPLICATION . '/' . DEFAULT_MODULE . '/admin/' . DEFAULT_MODULE . 'admin.utility.php')) {
$default_utility = '/admin/admin/adminadmin';
}
$util = $this->load->utility($default_utility);
$path = $util ? DEFAULT_MODULE . '/' . DEFAULT_MODULE : 'admin/index';
$default_config = array('roles' => array('admin' => array('home' => $path, 'modules' => '*')), 'time_limit' => 500, 'memory_limit' => '128M');
$this->config = array_merge($default_config, $this->config);
$roles = array_keys($this->config['roles']);
$this->plugin->Auth->addArea('admin-area', $roles);
foreach ($roles as $role) {
$this->plugin->Auth->addRole($role, array('member-area', 'admin-area', 'open-area'));
}
$this->plugin->Auth->authorize('admin-area', array('admin', 'node', 'node_process', 'error'), array(&$this, '_goLogin'));
if (isset($this->config['language']) && $this->config['language'] != Lang::getCurrent()) {
$this->helper->redirect->to(UrlHelper::current($this->config['language']));
}
if (!ini_get('safe_mode') && is_callable('set_time_limit') && is_callable('ini_set')) {
@set_time_limit($this->config['time_limit']);
@ini_set("memory_limit", $this->config['memory_limit']);
}
}
示例15: __callStatic
public function __callStatic($funName, $argu)
{
if (($index = strpos($funName, "Url")) && !method_exists(UrlHelper, $funName)) {
$type = strtolower(substr($funName, 0, $index));
return UrlHelper::CommonUrlHelper($type, $argu[0], $argu[1], $argu[2]);
}
}