本文整理汇总了PHP中UrlHelper::getCpUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper::getCpUrl方法的具体用法?PHP UrlHelper::getCpUrl怎么用?PHP UrlHelper::getCpUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UrlHelper
的用法示例。
在下文中一共展示了UrlHelper::getCpUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCpEditUrl
/**
* Returns the element's CP edit URL.
*
* @return string|false
*/
public function getCpEditUrl()
{
$calendar = $this->getCalendar();
if ($calendar) {
return UrlHelper::getCpUrl('events/' . $calendar->handle . '/' . $this->id);
}
}
示例2: editEntry
/**
* Get all available entries to edit from a section.
*
* @param array $variables
*
* @return array
*/
public function editEntry($variables)
{
if (!isset($variables['sectionHandle'])) {
return false;
}
// Gather commands
$commands = array();
// Find entries
$criteria = array('section' => $variables['sectionHandle'], 'locale' => craft()->language);
$entries = craft()->amCommand_elements->getElements(ElementType::Entry, $criteria);
if (!$entries) {
craft()->amCommand->setReturnMessage(Craft::t('No entries in this section exist yet.'));
} else {
foreach ($entries as $entry) {
// Get CP edit URL
$url = UrlHelper::getCpUrl('entries/' . $variables['sectionHandle'] . '/' . $entry['id'] . ($entry['slug'] ? '-' . $entry['slug'] : ''));
if (craft()->isLocalized()) {
$url .= '/' . craft()->language;
}
// Add command
$commands[] = array('name' => $entry['title'], 'info' => Craft::t('URI') . ': ' . $entry['uri'], 'url' => $url);
}
}
return $commands;
}
示例3: getCpEditUrl
/**
* Returns the element's CP edit URL.
*
* @return string|false
*/
public function getCpEditUrl()
{
$menu = $this->getMenu();
if ($menu) {
return UrlHelper::getCpUrl('menus/' . $menu->handle . '/' . $this->id);
}
}
示例4: actionInstall
/**
* Install examples
*
* @return void
*/
public function actionInstall()
{
$this->_installExampleTemplates();
$this->_installExampleData();
craft()->userSession->setNotice(Craft::t('Examples successfully installed.'));
$this->redirect(UrlHelper::getCpUrl() . '/sproutemail');
}
示例5: 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));
}
示例6: _loadCodeMirror
private function _loadCodeMirror()
{
if ($this->_actualSettingsPage()) {
craft()->templates->includeCssResource('cpcss/css/codemirror.css');
craft()->templates->includeCssResource('cpcss/css/blackboard.css');
craft()->templates->includeJsResource('cpcss/js/codemirror-css.js');
craft()->templates->includeJs('
$(function () {
var $redirect = $("' . addslashes('input[type="hidden"][name="redirect"][value$="settings/plugins"]') . '"),
$saveBtn = $("' . addslashes('input[type="submit"') . '").wrap("' . addslashes('<div class="btngroup" />') . '"),
$menuBtn = $("' . addslashes('<div class="btn submit menubtn" />') . '").appendTo($saveBtn.parent()),
$menu = $("' . addslashes('<div class="menu" />') . '").appendTo($saveBtn.parent()),
$items = $("<ul />").appendTo($menu),
$continueOpt = $("' . addslashes('<li><a class="formsubmit" data-redirect="' . UrlHelper::getCpUrl('settings/plugins/cpcss') . '">' . Craft::t('Save and continue editing') . '<span class="shortcut">' . (craft()->request->getClientOs() === 'Mac' ? '⌘' : 'Ctrl+') . 'S</span></a></li>') . '").appendTo($items);
new Garnish.MenuBtn($menuBtn, {
onOptionSelect : function (option) {
Craft.cp.submitPrimaryForm();
}
});
$saveBtn.on("click", function (e) { $redirect.attr("value", "' . UrlHelper::getCpUrl('settings/plugins') . '"); });
$redirect.attr("value", "' . UrlHelper::getCpUrl('settings/plugins/cpcss') . '");
CodeMirror.fromTextArea(document.getElementById("settings-additionalCss"), {
indentUnit: 4,
styleActiveLine: true,
lineNumbers: true,
lineWrapping: true,
theme: "blackboard"
});
});', true);
}
}
示例7: getCpEditUrl
/**
* @inheritDoc BaseElementModel::getCpEditUrl()
*
* @return string|false
*/
public function getCpEditUrl()
{
$group = $this->getGroup();
if ($group) {
return UrlHelper::getCpUrl('categories/' . $group->handle . '/' . $this->id . ($this->slug ? '-' . $this->slug : ''));
}
}
示例8: getCpEditUrl
/**
* Returns the element's CP edit URL.
*
* @return string|false
*/
public function getCpEditUrl()
{
$app = $this->getApp();
if ($app) {
return UrlHelper::getCpUrl('pushnotifications/devices/' . $app->handle . '/' . $this->id);
}
}
示例9: getCpEditUrl
public function getCpEditUrl()
{
$form = $this->getForm();
if ($form) {
return UrlHelper::getCpUrl('formerly/' . $form->handle . '/' . $this->id);
}
}
示例10: getCpEditUrl
/**
* @inheritDoc BaseElementModel::getCpEditUrl()
*
* @return string|false
*/
public function getCpEditUrl()
{
$group = $this->getGroup();
if ($group) {
return UrlHelper::getCpUrl('tagmanager/' . $group->handle . '/' . $this->id);
}
}
示例11: _handleSuccessfulLogin
/**
* Process Successful Login
*/
private function _handleSuccessfulLogin($setNotice)
{
// Get the current user
$currentUser = craft()->userSession->getUser();
// Were they trying to access a URL beforehand?
$returnUrl = craft()->userSession->getReturnUrl(null, true);
if ($returnUrl === null || $returnUrl == craft()->request->getPath()) {
// If this is a CP request and they can access the control panel, send them wherever
// postCpLoginRedirect tells us
if (craft()->request->isCpRequest() && $currentUser->can('accessCp')) {
$postCpLoginRedirect = craft()->config->get('postCpLoginRedirect');
$returnUrl = UrlHelper::getCpUrl($postCpLoginRedirect);
} else {
// Otherwise send them wherever postLoginRedirect tells us
$postLoginRedirect = craft()->config->get('postLoginRedirect');
$returnUrl = UrlHelper::getSiteUrl($postLoginRedirect);
}
}
// If this was an Ajax request, just return success:true
if (craft()->request->isAjaxRequest()) {
$this->returnJson(array('success' => true, 'returnUrl' => $returnUrl));
} else {
if ($setNotice) {
craft()->userSession->setNotice(Craft::t('Logged in.'));
}
$this->redirectToPostedUrl($currentUser, $returnUrl);
}
}
示例12: actionExport
public function actionExport()
{
$attributes = craft()->httpSession->get('__exportJob');
craft()->httpSession->remove('__exportJob');
if ($attributes && ($recipients = craft()->elements->getCriteria('SproutEmail_DefaultMailerRecipient', $attributes)->find())) {
$this->generateCsvExport($recipients);
craft()->end();
}
craft()->userSession->setError(Craft::t('Nothing to export.'));
craft()->request->redirect(UrlHelper::getCpUrl('sproutemail/recipients'));
}
示例13: getCpEditUrl
/**
* @inheritDoc BaseElementModel::getCpEditUrl()
*
* @return string|false
*/
public function getCpEditUrl()
{
$group = $this->getGroup();
if ($group) {
$url = UrlHelper::getCpUrl('categories/' . $group->handle . '/' . $this->id . ($this->slug ? '-' . $this->slug : ''));
if (craft()->isLocalized() && $this->locale != craft()->language) {
$url .= '/' . $this->locale;
}
return $url;
}
}
示例14: getSettingsUrl
/**
* Returns the URL to the plugin's settings in the CP.
*
* @return string|null
*/
public function getSettingsUrl()
{
// Is this plugin managing its own settings?
$url = $this->component->getSettingsUrl();
if (!$url) {
// Check to see if they're using getSettingsHtml(), etc.
if ($this->component->getSettingsHtml()) {
$url = 'settings/plugins/' . mb_strtolower($this->component->getClassHandle());
}
}
if ($url) {
return UrlHelper::getCpUrl($url);
}
}
示例15: getSettingsHtml
public function getSettingsHtml()
{
// If Craft Pro
if (craft()->getEdition() == Craft::Pro) {
$options = array();
$userGroups = craft()->userGroups->getAllGroups();
foreach ($userGroups as $group) {
$options[] = array('label' => $group->name, 'value' => $group->id);
}
$checkboxes = craft()->templates->render('_includes/forms/checkboxGroup', array('name' => 'userGroups', 'options' => $options, 'values' => $this->getSettings()->userGroups));
$noGroups = '<p class="error">No user groups exist. <a href="' . UrlHelper::getCpUrl('settings/users/groups/new') . '">Create one now...</a></p>';
craft()->templates->includeCssResource('autoassignusergroup/css/settings.css');
return craft()->templates->render('autoassignusergroup/_settings', array('userGroupsField' => TemplateHelper::getRaw(count($userGroups) ? $checkboxes : $noGroups)));
} else {
craft()->templates->includeJs('$(".btn.submit").val("Continue");');
$output = '<h2>Craft Upgrade Required</h2>';
$output .= '<p>In order to use this plugin, Craft Pro is required.</p>';
return craft()->templates->renderString($output);
}
}