Ejemplo n.º 1
2
 function generatePDF()
 {
     // tempfolder
     $tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (is_dir($tmpFolder)) {
         Filesystem::removeFolder($tmpFolder);
     }
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     //Get site
     Requirements::clear();
     $link = Director::absoluteURL($this->pdfLink() . "/?view=1");
     $response = Director::test($link);
     $content = $response->getBody();
     $content = utf8_decode($content);
     $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
     if (!file_exists($contentfile)) {
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $content);
             fclose($fh);
         }
     }
     return $contentfile;
 }
Ejemplo n.º 2
0
	/**
	 * Includes all JS required for ImageEditor. This method requires setting
	 * a fileToEdit URL in POST.
	 *
	 * @return String
	*/ 
	public function index() {
		Requirements::clear();
		Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/scriptaculous.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Utils.js');
		//Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageHistory.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Image.js');
		//Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageTransformation.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Resizeable.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Effects.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Environment.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Crop.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Resize.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageBox.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageEditor.js');
		Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/DocumentBody.js');

		Requirements::javascript(THIRDPARTY_DIR . '/loader.js');
		Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
		Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.js');
		Requirements::css(CMS_DIR . 'css/ImageEditor/ImageEditor.css');

		if(!isset($this->requestParams['fileToEdit'])) $this->raiseError();
		$fileWithPath = $this->requestParams['fileToEdit'];
		$this->fileToEdit = $this->file2Origin($fileWithPath);
		$this->fileToEditOnlyName = $this->urlToFilename($this->fileToEdit);  
		return $this->renderWith(__CLASS__);
	}
 /**
  * Gets the overview data from new relic
  */
 public function overview_data()
 {
     //Purge Requirements
     Requirements::clear();
     //If we're not configured properly return an error
     if (!$this->getIsConfigured()) {
         $msg = _t('NewRelicPerformanceReport.API_APP_CONFIG_ERROR', '_New Relic API Key or Application ID is missing, check configuration');
         $e = new SS_HTTPResponse_Exception($msg, 400);
         $e->getResponse()->addHeader('Content-Type', 'text/plain');
         $e->getResponse()->addHeader('X-Status', rawurlencode($msg));
         throw $e;
         return;
     }
     //Build the base restful service object
     $service = new RestfulService('https://api.newrelic.com/v2/applications/' . Convert::raw2url($this->config()->application_id) . '/metrics/data.json', $this->config()->refresh_rate);
     $service->httpHeader('X-Api-Key:' . Convert::raw2url($this->config()->api_key));
     //Perform the request
     $response = $service->request('', 'POST', 'names[]=HttpDispatcher&names[]=Apdex&names[]=EndUser/Apdex&names[]=Errors/all&names[]=EndUser&period=60');
     //Retrieve the body
     $body = $response->getBody();
     if (!empty($body)) {
         $this->response->addHeader('Content-Type', 'application/json; charset=utf-8');
         return $body;
     }
     //Data failed to load
     $msg = _t('NewRelicPerformanceReport.DATA_LOAD_FAIL', '_Failed to retrieve data from New Relic');
     $e = new SS_HTTPResponse_Exception($msg, 400);
     $e->getResponse()->addHeader('Content-Type', 'text/plain');
     $e->getResponse()->addHeader('X-Status', rawurlencode($msg));
     throw $e;
 }
 public function init()
 {
     parent::init();
     Requirements::clear();
     Requirements::insertHeadTags('<meta http-equiv="Content-language" content="' . i18n::get_locale() . '" />');
     Requirements::themedCSS('sendfriend', 'screen');
 }
