MINOR Formatting and documentation in LeftAndMain.php

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92748 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 03:16:48 +00:00
parent bcd0bcfd1f
commit 31c2aa9de8

View File

@ -314,12 +314,11 @@ class LeftAndMain extends Controller {
); );
} }
/** /**
* Returns the menu title for the given LeftAndMain subclass. * Returns the menu title for the given LeftAndMain subclass.
* Implemented static so that we can get this value without instantiating an object. * Implemented static so that we can get this value without instantiating an object.
* Menu title is *not* internationalised. * Menu title is *not* internationalised.
*/ */
static function menu_title_for_class($class) { static function menu_title_for_class($class) {
$title = eval("return $class::\$menu_title;"); $title = eval("return $class::\$menu_title;");
if(!$title) $title = preg_replace('/Admin$/', '', $class); if(!$title) $title = preg_replace('/Admin$/', '', $class);
@ -353,8 +352,8 @@ class LeftAndMain extends Controller {
// Main UI components // Main UI components
/** /**
* Returns the main menu of the CMS. This is also used by init() to work out which sections the user * Returns the main menu of the CMS. This is also used by init()
* has access to. * to work out which sections the user has access to.
* *
* @return DataObjectSet * @return DataObjectSet
*/ */
@ -392,7 +391,8 @@ class LeftAndMain extends Controller {
// already set in CMSMenu::populate_menu(), but from a static pre-controller // already set in CMSMenu::populate_menu(), but from a static pre-controller
// context, so doesn't respect the current user locale in _t() calls - as a workaround, // context, so doesn't respect the current user locale in _t() calls - as a workaround,
// we simply call LeftAndMain::menu_title_for_class() again if we're dealing with a controller // we simply call LeftAndMain::menu_title_for_class() again
// if we're dealing with a controller
if($menuItem->controller) { if($menuItem->controller) {
$defaultTitle = LeftAndMain::menu_title_for_class($menuItem->controller); $defaultTitle = LeftAndMain::menu_title_for_class($menuItem->controller);
$title = _t("{$menuItem->controller}.MENUTITLE", $defaultTitle); $title = _t("{$menuItem->controller}.MENUTITLE", $defaultTitle);
@ -414,22 +414,21 @@ class LeftAndMain extends Controller {
return $menu; return $menu;
} }
public function CMSTopMenu() { public function CMSTopMenu() {
return $this->renderWith(array('CMSTopMenu_alternative','CMSTopMenu')); return $this->renderWith(array('CMSTopMenu_alternative','CMSTopMenu'));
} }
/** /**
* Return a list of appropriate templates for this class, with the given suffix * Return a list of appropriate templates for this class, with the given suffix
*/ */
protected function getTemplatesWithSuffix($suffix) { protected function getTemplatesWithSuffix($suffix) {
$classes = array_reverse(ClassInfo::ancestry($this->class)); $classes = array_reverse(ClassInfo::ancestry($this->class));
foreach($classes as $class) { foreach($classes as $class) {
$templates[] = $class . $suffix; $templates[] = $class . $suffix;
if($class == 'LeftAndMain') break; if($class == 'LeftAndMain') break;
} }
return $templates; return $templates;
} }
public function Left() { public function Left() {
return $this->renderWith($this->getTemplatesWithSuffix('_left')); return $this->renderWith($this->getTemplatesWithSuffix('_left'));
@ -447,12 +446,13 @@ class LeftAndMain extends Controller {
} }
/** /**
* Get a site tree displaying the nodes under the given objects * Get a site tree displaying the nodes under the given objects.
*
* @param $className The class of the root object * @param $className The class of the root object
* @param $rootID The ID of the root object. If this is null then a complete tree will be * @param $rootID The ID of the root object. If this is null then a complete tree will be
* shown * shown
* @param $childrenMethod The method to call to get the children of the tree. For example, * @param $childrenMethod The method to call to get the children of the tree. For example,
* Children, AllChildrenIncludingDeleted, or AllHistoricalChildren * Children, AllChildrenIncludingDeleted, or AllHistoricalChildren
*/ */
function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null, $minNodeCount = 30) { function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
// Default childrenMethod // Default childrenMethod
@ -475,11 +475,12 @@ class LeftAndMain extends Controller {
// getChildrenAsUL is a flexible and complex way of traversing the tree // getChildrenAsUL is a flexible and complex way of traversing the tree
$titleEval = ' $titleEval = '
"<li id=\"record-$child->ID\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" . "<li id=\"record-$child->ID\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . $child->CMSTreeClasses($extraArg) . "\" title=\"' . _t('LeftAndMain.PAGETYPE','Page type: ') . '".$child->class."\" >" . "<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . $child->CMSTreeClasses($extraArg) . "\" title=\"'
($child->TreeTitle) . . _t('LeftAndMain.PAGETYPE','Page type: ')
"</a>" . '".$child->class."\" >" . ($child->TreeTitle) .
'; "</a>"
';
$siteTree = $obj->getChildrenAsUL( $siteTree = $obj->getChildrenAsUL(
"", "",
$titleEval, $titleEval,
@ -637,8 +638,8 @@ JS;
} }
/** /**
* Return a javascript snippet that that shows a single_instance_only page type in Create dropdownfield * Return a javascript snippet that that shows a single_instance_only page type
* if there isn't any of its instance in the site tree * in Create dropdownfield if there isn't any of its instance in the site tree
*/ */
protected function showSingleInstanceOnlyInCreateFieldJS($deletedPage) { protected function showSingleInstanceOnlyInCreateFieldJS($deletedPage) {
$className = $deletedPage->class; $className = $deletedPage->class;
@ -952,6 +953,12 @@ JS;
* @param String $logoText The logo text * @param String $logoText The logo text
*/ */
static $application_link = "http://www.silverstripe.org/"; static $application_link = "http://www.silverstripe.org/";
/**
* @param String $name
* @param String $logoText
* @param String $link (Optional)
*/
static function setApplicationName($name, $logoText = null, $link = null) { static function setApplicationName($name, $logoText = null, $link = null) {
self::$application_name = $name; self::$application_name = $name;
self::$application_logo_text = $logoText ? $logoText : $name; self::$application_logo_text = $logoText ? $logoText : $name;
@ -973,6 +980,10 @@ JS;
function getApplicationLogoText() { function getApplicationLogoText() {
return self::$application_logo_text; return self::$application_logo_text;
} }
/**
* @return String
*/
function ApplicationLink() { function ApplicationLink() {
return self::$application_link; return self::$application_link;
} }
@ -1075,4 +1086,4 @@ JS;
} }
?> ?>