Пример #1
0
 function init()
 {
     parent::init();
     Requirements::themedCSS('editor');
     Requirements::javascript('mysite/js/signup-now.js');
     SSViewer::setOption('rewriteHashlinks', false);
 }
Пример #2
0
 function init()
 {
     parent::init();
     Requirements::themedCSS('jquery-filestyle.min');
     Requirements::javascript('mysite/js/jquery-filestyle.min.js');
     Requirements::javascript('mysite/js/create-heatmap.js');
     SSViewer::setOption('rewriteHashlinks', false);
 }
 public function show($params)
 {
     if ($params['ID']) {
         $this->setCurrentPageID($params['ID']);
     }
     if (isset($params['OtherID'])) {
         Session::set('currentMember', $params['OtherID']);
     }
     if (Director::is_ajax()) {
         SSViewer::setOption('rewriteHashlinks', false);
         return $this->EditForm() ? $this->EditForm()->formHtmlContent() : false;
     }
     return array();
 }
Пример #4
0
 protected function showWithEditForm($params, $editForm)
 {
     if (isset($params['ID'])) {
         Session::set('currentPage', $params['ID']);
     }
     if (isset($params['OtherID'])) {
         Session::set('currentOtherID', $params['OtherID']);
     }
     if (Director::is_ajax()) {
         SSViewer::setOption('rewriteHashlinks', false);
         $result = $this->customise(array('EditForm' => $editForm))->renderWith($this->getTemplatesWithSuffix("_right"));
         return $this->getLastFormIn($result);
     } else {
         return array();
     }
 }
 public function getitem()
 {
     $id = isset($_REQUEST['ID']) ? $_REQUEST['ID'] : $this->templateID;
     $this->setCurrentPageID($id);
     SSViewer::setOption('rewriteHashlinks', false);
     if (isset($_REQUEST['ID']) && is_numeric($_REQUEST['ID'])) {
         $record = DataObject::get_by_id("DynamicTemplate", $_REQUEST['ID']);
         if ($record && !$record->canView()) {
             return Security::permissionFailure($this);
         }
     }
     $form = $this->EditForm();
     if ($form) {
         $content = $form->formHtmlContent();
         if ($this->ShowSwitchView()) {
             $content .= '<div id="AjaxSwitchView">' . $this->SwitchView() . '</div>';
         }
         return $content;
     } else {
         return "";
     }
 }
Пример #6
0
 public function show($request)
 {
     // TODO Necessary for TableListField URLs to work properly
     if ($request->param('ID')) {
         $this->setCurrentPageID($request->param('ID'));
     }
     if ($this->isAjax()) {
         SSViewer::setOption('rewriteHashlinks', false);
         $form = $this->getEditForm($request->param('ID'));
         $content = $form->formHtmlContent();
     } else {
         // Rendering is handled by template, which will call EditForm() eventually
         $content = $this->renderWith($this->getViewer('show'));
     }
     if ($this->ShowSwitchView()) {
         $content .= '<div id="AjaxSwitchView">' . $this->SwitchView() . '</div>';
     }
     return $content;
 }
 function sendFormToBrowser($templateData)
 {
     if (Director::is_ajax()) {
         SSViewer::setOption('rewriteHashlinks', false);
         $result = $this->customise($templateData)->renderWith($this->class . '_right');
         $parts = split('</?form[^>]*>', $result);
         return $parts[sizeof($parts) - 2];
     } else {
         return array("Right" => $this->customise($templateData)->renderWith($this->class . '_right'));
     }
 }