Ejemplo n.º 5
0
 /**
  * Loads the requirements, checks perms, etc. If an ID is in the URL, that becomes the
  * current folder.
  */
 public function init()
 {
     parent::init();
     if (!Permission::check("ADMIN") && !Permission::check("CMS_ACCESS_BrowseFiles")) {
         return Security::permissionFailure($this, _t('KickAssets.PERMISSIONFAIL', 'You do not have permission to access this section of the CMS.'));
     }
     Requirements::clear();
     Requirements::css('kickassets/css/core.css');
     Requirements::css('kickassets/css/kickassets.css');
     Requirements::javascript('kickassets/javascript/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
     Requirements::javascript('kickassets/javascript/apprise/apprise-1.5.full.js');
     Requirements::javascript('kickassets/javascript/jquery.tooltip.js');
     Requirements::css('kickassets/javascript/apprise/apprise.css');
     Requirements::javascript('kickassets/javascript/kickassets_ui.js');
     Requirements::javascript('kickassets/javascript/chosen/chosen.jquery.js');
     Requirements::css('kickassets/javascript/chosen/chosen.css');
     Requirements::javascript('kickassets/javascript/jquery.form.js');
     Requirements::javascript('kickassets/javascript/kickassets.js');
     Requirements::css('kickassets/css/kickassets_ui.css');
     if ($this->getRequest()->param('ID')) {
         $this->currentFolder = DataObject::get_by_id("Folder", (int) $this->getRequest()->param('ID'));
         $this->currentPath = KickAssetUtil::relative_asset_dir($this->currentFolder->Filename);
     } else {
         $this->currentFolder = singleton('Folder');
         $this->currentPath = false;
     }
 }
Ejemplo n.º 6
0
 /**
  * Show the content of the upload iframe.  The form is specified by a template.
  */
 function uploadiframe()
 {
     Requirements::clear();
     Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/loader.js');
     Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
     Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
     Requirements::javascript(SAPPHIRE_DIR . "/javascript/layout_helpers.js");
     Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
     Requirements::javascript(CMS_DIR . "/thirdparty/multifile/multifile.js");
     Requirements::css(CMS_DIR . "/thirdparty/multifile/multifile.css");
     Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/jquery/jquery.js");
     Requirements::javascript(SAPPHIRE_DIR . "/javascript/jquery_improvements.js");
     Requirements::css(CMS_DIR . "/css/typography.css");
     Requirements::css(CMS_DIR . "/css/layout.css");
     Requirements::css(CMS_DIR . "/css/cms_left.css");
     Requirements::css(CMS_DIR . "/css/cms_right.css");
     $id = (int) $this->request->param('ID');
     if ($id) {
         $folder = DataObject::get_by_id("Folder", $id);
     } else {
         $folder = singleton('Folder');
     }
     return array('CanUpload' => $folder->canEdit());
 }
 /**
  * Body for the preview iframe with just the typography styles included
  * @return string html
  */
 public function preview()
 {
     Requirements::clear();
     // Should contain text styles of the page by Silverstripe theme conventions.
     Requirements::css('themes/' . Config::inst()->get('SSViewer', 'theme') . '/css/editor.css');
     return $this->renderWith('PreviewFrame');
 }
 function init()
 {
     parent::init();
     // somehow themed css gets mixed in, remove it
     $reqbe = Requirements::backend();
     foreach ($reqbe->get_css() as $file => $val) {
         if (preg_match('/^themes\\//', $file)) {
             Requirements::block($file);
         }
     }
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-form/jquery.form.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.core.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.widget.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.mouse.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.tabs.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.button.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.position.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.dialog.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.draggable.js');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.core.css');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.dialog.css');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.theme.css');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.tabs.css');
     Requirements::clear('jsparty/prototype.js');
     Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js");
     Requirements::add_i18n_javascript('dbplumber/javascript/lang');
     Requirements::javascript("dbplumber/javascript/DatabaseBrowser.js");
     Requirements::javascript("dbplumber/thirdparty/jquery.event.drag-1.4.js");
     Requirements::javascript("dbplumber/thirdparty/jquery.kiketable.colsizable-1.1.js");
     Requirements::javascript("dbplumber/thirdparty/jquery.textarea-expander.js");
     Requirements::css("dbplumber/thirdparty/jquery.kiketable.colsizable-1.1.css");
     Requirements::css("dbplumber/css/DatabaseBrowser_left.css");
     Requirements::css("dbplumber/css/DatabaseBrowser_right.css");
 }
