public function getColumnContent($field, $record, $col) { if ($record->canView()) { $data = new ArrayData(array('Link' => Controller::join_links('CapturedEmailController', 'view', $record->ID))); return $data->renderWith('ViewEmailButton'); } }
function Link($action = null) { if ($this->isInDB()) { return parent::Link($action); } return Controller::join_links(self::$url_segment, $action); }
public function LinkWithSearch($extraParamStr = '') { $params = array_diff_key($this->request->getVars(), array('url' => null)); parse_str($extraParamStr, $extraParams); $params = array_merge($params, (array) $extraParams); return Controller::join_links($this->Link(), '?' . http_build_query($params)); }
/** * Gets the form used for viewing a time log */ public function getEditForm($id = null, $fields = null) { $record = $this->currentPage(); if ($this->action == 'view' && $record) { $fields = new FieldList(new HeaderField('LogHeader', _t('KapostBridgeLogViewer.VIEWING_ENTRY', '_Viewing Log Entry: {datetime}', array('datetime' => $record->dbObject('Created')->FormatFromSettings())), 3), new ReadonlyField('UserAgent', _t('KapostBridgeLogViewer.USER_AGENT', '_Requestor User Agent')), new ReadonlyField('Method', _t('KapostBridgeLogViewer.METHOD', '_Method')), ToggleCompositeField::create('RequestData', _t('KapostBridgeLogViewer.KAPOST_REQUEST', '_Kapost Request'), new FieldList(ReadonlyField::create('RequestFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3), ToggleCompositeField::create('ResponseData', _t('KapostBridgeLogViewer.SILVERSTRIPE_RESPONSE', '_SilverStripe Response'), new FieldList(ReadonlyField::create('ResponseFormatted', '')->setTemplate('KapostBridgeLogField')->addExtraClass('log-contents cms-panel-layout')))->setHeadingLevel(3)); $refObj = $record->ReferenceObject; if (!empty($refObj) && $refObj !== false && $refObj->exists()) { if (method_exists($refObj, 'CMSEditLink')) { $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObj->CMSEditLink(), _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData'); } else { if ($refObj instanceof File) { $refObjLink = Controller::join_links(LeftAndMain::config()->url_base, AssetAdmin::config()->url_segment, 'EditForm/field/File/item', $refObj->ID, 'edit'); $fields->insertBefore(new KapostLogLinkField('CMSEditLink', _t('KapostBridgeLogViewer.REFERENCED_OBJECT', '_Referenced Object'), $refObjLink, _t('KapostBridgeLogViewer.VIEW_REFERENCED_OBJECT', '_View Referenced Object')), 'RequestData'); } } } } else { $fields = new FieldList(); } $form = new CMSForm($this, 'EditForm', $fields, new FieldList()); $form->setResponseNegotiator($this->getResponseNegotiator()); $form->addExtraClass('cms-edit-form center'); $form->setAttribute('data-layout-type', 'border'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $form->setAttribute('data-pjax-fragment', 'CurrentForm'); $form->setHTMLID('Form_EditForm'); if ($record) { $form->loadDataFrom($record); } return $form; }
public function ProfileLink($action = null) { if ($directorypage = MembersDirectoryPage::get()->first()) { return Controller::join_links($directorypage->Link(), "view", $this->owner->ID, $action); } return Controller::join_links(MemberProfilePage_Controller::config()->url_segment, $action); }
/** * @param $key The nav key, e.g. "doc", "userhelp" * @return HTMLText */ public static function GlobalNav($key) { $baseURL = GlobalNavSiteTreeExtension::get_toolbar_baseurl(); Requirements::css(Controller::join_links($baseURL, Config::inst()->get('GlobalNav', 'css_path'))); // If this method haven't been called before, get the toolbar and cache it if (self::$global_nav_html === null) { // Set the default to empty self::$global_nav_html = ''; // Prevent recursion from happening if (empty($_GET['globaltoolbar'])) { $host = GlobalNavSiteTreeExtension::get_toolbar_hostname(); $path = Director::makeRelative(GlobalNavSiteTreeExtension::get_navbar_filename($key)); if (Config::inst()->get('GlobalNav', 'use_localhost')) { self::$global_nav_html = file_get_contents(BASE_PATH . $path); } else { $url = Controller::join_links($baseURL, $path, '?globaltoolbar=true'); $connectionTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'connection_timeout'); $transferTimeout = Config::inst()->get('GlobalNavTemplateProvider', 'transfer_timeout'); // Get the HTML and cache it self::$global_nav_html = self::curl_call($url, $connectionTimeout, $transferTimeout); } } } $html = DBField::create_field('HTMLText', self::$global_nav_html); $html->setOptions(array('shortcodes' => false)); return $html; }
/** * A form action that handles populating the record with mock data * * @param array $data The data that as passed in from the form * @param Form $form The Form object that was used * @return SSViewer */ public function doAddMockData($data, $form) { $this->owner->record->fill(array('only_empty' => true, 'include_relations' => false, 'download_images' => false)); Controller::curr()->getResponse()->addHeader("X-Pjax", "Content"); $link = Controller::join_links($this->owner->gridField->Link(), "item", $this->owner->record->ID); return Controller::curr()->redirect($link); }
/** * @return {Form} */ public function ItemEditForm() { //Timepicker Requirements::css('calendar/thirdparty/timepicker/jquery.timepicker.css'); //Requirements::javascript('calendar/thirdparty/timepicker/jquery.timepicker.js'); //modification to allow timepicker and timeentry to work in tandem: Requirements::javascript('calendar/thirdparty/timepicker/jquery.timepicker-timeentry.js'); //Timeentry Requirements::javascript('calendar/thirdparty/timeentry/jquery.timeentry.js'); //CSS/JS Dependencies Requirements::css("calendar/css/admin/CalendarEventGridFieldDetailForm.css"); Requirements::javascript("calendar/javascript/events/EventFields.js"); Requirements::javascript("calendar/javascript/admin/CalendarEventGridFieldDetailForm.js"); $form = parent::ItemEditForm(); if (!$form instanceof Form) { return $form; } $form->addExtraClass('CalendarEventGridfieldDetailForm'); if ($this->record->ID !== 0) { $actionFields = $form->Actions(); $link = Controller::join_links($this->gridField->Link('item'), 'new'); $actionFields->push(new LiteralField('addNew', '<a href="' . $link . '" class="action action-detail ss-ui-action-constructive ' . 'ss-ui-button ui-button ui-widget ui-state-default ui-corner-all new new-link" data-icon="add">Add new ' . $this->record->i18n_singular_name() . '</a>')); } return $form; }
public function register(SS_HTTPRequest $request) { if ($request->isPOST()) { try { if (Customer::get()->filter('Email', $request->postVar('Email'))->count()) { throw new ValidationException("Sorry a member with that email address already exists"); } $password = Customer::create_new_password(); /** @var Customer $member */ $member = Injector::inst()->create('ProfiledMemberClass'); $member->changePassword($password); // update member with cleansed posted variables $updateData = array_merge(ProfiledMemberForm::update_models('register', array_merge($request->postVars(), ['Password' => $password]), $member)); /** @var CryptofierImplementation $crypto */ $crypto = Injector::inst()->get('CryptofierService'); $token = $crypto->friendly($crypto->encrypt($member->Email)); $member->{ProfiledMemberExtension::VerificationFieldName} = $token; $member->write(); $member->addToGroupByCode(self::CustomerGroupCode); // add verification link and HasRegisteredFlag $updateData = array_merge(['Password' => $password, 'VerificationLink' => Controller::join_links(Director::absoluteBaseURL(), $this()->ActionLink("verify/{$token}"))], $updateData); $this->sendEmail('Register', $member, $updateData); Session::set(self::SessionEmailKey, $member->Email); $url = CrackerjackModule::get_config_setting(__CLASS__, 'post_register_url') ?: $this()->ActionLink('thanks'); return $this()->redirect($url); } catch (ValidationException $e) { ProfiledMemberForm::set_form_message($e->getMessage(), CrackerjackForm::Bad); return $this()->redirectBack(); } } else { return array(); } }
public function placeOrder(SS_HTTPRequest $request) { $eventbrite_event_header = $request->getHeader('X-Eventbrite-Event'); if (!$eventbrite_event_header) { return $this->httpError(403); } if ($eventbrite_event_header !== 'order.placed') { return $this->httpError(403); } if (!$this->isJson()) { return $this->httpError(403); } $json_request = $this->getJsonRequest(); if (!isset($json_request['config']) || !isset($json_request['api_url'])) { return $this->httpError(403); } $config = $json_request['config']; if (!isset($config['action']) || $config['action'] !== 'order.placed') { return $this->httpError(403); } $current_local_url = Controller::join_links(Director::absoluteBaseURL(), $request->getURL()); if (!isset($config['endpoint_url']) || $config['endpoint_url'] !== $current_local_url) { return $this->httpError(403); } try { $this->manager->registerEvent('ORDER_PLACED', $json_request['api_url']); } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); return $this->httpError(500); } return true; }
/** * Return a Link to this field, if the list is an instance of StatefulGridFieldList the session key for the state is appended to the url * @param {string} $action Action to append to the url * @return {string} Relative link to this form field */ public function Link($action = null) { if ($this->list instanceof StatefulGridFieldList) { return Controller::join_links(parent::Link($action), '?' . strtolower($this->name) . '_skey=' . $this->state->getSessionKey()); } return parent::Link($action); }
/** * Returns a list of months where blog posts are present. * * @return DataList **/ public function getArchive() { $query = $this->Blog()->getBlogPosts()->dataQuery(); if ($this->Type == "Yearly") { $query->groupBy("DATE_FORMAT(PublishDate, '%Y')"); } else { $query->groupBy("DATE_FORMAT(PublishDate, '%Y-%M')"); } $articles = $this->Blog()->getBlogPosts()->setDataQuery($query); if ($this->NumberToDisplay > 0) { $articles = $articles->limit($this->NumberToDisplay); } $archive = new ArrayList(); if ($articles->count() > 0) { foreach ($articles as $article) { if ($this->Type == "Yearly") { $year = date('Y', strtotime($article->PublishDate)); $month = null; $title = $year; } else { $year = date('Y', strtotime($article->PublishDate)); $month = date('m', strtotime($article->PublishDate)); $title = date('F Y', strtotime($article->PublishDate)); } $archive->push(new ArrayData(array("Title" => $title, "Link" => Controller::join_links($this->Blog()->Link("archive"), $year, $month)))); } } return $archive; }
public function doContinue($data) { Session::set('Checkout.PaymentMethodID', $data['PaymentMethodID']); Session::set("Checkout.PostageID", $data["PostageID"]); $url = Controller::join_links(Director::absoluteBaseUrl(), Payment_Controller::config()->url_segment); return $this->controller->redirect($url); }
public function getCMSFields() { $fields = parent::getCMSFields(); //adding upload field - if item has already been saved if ($this->ID && $this->AssetsFolderID != 0) { //this is the default, for non multi-language sites if (!class_exists('Translatable') || $this->Locale == Translatable::default_locale()) { //Use SortableUploadField instead of UploadField! //The upload directory is expected to have been set in {@see UploadDirRules}, //and should be something like: "assets/ID-Pagename" //TODO: This could easily be configurable through yml files (to e.g. "assets/galleries/ID"), //so this module could do without the upload dir rules // //read more about adding additinoal metadata to images here: //http://doc.silverstripe.org/framework/en/reference/uploadfield $imageField = new SortableUploadField('Images', ''); $fields->addFieldToTab('Root.Images', $imageField); } else { $orig = $this->getTranslation(Translatable::default_locale()); $html = sprintf('<a href="%s">%s</a>', Controller::join_links($orig->CMSEditLink(), '?locale=' . $orig->Locale), 'Images are administered through ' . i18n::get_locale_name($orig->Locale)); $fields->addFieldToTab('Root.Images', LiteralField::create('ImagesDesc', $html)); } } return $fields; }
/** * Perform an api request with the given options * * @param string $path the request path; can consist of resource name, identifier and GET params * @param array $options * * string `body` the data * * int `code` the expected response code * * string `method` the http method * * ApiSession `session` the test session * @return array * @throws SS_HTTPResponse_Exception */ public function makeApiRequest($path, $options = []) { $settings = array_merge(['session' => null, 'token' => null, 'method' => 'GET', 'body' => null, 'code' => 200], $options); $response = Director::test(Controller::join_links($this->namespace, $path), null, $settings['session'], $settings['method'], $settings['body'], ['Authorization' => $settings['token'], 'Accept' => 'application/json']); $this->assertEquals($settings['code'], $response->getStatusCode(), "Wrong status code: {$response->getBody()}"); return json_decode($response->getBody(), true); }
function updateCMSFields(FieldList $fields) { $subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain"); $subsitesMap = array(); if ($subsites && $subsites->Count()) { $subsitesMap = $subsites->map('ID', 'Title'); unset($subsitesMap[$this->owner->SubsiteID]); } // Master page edit field (only allowed from default subsite to avoid inconsistent relationships) $isDefaultSubsite = $this->owner->SubsiteID == 0 || $this->owner->Subsite()->DefaultSite; if ($isDefaultSubsite && $subsitesMap) { $fields->addFieldToTab('Root.Main', new DropdownField("CopyToSubsiteID", _t('SiteTreeSubsites.CopyToSubsite', "Copy page to subsite"), $subsitesMap, '')); $fields->addFieldToTab('Root.Main', $copyAction = new InlineFormAction("copytosubsite", _t('SiteTreeSubsites.CopyAction', "Copy"))); $copyAction->includeDefaultJS(false); } // replace readonly link prefix $subsite = $this->owner->Subsite(); $nested_urls_enabled = Config::inst()->get('SiteTree', 'nested_urls'); if ($subsite && $subsite->ID) { $baseUrl = Director::protocol() . $subsite->domain() . '/'; $baseLink = Controller::join_links($baseUrl, $nested_urls_enabled && $this->owner->ParentID ? $this->owner->Parent()->RelativeLink(true) : null); $urlsegment = $fields->dataFieldByName('URLSegment'); $urlsegment->setURLPrefix($baseLink); } }
/** * Handles the new/edit screen * @param {SS_HTTPRequest} $request HTTP Request * @return {string} HTML to be rendered */ public function edit($request) { $controller = $this->getToplevelController(); $form = $this->ItemEditForm($this->gridField, $request); if ($this->record->ID == 0) { if ($request->getVar('ItemType')) { if ($addButton = $this->gridField->getConfig()->getComponentByType('AddNewItemTypeButton')) { $values = $addButton->getRawDropdownValues(); if (!array_key_exists($request->getVar('ItemType'), $values)) { user_error('The item type "' . htmlentities($request->getVar('ItemType')) . '" is not one of the available item types', E_USER_ERROR); } $form->setFormAction(Controller::join_links($form->FormAction(), '?ItemType=' . $request->getVar('ItemType'))); } else { user_error('You must have the GridField Component "AddNewItemTypeButton" in your GridField config', E_USER_ERROR); } } } $return = $this->customise(array('Backlink' => $controller->hasMethod('Backlink') ? $controller->Backlink() : $controller->Link(), 'ItemEditForm' => $form))->renderWith($this->template); if ($request->isAjax()) { return $return; } else { // If not requested by ajax, we need to render it within the controller context+template return $controller->customise(array('Content' => $return)); } }
public function getColumnContent($field, $record, $col) { if ($record->canView()) { $data = new ArrayData(array('Link' => Controller::join_links($field->Link('item'), $record->ID, 'version', $record->Version, 'view'))); return $data->renderWith('GridFieldViewButton'); } }
/** * This does not actually perform any validation, but just creates the * initial registration object. */ public function validateStep($data, $form) { $form = $this->getForm(); $datetime = $form->getController()->getDateTime(); $confirmation = $datetime->Event()->RegEmailConfirm; $registration = $this->getForm()->getSession()->getRegistration(); // If we require email validation for free registrations, then send // out the email and mark the registration. Otherwise immediately // mark it as valid. if ($confirmation) { $email = new Email(); $config = SiteConfig::current_site_config(); $registration->TimeID = $datetime->ID; $registration->Status = 'Unconfirmed'; $registration->write(); if (Member::currentUserID()) { $details = array('Name' => Member::currentUser()->getName(), 'Email' => Member::currentUser()->Email); } else { $details = $form->getSavedStepByClass('EventRegisterTicketsStep'); $details = $details->loadData(); } $link = Controller::join_links($this->getForm()->getController()->Link(), 'confirm', $registration->ID, '?token=' . $registration->Token); $regLink = Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token); $email->setTo($details['Email']); $email->setSubject(sprintf('Confirm Registration For %s (%s)', $datetime->getTitle(), $config->Title)); $email->setTemplate('EventRegistrationConfirmationEmail'); $email->populateTemplate(array('Name' => $details['Name'], 'Registration' => $registration, 'RegLink' => $regLink, 'Title' => $datetime->getTitle(), 'SiteConfig' => $config, 'ConfirmLink' => Director::absoluteURL($link))); $email->send(); Session::set("EventRegistration.{$registration->ID}.message", $datetime->Event()->EmailConfirmMessage); } else { $registration->Status = 'Valid'; $registration->write(); } return true; }
protected function importMedia($item, $page) { $source = $item->getSource(); $params = $this->importer->getParams(); $folder = $params['AssetsPath']; $content = $item->Content; if ($folder) { $folderId = Folder::find_or_make($folder)->ID; } $url = trim(preg_replace('~^[a-z]+://~', null, $source->BaseUrl), '/'); $pattern = sprintf('~[a-z]+://%s/wp-content/uploads/[^"]+~', $url); if (!preg_match_all($pattern, $page->Content, $matches)) { return; } foreach ($matches[0] as $match) { if (!($contents = @file_get_contents($match))) { continue; } $name = basename($match); $path = Controller::join_links(ASSETS_PATH, $folder, $name); $link = Controller::join_links(ASSETS_DIR, $folder, $name); file_put_contents($path, $contents); $page->Content = str_replace($match, $link, $page->Content); } Filesystem::sync($folderId); $page->write(); }
/** * Handles validating the final step and writing the tickets data to the * registration object. */ public function finish($data, $form) { parent::finish($data, $form); $step = $this->getCurrentStep(); $datetime = $this->getController()->getDateTime(); $registration = $this->session->getRegistration(); $ticketsStep = $this->getSavedStepByClass('EventRegisterTicketsStep'); $tickets = $ticketsStep->loadData(); // Check that the requested tickets are still available. if (!$this->validateTickets($tickets['Tickets'], $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); $this->controller->redirectBack(); return false; } // Validate the final step. if (!$step->validateStep($data, $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); $this->controller->redirectBack(); return false; } $this->session->delete(); // If the registrations is already valid, then send a details email. if ($registration->Status == 'Valid') { EventRegistrationDetailsEmail::factory($registration)->send(); } $this->extend('onRegistrationComplete', $registration); $this->controller->redirect(Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token)); }
/** * Test Controller::join_links() */ function testJoinLinks() { /* Controller::join_links() will reliably join two URL-segments together so that they will be appropriately parsed by the URL parser */ $this->assertEquals("admin/crm/MyForm", Controller::join_links("admin/crm", "MyForm")); $this->assertEquals("admin/crm/MyForm", Controller::join_links("admin/crm/", "MyForm")); /* It will also handle appropriate combination of querystring variables */ $this->assertEquals("admin/crm/MyForm?flush=1", Controller::join_links("admin/crm/?flush=1", "MyForm")); $this->assertEquals("admin/crm/MyForm?flush=1", Controller::join_links("admin/crm/", "MyForm?flush=1")); $this->assertEquals("admin/crm/MyForm?field=1&other=1", Controller::join_links("admin/crm/?field=1", "MyForm?other=1")); /* It can handle arbitrary numbers of components, and will ignore empty ones */ $this->assertEquals("admin/crm/MyForm/", Controller::join_links("admin/", "crm", "", "MyForm/")); $this->assertEquals("admin/crm/MyForm/?a=1&b=2", Controller::join_links("admin/?a=1", "crm", "", "MyForm/?b=2")); /* It can also be used to attach additional get variables to a link */ $this->assertEquals("admin/crm?flush=1", Controller::join_links("admin/crm", "?flush=1")); $this->assertEquals("admin/crm?existing=1&flush=1", Controller::join_links("admin/crm?existing=1", "?flush=1")); $this->assertEquals("admin/crm/MyForm?a=1&b=2&c=3", Controller::join_links("?a=1", "admin/crm", "?b=2", "MyForm?c=3")); /* Note, however, that it doesn't deal with duplicates very well. */ $this->assertEquals("admin/crm?flush=1&flush=1", Controller::join_links("admin/crm?flush=1", "?flush=1")); $this->assertEquals('admin/action', Controller::join_links('admin/', '/', '/action'), 'Test that multiple slashes are trimmed.'); $this->assertEquals('/admin/action', Controller::join_links('/admin', 'action')); /* One fragment identifier is handled as you would expect */ $this->assertEquals("my-page?arg=var#subsection", Controller::join_links("my-page#subsection", "?arg=var")); /* If there are multiple, it takes the last one */ $this->assertEquals("my-page?arg=var#second-section", Controller::join_links("my-page#subsection", "?arg=var", "#second-section")); }
/** * SSCompactNavigator first checks if you are allowed to see the navigation bar, and if so, then checks * if third party templates have been specified. If so, it loads them, and provides them with the required * variables. If not, it loads the defaults instead. */ public function SSCompactNavigator() { if (Director::isDev() || Permission::check('CMS_ACCESS_CMSMain')) { $RenderTemplate = isset(CompactNavigator::$Template) ? CompactNavigator::$Template : $this->class; if (isset(CompactNavigator::$CssTheme)) { Requirements::css(CompactNavigator::$CssTheme); } else { Requirements::css('compactnavigator/css/CompactNavigator.css'); } if (isset(CompactNavigator::$JsTheme)) { Requirements::javascript(CompactNavigator::$JsTheme); } else { Requirements::javascript('compactnavigator/scripts/CompactNavigator.js'); } if (class_exists("CMSMain")) { $this->owner->cmsLink = Controller::join_links(singleton("CMSMain")->Link("edit"), "show"); } $this->owner->adminLink = self::$adminLink; if ($date = Versioned::current_archived_date()) { $this->owner->DisplayMode = 'Archived'; $this->owner->ArDate = Object::create('Datetime', $date, null); } else { $this->owner->DisplayMode = Versioned::current_stage(); } return $this->owner->renderWith(array($RenderTemplate, 'CompactNavigatior')); } }
/** * * @param GridField $gridField * @return string - HTML */ public function getHTMLFragments($gridField) { $searchState = $gridField->State->GridFieldSearchRelation; $dataClass = $gridField->getList()->dataClass(); $forTemplate = new ArrayData(array()); $forTemplate->Fields = new ArrayList(); $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass); $value = $this->findSingleEntry($gridField, $searchFields, $searchState, $dataClass); $searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"), $value); // Apparently the data-* needs to be double qouted for the jQuery.meta data plugin $searchField->setAttribute('data-search-url', '\'' . Controller::join_links($gridField->Link('search') . '\'')); $searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass)); $searchField->addExtraClass('relation-search no-change-track'); $findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find'); $findAction->setAttribute('data-icon', 'relationfind'); $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto'); $addAction->setAttribute('data-icon', 'chain--plus'); // If an object is not found, disable the action if (!is_int($gridField->State->GridFieldAddRelation)) { $addAction->setReadonly(true); } $forTemplate->Fields->push($searchField); $forTemplate->Fields->push($findAction); $forTemplate->Fields->push($addAction); return array($this->targetFragment => $forTemplate->renderWith($this->itemClass)); }
public function Breadcrumbs($unlinked = false) { $items = parent::Breadcrumbs($unlinked); //special case for building the breadcrumbs when calling the listchildren Pages ListView action if ($parentID = $this->getRequest()->getVar('ParentID')) { $page = DataObject::get_by_id('SiteTree', $parentID); //build a reversed list of the parent tree $pages = array(); while ($page) { array_unshift($pages, $page); //add to start of array so that array is in reverse order $page = $page->Parent; } //turns the title and link of the breadcrumbs into template-friendly variables $params = array_filter(array('view' => $this->getRequest()->getVar('view'), 'q' => $this->getRequest()->getVar('q'))); foreach ($pages as $page) { $params['ParentID'] = $page->ID; $item = new StdClass(); $item->Title = $page->Title; $item->Link = Controller::join_links($this->Link(), '?' . http_build_query($params)); $items->push(new ArrayData($item)); } } return $items; }
public function LinkFor($remoteObject, $action = null) { $link = parent::RelativeLink(); $id = $remoteObject->ID; // otherwise, we're after $this link (view) plus id return Controller::join_links($link, $action, $id); }
public function onBeforeWrite() { if ($this->owner->BaseClass == "Discussion" && $this->owner->ID == 0) { $discussion = Discussion::get()->byID($this->owner->ParentID); $discussion_author = $discussion->Author(); $holder = $discussion->Parent(); $author = Member::get()->byID($this->owner->AuthorID); // Get our default email from address if (DiscussionHolder::config()->send_emails_from) { $from = DiscussionHolder::config()->send_email_from; } else { $from = Email::config()->admin_email; } // Vars for the emails $vars = array("Title" => $discussion->Title, "Author" => $author, "Comment" => $this->owner->Comment, 'Link' => Controller::join_links($holder->Link("view"), $discussion->ID, "#comments-holder")); // Send email to discussion owner if ($discussion_author && $discussion_author->Email && $discussion_author->RecieveCommentEmails && $discussion_author->ID != $this->owner->AuthorID) { $subject = _t("Discussions.NewCreatedReplySubject", "{Nickname} replied to your discussion", null, array("Nickname" => $author->Nickname)); $email = new Email($from, $discussion_author->Email, $subject); $email->setTemplate('NewCreatedReplyEmail'); $email->populateTemplate($vars); $email->send(); } // Send to anyone who liked this, if they want notifications foreach ($discussion->LikedBy() as $liked) { if ($liked->RecieveLikedReplyEmails && $liked->Email && $liked->ID != $author->ID) { $subject = _t("Discussions.NewLikedReplySubject", "{Nickname} replied to your liked discussion", null, array("Nickname" => $author->Nickname)); $email = new Email($from, $liked->Email, $subject); $email->setTemplate('NewLikedReplyEmail'); $email->populateTemplate($vars); $email->send(); } } } }
function LinkFor($item) { if ($item->parent !== $this) { user_error('Tried to get link for noun that is not a root item', E_USER_ERROR); } return Controller::join_links($this->Link(), $item->linkFragment); }
/** * @param GridField $gridField * @param DataObject $record * @param string $columnName * * @return string - the HTML for the column */ public function getColumnContent($gridField, $record, $columnName) { // No permission checks, handled through GridFieldDetailForm, // which can make the form readonly if no edit permissions are available. $data = new ArrayData(array('Link' => Controller::join_links($gridField->Link('item'), $record->ID, 'edit'))); return $data->renderWith('GridFieldEditButton'); }
/** * Handles validating the final step and writing the tickets data to the * registration object. */ public function finish($data, $form) { $step = $this->getCurrentStep(); $datetime = $this->getController()->getDateTime(); $registration = $this->session->getRegistration(); $ticketsStep = $this->getSavedStepByClass('EventRegisterTicketsStep'); $tickets = $ticketsStep->loadData(); // Check that the requested tickets are still available. if (!$this->validateTickets($tickets['Tickets'], $form)) { Session::set("FormInfo.{$form->FormName()}.data", $form->getData()); $this->controller->redirectBack(); return false; } $success = parent::finish($data, $form); if ($success === false) { return false; } // see whether we've been redirected by the step (most typically with Payment steps) $controller = Controller::curr(); /* @var $controller Controller */ if ($controller->redirectedTo()) { return; } $this->session->delete(); // If the registrations is already valid, then send a details email. if ($registration->Status == 'Valid') { EventRegistrationDetailsEmail::factory($registration)->send(); } $this->extend('onRegistrationComplete', $registration); $this->controller->redirect(Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token)); }