Ejemplo n.º 1
0
 /**
  * Test the Group::map() function
  */
 function testGroupMap()
 {
     /* Group::map() returns an SQLMap object implementing iterator.  You can use foreach to get ID-Title pairs. */
     // We will iterate over the map and build mapOuput to more easily call assertions on the result.
     $map = Group::map();
     $mapOutput = $map->getItems()->map('ID', 'Title');
     $group1 = $this->objFromFixture('Group', 'group1');
     $group2 = $this->objFromFixture('Group', 'group2');
     /* We have added 2 groups to our fixture.  They should both appear in $mapOutput. */
     $this->assertEquals($mapOutput[$group1->ID], $group1->Title);
     $this->assertEquals($mapOutput[$group2->ID], $group2->Title);
 }
Ejemplo n.º 2
0
 /**
  * Test the Group::map() function
  */
 public function testGroupMap()
 {
     // 2.4 only
     $originalDeprecation = Deprecation::dump_settings();
     Deprecation::notification_version('2.4');
     /* Group::map() returns an SQLMap object implementing iterator.  You can use foreach to get ID-Title pairs. */
     // We will iterate over the map and build mapOuput to more easily call assertions on the result.
     $map = Group::map();
     $mapOutput = $map->toArray();
     $group1 = $this->objFromFixture('Group', 'group1');
     $group2 = $this->objFromFixture('Group', 'group2');
     /* We have added 2 groups to our fixture.  They should both appear in $mapOutput. */
     $this->assertEquals($mapOutput[$group1->ID], $group1->Title);
     $this->assertEquals($mapOutput[$group2->ID], $group2->Title);
     Deprecation::restore_settings($originalDeprecation);
 }
