示例#1
0
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
 /**
  * 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);
     }
 }
 /**
  * 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
0
 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
0
    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
0
 /**
  * @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 : ''));
     }
 }
 /**
  * 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);
     }
 }
 public function getCpEditUrl()
 {
     $form = $this->getForm();
     if ($form) {
         return UrlHelper::getCpUrl('formerly/' . $form->handle . '/' . $this->id);
     }
 }
示例#10
0
 /**
  * @inheritDoc BaseElementModel::getCpEditUrl()
  *
  * @return string|false
  */
 public function getCpEditUrl()
 {
     $group = $this->getGroup();
     if ($group) {
         return UrlHelper::getCpUrl('tagmanager/' . $group->handle . '/' . $this->id);
     }
 }
 /**
  * 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);
     }
 }
 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'));
 }
 /**
  * @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
0
 /**
  * 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);
     }
 }
 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);
     }
 }
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'user':
             $user = craft()->users->getUserById($element->userId);
             if ($user == null) {
                 return $element->name;
             } else {
                 $url = UrlHelper::getCpUrl('users/' . $user->id);
                 return "<a href='" . $url . "'>" . $user->getFriendlyName() . "</a>";
             }
         case 'element':
             $element = craft()->elements->getElementById($element->elementId);
             if ($element == null) {
                 return Craft::t('[Deleted element]');
             } else {
                 return "<a href='" . $element->cpEditUrl . "'>" . $element->title . "</a>";
             }
         case 'status':
             return '<span class="status ' . $element->status . '"></span>';
         case 'comment':
             $user = craft()->users->getUserById($element->userId);
             if ($user == null) {
                 $userName = $element->name;
             } else {
                 $url = UrlHelper::getCpUrl('users/' . $user->id);
                 $userName = $user->getFriendlyName();
             }
             $html = '<div class="comment-block">';
             $html .= '<a href="' . $element->getCpEditUrl() . '">';
             $html .= '<span class="username">' . $userName . '</span>';
             $html .= '<small>' . $element->getExcerpt(0, 150) . '</small></a>';
             $html .= '</div>';
             return $html;
         default:
             return parent::getTableAttributeHtml($element, $attribute);
     }
 }
 /**
  */
 public function onAfterInstall()
 {
     /* -- Show our "Welcome to Instant Analytics" message */
     if (!craft()->isConsole()) {
         craft()->request->redirect(UrlHelper::getCpUrl('instantanalytics/welcome'));
     }
 }
 /**
  * Returns the table view HTML for a given attribute.
  *
  * @param BaseElementModel $element
  * @param string $attribute
  * @return string
  */
 public function getTableAttributeHtml(BaseElementModel $element, $attribute)
 {
     switch ($attribute) {
         case 'owner':
             if ($element->ownerType == 'guest') {
                 return Craft::t('Guest');
             } else {
                 $user = craft()->users->getUserById($element->ownerId);
                 if ($user == null) {
                     return Craft::t('[Deleted User]');
                 } else {
                     $url = UrlHelper::getCpUrl('users/' . $user->id);
                     return "<a href='" . $url . "'>" . $user->getFriendlyName() . "</a>";
                 }
             }
         case 'itemCount':
             return count($element->items());
         case 'itemList':
             $items = $element->items();
             $str = array();
             $i = 0;
             foreach ($items as $item) {
                 if ($i < $this->listInlineViewLimit) {
                     $parent = craft()->entries->getEntryById($item->elementId);
                     $url = UrlHelper::getCpUrl('shortlist/list/' . $element->id . '#' . $item->elementId);
                     $str[] = '<a href="' . $url . '">' . $parent->title . '</a>';
                 }
                 $i++;
             }
             $ret = implode(', ', $str);
             if (count($items) > $this->listInlineViewLimit) {
                 $hidden = count($items) - $this->listInlineViewLimit;
                 $moreUrl = UrlHelper::getCpUrl('shortlist/list/' . $element->id . '#items');
                 $ret .= " .. <a href='" . $moreUrl . "'>+" . $hidden . " more</a>";
             }
             return $ret;
         default:
             return $element->{$attribute};
     }
 }
 /**
  * Sidebar Navigation
  *
  */
 public function navigation()
 {
     $navigationSections = [['heading' => Craft::t('Menu'), 'nav' => [['label' => Craft::t('Dashboard'), 'icon' => 'tachometer', 'extra' => '', 'url' => UrlHelper::getCpUrl('formbuilder2')], ['label' => Craft::t('Forms'), 'icon' => 'list-alt', 'extra' => craft()->formBuilder2_form->getTotalForms(), 'url' => UrlHelper::getCpUrl('formbuilder2/forms')], ['label' => Craft::t('Entries'), 'icon' => 'file-text-o', 'extra' => craft()->formBuilder2_entry->getTotalEntries(), 'url' => UrlHelper::getCpUrl('formbuilder2/entries')]]], ['heading' => Craft::t('Quick Links'), 'nav' => [['label' => Craft::t('Create New Form'), 'icon' => 'pencil-square-o', 'extra' => '', 'url' => UrlHelper::getCpUrl('formbuilder2/forms/new')]]], ['heading' => Craft::t('Tools'), 'nav' => [['label' => Craft::t('Export'), 'icon' => 'share-square-o', 'extra' => '', 'url' => UrlHelper::getCpUrl('formbuilder2/tools/export')], ['label' => Craft::t('Configuration'), 'icon' => 'sliders', 'extra' => '', 'url' => UrlHelper::getCpUrl('formbuilder2/tools/configuration')]]]];
     return $navigationSections;
 }
