public function testLinkRewritingOnAPublishedPageDoesntMakeItEditedOnDraft()
 {
     // Publish the source page
     $page = $this->objFromFixture('Page', 'page1');
     $this->assertTrue($page->doPublish());
     $this->assertFalse($page->getIsModifiedOnStage());
     // Rename the file
     $file = $this->objFromFixture('Image', 'file1');
     $file->Name = 'renamed-test-file.jpg';
     $file->write();
     // Caching hack
     Versioned::prepopulate_versionnumber_cache('SiteTree', 'Stage', array($page->ID));
     Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($page->ID));
     // Confirm that the page hasn't gone green.
     $this->assertFalse($page->getIsModifiedOnStage());
 }
 public function updateStatusFlags(&$flags)
 {
     static $prepop = true;
     if ($prepop) {
         Versioned::prepopulate_versionnumber_cache('SiteTree', 'Stage');
         Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live');
         $prepop = false;
     }
     $stageVersion = intval(Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->owner->ID));
     $liveVersion = intval(Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->owner->ID));
     if ($liveVersion == 0) {
         $flags['status_draft'] = '';
     } elseif ($stageVersion > $liveVersion) {
         $flags['status_draft_published'] = '';
     } else {
         $flags['status_published'] = '';
     }
 }
 public function fixVersionNumberCache($page)
 {
     $pages = func_get_args();
     foreach ($pages as $p) {
         Versioned::prepopulate_versionnumber_cache('SiteTree', 'Stage', array($p->ID));
         Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($p->ID));
     }
 }
 /**
  * Return the entire site tree as a nested set of ULs
  */
 public function SiteTreeAsUL()
 {
     $this->generateDataTreeHints();
     $this->generateTreeStylingJS();
     // Pre-cache sitetree version numbers for querying efficiency
     Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage");
     Versioned::prepopulate_versionnumber_cache("SiteTree", "Live");
     return $this->getSiteTreeFor("SiteTree");
 }
Exemplo n.º 5
0
 /**
  * Return the entire site tree as a nested set of ULs
  */
 public function SiteTreeAsUL()
 {
     // Pre-cache sitetree version numbers for querying efficiency
     Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage");
     Versioned::prepopulate_versionnumber_cache("SiteTree", "Live");
     $html = $this->getSiteTreeFor($this->stat('tree_class'));
     $this->extend('updateSiteTreeAsUL', $html);
     return $html;
 }
Exemplo n.º 6
0
	/**
	 * Returns a filtered Site Tree
	 */
	public function filtersitetree() {
		// Pre-cache sitetree version numbers for querying efficiency
		Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage");
		Versioned::prepopulate_versionnumber_cache("SiteTree", "Live");
		
		$className = 'SiteTree';
		$rootID = null;
		$obj = $rootID ? $this->getRecord($rootID) : singleton($className);
		$obj->setMarkingFilterFunction('cmsMainMarkingFilterFunction');
		$obj->markPartialTree();

		if($p = $this->currentPage()) $obj->markToExpose($p);

		// getChildrenAsUL is a flexible and complex way of traversing the tree
		$siteTree = $obj->getChildrenAsUL("", '
					"<li id=\"record-$child->ID\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
					"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" " . (($child->canEdit() || $child->canAddChildren()) ? "" : "class=\"disabled\"") . " title=\"' . _t('LeftAndMain.PAGETYPE') . '".$child->class."\" >" .
					($child->TreeTitle()) .
					"</a>"
'
					,$this, true);

		// Wrap the root if needs be.

		if(!$rootID) {
			$rootLink = $this->Link() . '0';
			$siteTree = "<ul id=\"sitetree\" class=\"tree unformatted\"><li id=\"record-0\" class=\"Root nodelete\"><a href=\"$rootLink\">" .
				 _t('LeftAndMain.TREESITECONTENT',"Site Content",PR_HIGH,'Root node on left') . "</a>"
				. $siteTree . "</li></ul>";
		}

		return $siteTree;

	}
Exemplo n.º 7
0
	/**
	 * Return the entire site tree as a nested set of ULs
	 */
	public function SiteTreeAsUL() {
		$html = '';

		// Include custom CSS for tree icons inline, as the tree might be loaded
		// via Ajax, in which case we can't inject it into the HTML header easily through the HTTP response.
		$css = $this->generateTreeStylingCSS();
		if($this->request->isAjax()) {
			$html .= "<style type=\"text/css\">\n" . $css . "</style>\n";				
		} else {
			Requirements::customCSS($css);
		}

		// Pre-cache sitetree version numbers for querying efficiency
		Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage");
		Versioned::prepopulate_versionnumber_cache("SiteTree", "Live");
		$html .= $this->getSiteTreeFor($this->stat('tree_class'));

		return $html;
	}