function updateCMSFields(&$fields)
 {
     /*
      * don't want slideshow on a redirector page
      */
     if ($this->owner->ClassName == 'RedirectorPage') {
         return $fields;
     }
     /*
      * if this is a new page set defaults 
      */
     if ($this->owner->Version == 1) {
         $this->set_defaults();
     }
     $tabSlides = new Tab('Slides');
     $tabSlides->setTitle(_t('Slideshow.SLIDESTABTITLE', 'Slides'));
     $tabSettings = new Tab('Settings');
     $tabSettings->setTitle(_t('Slideshow.SETTINGSTABTITLE', 'Settings'));
     $tabSlideShow = new TabSet('SlideshowTabs', $tabSlides, $tabSettings);
     $tabSlideShow->setTitle(_t('Slideshow.SLIDESHOWTABTITLE', 'Slideshow'));
     $fields->addFieldToTab('Root.Content', $tabSlideShow);
     $image_manager = new ImageDataObjectManager($this->owner, 'SlideshowSlides', 'SlideshowSlide', 'SlideImage', array(), 'getCMSFields_forPopup');
     $image_manager->copyOnImport = false;
     $fields->addFieldToTab('Root.Content.SlideshowTabs.Slides', $image_manager);
     /*
      * settings
      */
     if (count(self::$effects) > 1) {
         $fields->addFieldToTab('Root.Content.SlideshowTabs.Settings', new DropdownField($name = 'SlideEffect', $title = _t('Slideshow.EFFECT', 'Slide effect'), $source = array_combine(array_keys(self::$effects), array_keys(self::$effects))));
     } else {
         $fields->addFieldToTab('Root.Content.SlideshowTabs.Settings', new HiddenField($name = 'SlideEffect', $title = 'Slide Effect', $value = key(self::$effects)));
     }
     $fields->addFieldsToTab('Root.Content.SlideshowTabs.Settings', array(new TextField($name = 'SlideDuration', $title = _t('Slideshow.SLIDEDURATIOM', 'Duration of Each Slide (milliseconds)')), new TextField($name = 'TransitionDuration', $title = _t('Slideshow.TRANSITIONDURATION', 'Duration of Transition Between Slides (milliseconds)')), new CheckboxField($name = 'AutoPlay', $title = _t('Slideshow.AUTOPLAY', 'Start slideshow automatically')), new CheckboxField($name = 'Loop', $title = _t('Slideshow.LOOP', 'Loop slides')), new CheckboxField($name = 'PauseOnHover', $title = _t('Slideshow.PAUSEONHOVER', 'Pause the slideshow when the mouse hovers over it')), new OptionsetField($name = 'UpdateSlideshows', $title = _t('Slideshow.UPDATE', 'Update slideshows'), $source = array('page' => _t('Slideshow.UPDATEPAGEONLY', 'Apply to this page only'), 'section' => _t('Slideshow.UPDATESECTION', 'Apply to all slideshows in this section'), 'site' => _t('Slideshow.UPDATEALL', 'Apply to all slideshows on this site')), $value = 'page')));
 }
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
        Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
        Requirements::javascript('memberprofiles/javascript/MemberProfilePageCms.js');
        // Setup tabs
        $fields->addFieldToTab('Root', $profile = new TabSet('Profile'), 'Content');
        $fields->addFieldToTab('Root', $email = new Tab('Email'), 'Behaviour');
        $profile->setTitle(_t('MemberProfiles.PROFILE', 'Profile'));
        $email->setTitle(_t('MemberProfiles.EMAIL', 'Email'));
        $fields->findOrMakeTab('Root.Profile.Fields', _t('MemberProfiles.FIELDS', 'Fields'));
        $fields->findOrMakeTab('Root.Profile.Groups', _t('MemberProfiles.GROUPS', 'Groups'));
        $fields->findOrMakeTab('Root.Profile.PublicProfile', _t('MemberProfiles.PUBLICPROFILE', 'Public Profile'));
        // Profile fields
        $fields->addFieldsToTab('Root.Profile.Fields', array(new HeaderField('ProfileFieldsHeader', _t('MemberProfiles.PROFILEFIELDS', 'Profile Fields')), $table = new OrderableComplexTableField($this, 'Fields', 'MemberProfileField')));
        $table->setPermissions(array('show', 'edit'));
        $table->setCustomSourceItems($this->getProfileFields());
        // Groups
        $fields->addFieldsToTab('Root.Profile.Groups', array(new HeaderField('GroupsHeader', _t('MemberProfiles.GROUPASSIGNMENT', 'Group Assignment')), new LiteralField('GroupsNote', '<p>' . _t('MemberProfiles.GROUPSNOTE', 'Any users registering via this page will always be added to ' . 'the below groups (if registration is enabled). Conversely, a ' . 'member must belong to these groups in order to edit their ' . 'profile on this page.') . '</p>'), new CheckboxSetField('Groups', '', DataObject::get('Group')->map()), new HeaderField('SelectableGroupsHeader', _t('MemberProfiles.USERSELECTABLE', 'User Selectable')), new LiteralField('SelectableGroupsNote', '<p>' . _t('MemberProfiles.SELECTABLEGROUPSNOTE', 'Users can choose to belong to the following groups, if the ' . '"Groups" field is enabled in the "Fields" tab.') . '</p>'), new CheckboxSetField('SelectableGroups', '', DataObject::get('Group')->map())));
        // Public profile
        $fields->addFieldsToTab('Root.Profile.PublicProfile', array(new HeaderField('PublicProfileHeader', _t('MemberProfiles.PUBLICPROFILE', 'Public Profile')), new CheckboxField('AllowProfileViewing', _t('MemberProfiles.ALLOWPROFILEVIEWING', 'Allow people to view user profiles.')), new HeaderField('ProfileSectionsHeader', _t('MemberProfiles.PROFILESECTIONS', 'Profile Sections')), new MemberProfileSectionField($this, 'Sections', 'MemberProfileSection')));
        // Email confirmation and validation
        $fields->addFieldsToTab('Root.Email', array(new HeaderField('EmailHeader', 'Email Confirmation and Validation'), new OptionSetField('EmailType', '', array('Validation' => 'Require email validation to activate an account', 'Confirmation' => 'Send a confirmation email after a user registers', 'None' => 'Do not send any emails')), new ToggleCompositeField('EmailContent', 'Email Content', array(new TextField('EmailSubject', 'Email subject'), new TextField('EmailFrom', 'Email from'), new TextareaField('EmailTemplate', 'Email template'), new LiteralField('TemplateNote', MemberConfirmationEmail::TEMPLATE_NOTE))), new ToggleCompositeField('ConfirmationContent', 'Confirmation Content', array(new LiteralField('ConfirmationNote', '<p>This content is dispayed when
					a user confirms their account.</p>'), new TextField('ConfirmationTitle', 'Title'), new HtmlEditorField('ConfirmationContent', 'Content')))));
        // Content
        $fields->removeFieldFromTab('Root.Content.Main', 'Content');
        $fields->addFieldToTab('Root.Content', $profileContent = new Tab('Profile'), 'Metadata');
        $fields->addFieldToTab('Root.Content', $regContent = new Tab('Registration'), 'Metadata');
        $fields->addFieldToTab('Root.Content', $afterReg = new Tab('AfterRegistration'), 'Metadata');
        $profileContent->setTitle(_t('MemberProfiles.PROFILE', 'Profile'));
        $regContent->setTitle(_t('MemberProfiles.REGISTRATION', 'Registration'));
        $afterReg->setTitle(_t('MemberProfiles.AFTERREG', 'After Registration'));
        $tabs = array('Profile', 'Registration', 'AfterRegistration');
        foreach ($tabs as $tab) {
            $fields->addFieldsToTab("Root.Content.{$tab}", array(new TextField("{$tab}Title", _t('MemberProfiles.TITLE', 'Title')), new HtmlEditorField("{$tab}Content", _t('MemberProfiles.CONTENT', 'Content'))));
        }
        $fields->addFieldToTab('Root.Content.AfterRegistration', new CheckboxField('RegistrationRedirect', _t('MemberProfiles.REDIRECT_AFTER_REG', 'Redirect after registration?')), 'AfterRegistrationContent');
        $fields->addFieldToTab('Root.Content.AfterRegistration', new TreeDropdownField('PostRegistrationTargetID', _t('MemberProfiles.REDIRECT_TARGET', 'Redirect to page'), 'SiteTree'), 'AfterRegistrationContent');
        // Behaviour
        $fields->addFieldToTab('Root.Behaviour', new HeaderField('ProfileBehaviour', _t('MemberProfiles.PROFILEBEHAVIOUR', 'Profile Behaviour')), 'ClassName');
        $fields->addFieldToTab('Root.Behaviour', new CheckboxField('AllowRegistration', _t('MemberProfiles.ALLOWREG', 'Allow registration via this page')), 'ClassName');
        $fields->addFieldToTab('Root.Behaviour', new CheckboxField('AllowProfileEditing', _t('MemberProfiles.ALLOWEDITING', 'Allow users to edit their own profile on this page')), 'ClassName');
        $fields->addFieldToTab('Root.Behaviour', new CheckboxField('AllowAdding', _t('MemberProfiles.ALLOWADD', 'Allow members with member creation permissions to add members via this page')), 'ClassName');
        $requireApproval = new CheckboxField('RequireApproval', _t('MemberProfiles.REQUIREREGAPPROVAL', 'Require registration approval by an administrator?'));
        $fields->addFieldToTab('Root.Behaviour', $requireApproval, 'ClassName');
        $approvalGroups = _t('MemberProfiles.NOTIFYTHESEGROUPS', 'Notify these groups to approve new registrations');
        $approvalGroups = new TreeMultiselectField('ApprovalGroups', $approvalGroups, 'Group');
        $fields->addFieldToTab('Root.Behaviour', $approvalGroups, 'ClassName');
        $pageSettings = new HeaderField('PageSettingsHeader', _t('MemberProfiles.PAGEBEHAVIOUR', 'Page Behaviour'));
        $fields->addFieldToTab('Root.Behaviour', $pageSettings, 'ClassName');
        return $fields;
    }
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(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
     Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
     Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
     Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/UpdateURL.js');
     // Status / message
     // Create a status message for multiple parents
     if ($this->ID && is_numeric($this->ID)) {
         $linkedPages = $this->VirtualPages();
     }
     $parentPageLinks = array();
     if (isset($linkedPages)) {
         foreach ($linkedPages as $linkedPage) {
             $parentPage = $linkedPage->Parent;
             if ($parentPage) {
                 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);
     }
     $dependentNote = '';
     $dependentTable = new LiteralField('DependentNote', '<p></p>');
     // Create a table for showing pages linked to this one
     $dependentPagesCount = $this->DependentPagesCount();
     if ($dependentPagesCount) {
         $dependentColumns = array('Title' => $this->fieldLabel('Title'), 'AbsoluteLink' => _t('SiteTree.DependtPageColumnURL', 'URL'), 'DependentLinkType' => _t('SiteTree.DependtPageColumnLinkType', 'Link type'));
         if (class_exists('Subsite')) {
             $dependentColumns['Subsite.Title'] = singleton('Subsite')->i18n_singular_name();
         }
         $dependentNote = new LiteralField('DependentNote', '<p>' . _t('SiteTree.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>');
         $dependentTable = new TableListField('DependentPages', 'SiteTree', $dependentColumns);
         $dependentTable->setCustomSourceItems($this->DependentPages());
         $dependentTable->setFieldFormatting(array('Title' => '<a href=\\"admin/show/$ID\\">$Title</a>', 'AbsoluteLink' => '<a href=\\"$value\\">$value</a>'));
         $dependentTable->setPermissions(array('show', 'export'));
     }
     // Lay out the fields
     $fields = new FieldSet($rootTab = new TabSet("Root", $tabContent = new TabSet('Content', $tabMain = new Tab('Main', new TextField("Title", $this->fieldLabel('Title')), new TextField("MenuTitle", $this->fieldLabel('MenuTitle')), new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))), $tabMeta = new Tab('Metadata', new FieldGroup(_t('SiteTree.URL', "URL"), new LabelField('BaseUrlLabel', Controller::join_links(Director::absoluteBaseURL(), self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)), 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('TrailingSlashLabel', "/")), new LiteralField('LinkChangeNote', self::nested_urls() && count($this->Children()) ? '<p>' . $this->fieldLabel('LinkChangeNote') . '</p>' : null), new HeaderField('MetaTagsHeader', $this->fieldLabel('MetaTagsHeader')), new TextField("MetaTitle", $this->fieldLabel('MetaTitle')), new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1), new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')), new TextareaField("ExtraMeta", $this->fieldLabel('ExtraMeta')))), $tabBehaviour = new Tab('Behaviour', new DropdownField("ClassName", $this->fieldLabel('ClassName'), $this->getClassDropdown()), new OptionsetField("ParentType", _t("SiteTree.PAGELOCATION", "Page location"), array("root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"), "subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page (choose below)"))), $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree'), new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')), new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch')), new CheckboxField("ProvideComments", $this->fieldLabel('ProvideComments')), new LiteralField("HomepageForDomainInfo", "<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(_t('SiteTree.TABTODO', 'To-do') . ($this->ToDo ? '**' : ''), 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", "", 10)), $tabDependent = new Tab('Dependent', $dependentNote, $dependentTable), $tabAccess = new Tab('Access', new HeaderField('WhoCanViewHeader', _t('SiteTree.ACCESSHEADER', "Who can view this page?"), 2), $viewersOptionsField = new OptionsetField("CanViewType", ""), $viewerGroupsField = new TreeMultiselectField("ViewerGroups", $this->fieldLabel('ViewerGroups')), new HeaderField('WhoCanEditHeader', _t('SiteTree.EDITHEADER', "Who can edit this page?"), 2), $editorsOptionsField = new OptionsetField("CanEditType", ""), $editorGroupsField = new TreeMultiselectField("EditorGroups", $this->fieldLabel('EditorGroups')))));
     /*
      * This filter ensures that the ParentID dropdown selection does not show this node,
      * or its descendents, as this causes vanishing bugs.
      */
     $parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};"));
     // Conditional dependent pages tab
     if ($dependentPagesCount) {
         $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ({$dependentPagesCount})");
     } else {
         $fields->removeFieldFromTab('Root', 'Dependent');
     }
     // Make page location fields read-only if the user doesn't have the appropriate permission
     if (!Permission::check("SITETREE_REORGANISE")) {
         $fields->makeFieldReadonly('ParentType');
         if ($this->ParentType == 'root') {
             $fields->removeByName('ParentID');
         } else {
             $fields->makeFieldReadonly('ParentID');
         }
     }
     $viewersOptionsSource = array();
     $viewersOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     if (!Permission::check('SITETREE_GRANT_ACCESS')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         if ($this->CanViewType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($viewerGroupsField);
         } else {
             $fields->removeByName('ViewerGroups');
         }
         $fields->makeFieldReadonly($editorsOptionsField);
         if ($this->CanEditType == 'OnlyTheseUsers') {
             $fields->makeFieldReadonly($editorGroupsField);
         } else {
             $fields->removeByName('EditorGroups');
         }
     }
     $tabContent->setTitle(_t('SiteTree.TABCONTENT', "Content"));
     $tabMain->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $tabMeta->setTitle(_t('SiteTree.TABMETA', "Metadata"));
     $tabBehaviour->setTitle(_t('SiteTree.TABBEHAVIOUR', "Behavior"));
     $tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Content.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     if (self::$runCMSFieldsExtensions) {
         $this->extend('updateCMSFields', $fields);
     }
     return $fields;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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_DIR . "/javascript/SitetreeAccess.js");
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/UpdateURL.js');

		// 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);
		}
		
		$backLinksNote = '';
		$backLinksTable = new LiteralField('BackLinksNote', '<p>' . _t('NOBACKLINKEDPAGES', 'There are no pages linked to this page.') . '</p>');
		
		// Create a table for showing pages linked to this one
		if($this->BackLinkTracking() && $this->BackLinkTracking()->Count() > 0) {
			$backLinksNote = new LiteralField('BackLinksNote', '<p>' . _t('SiteTree.PAGESLINKING', 'The following pages link to this page:') . '</p>');
			$backLinksTable = new TableListField(
				'BackLinkTracking',
				'SiteTree',
				array(
					'Title' => 'Title'
				),
				'ChildID = ' . $this->ID,
				'',
				'LEFT JOIN SiteTree_LinkTracking ON SiteTree.ID = SiteTree_LinkTracking.SiteTreeID'
			);
			$backLinksTable->setFieldFormatting(array(
				'Title' => '<a href=\"admin/show/$ID\">$Title</a>'
			));
			$backLinksTable->setPermissions(array(
				'show',
				'export'
			));
		}
		
		// Lay out the fields
		$fields = new FieldSet(
			new TabSet("Root",
				$tabContent = new TabSet('Content',
					$tabMain = new Tab('Main',
						new TextField("Title", $this->fieldLabel('Title')),
						new TextField("MenuTitle", $this->fieldLabel('MenuTitle')),
						new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))
					),
					$tabMeta = new Tab('Metadata',
						new FieldGroup(_t('SiteTree.URL', "URL"),
							new LabelField('BaseUrlLabel',Director::absoluteBaseURL()),
							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('TrailingSlashLabel',"/")
						),
						new HeaderField('MetaTagsHeader',$this->fieldLabel('MetaTagsHeader')),
						new TextField("MetaTitle", $this->fieldLabel('MetaTitle')),
						new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')),
						new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords')),
						new TextareaField("ExtraMeta",$this->fieldLabel('ExtraMeta'))
					)
				),
				$tabBehaviour = new Tab('Behaviour',
					new DropdownField(
						"ClassName", 
						$this->fieldLabel('ClassName'), 
						$this->getClassDropdown()
					),
					new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')),
					new CheckboxField("ShowInSearch", $this->fieldLabel('ShowInSearch')),
					/*, new TreeMultiselectField("MultipleParents", "Page appears within", "SiteTree")*/
					new CheckboxField("ProvideComments", $this->fieldLabel('ProvideComments')),
					new LiteralField(
						"", 
						"<p>" . 
							_t('SiteTree.NOTEUSEASHOMEPAGE', 
							"Use this page as the 'home page' for the following domains: 
							(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',
						$backLinksNote,
						$backLinksTable
					)
				),
				$tabAccess = new Tab('Access',
					new HeaderField('WhoCanViewHeader',_t('SiteTree.ACCESSHEADER', "Who can view this page?"), 2),
					$viewersOptionsField = new OptionsetField(
						"CanViewType", 
						""
					),
					$viewerGroupsField = new TreeMultiselectField("ViewerGroups", $this->fieldLabel('ViewerGroups')),
					new HeaderField('WhoCanEditHeader',_t('SiteTree.EDITHEADER', "Who can edit this page?"), 2),
					$editorsOptionsField = new OptionsetField(
						"CanEditType", 
						""
					),
					$editorGroupsField = new TreeMultiselectField("EditorGroups", $this->fieldLabel('EditorGroups'))
				)
			)
			//new NamedLabelField("Status", $message, "pageStatusMessage", true)
		);

		if(!Permission::check('SITETREE_GRANT_ACCESS')) {
			$fields->makeFieldReadonly($viewersOptionsField);
			$fields->makeFieldReadonly($viewerGroupsField);
			$fields->makeFieldReadonly($editorsOptionsField);
			$fields->makeFieldReadonly($editorGroupsField);
		}
		
		$viewersOptionsSource = array();
		if($this->Parent()->ID || $this->CanViewType == 'Inherit') $viewersOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
		$viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
		$viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
		$viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
		$viewersOptionsField->setSource($viewersOptionsSource);
		
		$editorsOptionsSource = array();
		if($this->Parent()->ID || $this->CanEditType == 'Inherit') $editorsOptionsSource["Inherit"] = _t('SiteTree.INHERIT', "Inherit from parent page");
		$editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
		$editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
		$editorsOptionsField->setSource($editorsOptionsSource);
		
		$tabContent->setTitle(_t('SiteTree.TABCONTENT', "Content"));
		$tabMain->setTitle(_t('SiteTree.TABMAIN', "Main"));
		$tabMeta->setTitle(_t('SiteTree.TABMETA', "Metadata"));
		$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;
	}