Ejemplo n.º 3
0
 /**
  * Returns a FieldSet with which to create the CMS editing form.
  *
  * You can override this in your child classes to add extra fields - first
  * get the parent fields using parent::getCMSFields(), then use
  * addFieldToTab() on the FieldSet.
  *
  * @return FieldSet The fields to be displayed in the CMS.
  */
 function getCMSFields()
 {
     require_once "forms/Form.php";
     Requirements::javascript("cms/javascript/SitetreeAccess.js");
     // Backlink report
     if ($this->hasMethod('BackLinkTracking')) {
         $links = $this->BackLinkTracking();
         if ($links->exists()) {
             foreach ($links as $link) {
                 $backlinks[] = "<li><a class=\"cmsEditlink\" href=\"admin/show/{$link->ID}\">" . $link->Breadcrumbs(null, true) . "</a></li>";
             }
             $backlinks = "<div style=\"clear:left\">\n\t\t\t\t\t" . _t('SiteTree.PAGESLINKING', 'The following pages link to this page:') . "<ul>" . implode("", $backlinks) . "</ul></div>";
         }
     }
     if (!isset($backlinks)) {
         $backlinks = "<p>" . _t('SiteTree.NOBACKLINKS', 'This page hasn\'t been linked to from any pages.') . "</p>";
     }
     // Status / message
     // Create a status message for multiple parents
     if ($this->ID && is_numeric($this->ID)) {
         $linkedPages = DataObject::get("VirtualPage", "CopyContentFromID = {$this->ID}");
     }
     if (isset($linkedPages)) {
         foreach ($linkedPages as $linkedPage) {
             $parentPage = $linkedPage->Parent;
             $parentPageTitle = $parentPage->Title;
             if ($parentPage->ID) {
                 $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">{$parentPage->Title}</a>";
             } else {
                 $parentPageLinks[] = "<a class=\"cmsEditlink\" href=\"admin/show/{$linkedPage->ID}\">" . _t('SiteTree.TOPLEVEL', 'Site Content (Top Level)') . "</a>";
             }
         }
         $lastParent = array_pop($parentPageLinks);
         $parentList = "'{$lastParent}'";
         if (count($parentPageLinks) > 0) {
             $parentList = "'" . implode("', '", $parentPageLinks) . "' and " . $parentList;
         }
         $statusMessage[] = sprintf(_t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the %s sections."), $parentList);
     }
     if ($this->HasBrokenLink || $this->HasBrokenFile) {
         $statusMessage[] = _t('SiteTree.HASBROKENLINKS', "This page has broken links.");
     }
     $message = "STATUS: {$this->Status}<br />";
     if (isset($statusMessage)) {
         $message .= "NOTE: " . implode("<br />", $statusMessage);
     }
     $pagePriorities = array('0.0' => _t('SiteTree.PRIORITYNOTINDEXED', "Not indexed"), '1.0' => '1 - ' . _t('SiteTree.PRIORITYMOSTIMPORTANT', "Most important"), '0.9' => '2', '0.8' => '3', '0.7' => '4', '0.6' => '5', '0.5' => '6', '0.4' => '7', '0.3' => '8', '0.2' => '9', '0.1' => '10 - ' . _t('SiteTree.PRIORITYLEASTIMPORTANT', "Least important"));
     // Lay out the fields
     $fields = new FieldSet(new TabSet("Root", $tabContent = new TabSet('Content', $tabMain = new Tab('Main', new TextField("Title", _t('SiteTree.PAGETITLE', "Page name")), new TextField("MenuTitle", _t('SiteTree.MENUTITLE', "Navigation label")), new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))), $tabMeta = new Tab('Meta-data', new FieldGroup(_t('SiteTree.URL', "URL"), new LabelField("http://www.yoursite.com/"), new UniqueRestrictedTextField("URLSegment", "URLSegment", "SiteTree", _t('SiteTree.VALIDATIONURLSEGMENT1', "Another page is using that URL. URL must be unique for each page"), "[^A-Za-z0-9-]+", "-", _t('SiteTree.VALIDATIONURLSEGMENT2', "URLs can only be made up of letters, digits and hyphens."), "", "", "", 50), new LabelField("/")), new HeaderField(_t('SiteTree.METAHEADER', "Search Engine Meta-tags")), new TextField("MetaTitle", _t('SiteTree.METATITLE', "Title")), new TextareaField("MetaDescription", _t('SiteTree.METADESC', "Description")), new TextareaField("MetaKeywords", _t('SiteTree.METAKEYWORDS', "Keywords")), new ToggleCompositeField('AdvancedOptions', _t('SiteTree.METAADVANCEDHEADER', "Advanced Options..."), array(new TextareaField("ExtraMeta", _t('SiteTree.METAEXTRA', "Custom Meta Tags")), new LiteralField("", "<p>" . sprintf(_t('SiteTree.METANOTEPRIORITY', "Manually specify a Google Sitemaps priority for this page (%s)"), '<a href="https://www.google.com/webmasters/tools/docs/en/protocol.html#prioritydef">?</a>') . "</p>"), new DropdownField("Priority", _t('SiteTree.METAPAGEPRIO', "Page Priority"), $pagePriorities)), true))), $tabBehaviour = new Tab('Behaviour', new DropdownField("ClassName", _t('SiteTree.PAGETYPE', "Page type", PR_MEDIUM, 'Classname of a page object'), $this->getClassDropdown()), new CheckboxField("ShowInMenus", _t('SiteTree.SHOWINMENUS', "Show in menus?")), new CheckboxField("ShowInSearch", _t('SiteTree.SHOWINSEARCH', "Show in search?")), new CheckboxField("ProvideComments", _t('SiteTree.ALLOWCOMMENTS', "Allow comments on this page?")), new LiteralField("", "<p>" . _t('SiteTree.NOTEUSEASHOMEPAGE', "Use this page as the 'home page' for the following domains: \n\t\t\t\t\t\t\t(separate multiple domains with commas)") . "</p>"), new TextField("HomepageForDomain", _t('SiteTree.HOMEPAGEFORDOMAIN', "Domain(s)", PR_MEDIUM, 'Listing domains that should be used as homepage'))), $tabToDo = new Tab($this->ToDo ? 'To-do **' : 'To-do', new LiteralField("ToDoHelp", _t('SiteTree.TODOHELP', "<p>You can use this to keep track of work that needs to be done to the content of your site.  To see all your pages with to do information, open the 'Site Reports' window on the left and select 'To Do'</p>")), new TextareaField("ToDo", "")), $tabReports = new TabSet('Reports', $tabBacklinks = new Tab('Backlinks', new LiteralField("Backlinks", $backlinks))), $tabAccess = new Tab('Access', new HeaderField(_t('SiteTree.ACCESSHEADER', "Who can view this page on my site?"), 2), new OptionsetField("Viewers", "", array("Anyone" => _t('SiteTree.ACCESSANYONE', "Anyone"), "LoggedInUsers" => _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users"), "OnlyTheseUsers" => _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)"))), new DropdownField("ViewersGroup", _t('SiteTree.GROUP', "Group"), Group::map()), new HeaderField(_t('SiteTree.EDITHEADER', "Who can edit this inside the CMS?"), 2), new OptionsetField("Editors", "", array("LoggedInUsers" => _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS"), "OnlyTheseUsers" => _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)"))), new DropdownField("EditorsGroup", _t('SiteTree.GROUP'), Group::map()))));
     $tabContent->setTitle(_t('SiteTree.TABCONTENT', "Content"));
     $tabMain->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $tabMeta->setTitle(_t('SiteTree.TABMETA', "Meta-data"));
     $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behaviour"));
     $tabReports->setTitle(_t('SiteTree.TABREPORTS', "Reports"));
     $tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
     $tabBacklinks->setTitle(_t('SiteTree.TABBACKLINKS', "BackLinks"));
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateCMSFields', $fields);
     }
     return $fields;
 }