本文整理汇总了PHP中UrlHelper::getUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper::getUrl方法的具体用法?PHP UrlHelper::getUrl怎么用?PHP UrlHelper::getUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlHelper
的用法示例。
在下文中一共展示了UrlHelper::getUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEditForm
/**
* View/Edit Form
*
*/
public function actionEditForm(array $variables = array())
{
$variables['brandNewForm'] = false;
$variables['navigation'] = $this->navigation();
if (!empty($variables['formId'])) {
if (empty($variables['form'])) {
$variables['form'] = craft()->formBuilder2_form->getFormById($variables['formId']);
$variables['crumbs'] = array(array('label' => Craft::t('FormBuilder 2'), 'url' => UrlHelper::getUrl('formbuilder2')), array('label' => Craft::t('Forms'), 'url' => UrlHelper::getUrl('formbuilder2/forms')), array('label' => $variables['formId'], 'url' => UrlHelper::getUrl('formbuilder2/forms/' . $variables['formId'] . '/edit')));
if (!$variables['form']) {
throw new HttpException(404);
}
// Get Logo Asset
$customEmailLogo = $variables['form']->notificationSettings['templateSettings']['emailCustomLogo'];
if ($customEmailLogo) {
$criteria = craft()->elements->getCriteria(ElementType::Asset);
$criteria->id = $customEmailLogo[0];
$criteria->limit = 1;
$elements = $criteria->find();
} else {
$elements = [];
}
$variables['elements'] = $elements;
}
$variables['title'] = $variables['form']->name;
} else {
if (empty($variables['form'])) {
$variables['form'] = new FormBuilder2_FormModel();
$variables['brandNewForm'] = true;
$variables['crumbs'] = array(array('label' => Craft::t('FormBuilder 2'), 'url' => UrlHelper::getUrl('formbuilder2')), array('label' => Craft::t('Forms'), 'url' => UrlHelper::getUrl('formbuilder2/forms')), array('label' => Craft::t('New Form'), 'url' => UrlHelper::getUrl('formbuilder2/forms/new')));
}
$variables['title'] = Craft::t('Create a new form');
}
$this->renderTemplate('formbuilder2/forms/_edit', $variables);
}
示例2: actionEditRedirect
/**
* Edit a Redirect.
*
* @param array $variables
* @throws HttpException
*/
public function actionEditRedirect(array $variables = array())
{
//Get method options
$variables['methodOptions'] = sproutSeo()->redirects->getMethods();
//Set title
$variables['subTitle'] = Craft::t('Create a new redirect');
// Now let's set up the actual redirect
if (empty($variables['redirect'])) {
if (!empty($variables['redirectId'])) {
//Set title
$variables['subTitle'] = Craft::t('Edit redirect');
$variables['redirect'] = sproutSeo()->redirects->getRedirectById($variables['redirectId']);
if (!$variables['redirect']) {
throw new HttpException(404);
}
} else {
$variables['redirect'] = new SproutSeo_RedirectModel();
}
}
// Set the "Continue Editing" URL
$variables['continueEditingUrl'] = 'sproutseo/redirects/{id}';
// Breadcrumbs
$variables['crumbs'] = array(array('label' => Craft::t('Redirects'), 'url' => UrlHelper::getUrl('redirects')));
$this->renderTemplate('sproutseo/redirects/_edit', $variables);
}
示例3: 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);
}
示例4: actionEditDevice
/**
* Edit an device.
*
* @param array $variables
*
* @throws HttpException
*/
public function actionEditDevice(array $variables = array())
{
if (!empty($variables['appHandle'])) {
$variables['app'] = craft()->pushNotifications_apps->getAppByHandle($variables['appHandle']);
} elseif (!empty($variables['appId'])) {
$variables['app'] = craft()->pushNotifications_apps->getAppById($variables['appId']);
}
if (empty($variables['app'])) {
throw new HttpException(404);
}
// Now let's set up the actual device
if (empty($variables['device'])) {
if (!empty($variables['deviceId'])) {
$variables['device'] = craft()->pushNotifications_devices->getDeviceById($variables['deviceId']);
if (!$variables['device']) {
throw new HttpException(404);
}
} else {
$variables['device'] = new PushNotifications_DeviceModel();
$variables['device']->appId = $variables['app']->id;
}
}
if (!$variables['device']->id) {
$variables['title'] = Craft::t('Create a new device');
} else {
$variables['title'] = $variables['device']->title;
}
// Breadcrumbs
$variables['crumbs'] = array(array('label' => Craft::t('Push Notifications'), 'url' => UrlHelper::getUrl('pushnotifications')), array('label' => $variables['app']->name, 'url' => UrlHelper::getUrl('pushnotifications')));
// Set the "Continue Editing" URL
$variables['continueEditingUrl'] = 'pushnotifications/devices/' . $variables['app']->handle . '/{id}';
// Render the template!
$this->renderTemplate('pushnotifications/devices/_edit', $variables);
}
示例5: init
public function init()
{
parent::init();
$user = craft()->userSession->getUser();
if (craft()->request->isCpRequest()) {
$allNavs = craft()->cpNav_nav->getDefaultOrUserNavs();
if ($user) {
if ($this->getSettings()->showQuickAddMenu && $user->can('quickAddMenu')) {
$this->insertJsForQuickMenuAdd($allNavs);
}
}
if ($allNavs) {
foreach ($allNavs as $nav) {
// Allow links to be opened in new window - insert some small JS
if ($nav->newWindow) {
$this->insertJsForNewWindow($nav);
}
// Check to ensure this page is enabled - otherwise simply redirect to first available menu item
if (craft()->request->path == $nav->url) {
if (!$nav->enabled) {
$enabledNavs = craft()->cpNav_nav->getAllNavsByAttributes(array('enabled' => true));
// We're on a page that's disabled - redirect to the first enabled one!
craft()->request->redirect(UrlHelper::getUrl($enabledNavs[0]->url));
}
} else {
if (craft()->request->path == preg_replace(sprintf('/^(https?:\\/\\/)?(%s)?\\/?%s\\//', preg_quote(craft()->getSiteUrl(''), '/'), preg_quote(craft()->config->get('cpTrigger')), '/'), '', $nav->url) && $nav->enabled && $nav->manualNav) {
// Add some JavaScript to correct the selected nav item for manually added navigation items.
// Have to do this with JavaScript for now as the nav item selection is made after the modifyCpNav hook.
$this->insertJsForManualNavSelection($nav);
}
}
}
}
}
}
示例6: 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);
}
示例7: afterFetch
/**
* Add additional information to the image after the model has fetched
* an image from the database
*/
public function afterFetch()
{
$this->resizedUrl = $this->getDI()->get('imageLocation') . $this->id . '_1024.jpg';
$this->thumbUrl = $this->getDI()->get('imageLocation') . $this->id . '_thumb.jpg';
$this->originalUrl = str_replace(UrlHelper::getUrl($this->getDI()), 'http://hack4dk.dr.dk', $this->url);
$this->imagePageUrl = UrlHelper::getUrl($this->getDI()) . '?image_id=' . $this->id;
}
示例8: 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);
}
}
示例9: actionEditForm
public function actionEditForm(array $variables = array())
{
if (!empty($variables['formId'])) {
if (empty($variables['form'])) {
$variables['form'] = craft()->formerly_forms->getFormById($variables['formId']);
$variables['questions'] = craft()->formerly_forms->getQuestionsByFormId($variables['formId'], 'id');
if (!$variables['form']) {
throw new HttpException(404);
}
}
$variables['title'] = $variables['form']->name;
} else {
if (empty($variables['form'])) {
$user = craft()->userSession->getUser();
$form = new Formerly_FormModel();
$form->emails = array(array('to' => '{email}', 'from' => $user->email, 'subject' => 'Thank you for your enquiry', 'body' => "<p>Hi {name},</p>\n<p>Thanks for your enquiry! We'll get back to you shortly.</p>\n<p>{$user->name}</p>"), array('to' => $user->email, 'from' => '{email}', 'subject' => 'Website enquiry', 'body' => ''));
$questions = array('new_1' => new Formerly_QuestionModel(array('name' => 'Name', 'handle' => 'name', 'type' => Formerly_QuestionType::PlainText, 'required' => true)), 'new_2' => new Formerly_QuestionModel(array('name' => 'Email', 'handle' => 'email', 'type' => Formerly_QuestionType::Email, 'required' => true)), 'new_3' => new Formerly_QuestionModel(array('name' => 'Message', 'handle' => 'message', 'type' => Formerly_QuestionType::MultilineText, 'required' => true)));
$variables['form'] = $form;
$variables['questions'] = $questions;
}
$variables['title'] = Craft::t('New form');
}
$variables['crumbs'] = array(array('label' => Craft::t('Formerly'), 'url' => UrlHelper::getUrl('formerly')));
$this->renderTemplate('formerly/forms/_edit', $variables);
}
示例10: 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>';
}
示例11: checkRequirements
/**
* Check requirements
*
* @return bool
*/
public function checkRequirements($redirect = false)
{
// dependencies
$plugin = craft()->plugins->getPlugin('analytics');
$pluginDependencies = $plugin->getPluginDependencies();
if (count($pluginDependencies) > 0) {
if ($redirect) {
$url = UrlHelper::getUrl('analytics/install');
craft()->request->redirect($url);
}
return false;
} else {
// oauth
$provider = craft()->oauth->getProvider('google');
if ($provider && $provider->isConfigured()) {
$token = craft()->analytics_oauth->getToken();
if ($token) {
return true;
} else {
return false;
}
} else {
if ($redirect) {
$url = UrlHelper::getUrl('analytics/install');
craft()->request->redirect($url);
}
return false;
}
}
}
示例12: nav
/**
* Get the sections of the CP.
*
* @return array
*/
public function nav($iconSize = 32)
{
$nav['dashboard'] = array('label' => Craft::t('Dashboard'), 'icon' => 'gauge');
if (craft()->sections->getTotalEditableSections()) {
$nav['entries'] = array('label' => Craft::t('Entries'), 'icon' => 'section');
}
$globals = craft()->globals->getEditableSets();
if ($globals) {
$nav['globals'] = array('label' => Craft::t('Globals'), 'url' => 'globals/' . $globals[0]->handle, 'icon' => 'globe');
}
if (craft()->categories->getEditableGroupIds()) {
$nav['categories'] = array('label' => Craft::t('Categories'), 'icon' => 'categories');
}
if (craft()->assetSources->getTotalViewableSources()) {
$nav['assets'] = array('label' => Craft::t('Assets'), 'icon' => 'assets');
}
if (craft()->getEdition() == Craft::Pro && craft()->userSession->checkPermission('editUsers')) {
$nav['users'] = array('label' => Craft::t('Users'), 'icon' => 'users');
}
// Add any Plugin nav items
$plugins = craft()->plugins->getPlugins();
foreach ($plugins as $plugin) {
if ($plugin->hasCpSection()) {
$pluginHandle = $plugin->getClassHandle();
if (craft()->userSession->checkPermission('accessPlugin-' . $pluginHandle)) {
$lcHandle = StringHelper::toLowerCase($pluginHandle);
$iconPath = craft()->path->getPluginsPath() . $lcHandle . '/resources/icon-mask.svg';
if (IOHelper::fileExists($iconPath)) {
$iconSvg = IOHelper::getFileContents($iconPath);
} else {
$iconSvg = false;
}
$nav[$lcHandle] = array('label' => $plugin->getName(), 'iconSvg' => $iconSvg);
}
}
}
if (craft()->userSession->isAdmin()) {
$nav['settings'] = array('label' => Craft::t('Settings'), 'icon' => 'settings');
}
// Allow plugins to modify the nav
craft()->plugins->call('modifyCpNav', array(&$nav));
// Figure out which item is selected, and normalize the items
$firstSegment = craft()->request->getSegment(1);
if ($firstSegment == 'myaccount') {
$firstSegment = 'users';
}
foreach ($nav as $handle => &$item) {
if (is_string($item)) {
$item = array('label' => $item);
}
$item['sel'] = $handle == $firstSegment;
if (isset($item['url'])) {
$item['url'] = UrlHelper::getUrl($item['url']);
} else {
$item['url'] = UrlHelper::getUrl($handle);
}
}
return $nav;
}
示例13: getSettingsUrl
public function getSettingsUrl()
{
if ($this->isPluginEnabled()) {
return UrlHelper::getUrl('/golive/settings');
} else {
return false;
}
}
示例14: viewEntryLinkOnElementsTable
/**
* View Submission Link in Elements Table
*
*/
public function viewEntryLinkOnElementsTable()
{
$entry = craft()->formBuilder2_entry->getSubmissionById($this->id);
// url('formbuilder2/forms/' ~ form.id ~ '/edit')
$url = UrlHelper::getUrl('formbuilder2/entries/' . $this->id . '/edit');
$link = '<a href="' . $url . '" class="view-submission">' . Craft::t('View Submission') . '</a>';
$this->__set('submission', $link);
return $this;
}
示例15: newFieldInGroup
/**
* Get Field Groups to add a field to.
*
* @return array
*/
public function newFieldInGroup()
{
$commands = array();
$groups = craft()->fields->getAllGroups();
foreach ($groups as $group) {
$commands[] = array('name' => $group->name, 'url' => UrlHelper::getUrl('settings/fields/new?groupId=' . $group->id));
}
return $commands;
}