Ejemplo n.º 9
0
 /**
  * When an error page is published, create a static HTML page with its
  * content, so the page can be shown even when SilverStripe is not
  * functioning correctly before publishing this page normally.
  * @param string|int $fromStage Place to copy from. Can be either a stage name or a version number.
  * @param string $toStage Place to copy to. Must be a stage name.
  * @param boolean $createNewVersion Set this to true to create a new version number.  By default, the existing version number will be copied over.
  */
 function publish($fromStage, $toStage, $createNewVersion = false)
 {
     // Temporarily log out when producing this page
     $loggedInMember = Member::currentUser();
     Session::clear("loggedInAs");
     $alc_enc = isset($_COOKIE['alc_enc']) ? $_COOKIE['alc_enc'] : null;
     Cookie::set('alc_enc', null);
     $oldStage = Versioned::current_stage();
     // Run the page
     Requirements::clear();
     $controller = new ErrorPage_Controller($this);
     $errorContent = $controller->run(array())->getBody();
     if (!file_exists("../assets")) {
         mkdir("../assets", 02775);
     }
     if ($fh = fopen("../assets/error-{$this->ErrorCode}.html", "w")) {
         fwrite($fh, $errorContent);
         fclose($fh);
     }
     // Restore the version we're currently connected to.
     Versioned::reading_stage($oldStage);
     // Log back in
     if ($loggedInMember) {
         Session::set("loggedInAs", $loggedInMember->ID);
     }
     if (isset($alc_enc)) {
         Cookie::set('alc_enc', $alc_enc);
     }
     return $this->extension_instances['Versioned']->publish($fromStage, $toStage, $createNewVersion);
 }
Ejemplo n.º 10
0
 public function init()
 {
     if (!$this->trackChairCheck()) {
         Security::permissionFailure($this);
     }
     parent::init();
     Requirements::clear();
 }
Ejemplo n.º 11
0
	/**
	 * Handle the print, for both the action button and the URL
 	 */
	public function handlePrint($gridField, $request = null) {
		set_time_limit(60);
		Requirements::clear();
		Requirements::css(FRAMEWORK_DIR . '/css/GridField_print.css');
		if($data = $this->generatePrintData($gridField)){
			return $data->renderWith("GridField_print");
		}
	}
 /**
  * this is mainly a test harness
  * @return [type] [description]
  */
 public function setupMailer()
 {
     Requirements::clear();
     $this->parseVariables(true);
     if (empty($this->from)) {
         $this->from = Email::config()->admin_email;
     }
     $headers = $this->customHeaders;
     if (project()) {
         $headers['X-SilverStripeSite'] = project();
     }
     $to = $this->to;
     $from = $this->from;
     $subject = $this->subject;
     if ($sendAllTo = $this->config()->send_all_emails_to) {
         $subject .= " [addressed to {$to}";
         $to = $sendAllTo;
         if ($this->cc) {
             $subject .= ", cc to {$this->cc}";
         }
         if ($this->bcc) {
             $subject .= ", bcc to {$this->bcc}";
         }
         $subject .= ']';
         unset($headers['Cc']);
         unset($headers['Bcc']);
     } else {
         if ($this->cc) {
             $headers['Cc'] = $this->cc;
         }
         if ($this->bcc) {
             $headers['Bcc'] = $this->bcc;
         }
     }
     if ($ccAllTo = $this->config()->cc_all_emails_to) {
         if (!empty($headers['Cc']) && trim($headers['Cc'])) {
             $headers['Cc'] .= ', ' . $ccAllTo;
         } else {
             $headers['Cc'] = $ccAllTo;
         }
     }
     if ($bccAllTo = $this->config()->bcc_all_emails_to) {
         if (!empty($headers['Bcc']) && trim($headers['Bcc'])) {
             $headers['Bcc'] .= ', ' . $bccAllTo;
         } else {
             $headers['Bcc'] = $bccAllTo;
         }
     }
     if ($sendAllfrom = $this->config()->send_all_emails_from) {
         if ($from) {
             $subject .= " [from {$from}]";
         }
         $from = $sendAllfrom;
     }
     Requirements::restore();
     return self::mailer()->setupMailer($to, $from, $subject, $this->attachments, $headers);
 }
 /**
  * @param MailingListEmail $email
  * @param string           $listID
  */
 public function send(MailingListEmail $email, $listID = '')
 {
     if (empty($listID)) {
         $listID = $this->getDefaultListID();
     }
     Requirements::clear();
     $body = $email->renderWith(array('MailingListEmail'));
     $body = str_replace(array('{{{FullName}}}', '{{{FirstName}}}', '{{{LastName}}}', '{{{Email}}}', '{{{UnsubscribeLink}}}'), array('%recipient_name%', '%recipient_fname%', '%recipient_lname%', '%recipient_email%', '%unsubscribe_url%'), $body);
     $this->getApi()->sendMessage($this->getDomain(), array('from' => $email->getFrom(), 'to' => $listID, 'subject' => $email->Subject, 'html' => $body, 'o:testmode' => Config::inst()->get('MailgunMailingListAdapter', 'test_mode')));
 }
 public function renderPdf()
 {
     Requirements::clear();
     if (!$this->Template) {
         throw new Exception("Please specify a template before rendering.");
     }
     $content = $this->renderWith($this->Template);
     Requirements::restore();
     return $content;
 }
 /**
  *	Retrieve the correct error page for the current multisite instance.
  *	@param integer
  *	@param SS_HTTPRequest
  *	@throws SS_HTTPResponse_Exception
  */
 public function onBeforeHTTPError($code, $request)
 {
     $errorPage = ErrorPage::get()->filter(array('ErrorCode' => $code, 'SiteID' => Multisites::inst()->getCurrentSiteId()))->first();
     if ($errorPage) {
         Requirements::clear();
         Requirements::clear_combined_files();
         $response = ModelAsController::controller_for($errorPage)->handleRequest($request, DataModel::inst());
         throw new SS_HTTPResponse_Exception($response, $code);
     }
 }
 public function setUp()
 {
     Requirements::clear();
     // Reset Yepnope::$backend to null for each test
     $yep = new Yepnope();
     $reflection = new ReflectionClass('Yepnope');
     $backendProp = $reflection->getProperty('backend');
     $backendProp->setAccessible(true);
     $backendProp->setValue($yep, null);
 }