示例#20
0
 public function onAfterInstall()
 {
     /* -- Show our "Welcome to SEOmatic" message */
     if (!craft()->isConsole()) {
         craft()->request->redirect(UrlHelper::getCpUrl('seomatic/welcome'));
     }
 }
 /**
  * Returns the element's CP edit URL.
  *
  * @return string|false
  */
 public function getCpEditUrl()
 {
     return UrlHelper::getCpUrl('shortlist/item/' . $this->id);
 }
 /**
  * Get Control Panel Edit Url
  *
  */
 public function getCpEditUrl()
 {
     return UrlHelper::getCpUrl('formbuilder2/entries/' . $this->id . '/edit');
 }
示例#23
0
 /**
  * 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();
     $path = craft()->config->get('actionTrigger') . '/users/setpassword';
     $params = array('code' => $unhashedVerificationCode, 'id' => $userRecord->uid);
     $scheme = UrlHelper::getProtocolForTokenizedUrl();
     if ($user->can('accessCp')) {
         return UrlHelper::getCpUrl($path, $params, $scheme);
     } else {
         $locale = $user->preferredLocale ?: craft()->i18n->getPrimarySiteLocaleId();
         return UrlHelper::getSiteUrl($path, $params, $scheme, $locale);
     }
 }
示例#24
0
 /**
  * @inheritDoc BaseElementModel::getCpEditUrl()
  *
  * @return string|false
  */
 public function getCpEditUrl()
 {
     if ($this->isCurrent()) {
         return UrlHelper::getCpUrl('myaccount');
     } else {
         if (craft()->getEdition() == Craft::Client && $this->client) {
             return UrlHelper::getCpUrl('clientaccount');
         } else {
             if (craft()->getEdition() == Craft::Pro) {
                 return UrlHelper::getCpUrl('users/' . $this->id);
             } else {
                 return false;
             }
         }
     }
 }
示例#25
0
 /**
  * Start import task.
  */
 public function actionImport()
 {
     // Get import post
     $settings = craft()->request->getRequiredPost('import');
     // Get file
     $fileId = craft()->request->getParam('file');
     $file = craft()->assets->getFileById($fileId);
     // Get mapping fields
     $map = craft()->request->getParam('fields');
     $unique = craft()->request->getParam('unique');
     // Get rows/steps from file
     $rows = count(craft()->import->data($file->id));
     // Proceed when atleast one row
     if ($rows) {
         // Set more settings
         $settings = array_merge(array('user' => craft()->userSession->getUser()->id, 'file' => $file->id, 'rows' => $rows, 'map' => $map, 'unique' => $unique), $settings);
         // Create history
         $history = craft()->import_history->start($settings);
         // Add history to settings
         $settings['history'] = $history;
         // UNCOMMENT FOR DEBUGGING
         //craft()->import->debug($settings, $history, 1);
         // Create the import task
         $task = craft()->tasks->createTask('Import', Craft::t('Importing') . ' ' . $file->filename, $settings);
         // Notify user
         craft()->userSession->setNotice(Craft::t('Import process started.'));
         // Redirect to history
         $this->redirect(UrlHelper::getCpUrl('import/history', array('task' => $task->id)));
     } else {
         // Redirect to history
         $this->redirect(UrlHelper::getCpUrl('import/history'));
     }
 }
 public function onAfterInstall()
 {
     craft()->request->redirect(UrlHelper::getCpUrl('/bluefootcart/thanks/'));
 }
 /**
  * @inheritDoc BaseElementModel::getCpEditUrl()
  *
  * @return string|false
  */
 public function getCpEditUrl()
 {
     return UrlHelper::getCpUrl('globals/' . $this->handle);
 }
 /**
  * Takes over after a user has been activated.
  *
  * @param UserModel $user
  */
 private function _onAfterActivateUser(UserModel $user)
 {
     // Should we log them in?
     $loggedIn = false;
     if (craft()->config->get('autoLoginAfterAccountActivation')) {
         $loggedIn = craft()->userSession->loginByUserId($user->id, false, true);
     }
     // Can they access the CP?
     if ($user->can('accessCp')) {
         $postCpLoginRedirect = craft()->config->get('postCpLoginRedirect');
         $url = UrlHelper::getCpUrl($postCpLoginRedirect);
     } else {
         $activateAccountSuccessPath = craft()->config->getLocalized('activateAccountSuccessPath');
         $url = UrlHelper::getSiteUrl($activateAccountSuccessPath);
     }
     $this->redirect($url);
 }
示例#29
0
 /**
  * Returns the element's CP edit URL.
  *
  * @return string|false
  */
 public function getCpEditUrl()
 {
     $locale = craft()->isLocalized() && $this->locale != craft()->language ? '/' . $this->locale : '';
     return UrlHelper::getCpUrl('seomatic/' . 'meta' . '/' . $this->id . $locale);
 }
示例#30
0
 /**
  * Returns the element's CP edit URL.
  *
  * @return string|false
  */
 public function getCpEditUrl()
 {
     return UrlHelper::getCpUrl('amforms/forms/edit/' . $this->id);
 }