Пример #8
0
    public function testRewriteHashlinksInPhpMode()
    {
        $oldRewriteHashLinks = SSViewer::getOption('rewriteHashlinks');
        SSViewer::setOption('rewriteHashlinks', 'php');
        $tmplFile = TEMP_FOLDER . '/SSViewerTest_testRewriteHashlinksInPhpMode_' . sha1(rand()) . '.ss';
        // Note: SSViewer_FromString doesn't rewrite hash links.
        file_put_contents($tmplFile, '<!DOCTYPE html>
			<html>
				<head><% base_tag %></head>
				<body>
				<a class="inline" href="#anchor">InlineLink</a>
				$InsertedLink
				<body>
			</html>');
        $tmpl = new SSViewer($tmplFile);
        $obj = new ViewableData();
        $obj->InsertedLink = '<a class="inserted" href="#anchor">InsertedLink</a>';
        $result = $tmpl->process($obj);
        $this->assertContains('<a class="inserted" href="<?php echo strip_tags(', $result);
        // TODO Fix inline links in PHP mode
        // $this->assertContains(
        // 	'<a class="inline" href="<?php echo str_replace(',
        // 	$result
        // );
        unlink($tmplFile);
        SSViewer::setOption('rewriteHashlinks', $oldRewriteHashLinks);
    }
Пример #9
0
 public function getitem()
 {
     $this->setCurrentPageID($_REQUEST['ID']);
     SSViewer::setOption('rewriteHashlinks', false);
     // Changed 3/11/2006 to not use getLastFormIn because that didn't have _form_action, _form_name, etc.
     $form = $this->EditForm();
     if ($form) {
         return $form->formHtmlContent();
     } else {
         return "";
     }
 }
Пример #10
0
 public function newmember()
 {
     Session::clear('currentMember');
     $newMemberForm = array("MemberForm" => $this->getMemberForm('new'));
     // This should be using FormResponse ;-)
     if (Director::is_ajax()) {
         SSViewer::setOption('rewriteHashlinks', false);
         $customised = $this->customise($newMemberForm);
         $result = $customised->renderWith($this->class . "_rightbottom");
         $parts = split('</?form[^>]*>', $result);
         return $parts[1];
     } else {
         return $newMemberForm;
     }
 }
Пример #11
0
 /**
  * @uses LeftAndMainExtension->init()
  * @uses LeftAndMainExtension->accessedCMS()
  * @uses CMSMenu
  */
 function init()
 {
     parent::init();
     SSViewer::setOption('rewriteHashlinks', false);
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     if (!empty($member->DateFormat)) {
         i18n::set_date_format($member->DateFormat);
     }
     if (!empty($member->TimeFormat)) {
         i18n::set_time_format($member->TimeFormat);
     }
     // can't be done in cms/_config.php as locale is not set yet
     CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', PR_HIGH, 'Menu title'), self::$help_link);
     // Allow customisation of the access check by a extension
     // Also all the canView() check to execute Director::redirect()
     if (!$this->canView() && !$this->response->isFinished()) {
         // When access /admin/, we should try a redirect to another part of the admin rather than be locked out
         $menu = $this->MainMenu();
         foreach ($menu as $candidate) {
             if ($candidate->Link && $candidate->Link != $this->Link() && $candidate->MenuItem->controller && singleton($candidate->MenuItem->controller)->canView()) {
                 return Director::redirect($candidate->Link);
             }
         }
         if (Member::currentUser()) {
             Session::set("BackURL", null);
         }
         // if no alternate menu items have matched, return a permission error
         $messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "Please choose an authentication method and enter your credentials to access the CMS."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS.  If you would like to log in again, enter a username and password below."));
         return Security::permissionFailure($this, $messageSet);
     }
     // Don't continue if there's already been a redirection request.
     if (Director::redirected_to()) {
         return;
     }
     // Audit logging hook
     if (empty($_REQUEST['executeForm']) && !$this->isAjax()) {
         $this->extend('accessedCMS');
     }
     // Requirements
     Requirements::combine_files('lib.js', array(THIRDPARTY_DIR . '/prototype/prototype.js', THIRDPARTY_DIR . '/behaviour/behaviour.js', THIRDPARTY_DIR . '/jquery/jquery.js', SAPPHIRE_DIR . '/javascript/jquery_improvements.js', THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js', SAPPHIRE_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js', THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', THIRDPARTY_DIR . '/json-js/json2.js', THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js', THIRDPARTY_DIR . '/jquery-cookie/jquery.cookie.js', THIRDPARTY_DIR . '/jquery-query/jquery.query.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.js', THIRDPARTY_DIR . '/jquery-metadata/jquery.metadata.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/jsizes/lib/jquery.sizes.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/jlayout/lib/jlayout.border.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.adapter.jquery.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.html4.js', THIRDPARTY_DIR . '/jstree/jquery.jstree.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/jquery-hoverIntent/jquery.hoverIntent.js', SAPPHIRE_ADMIN_DIR . '/javascript/jquery-changetracker/lib/jquery.changetracker.js', SAPPHIRE_DIR . '/javascript/TreeDropdownField.js', SAPPHIRE_DIR . "/thirdparty/jquery-form/jquery.form.js", SAPPHIRE_DIR . '/javascript/DateField.js', SAPPHIRE_DIR . '/javascript/HtmlEditorField.js', SAPPHIRE_DIR . '/javascript/TabSet.js', SAPPHIRE_DIR . '/javascript/Validator.js', SAPPHIRE_DIR . '/javascript/i18n.js', SAPPHIRE_ADMIN_DIR . '/javascript/ssui.core.js'));
     Requirements::combine_files('leftandmain.js', array(SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Panel.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Tree.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Ping.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Content.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.EditForm.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Menu.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.AddForm.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.Preview.js', SAPPHIRE_ADMIN_DIR . '/javascript/LeftAndMain.BatchActions.js'));
     Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
     Requirements::add_i18n_javascript(SAPPHIRE_ADMIN_DIR . '/javascript/lang');
     Requirements::combine_files('lib.css', array(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css', SAPPHIRE_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.css', THIRDPARTY_DIR . '/jstree/themes/apple/style.css', SAPPHIRE_DIR . '/javascript/TreeDropdownField.css', SAPPHIRE_ADMIN_DIR . '/css/unjquery.css'));
     Requirements::css(SAPPHIRE_ADMIN_DIR . '/css/screen.css');
     // Set the members html editor config
     HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
     // Set default values in the config if missing.  These things can't be defined in the config
     // file because insufficient information exists when that is being processed
     $htmlEditorConfig = HtmlEditorConfig::get_active();
     $htmlEditorConfig->setOption('language', i18n::get_tinymce_lang());
     if (!$htmlEditorConfig->getOption('content_css')) {
         $cssFiles = array();
         $cssFiles[] = 'sapphire/admin/css/editor.css';
         // Use theme from the site config
         if (class_exists('SiteConfig') && ($config = SiteConfig::current_site_config()) && $config->Theme) {
             $theme = $config->Theme;
         } elseif (SSViewer::current_theme()) {
             $theme = SSViewer::current_theme();
         } else {
             $theme = false;
         }
         if ($theme) {
             $cssFiles[] = THEMES_DIR . "/{$theme}/css/editor.css";
         } else {
             if (project()) {
                 $cssFiles[] = project() . '/css/editor.css';
             }
         }
         // Remove files that don't exist
         foreach ($cssFiles as $k => $cssFile) {
             if (!file_exists(BASE_PATH . '/' . $cssFile)) {
                 unset($cssFiles[$k]);
             }
         }
         $htmlEditorConfig->setOption('content_css', implode(',', $cssFiles));
     }
     foreach (self::$extra_requirements['javascript'] as $file) {
         Requirements::javascript($file[0]);
     }
     foreach (self::$extra_requirements['css'] as $file) {
         Requirements::css($file[0], $file[1]);
     }
     foreach (self::$extra_requirements['themedcss'] as $file) {
         Requirements::themedCSS($file[0], $file[1]);
     }
     $dummy = null;
     $this->extend('init', $dummy);
     // The user's theme shouldn't affect the CMS, if, for example, they have replaced
     // TableListField.ss or Form.ss.
     SSViewer::set_theme(null);
 }
Пример #12
0
	public function getitem() {
		$this->setCurrentPageID($_REQUEST['ID']);
		SSViewer::setOption('rewriteHashlinks', false);

		if(isset($_REQUEST['ID']) && is_numeric($_REQUEST['ID'])) {
			$record = DataObject::get_by_id($this->stat('tree_class'), $_REQUEST['ID']);
			if($record && !$record->canView()) return Security::permissionFailure($this);
		}

		$form = $this->EditForm();
		if($form) return $form->formHtmlContent();
		else return "";
	}
 function publishPages($urls)
 {
     // Do we need to map these?
     // Detect a numerically indexed arrays
     if (is_numeric(join('', array_keys($urls)))) {
         $urls = $this->urlsToPaths($urls);
     }
     // This can be quite memory hungry and time-consuming
     // @todo - Make a more memory efficient publisher
     increase_time_limit_to();
     increase_memory_limit_to();
     // Set the appropriate theme for this publication batch.
     // This may have been set explicitly via StaticPublisher::static_publisher_theme,
     // or we can use the last non-null theme.
     if (!StaticPublisher::static_publisher_theme()) {
         SSViewer::set_theme(SSViewer::current_custom_theme());
     } else {
         SSViewer::set_theme(StaticPublisher::static_publisher_theme());
     }
     $currentBaseURL = Director::baseURL();
     if (self::$static_base_url) {
         Director::setBaseURL(self::$static_base_url);
     }
     if ($this->fileExtension == 'php') {
         SSViewer::setOption('rewriteHashlinks', 'php');
     }
     if (StaticPublisher::echo_progress()) {
         echo $this->class . ": Publishing to " . self::$static_base_url . "\n";
     }
     $files = array();
     $i = 0;
     $totalURLs = sizeof($urls);
     foreach ($urls as $url => $path) {
         if (self::$static_base_url) {
             Director::setBaseURL(self::$static_base_url);
         }
         $i++;
         if ($url && !is_string($url)) {
             user_error("Bad url:" . var_export($url, true), E_USER_WARNING);
             continue;
         }
         if (StaticPublisher::echo_progress()) {
             echo " * Publishing page {$i}/{$totalURLs}: {$url}\n";
             flush();
         }
         Requirements::clear();
         if ($url == "") {
             $url = "/";
         }
         if (Director::is_relative_url($url)) {
             $url = Director::absoluteURL($url);
         }
         $response = Director::test(str_replace('+', ' ', $url));
         Requirements::clear();
         singleton('DataObject')->flushCache();
         //skip any responses with a 404 status code. We don't want to turn those into statically cached pages
         if (!$response || $response->getStatusCode() == '404') {
             continue;
         }
         // Generate file content
         // PHP file caching will generate a simple script from a template
         if ($this->fileExtension == 'php') {
             if (is_object($response)) {
                 if ($response->getStatusCode() == '301' || $response->getStatusCode() == '302') {
                     $content = $this->generatePHPCacheRedirection($response->getHeader('Location'));
                 } else {
                     $content = $this->generatePHPCacheFile($response->getBody(), HTTP::get_cache_age(), date('Y-m-d H:i:s'));
                 }
             } else {
                 $content = $this->generatePHPCacheFile($response . '', HTTP::get_cache_age(), date('Y-m-d H:i:s'));
             }
             // HTML file caching generally just creates a simple file
         } else {
             if (is_object($response)) {
                 if ($response->getStatusCode() == '301' || $response->getStatusCode() == '302') {
                     $absoluteURL = Director::absoluteURL($response->getHeader('Location'));
                     $content = "<meta http-equiv=\"refresh\" content=\"2; URL={$absoluteURL}\">";
                 } else {
                     $content = $response->getBody();
                 }
             } else {
                 $content = $response . '';
             }
         }
         $files[] = array('Content' => $content, 'Folder' => dirname($path) . '/', 'Filename' => basename($path));
         // Add externals
         /*
         			$externals = $this->externalReferencesFor($content);
         			if($externals) foreach($externals as $external) {
         				// Skip absolute URLs
         				if(preg_match('/^[a-zA-Z]+:\/\//', $external)) continue;
         				// Drop querystring parameters
         				$external = strtok($external, '?');
         				
         				if(file_exists("../" . $external)) {
         					// Break into folder and filename
         					if(preg_match('/^(.*\/)([^\/]+)$/', $external, $matches)) {
         						$files[$external] = array(
         							"Copy" => "../$external",
         							"Folder" => $matches[1],
         							"Filename" => $matches[2],
         						);
         					
         					} else {
         						user_error("Can't parse external: $external", E_USER_WARNING);
         					}
         				} else {
         					$missingFiles[$external] = true;
         				}
         			}*/
     }
     if (self::$static_base_url) {
         Director::setBaseURL($currentBaseURL);
     }
     if ($this->fileExtension == 'php') {
         SSViewer::setOption('rewriteHashlinks', true);
     }
     $base = BASE_PATH . "/{$this->destFolder}";
     foreach ($files as $file) {
         Filesystem::makeFolder("{$base}/{$file['Folder']}");
         if (isset($file['Content'])) {
             $fh = fopen("{$base}/{$file['Folder']}{$file['Filename']}", "w");
             fwrite($fh, $file['Content']);
             fclose($fh);
         } else {
             if (isset($file['Copy'])) {
                 copy($file['Copy'], "{$base}/{$file['Folder']}{$file['Filename']}");
             }
         }
     }
 }
Пример #14
0
 /**
  * @uses LeftAndMainExtension->init()
  * @uses LeftAndMainExtension->accessedCMS()
  * @uses CMSMenu
  */
 function init()
 {
     parent::init();
     SSViewer::setOption('rewriteHashlinks', false);
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     if (!empty($member->DateFormat)) {
         i18n::set_date_format($member->DateFormat);
     }
     if (!empty($member->TimeFormat)) {
         i18n::set_time_format($member->TimeFormat);
     }
     // can't be done in cms/_config.php as locale is not set yet
     CMSMenu::add_link('Help', _t('LeftAndMain.HELP', 'Help', 'Menu title'), self::$help_link);
     // Allow customisation of the access check by a extension
     // Also all the canView() check to execute Controller::redirect()
     if (!$this->canView() && !$this->response->isFinished()) {
         // When access /admin/, we should try a redirect to another part of the admin rather than be locked out
         $menu = $this->MainMenu();
         foreach ($menu as $candidate) {
             if ($candidate->Link && $candidate->Link != $this->Link() && $candidate->MenuItem->controller && singleton($candidate->MenuItem->controller)->canView()) {
                 return $this->redirect($candidate->Link);
             }
         }
         if (Member::currentUser()) {
             Session::set("BackURL", null);
         }
         // if no alternate menu items have matched, return a permission error
         $messageSet = array('default' => _t('LeftAndMain.PERMDEFAULT', "Please choose an authentication method and enter your credentials to access the CMS."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS.  If you would like to log in again, enter a username and password below."));
         return Security::permissionFailure($this, $messageSet);
     }
     // Don't continue if there's already been a redirection request.
     if ($this->redirectedTo()) {
         return;
     }
     // Audit logging hook
     if (empty($_REQUEST['executeForm']) && !$this->request->isAjax()) {
         $this->extend('accessedCMS');
     }
     // Set the members html editor config
     HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
     // Set default values in the config if missing.  These things can't be defined in the config
     // file because insufficient information exists when that is being processed
     $htmlEditorConfig = HtmlEditorConfig::get_active();
     $htmlEditorConfig->setOption('language', i18n::get_tinymce_lang());
     if (!$htmlEditorConfig->getOption('content_css')) {
         $cssFiles = array();
         $cssFiles[] = FRAMEWORK_ADMIN_DIR . '/css/editor.css';
         // Use theme from the site config
         if (class_exists('SiteConfig') && ($config = SiteConfig::current_site_config()) && $config->Theme) {
             $theme = $config->Theme;
         } elseif (SSViewer::current_theme()) {
             $theme = SSViewer::current_theme();
         } else {
             $theme = false;
         }
         if ($theme) {
             $cssFiles[] = THEMES_DIR . "/{$theme}/css/editor.css";
         } else {
             if (project()) {
                 $cssFiles[] = project() . '/css/editor.css';
             }
         }
         // Remove files that don't exist
         foreach ($cssFiles as $k => $cssFile) {
             if (!file_exists(BASE_PATH . '/' . $cssFile)) {
                 unset($cssFiles[$k]);
             }
         }
         $htmlEditorConfig->setOption('content_css', implode(',', $cssFiles));
     }
     // Using uncompressed files as they'll be processed by JSMin in the Requirements class.
     // Not as effective as other compressors or pre-compressed+finetuned files,
     // but overall the unified minification into a single file brings more performance benefits
     // than a couple of saved bytes (after gzip) in individual files.
     // We also re-compress already compressed files through JSMin as this causes weird runtime bugs.
     Requirements::combine_files('lib.js', array(THIRDPARTY_DIR . '/jquery/jquery.js', FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js', FRAMEWORK_ADMIN_DIR . '/javascript/lib.js', THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', THIRDPARTY_DIR . '/json-js/json2.js', THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js', THIRDPARTY_DIR . '/jquery-cookie/jquery.cookie.js', THIRDPARTY_DIR . '/jquery-query/jquery.query.js', THIRDPARTY_DIR . '/jquery-form/jquery.form.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jsizes/lib/jquery.sizes.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jlayout.border.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.adapter.jquery.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.html4.js', THIRDPARTY_DIR . '/jstree/jquery.jstree.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js', FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-hoverIntent/jquery.hoverIntent.js', FRAMEWORK_ADMIN_DIR . '/javascript/jquery-changetracker/lib/jquery.changetracker.js', FRAMEWORK_DIR . '/javascript/TreeDropdownField.js', FRAMEWORK_DIR . '/javascript/DateField.js', FRAMEWORK_DIR . '/javascript/HtmlEditorField.js', FRAMEWORK_DIR . '/javascript/TabSet.js', FRAMEWORK_DIR . '/javascript/i18n.js', FRAMEWORK_ADMIN_DIR . '/javascript/ssui.core.js', FRAMEWORK_DIR . '/javascript/GridField.js'));
     if (Director::isDev()) {
         Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/leaktools.js');
     }
     HTMLEditorField::include_js();
     Requirements::combine_files('leftandmain.js', array_unique(array_merge(array(FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Panel.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Tree.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Ping.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Content.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.EditForm.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Menu.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.AddForm.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.Preview.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.BatchActions.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.FieldHelp.js', FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.TreeDropdownField.js'), Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/javascript/lang', true, true), Requirements::add_i18n_javascript(FRAMEWORK_ADMIN_DIR . '/javascript/lang', true, true))));
     // TODO Confuses jQuery.ondemand through document.write()
     if (Director::isDev()) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/src/jquery.entwine.inspector.js');
     }
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/jquery-notice/jquery.notice.css');
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.css');
     Requirements::css(THIRDPARTY_DIR . '/jstree/themes/apple/style.css');
     Requirements::css(FRAMEWORK_DIR . '/css/TreeDropdownField.css');
     Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/screen.css');
     Requirements::css(FRAMEWORK_DIR . '/css/GridField.css');
     // Browser-specific requirements
     $ie = isset($_SERVER['HTTP_USER_AGENT']) ? strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') : false;
     if ($ie) {
         $version = substr($_SERVER['HTTP_USER_AGENT'], $ie + 5, 3);
         if ($version == 7) {
             Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/ie7.css');
         } else {
             if ($version == 8) {
                 Requirements::css(FRAMEWORK_ADMIN_DIR . '/css/ie8.css');
             }
         }
     }
     // Custom requirements
     foreach (self::$extra_requirements['javascript'] as $file) {
         Requirements::javascript($file[0]);
     }
     foreach (self::$extra_requirements['css'] as $file) {
         Requirements::css($file[0], $file[1]);
     }
     foreach (self::$extra_requirements['themedcss'] as $file) {
         Requirements::themedCSS($file[0], $file[1]);
     }
     $dummy = null;
     $this->extend('init', $dummy);
     // The user's theme shouldn't affect the CMS, if, for example, they have replaced
     // TableListField.ss or Form.ss.
     SSViewer::set_theme(null);
 }
Пример #15
0
 /**
  * Supports both direct URL links (format: admin/getversion/<page-id>/<version>),
  * and through GET parameters: admin/getversion/?ID=<page-id>&Versions[]=<version>
  */
 function getversion()
 {
     $id = $this->request->param('ID') ? $this->request->param('ID') : $this->request->requestVar('ID');
     $version = $this->request->param('OtherID') ? $this->request->param('OtherID') : $this->request->requestVar('Versions');
     $record = Versioned::get_version("SiteTree", $id, $version);
     if ($record) {
         if ($record && !$record->canView()) {
             return Security::permissionFailure($this);
         }
         $fields = $record->getCMSFields($this);
         $fields->removeByName("Status");
         $fields->push(new HiddenField("ID"));
         $fields->push(new HiddenField("Version"));
         $versionAuthor = DataObject::get_by_id('Member', $record->AuthorID);
         if (!$versionAuthor) {
             $versionAuthor = new ArrayData(array('Title' => 'Unknown author'));
         }
         $fields->insertBefore(new LiteralField('YouAreViewingHeader', '<p class="message notice">' . sprintf(_t('CMSMain.VIEWING', "You are viewing version #%s, created %s by %s", PR_MEDIUM, 'Version number is a linked string, created is a relative time (e.g. 2 days ago), by a specific author'), "<a href=\"admin/getversion/{$record->ID}/{$version}\" title=\"" . ($versionAuthor ? $versionAuthor->Title : '') . "\">{$version}</a>", $record->obj('LastEdited')->Ago(), $versionAuthor ? $versionAuthor->Title : '') . '</p>'), 'Root');
         $actions = new FieldSet(new FormAction("email", _t('CMSMain.EMAIL', "Email")), new FormAction("rollback", _t('CMSMain.ROLLBACK', "Roll back to this version")));
         // encode the message to appear in the body of the email
         $archiveURL = Director::absoluteBaseURL() . $record->URLSegment . '?archiveDate=' . $record->obj('LastEdited')->URLDatetime();
         // Ensure that source file comments are disabled
         SSViewer::set_source_file_comments(false);
         $archiveEmailMessage = urlencode($this->customise(array('ArchiveDate' => $record->obj('LastEdited'), 'ArchiveURL' => $archiveURL))->renderWith('ViewArchivedEmail'));
         $archiveEmailMessage = preg_replace('/\\+/', '%20', $archiveEmailMessage);
         $fields->push(new HiddenField('ArchiveEmailMessage', '', $archiveEmailMessage));
         $fields->push(new HiddenField('ArchiveEmailSubject', '', preg_replace('/\\+/', '%20', urlencode('Archived version of ' . $record->Title))));
         $fields->push(new HiddenField('ArchiveURL', '', $archiveURL));
         $form = new Form($this, "EditForm", $fields, $actions);
         $form->loadDataFrom($record);
         $form->loadDataFrom(array("ID" => $id, "Version" => $version));
         // historical version shouldn't be editable
         $readonlyFields = $form->Fields()->makeReadonly();
         $form->setFields($readonlyFields);
         SSViewer::setOption('rewriteHashlinks', false);
         if ($this->isAjax()) {
             $content = $form->formHtmlContent();
             if ($this->ShowSwitchView()) {
                 $content .= '<div id="AjaxSwitchView">' . $this->SwitchView($record) . '</div>';
             }
             return $content;
         } else {
             $templateData = $this->customise(array("EditForm" => $form));
             return $templateData->renderWith('LeftAndMain');
         }
     }
 }
<?php

SiteTree::add_extension('OrbitPage');
// Disable hash re-writing
SSViewer::setOption('rewriteHashlinks', false);
Пример #17
0
 public function init()
 {
     parent::init();
     Requirements::javascript('mysite/js/prepaid-signup.js');
     SSViewer::setOption('rewriteHashlinks', false);
 }
Пример #18
0
 /**
  * Returns the content to be placed in Form_SubForm when editing a file.
  * Called using ajax.
  */
 public function getfile()
 {
     SSViewer::setOption('rewriteHashlinks', false);
     // bdc: only try to return something if user clicked on an object
     if (is_object($this->getSubForm($this->urlParams['ID']))) {
         return $this->getSubForm($this->urlParams['ID'])->formHtmlContent();
     } else {
         return null;
     }
 }
Пример #19
0
 function publishPages($urls)
 {
     set_time_limit(0);
     ini_set("memory_limit", -1);
     //$base = Director::absoluteURL($this->destFolder);
     //$base = preg_replace('/\/[^\/]+\/\.\./','',$base) . '/';
     if (self::$static_base_url) {
         Director::setBaseURL(self::$static_base_url);
     }
     if ($this->fileExtension == 'php') {
         SSViewer::setOption('rewriteHashlinks', 'php');
     }
     $files = array();
     $i = 0;
     $totalURLs = sizeof($urls);
     foreach ($urls as $url) {
         $i++;
         if (StaticPublisher::echo_progress()) {
             echo " * Publishing page {$i}/{$totalURLs}: {$url}\n";
             flush();
         }
         Requirements::clear();
         $response = Director::test($url);
         Requirements::clear();
         /*
         			if(!is_object($response)) {
         				echo "String response for url '$url'\n";
         				print_r($response);
         			}*/
         if (is_object($response)) {
             $content = $response->getBody();
         } else {
             $content = $response . '';
         }
         if ($this->fileExtension) {
             $filename = $url ? "{$url}.{$this->fileExtension}" : "index.{$this->fileExtension}";
         } else {
             $filename = $url ? "{$url}/index.html" : "index.html";
         }
         $files[$filename] = array('Content' => $content, 'Folder' => dirname($filename) == '/' ? '' : dirname($filename) . '/', 'Filename' => basename($filename));
         // Add externals
         /*
         			$externals = $this->externalReferencesFor($content);
         			if($externals) foreach($externals as $external) {
         				// Skip absolute URLs
         				if(preg_match('/^[a-zA-Z]+:\/\//', $external)) continue;
         				// Drop querystring parameters
         				$external = strtok($external, '?');
         				
         				if(file_exists("../" . $external)) {
         					// Break into folder and filename
         					if(preg_match('/^(.*\/)([^\/]+)$/', $external, $matches)) {
         						$files[$external] = array(
         							"Copy" => "../$external",
         							"Folder" => $matches[1],
         							"Filename" => $matches[2],
         						);
         					
         					} else {
         						user_error("Can't parse external: $external", E_USER_WARNING);
         					}
         				} else {
         					$missingFiles[$external] = true;
         				}
         			}*/
     }
     if (self::$static_base_url) {
         Director::setBaseURL(null);
     }
     if ($this->fileExtension == 'php') {
         SSViewer::setOption('rewriteHashlinks', true);
     }
     //Debug::show(array_keys($files));
     //Debug::show(array_keys($missingFiles));
     $base = "../{$this->destFolder}";
     foreach ($files as $file) {
         Filesystem::makeFolder("{$base}/{$file['Folder']}");
         if (isset($file['Content'])) {
             $fh = fopen("{$base}/{$file['Folder']}{$file['Filename']}", "w");
             fwrite($fh, $file['Content']);
             fclose($fh);
         } else {
             if (isset($file['Copy'])) {
                 copy($file['Copy'], "{$base}/{$file['Folder']}{$file['Filename']}");
             }
         }
     }
 }