Ejemplo n.º 17
0
 public function init()
 {
     parent::init();
     Requirements::clear();
     $themeDir = SSViewer::get_theme_folder();
     Requirements::css("{$themeDir}/css/dp_calendar.css");
     Requirements::combine_files('combined.css', array("{$themeDir}/css/reset.css", "{$themeDir}/css/layout.css", "{$themeDir}/css/typography.css", "{$themeDir}/css/form.css", "{$themeDir}/css/flexslider.css"));
     Requirements::javascript('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
     Requirements::combine_files('combined.js', array("{$themeDir}/javascript/lib/jquery.ui.core.js", "{$themeDir}/javascript/lib/jquery.ui.position.js", "{$themeDir}/javascript/lib/jquery.ui.datepicker.js", "{$themeDir}/javascript/lib/jquery.flexslider.js", "{$themeDir}/javascript/lib/date.js", "{$themeDir}/javascript/lib/jquery.dp_calendar.js", "{$themeDir}/javascript/script.js"));
     Requirements::set_combined_files_folder("{$themeDir}/_combined");
 }
 public function loadStyles()
 {
     $config = Config::inst();
     $_path = 'themes/' . $config->get("SSViewer", 'theme') . '/';
     $_isCustomCSSSpecified = count($this->_css);
     $_isCustomJSSpecified = count($this->_js);
     Requirements::clear();
     $jsItems = array(THIRDPARTY_DIR . '/jquery/jquery.js', THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', $_path . 'javascript/jquery.pubsub.js', $_path . 'javascript/getParameterByName.js', $_path . 'javascript/URLEncode.js', $_path . 'javascript/forCrappyBrowsers.js', $_path . 'javascript/ga.js', $_path . 'javascript/SocialScripts.js');
     $jsItemsCustom = array();
     if ($_isCustomJSSpecified) {
         foreach ($this->_js as $jsFileName) {
             array_push($jsItemsCustom, $_path . 'javascript/' . $jsFileName . '.js');
         }
     }
     $cssItems = array($_path . 'css/layout.css');
     $cssItemsCustom = array();
     if ($_isCustomCSSSpecified) {
         foreach ($this->_css as $cssFileName) {
             array_push($cssItemsCustom, $_path . 'css/' . $cssFileName . '.css');
         }
     }
     foreach ($jsItems as $item) {
         Requirements::javascript($item);
     }
     foreach ($cssItems as $item) {
         Requirements::css($item);
     }
     foreach ($jsItemsCustom as $item) {
         Requirements::javascript($item);
     }
     foreach ($cssItemsCustom as $item) {
         Requirements::css($item);
     }
     /*
     Combine the files, append the custom file name if specified to avoid conflict
     */
     Requirements::combine_files('assets/cache/css/cssmin.css', $cssItems);
     if ($_isCustomCSSSpecified) {
         Requirements::combine_files('assets/cache/css/cssmin_' . str_replace('/', '_', $this->Link()) . '.css', $cssItemsCustom);
     }
     Requirements::combine_files('assets/cache/javascript/jsmin.js', $jsItems);
     if ($_isCustomJSSpecified) {
         Requirements::combine_files('assets/cache/javascript/jsmin_' . str_replace('/', '_', $this->Link()) . '.js', $jsItemsCustom);
     }
     // Now do the combine
     Requirements::process_combined_files();
     if ($pos = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
         $version = substr($_SERVER['HTTP_USER_AGENT'], $pos + 5, 3);
         if ($version <= 7) {
             Requirements::css($_path . 'css/iesucks.css');
         }
         Requirements::javascript($_path . 'javascript/ie-placeholder.js');
     }
 }
 /**
  * @return string
  */
 public function iframe()
 {
     // clear the requirements added by any parent controllers
     Requirements::clear();
     Requirements::add_i18n_javascript('sapphire/javascript/lang');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
     Requirements::javascript('sapphire/javascript/FileIFrameField.js');
     Requirements::css('cms/css/typography.css');
     Requirements::css('sapphire/css/FileIFrameField.css');
     return $this->renderWith('FileIFrameField');
 }
 public function checkMaintenance()
 {
     $checkHomeForMaintenance = SiteConfig::current_site_config();
     if ($checkHomeForMaintenance->Maintenance == 1) {
         if ($this->owner->URLSegment != 'Security') {
             Requirements::clear();
             $view = new SSViewer(array('MaintenanceView'));
             echo $view->process(_t('Maintenance.MESSAGE', "Site under maintenance"));
             exit;
         }
     }
 }
Ejemplo n.º 21
0
 function __construct($controller, $name, $fields, $validator, $readonly, $dataObject)
 {
     $this->dataObject = $dataObject;
     Requirements::clear();
     $actions = new FieldList();
     if (!$readonly) {
         $actions->push($saveAction = new FormAction("saveComplexTableField", "Save"));
         $saveAction->addExtraClass('save');
     }
     $fields->push(new HiddenField("ComplexTableField_Path", Director::absoluteBaseURL()));
     parent::__construct($controller, $name, $fields, $validator, $readonly, $dataObject);
 }
Ejemplo n.º 22
0
 function export()
 {
     if ($_REQUEST['baseurl']) {
         $base = $_REQUEST['baseurl'];
         if (substr($base, -1) != '/') {
             $base .= '/';
         }
         Director::setBaseURL($base);
     }
     $folder = '/tmp/static-export/' . project();
     if (!project()) {
         $folder .= 'site';
     }
     if (!file_exists($folder)) {
         mkdir($folder, Filesystem::$folder_create_mask, true);
     }
     $f1 = Director::baseFolder() . '/assets';
     $f2 = Director::baseFolder() . '/' . project();
     `cd {$folder}; ln -s {$f1}; ln -s {$f2}`;
     $baseFolder = basename($folder);
     if ($folder && file_exists($folder)) {
         $pages = DataObject::get("SiteTree");
         foreach ($pages as $page) {
             $subfolder = "{$folder}/{$page->URLSegment}";
             $contentfile = "{$folder}/{$page->URLSegment}/index.html";
             // Make the folder
             if (!file_exists($subfolder)) {
                 mkdir($subfolder, Filesystem::$folder_create_mask);
             }
             // Run the page
             Requirements::clear();
             $controllerClass = "{$page->class}_Controller";
             if (class_exists($controllerClass)) {
                 $controller = new $controllerClass($page);
                 $pageContent = $controller->run(array());
                 // Write to file
                 if ($fh = fopen($contentfile, 'w')) {
                     fwrite($fh, $pageContent->getBody());
                     fclose($fh);
                 }
             }
         }
         copy("{$folder}/home/index.html", "{$folder}/index.html");
         `cd /tmp/static-export; tar -czhf {$baseFolder}.tar.gz {$baseFolder}`;
         $content = file_get_contents("/tmp/static-export/{$baseFolder}.tar.gz");
         Filesystem::removeFolder('/tmp/static-export');
         HTTP::sendFileToBrowser($content, "{$baseFolder}.tar.gz");
         return null;
     } else {
         echo _t('StaticExporter.ONETHATEXISTS', "Please specify a folder that exists");
     }
 }
Ejemplo n.º 23
0
 public function init()
 {
     $parts = parse_url($_SERVER['REQUEST_URI']);
     $path = $parts['path'];
     if ($path . '/' == $this->Link()) {
         return $this->redirect($path . '/' . (isset($parts['query']) ? '?' . $parts['query'] : ''));
     }
     if (!$this->trackChairCheck()) {
         Security::permissionFailure($this);
     }
     parent::init();
     Requirements::clear();
 }
Ejemplo n.º 24
0
 /**
  * Render order for printing
  */
 public function printorder()
 {
     Requirements::clear();
     //include print javascript, if print argument is provided
     if (isset($_REQUEST['print']) && $_REQUEST['print']) {
         Requirements::customScript("if(document.location.href.indexOf('print=1') > 0) {window.print();}");
     }
     $title = i18n::_t("ORDER.INVOICE", "Invoice");
     if ($id = $this->popupController->getRequest()->param('ID')) {
         $title .= " #{$id}";
     }
     return $this->record->customise(array('SiteConfig' => SiteConfig::current_site_config(), 'Title' => $title))->renderWith('OrderAdmin_Printable');
 }
Ejemplo n.º 25
0
 function init()
 {
     if (!$this->request->param('Action')) {
         $this->redirect($this->Link() . 'Presentation/');
     }
     parent::init();
     Requirements::clear();
     Requirements::javascript('themes/openstack/javascript/jquery.min.js');
     Requirements::javascript('themes/openstack/javascript/bootstrap.min.js');
     Requirements::javascript('themes/openstack/javascript/bootstrap.min.js');
     Requirements::javascript('themes/openstack/javascript/presentationeditor/mousetrap.min.js');
     Requirements::javascript('themes/openstack/javascript/speaker-voting.js');
 }
 function export()
 {
     // specify custom baseurl for publishing to other webroot
     if (isset($_REQUEST['baseurl'])) {
         $base = $_REQUEST['baseurl'];
         if (substr($base, -1) != '/') {
             $base .= '/';
         }
         Director::setBaseURL($base);
     }
     // setup temporary folders
     $tmpBaseFolder = TEMP_FOLDER . '/static-export';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     // symlink /assets
     $f1 = ASSETS_PATH;
     $f2 = Director::baseFolder() . '/' . project();
     `cd {$tmpFolder}; ln -s {$f1}; ln -s {$f2}`;
     // iterate through all instances of SiteTree
     $pages = DataObject::get("SiteTree");
     foreach ($pages as $page) {
         $subfolder = "{$tmpFolder}/" . trim($page->RelativeLink(null, true), '/');
         $contentfile = "{$tmpFolder}/" . trim($page->RelativeLink(null, true), '/') . '/index.html';
         // Make the folder
         if (!file_exists($subfolder)) {
             Filesystem::makeFolder($subfolder);
         }
         // Run the page
         Requirements::clear();
         $link = Director::makeRelative($page->Link());
         $response = Director::test($link);
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $response->getBody());
             fclose($fh);
         }
     }
     // copy homepage (URLSegment: "home") to webroot
     copy("{$tmpFolder}/home/index.html", "{$tmpFolder}/index.html");
     // archive all generated files
     `cd {$tmpBaseFolder}; tar -czhf {$baseFolderName}.tar.gz {$baseFolderName}`;
     $archiveContent = file_get_contents("{$tmpBaseFolder}/{$baseFolderName}.tar.gz");
     // remove temporary files and folder
     Filesystem::removeFolder($tmpBaseFolder);
     // return as download to the client
     $response = SS_HTTPRequest::send_file($archiveContent, "{$baseFolderName}.tar.gz", 'application/x-tar-gz');
     echo $response->output();
 }
