本文整理汇总了PHP中UrlHelper::getActionUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper::getActionUrl方法的具体用法?PHP UrlHelper::getActionUrl怎么用?PHP UrlHelper::getActionUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlHelper
的用法示例。
在下文中一共展示了UrlHelper::getActionUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: obfuscateAssetUrl
public function obfuscateAssetUrl($asset)
{
craft()->fixMeALink->cleanUpStaleLinks();
$obfuscated_link_hash = craft()->fixMeALink->saveAssetLink($asset);
$obfuscated_link = UrlHelper::getActionUrl('fixMeALink/link/followLink', array('hash' => $obfuscated_link_hash));
return $obfuscated_link;
}
示例2: init
public function init()
{
Craft::log(__METHOD__, LogLevel::Info, true);
// request params
$providerHandle = craft()->request->getParam('provider');
$namespace = craft()->request->getParam('namespace');
$scope = unserialize(base64_decode(craft()->request->getParam('scope')));
// userMode
$userMode = false;
if (!$namespace) {
$userMode = true;
}
// clean session vars
if (!craft()->httpSession->get('oauth.social')) {
craft()->oauth->sessionClean();
}
// set session vars
craft()->oauth->sessionAdd('oauth.providerClass', $providerHandle);
craft()->oauth->sessionAdd('oauth.userMode', $userMode);
craft()->oauth->sessionAdd('oauth.referer', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
craft()->oauth->sessionAdd('oauth.scope', $scope);
// redirect
$url = UrlHelper::getActionUrl('oauth/public/connect/', array('provider' => $providerHandle, 'namespace' => $namespace));
$this->redirect($url);
}
示例3: actionConnect
/**
* Connect
*
* @return null
*/
public function actionConnect()
{
$referer = craft()->request->getUrlReferrer();
$providerHandle = craft()->request->getParam('provider');
craft()->httpSession->add('oauth.console.referer', $referer);
craft()->httpSession->add('oauth.console.providerHandle', $providerHandle);
craft()->httpSession->remove('oauth.console.token.' . $providerHandle);
$this->redirect(UrlHelper::getActionUrl('oauth/console/connectStep2'));
}
示例4: actionConnect
public function actionConnect()
{
$referer = craft()->httpSession->get('socialPoster.referer');
if (!$referer) {
$referer = craft()->request->getUrlReferrer();
craft()->httpSession->add('socialPoster.referer', $referer);
}
$handle = craft()->request->getParam('handle');
$redirectUrl = UrlHelper::getActionUrl('socialPoster/oauth/connect', array('handle' => $handle));
$this->redirect($redirectUrl);
}
示例5: downvoteAction
public function downvoteAction($comment, $options = array())
{
$user = craft()->userSession->getUser();
$params = array('id' => $comment->id, 'return' => craft()->request->getUrl());
// Only logged in users can downvote a comment
if ($user) {
// Ensure the user hasn't voted yet
$hasVoted = craft()->comments_vote->hasDownVoted($comment, $user);
if (!$hasVoted) {
return UrlHelper::getActionUrl('comments/downvoteComment', $params);
}
}
}
示例6: removeAction
public static function removeAction($itemId, $listId = null, $options = array())
{
$params = array();
$params['itemId'] = $itemId;
$params['return'] = craft()->request->getUrl();
if ($listId !== null) {
$params['listId'] = $listId;
}
if (isset($options['return'])) {
$params['return'] = $options['return'];
}
return UrlHelper::getActionUrl('shortlist/item/remove', $params);
}
示例7: init
public function init()
{
Craft::log(__METHOD__, LogLevel::Info, true);
// request params
$params = array();
$params['provider'] = craft()->request->getParam('provider');
$params['namespace'] = craft()->request->getParam('namespace');
// clean session vars
craft()->oauth->sessionClean();
craft()->oauth->sessionAdd('oauth.referer', $_SERVER['HTTP_REFERER']);
// redirect
$url = UrlHelper::getActionUrl('oauth/public/disconnect/', $params);
$this->redirect($url);
}
示例8: form
/**
* Returns our dropzone form to the template
* @param array $config An array of settings
* @return String The resulting HTML form
*/
public function form($config = array())
{
$this->_includeDropzoneResources();
$actionUrl = UrlHelper::getActionUrl('dropzone/upload');
$form = "<form method=\"POST\" enctype=\"multipart/form-data\" class=\"dropzone\" action=\"{$actionUrl}\">";
if (isset($config['sourceId'])) {
$form .= "<input type=\"hidden\" name=\"sourceId\" value=\"{$config['sourceId']}\">";
}
if (isset($config['allowAnonymous'])) {
$form .= "<input type=\"hidden\" name=\"allowAnonymous\" value=\"{$config['allowAnonymous']}\">";
}
$form .= "</form>";
return $form;
}
示例9: actionDownload
/**
* Download
*
* @return null
*/
public function actionDownload()
{
Craft::log(__METHOD__, LogLevel::Info, true);
$pluginHandle = craft()->request->getParam('plugin');
// download plugin (includes download, unzip)
$download = $this->pluginService->download($pluginHandle);
if ($download['success'] == true) {
$this->redirect(UrlHelper::getActionUrl($this->pluginHandle . '/plugin/install', array('plugin' => $pluginHandle, 'redirect' => craft()->request->getUrlReferrer())));
} else {
// download failure
$msg = 'Couldn’t install plugin.';
if (isset($download['msg'])) {
$msg = $download['msg'];
}
Craft::log(__METHOD__ . ' : ' . $msg, LogLevel::Info, true);
craft()->userSession->setError(Craft::t($msg));
}
// redirect
$this->redirect(craft()->request->getUrlReferrer());
}
示例10: actionEditCategory
/**
* Displays the category edit page.
*
* @param array $variables The route variables.
*
* @throws HttpException
* @return null
*/
public function actionEditCategory(array $variables = array())
{
$this->_prepEditCategoryVariables($variables);
$this->_enforceEditCategoryPermissions($variables['category']);
// Parent Category selector variables
// ---------------------------------------------------------------------
if ($variables['group']->maxLevels != 1) {
$variables['elementType'] = new ElementTypeVariable(craft()->elements->getElementType(ElementType::Category));
// Define the parent options criteria
$variables['parentOptionCriteria'] = array('locale' => $variables['localeId'], 'groupId' => $variables['group']->id, 'status' => null, 'localeEnabled' => null);
if ($variables['group']->maxLevels) {
$variables['parentOptionCriteria']['level'] = '< ' . $variables['group']->maxLevels;
}
if ($variables['category']->id) {
// Prevent the current category, or any of its descendants, from being options
$idParam = array('and', 'not ' . $variables['category']->id);
$descendantCriteria = craft()->elements->getCriteria(ElementType::Category);
$descendantCriteria->descendantOf = $variables['category'];
$descendantCriteria->status = null;
$descendantCriteria->localeEnabled = null;
$descendantIds = $descendantCriteria->ids();
foreach ($descendantIds as $id) {
$idParam[] = 'not ' . $id;
}
$variables['parentOptionCriteria']['id'] = $idParam;
}
// Get the initially selected parent
$parentId = craft()->request->getParam('parentId');
if ($parentId === null && $variables['category']->id) {
$parentIds = $variables['category']->getAncestors(1)->status(null)->localeEnabled(null)->ids();
if ($parentIds) {
$parentId = $parentIds[0];
}
}
if ($parentId) {
$variables['parent'] = craft()->categories->getCategoryById($parentId, $variables['localeId']);
}
}
// Other variables
// ---------------------------------------------------------------------
// Page title
if (!$variables['category']->id) {
$variables['title'] = Craft::t('Create a new category');
} else {
$variables['docTitle'] = $variables['title'] = $variables['category']->title;
}
// Breadcrumbs
$variables['crumbs'] = array(array('label' => Craft::t('Categories'), 'url' => UrlHelper::getUrl('categories')), array('label' => Craft::t($variables['group']->name), 'url' => UrlHelper::getUrl('categories/' . $variables['group']->handle)));
foreach ($variables['category']->getAncestors() as $ancestor) {
$variables['crumbs'][] = array('label' => $ancestor->title, 'url' => $ancestor->getCpEditUrl());
}
// Enable Live Preview?
if (!craft()->request->isMobileBrowser(true) && craft()->categories->isGroupTemplateValid($variables['group'])) {
craft()->templates->includeJs('Craft.LivePreview.init(' . JsonHelper::encode(array('fields' => '#title-field, #fields > div > div > .field', 'extraFields' => '#settings', 'previewUrl' => $variables['category']->getUrl(), 'previewAction' => 'categories/previewCategory', 'previewParams' => array('groupId' => $variables['group']->id, 'categoryId' => $variables['category']->id, 'locale' => $variables['category']->locale))) . ');');
$variables['showPreviewBtn'] = true;
// Should we show the Share button too?
if ($variables['category']->id) {
// If the category is enabled, use its main URL as its share URL.
if ($variables['category']->getStatus() == BaseElementModel::ENABLED) {
$variables['shareUrl'] = $variables['category']->getUrl();
} else {
$variables['shareUrl'] = UrlHelper::getActionUrl('categories/shareCategory', array('categoryId' => $variables['category']->id, 'locale' => $variables['category']->locale));
}
}
} else {
$variables['showPreviewBtn'] = false;
}
// Set the base CP edit URL
$variables['baseCpEditUrl'] = 'categories/' . $variables['group']->handle . '/{id}-{slug}';
// Set the "Continue Editing" URL
$variables['continueEditingUrl'] = $variables['baseCpEditUrl'] . (craft()->isLocalized() && craft()->getLanguage() != $variables['localeId'] ? '/' . $variables['localeId'] : '');
// Render the template!
craft()->templates->includeCssResource('css/category.css');
$this->renderTemplate('categories/_edit', $variables);
}
示例11: getPasswordResetUrl
/**
* Sets a new verification code on a user, and returns their new Password Reset URL.
*
* @param UserModel $user The user that should get the new Password Reset URL
*
* @return string The new Password Reset URL.
*/
public function getPasswordResetUrl(UserModel $user)
{
$userRecord = $this->_getUserRecordById($user->id);
$unhashedVerificationCode = $this->_setVerificationCodeOnUserRecord($userRecord);
$userRecord->save();
if ($user->can('accessCp')) {
$url = UrlHelper::getActionUrl('users/setpassword', array('code' => $unhashedVerificationCode, 'id' => $userRecord->uid), craft()->request->isSecureConnection() ? 'https' : 'http');
} else {
// We want to hide the CP trigger if they don't have access to the CP.
$path = craft()->config->get('actionTrigger') . '/users/setpassword';
$url = UrlHelper::getSiteUrl($path, array('code' => $unhashedVerificationCode, 'id' => $userRecord->uid), craft()->request->isSecureConnection() ? 'https' : 'http');
}
return $url;
}
示例12: handleRequestEnd
/**
* Figure out how to initiate a new task runner.
*/
public function handleRequestEnd()
{
// Make sure a future call to craft()->end() dosen't trigger this a second time
craft()->detachEventHandler('onEndRequest', array($this, '_onEndRequest'));
// Make sure nothing has been output to the browser yet, and there's no pending response body
if (!headers_sent() && !ob_get_length()) {
$this->closeAndRun();
} else {
if (craft()->request->isSiteRequest() && in_array(HeaderHelper::getMimeType(), array('text/html', 'application/xhtml+xml')) && !craft()->request->isAjaxRequest()) {
// Just output JS that tells the browser to fire an Ajax request to kick off task running
$url = JsonHelper::encode(UrlHelper::getActionUrl('tasks/runPendingTasks'));
// Ajax request code adapted from http://www.quirksmode.org/js/xmlhttp.html - thanks ppk!
echo <<<EOT
<script type="text/javascript">
/*<![CDATA[*/
(function(){
\tvar XMLHttpFactories = [
\t\tfunction () {return new XMLHttpRequest()},
\t\tfunction () {return new ActiveXObject("Msxml2.XMLHTTP")},
\t\tfunction () {return new ActiveXObject("Msxml3.XMLHTTP")},
\t\tfunction () {return new ActiveXObject("Microsoft.XMLHTTP")}
\t];
\tvar req = false;
\tfor (var i = 0; i < XMLHttpFactories.length; i++) {
\t\ttry {
\t\t\treq = XMLHttpFactories[i]();
\t\t}
\t\tcatch (e) {
\t\t\tcontinue;
\t\t}
\t\tbreak;
\t}
\tif (!req) return;
\treq.open('GET', {$url}, true);
\tif (req.readyState == 4) return;
\treq.send();
})();
/*]]>*/
</script>
EOT;
}
}
}
示例13: actionEditEntryTemplate
/**
* Route Controller for Edit Entry Template
*
* @param array $variables
*
* @throws HttpException
* @throws Exception
*/
public function actionEditEntryTemplate(array $variables = array())
{
$entryId = craft()->request->getSegment(4);
$campaignId = craft()->request->getSegment(3);
// Check if we already have an entry route variable
// If so it's probably due to a bad form submission and has an error object
// that we don't want to overwrite.
if (!isset($variables['entry'])) {
if (is_numeric($entryId)) {
$variables['entry'] = craft()->elements->getElementById($entryId);
$variables['entryId'] = $entryId;
} else {
$variables['entry'] = new SproutEmail_EntryModel();
}
}
if (!is_numeric($campaignId)) {
$campaignId = $variables['entry']->campaignId;
}
$variables['campaign'] = sproutEmail()->campaigns->getCampaignById($campaignId);
$variables['campaignId'] = $campaignId;
// Tabs
$variables['tabs'] = array();
foreach ($variables['campaign']->getFieldLayout()->getTabs() as $index => $tab) {
// Do any of the fields on this tab have errors?
$hasErrors = false;
if ($variables['entry']->hasErrors()) {
foreach ($tab->getFields() as $field) {
if ($variables['entry']->getErrors($field->getField()->handle)) {
$hasErrors = true;
break;
}
}
}
$variables['tabs'][] = array('url' => '#tab' . ($index + 1), 'label' => Craft::t($tab->name), 'class' => $hasErrors ? 'error' : null);
}
$shareParamsHtml = array('entryId' => $variables['entry']->id, 'template' => 'html');
$shareParamsText = array('entryId' => $variables['entry']->id, 'template' => 'txt');
// Enable Live Preview?
if (!craft()->request->isMobileBrowser(true) && sproutEmail()->doesSiteTemplateExist($variables['campaign']->template)) {
craft()->templates->includeJs('Craft.LivePreview.init(' . JsonHelper::encode(array('fields' => '#subjectLine-field, #title-field, #fields > div > div > .field', 'extraFields' => '#settings', 'previewUrl' => $variables['entry']->getUrl(), 'previewAction' => 'sproutEmail/entry/livePreviewEntry', 'previewParams' => array('entryId' => $variables['entry']->id, 'campaignId' => $variables['campaign']->id))) . ');');
$variables['showPreviewBtn'] = true;
// Should we show the Share button too?
if ($variables['entry']->id) {
if ($variables['entry']->enabled) {
$variables['shareUrl'] = $variables['entry']->getUrl();
} else {
$shareParams = array('entryId' => $variables['entry']->id, 'campaignId' => $variables['campaign']->id);
$variables['shareUrl'] = UrlHelper::getActionUrl('sproutEmail/entry/shareEntry', $shareParams);
}
}
} else {
$variables['showPreviewBtn'] = false;
}
if ($variables['campaign']->type == 'notification') {
$notificationId = null;
$notification = sproutEmail()->notifications->getNotification(array('campaignId' => $campaignId));
if ($notification) {
$notificationId = $notification->eventId;
}
$variables['notificationEvent'] = $notificationId;
}
$variables['shareUrlHtml'] = UrlHelper::getActionUrl('sproutEmail/entry/shareEntry', $shareParamsHtml);
$variables['shareUrlText'] = UrlHelper::getActionUrl('sproutEmail/entry/shareEntry', $shareParamsText);
// end <
$variables['recipientLists'] = sproutEmail()->entries->getRecipientListsByEntryId($entryId);
$this->renderTemplate('sproutemail/entries/_edit', $variables);
}
示例14: link
/**
* craft.sass.link() returns a URL that will return the compiled, CSS
* version of a specified Sass file. The path should be relative to the
* document root.
*
* @param string $filename File to compile.
* @return string Relative URL to the compiled CSS version.
*/
public function link($filename)
{
return UrlHelper::getActionUrl('sass/compiler/sass', array('filename' => $filename));
}
示例15: actionEditEntry
//.........这里部分代码省略.........
if ($variables['entry']->id) {
$variables['enabledLocales'] = craft()->elements->getEnabledLocalesForElement($variables['entry']->id);
} else {
$variables['enabledLocales'] = array();
foreach ($variables['section']->getLocales() as $locale) {
if ($locale->enabledByDefault) {
$variables['enabledLocales'][] = $locale->locale;
}
}
}
}
// Page title w/ revision label
if (craft()->getEdition() >= Craft::Client) {
switch ($variables['entry']->getClassHandle()) {
case 'EntryDraft':
$variables['revisionLabel'] = $variables['entry']->name;
break;
case 'EntryVersion':
$variables['revisionLabel'] = Craft::t('Version {num}', array('num' => $variables['entry']->num));
break;
default:
$variables['revisionLabel'] = Craft::t('Current');
}
}
if (!$variables['entry']->id) {
$variables['title'] = Craft::t('Create a new entry');
} else {
$variables['docTitle'] = Craft::t($variables['entry']->title);
$variables['title'] = HtmlHelper::encode(Craft::t($variables['entry']->title));
if (craft()->getEdition() >= Craft::Client && $variables['entry']->getClassHandle() != 'Entry') {
$variables['title'] .= ' <span class="hidden">(' . $variables['revisionLabel'] . ')</span>';
}
}
// Breadcrumbs
$variables['crumbs'] = array(array('label' => Craft::t('Entries'), 'url' => UrlHelper::getUrl('entries')));
if ($variables['section']->type == SectionType::Single) {
$variables['crumbs'][] = array('label' => Craft::t('Singles'), 'url' => UrlHelper::getUrl('entries/singles'));
} else {
$variables['crumbs'][] = array('label' => Craft::t($variables['section']->name), 'url' => UrlHelper::getUrl('entries/' . $variables['section']->handle));
if ($variables['section']->type == SectionType::Structure) {
foreach ($variables['entry']->getAncestors() as $ancestor) {
$variables['crumbs'][] = array('label' => $ancestor->title, 'url' => $ancestor->getCpEditUrl());
}
}
}
// Multiple entry types?
$entryTypes = $variables['section']->getEntryTypes();
if (count($entryTypes) > 1) {
$variables['showEntryTypes'] = true;
foreach ($entryTypes as $entryType) {
$variables['entryTypeOptions'][] = array('label' => Craft::t($entryType->name), 'value' => $entryType->id);
}
craft()->templates->includeJsResource('js/EntryTypeSwitcher.js');
craft()->templates->includeJs('new Craft.EntryTypeSwitcher();');
} else {
$variables['showEntryTypes'] = false;
}
// Enable preview mode?
if (!craft()->request->isMobileBrowser(true) && craft()->sections->isSectionTemplateValid($variables['section'])) {
craft()->templates->includeJsResource('js/LivePreview.js');
craft()->templates->includeJs('Craft.livePreview = new Craft.LivePreview(' . JsonHelper::encode($variables['entry']->getUrl()) . ', "' . $variables['entry']->locale . '");');
$variables['showPreviewBtn'] = true;
// Should we show the Share button too?
if ($variables['entry']->id) {
$classHandle = $variables['entry']->getClassHandle();
// If we're looking at the live version of an entry, just use
// the entry's main URL as its share URL
if ($classHandle == 'Entry' && $variables['entry']->getStatus() == EntryModel::LIVE) {
$variables['shareUrl'] = $variables['entry']->getUrl();
} else {
switch ($classHandle) {
case 'EntryDraft':
$shareParams = array('draftId' => $variables['entry']->draftId);
break;
case 'EntryVersion':
$shareParams = array('versionId' => $variables['entry']->versionId);
break;
default:
$shareParams = array('entryId' => $variables['entry']->id, 'locale' => $variables['entry']->locale);
break;
}
$variables['shareUrl'] = UrlHelper::getActionUrl('entries/shareEntry', $shareParams);
}
}
} else {
$variables['showPreviewBtn'] = false;
}
// Set the base CP edit URL
// Can't just use the entry's getCpEditUrl() because that might include the locale ID when we don't want it
$variables['baseCpEditUrl'] = 'entries/' . $variables['section']->handle . '/{id}-{slug}';
// Set the "Continue Editing" URL
$variables['continueEditingUrl'] = $variables['baseCpEditUrl'] . (isset($variables['draftId']) ? '/drafts/' . $variables['draftId'] : '') . (craft()->isLocalized() && craft()->getLanguage() != $variables['localeId'] ? '/' . $variables['localeId'] : '');
// Can the user delete the entry?
$variables['canDeleteEntry'] = $variables['entry']->id && ($variables['entry']->authorId == $currentUser->id && $currentUser->can('deleteEntries' . $variables['permissionSuffix']) || $variables['entry']->authorId != $currentUser->id && $currentUser->can('deletePeerEntries' . $variables['permissionSuffix']));
// Include translations
craft()->templates->includeTranslations('Live Preview');
// Render the template!
craft()->templates->includeCssResource('css/entry.css');
$this->renderTemplate('entries/_edit', $variables);
}