/** * Cache search with the home url to make sure it * a. belongs to a subsite and * b. only gets cached once * * @return array */ public function urlsToCache() { if ($this->owner->URLSegment == 'home') { $urls[Director::BaseURL() . 'search'] = 0; } $urls[$this->owner->Link()] = 0; return $urls; }
public function updateCMSFields(FieldList $fields) { if ($this->owner->ID) { $uf = SiteTreeURLSegmentField::create("URLSegment", "URL Segment"); $uf->setURLPrefix(Director::BaseURL() . $this->getURLPrefix()); $fields->addFieldToTab("Root.Main", $uf, "Title"); } else { $fields->removeByName("URLSegment"); } }
function finish($data, $form) { parent::finish($data, $form); $savedSteps = $this->getSavedSteps(); $savedData = array(); foreach ($savedSteps as $step) { $savedData = array_merge($savedData, $step->loadData()); } $fields = new FieldSet(); $fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>")); foreach ($savedData as $key => $value) { $fields->push(new LiteralField($key . '_copy', "<p><strong>{$key}</strong> {$value}</p>")); } Session::set("MultiFormMessage", "Your information has been submitted."); Director::redirect(Director::BaseURL() . $this->Controller()->URLSegment); }
public function onBeforeInit() { /* ========================================= * Combine JS =========================================*/ Requirements::combine_files('combined.js', array('boilerplate/javascript/jquery.1.11.1.min.js', 'boilerplate/javascript/modernizr.2.8.3.js', 'boilerplate/javascript/bootstrap-3.2.0.min.js', 'boilerplate/javascript/script.js')); /* ========================================= * CSS =========================================*/ Requirements::css('boilerplate/css/main.min.css'); //Requirements::css('themes/boilerplate/css/main.min.css'); /* ========================================= * IE Shivs =========================================*/ $baseHref = Director::BaseURL(); Requirements::insertHeadTags('<!--[if lt IE 9]> <script type="text/javascript" src="' . $baseHref . 'boilerplate/javascript/html5.js"></script> <script type="text/javascript" src="' . $baseHref . 'boilerplate/javascript/respond.min.js"></script> <![endif]-->'); }
/** * ACTION /view * Fetch the requested product and render its product page. * If it doesn't exist, return HTTP 404. * * @return HTMLText */ public function view() { /** * StoreSettings */ $conf = StoreSettings::get_settings(); /** * Get the URLSegment of the Product from the request */ $URLSegment = $this->request->param('ID'); /** * If URLSegment doesn't exist redirect with Error 404 redirect to the StoreFront. */ if (!$URLSegment) { return $this->httpError(404); } /* The Product selected */ $Product = DataObject::get_one("Product", "`URLSegment`='{$URLSegment}'"); /** * If the Product doesn't exist, fail with httpError(404). */ if (!$Product) { return $this->httpError(404); } else { /** * If product is out of stock, and admin has defined it should be completely * hidden, then return HTTP error 302 and temporarily redirect to the storefront. * Error 302 should prevent Search Engines modifying their entry for this product * whilst its hidden. */ if ($Product->StockLevel <= $conf->Stock_OutOfStockThreshold && $conf->Stock_ProductOutOfStock == 1) { return $this->redirect(Director::BaseURL() . DataObject::get_one("SiteTree", "ClassName='Store'")->URLSegment, 302); } /** * If Product visibility is set to false return with httpError(404) otherwise * return the Product page with renderWith() */ return !$Product->Visible ? $this->httpError(404) : $this->customise(array("Title" => $Product->Title, "Product" => $Product))->renderWith(array("Store_Product", "Page")); } }
public function init() { $baseHref = Director::BaseURL(); /** ----------------------------------------- * Javascript * ----------------------------------------*/ Requirements::insertHeadTags('<script type="text/javascript" src="' . $baseHref . project() . '/javascript/lib/modernizr.min.js"></script>', 'Modernizr'); /** * Set All JS to be right before the closing </body> tag. */ Requirements::set_force_js_to_bottom(true); if (Director::isDev()) { Requirements::javascript(project() . '/javascript/main.js'); } else { Requirements::javascript(project() . '/javascript/main.min.js'); } /** ----------------------------------------- * CSS * ----------------------------------------*/ Requirements::css(project() . '/css/main.min.css', 'all'); parent::init(); }
/** * Show the lists for the user with the given email address */ function sendmeunsubscribelink($data) { if (isset($data['Email']) && $data['Email']) { $member = DataObject::get_one("Member", "Email = '" . $data['Email'] . "'"); if ($member) { if (!($from = Email::getAdminEmail())) { $from = 'noreply@' . Director::BaseURL(); } $to = $member->Email; $subject = "Unsubscribe Link"; if ($member->AutoLoginHash) { $member->AutoLoginExpired = date('Y-m-d', time() + 86400 * 2); $member->write(); } else { $member->generateAutologinHash(); } $link = Director::absoluteBaseURL() . $this->RelativeLink('index') . "/" . $member->AutoLoginHash; $membername = $member->getName(); $body = $this->customise(array('Content' => <<<HTML Dear {$membername},<br /> <p>Please click the link below to unsubscribe from our newsletters<br /> {$link}<br /> <br > <br > Thanks </p> HTML ))->renderWith('Page'); $email = new Email($from, $to, $subject, $body); $result = $email->send(); if ($result) { Director::redirect(Director::absoluteBaseURL() . $this->RelativeLink('linksent') . "?SendEmail=" . $data['Email']); } else { Director::redirect(Director::absoluteBaseURL() . $this->RelativeLink('linksent') . "?SendError=" . $data['Email']); } } else { $form = $this->EmailAddressForm(); $message = sprintf(_t("Unsubscribe.NOTSIGNUP", "Sorry, '%s' doesn't appear to be an sign-up member with us"), $data['Email']); $form->sessionMessage($message, 'bad'); Director::redirectBack(); } } else { $form = $this->EmailAddressForm(); $message = _t("Unsubscribe.NOEMAILGIVEN", "Sorry, please type in a valid email address"); $form->sessionMessage($message, 'bad'); Director::redirectBack(); } }
/** * This method can be called by a payment gateway to provide * automated integration. * * This action performs some basic setup then hands control directly * to the payment handler's "callback" action. * * @param $request Current Request Object */ public function callback($request) { // If post data exists, process. Otherwise provide error if ($this->payment_handler === null) { // Redirect to error page return $this->redirect(Controller::join_links(Director::BaseURL(), $this->config()->url_segment, 'complete', 'error')); } // Hand the request over to the payment handler return $this->payment_handler->handleRequest($request, $this->model); }
public function FileBasePath() { return Director::BaseURL() . "assets/tinymce_templates/"; }
/** * This method is what is called at the end of the transaction. It takes * either post data or get data and then sends it to the relevent payment * method for processing. */ public function callback() { // If post data exists, process. Otherwise provide error if ($this->payment_handler !== null) { $callback = $this->payment_handler->callback(); } else { // Redirect to error page return $this->redirect(Controller::join_links(Director::BaseURL(), $this->config()->url_segment, 'complete', 'error')); } return $callback; }
public function subscribeverify() { if ($hash = $this->urlParams['ID']) { $recipient = DataObject::get_one("Recipient", "\"ValidateHash\" = '" . Convert::raw2sql($hash) . "'"); if ($recipient && $recipient->exists()) { $now = date('Y-m-d H:i:s'); if ($now <= $recipient->ValidateHashExpired) { $recipient->Verified = true; // extends the ValidateHashExpired so the a unsubscirbe link will stay alive in that peroid by law $days = UnsubscribeController::get_days_unsubscribe_link_alive(); $recipient->ValidateHashExpired = date('Y-m-d H:i:s', time() + 86400 * $days); $recipient->write(); $mailingLists = $recipient->MailingLists(); $ids = implode(",", $mailingLists->getIDList()); $templateData = array('FirstName' => $recipient->FirstName, 'MailingLists' => $mailingLists, 'UnsubscribeLink' => Director::BaseURL() . "unsubscribe/index/" . $recipient->ValidateHash . "/" . $ids, 'HashText' => $recipient->getHashText(), 'SiteConfig' => $this->SiteConfig()); //send notification email if ($this->SendNotification) { $email = new Email(); $email->setTo($recipient->Email); $from = $this->NotificationEmailFrom ? $this->NotificationEmailFrom : Email::getAdminEmail(); $email->setFrom($from); $email->setTemplate('SubscriptionConfirmationEmail'); $email->setSubject(_t('Newsletter.ConfirmSubject', "Confirmation of your subscription to our mailing lists")); $email->populateTemplate($templateData); $email->send(); } $url = $this->Link('completed') . "/" . $recipient->ID; $this->redirect($url); } } if ($recipient && $recipient->exists()) { $recipientData = $recipient->toMap(); } else { $recipientData = array(); } $daysExpired = SubscriptionPage::get_days_verification_link_alive(); $recipientData['VerificationExpiredContent1'] = sprintf(_t('Newsletter.VerificationExpiredContent1', 'The verification link is only validate for %s days.'), $daysExpired); return $this->customise(array('Title' => _t('Newsletter.VerificationExpired', 'The verification link has been expired'), 'Content' => $this->customise($recipientData)->renderWith('VerificationExpired')))->renderWith('Page'); } }
/** * standard, required method * @param String $action * @return String link for the "Controller" */ public function Link($action = null) { return Controller::join_links(Director::BaseURL(), 'dev/ecommerce/', $action); }
/** * Override Link */ public function Link($action = null) { return Director::BaseURL() . "admin/store-orders/"; }
public function Link($action = null) { return Controller::join_links(Director::BaseURL(), $this->config()->url_segment, $action); }
public static function staticAbsoluteLink($action = null) { return Controller::join_links(Director::absoluteURL(Director::BaseURL()), self::$url_segment, $action); }
/** * @ToDO: check this method * It looks like this: /$ClassName/$action/ * @return String */ function Link($action = null) { $URLSegment = Config::inst()->get($this->class, "url_segment"); if (!$URLSegment) { $URLSegment = $this->class; } return Controller::join_links(Director::BaseURL(), $URLSegment, $action); }
/** * Return the URL to the specific product handled by the Store_ProductController. */ public function link() { return Director::BaseURL() . DataObject::get_one("SiteTree", "ClassName='Store'")->URLSegment . "/product"; }
/** * Override Link */ public function link($action = null) { return Director::BaseURL() . DataObject::get_one("SiteTree", "ClassName='Store'")->URLSegment; }
<?php HtmlEditorConfig::get('cms')->enablePlugins(['viewtemplate' => Director::BaseURL() . 'viewtemplate/javascript/tinymce_viewtemplate/editor_plugin_src.js']); HtmlEditorConfig::get('cms')->addButtonsToLine(1, 'viewtemplate');
public function testBaseURL() { Director::setBaseURL('/baseurl/'); $this->assertEquals(Controller::BaseURL(), Director::BaseURL()); }