Ejemplo n.º 27
0
 /**
  * Get a {@link SS_HTTPResponse} to response to a HTTP error code if an
  * {@link ErrorPage} for that code is present.
  *
  * @param int $statusCode
  *
  * @return SS_HTTPResponse
  */
 public static function response_for($statusCode)
 {
     // first attempt to dynamically generate the error page
     if ($errorPage = DataObject::get_one('ErrorPage', "\"ErrorPage\".\"ErrorCode\" = {$statusCode}")) {
         Requirements::clear();
         Requirements::clear_combined_files();
         return ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
     }
     // then fall back on a cached version
     $cachedPath = self::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
     if (file_exists($cachedPath)) {
         $response = new SS_HTTPResponse();
         $response->setStatusCode($statusCode);
         $response->setBody(file_get_contents($cachedPath));
         return $response;
     }
 }
 public function init()
 {
     parent::init();
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             $reponse = '';
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(404);
             }
             return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.');
         }
     }
     // this prevents loading frontend css and javscript files
     Requirements::clear();
     Requirements::css('adminlogin/css/style.css');
 }
 /**
  * Get a {@link SS_HTTPResponse} to response to a HTTP error code if an
  * {@link ErrorPage} for that code is present. First tries to serve it
  * through the standard SilverStripe request method. Falls back to a static
  * file generated when the user hit's save and publish in the CMS
  *
  * @param int $statusCode
  * @return SS_HTTPResponse
  */
 public static function response_for($statusCode)
 {
     // first attempt to dynamically generate the error page
     $errorPage = ErrorPage::get()->filter(array("ErrorCode" => $statusCode))->first();
     if ($errorPage) {
         Requirements::clear();
         Requirements::clear_combined_files();
         return ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
     }
     // then fall back on a cached version
     $content = self::get_content_for_errorcode($statusCode);
     if ($content) {
         $response = new SS_HTTPResponse();
         $response->setStatusCode($statusCode);
         $response->setBody($content);
         return $response;
     }
 }
 /** 
  * Action to emulate a specific user
  * @param $request = HTTPRequest
  * @return redirect
  **/
 public function emulateuser($request)
 {
     Requirements::clear();
     Requirements::css(DEVTOOLS_DIR . '/css/dev-tools.css');
     // not enabled, or not allowed >> get out
     if (!$this->CanEmulateUser()) {
         echo 'You cannot do that';
         die;
     }
     // get URL parameters
     $params = $this->owner->getRequest()->params();
     // URL attribute?
     if (!isset($params['ID'])) {
         $members = Member::get();
         $membersList = array();
         foreach ($members as $member) {
             $membersList[$member->ID] = $member;
         }
         $membersList = ArrayList::create($membersList);
         $membersList = PaginatedList::create($membersList, $this->owner->getRequest());
         $membersList->setPageLength(20);
         return $this->owner->customise(array('Users' => $membersList))->renderWith('EmulateUserPage');
     }
     $member = Member::get()->byID($params['ID']);
     if (!isset($member->ID)) {
         echo 'Could not find user by #' . $params['ID'];
         die;
     }
     $member->logIn();
     return $this->owner->redirect($this->owner->Link());
 }