function updateCMSFields(FieldSet &$fields)
 {
     if ($this->hasColour()) {
         $fields->addFieldToTab("Root.Colour", new TextField("RGBCode", "RGBCode"));
         $fields->addFieldToTab("Root.Colour", new TextField("ContrastRGBCode", "Contrast RGB Colour"));
     } else {
         $fields->removeFieldFromTab("Root.Main", "RGBCode");
         $fields->removeFieldFromTab("Root.Main", "ContrastRGBCode");
     }
 }
Ejemplo n.º 2
0
 /**
  * Caution: Only call on instances, not through a singleton.
  *
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField($this, "Members", $this, null, false)), new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new LiteralField("", "<p>" . _t('SecurityAdmin.ADVANCEDONLY', "This section is for advanced users only.\n\t\t\t\t\t\t\tSee <a href=\"http://doc.silverstripe.com/doku.php?id=permissions:codes\" target=\"_blank\">this page</a>\n\t\t\t\t\t\t\tfor more information.") . "</p>"), new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', HtmlEditorConfig::get_available_configs_map()), new TableField("Permissions", "Permission", array("Code" => _t('SecurityAdmin.CODE', 'Code'), "Arg" => _t('SecurityAdmin.OPTIONALID', 'Optional ID')), array("Code" => "PermissionDropdownField", "Arg" => "TextField"), "GroupID", $this->ID)), new Tab(_t('Security.IPADDRESSES', 'IP Addresses'), new LiteralField("", _t('SecurityAdmin.IPADDRESSESHELP', "<p>You can restrict this group to a particular \n\t\t\t\t\t\tIP address range (one range per line). <br />Ranges can be in any of the following forms: <br />\n\t\t\t\t\t\t203.96.152.12<br />\n\t\t\t\t\t\t203.96.152/24<br />\n\t\t\t\t\t\t203.96/16<br />\n\t\t\t\t\t\t203/8<br /><br />If you enter one or more IP address ranges in this box, then members will only get\n\t\t\t\t\t\tthe rights of being in this group if they log on from one of the valid IP addresses.  It won't prevent\n\t\t\t\t\t\tpeople from logging in.  This is because the same user might have to log in to access parts of the\n\t\t\t\t\t\tsystem without IP address restrictions.")), new TextareaField("IPRestrictions", "IP Ranges", 10))));
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
         $fields->removeFieldFromTab('Root', 'IP Addresses');
     }
     $memberList->setController($this);
     $memberList->setPermissions(array('show', 'edit', 'delete', 'export', 'add'));
     $memberList->setParentClass('Group');
     $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Ejemplo n.º 3
0
 /**
  * standard SS method
  *
  */
 function updateCMSFields(FieldSet &$fields)
 {
     if ($brands = Dataobject::get("Brand")) {
         $fields->removeFieldFromTab("Root.Content.Main", "Model");
         $fields->addFieldToTab('Root.Content.Main', new DropdownField('BrandID', 'Please choose an brand', $brands->map("ID", "Title", "Please Select")), "FeaturedProduct");
     }
 }
Ejemplo n.º 4
0
 /**
  * Caution: Only call on instances, not through a singleton.
  *
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $memberList = new MemberTableField($this, "Members", $this, null, false)), $permissionsTab = new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this)), new Tab(_t('Security.IPADDRESSES', 'IP Addresses'), new LiteralField("", _t('SecurityAdmin.IPADDRESSESHELP', "<p>You can restrict this group to a particular \n\t\t\t\t\t\tIP address range (one range per line). <br />Ranges can be in any of the following forms: <br />\n\t\t\t\t\t\t203.96.152.12<br />\n\t\t\t\t\t\t203.96.152/24<br />\n\t\t\t\t\t\t203.96/16<br />\n\t\t\t\t\t\t203/8<br /><br />If you enter one or more IP address ranges in this box, then members will only get\n\t\t\t\t\t\tthe rights of being in this group if they log on from one of the valid IP addresses.  It won't prevent\n\t\t\t\t\t\tpeople from logging in.  This is because the same user might have to log in to access parts of the\n\t\t\t\t\t\tsystem without IP address restrictions.")), new TextareaField("IPRestrictions", "IP Ranges", 10))));
     // Only add a dropdown for HTML editor configurations if more than one is available.
     // Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
     $editorConfigMap = HtmlEditorConfig::get_available_configs_map();
     if (count($editorConfigMap) > 1) {
         $fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
     }
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
         $fields->removeFieldFromTab('Root', 'IP Addresses');
     }
     // Only show the "Roles" tab if permissions are granted to edit them,
     // and at least one role exists
     if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
         $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "This section allows you to add roles to this group. Roles are logical groupings of permissions, which can be editied in the Roles tab") . "</p>"));
         // Add roles (and disable all checkboxes for inherited roles)
         $allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0');
         $groupRoles = $this->Roles();
         $inheritedRoles = new DataObjectSet();
         $ancestors = $this->getAncestors();
         foreach ($ancestors as $ancestor) {
             $ancestorRoles = $ancestor->Roles();
             if ($ancestorRoles) {
                 $inheritedRoles->merge($ancestorRoles);
             }
         }
         $fields->findOrMakeTab('Root.Roles', 'Root.' . _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', $rolesField = new CheckboxSetField('Roles', 'Roles', $allRoles));
         $rolesField->setDefaultItems($inheritedRoles->column('ID'));
         $rolesField->setDisabledItems($inheritedRoles->column('ID'));
     }
     $memberList->setController($this);
     $memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
     $memberList->setParentClass('Group');
     $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
     $memberList->setRelationAutoSetting(false);
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * Test removing a single field from a tab in a set.
  */
 function testRemoveSingleFieldFromTab()
 {
     $fields = new FieldSet();
     $tab = new Tab('Root');
     $fields->push($tab);
     /* We add a field to the "Root" tab */
     $fields->addFieldToTab('Root', new TextField('Country'));
     /* We have 1 field inside the tab, which is the field we just created */
     $this->assertEquals(1, $tab->Fields()->Count());
     /* We remove the field from the tab */
     $fields->removeFieldFromTab('Root', 'Country');
     /* We'll have no fields in the tab now */
     $this->assertEquals(0, $tab->Fields()->Count());
 }
Ejemplo n.º 6
0
 public function getEditForm($id)
 {
     $record = DataObject::get_by_id("Group", $id);
     if ($record) {
         $fields = new FieldSet(new TabSet("Root", new Tab(_t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", _t('SecurityAdmin.GROUPNAME', 'Group name')), $memberList = new MemberTableField($this, "Members", $record, null, false)), new Tab(_t('SecurityAdmin.PERMISSIONS', 'Permissions'), new LiteralField("", "<p>" . _t('SecurityAdmin.ADVANCEDONLY', "This section is for advanced users only.\n\t\t\t\t\t\t\tSee <a href=\"http://doc.silverstripe.com/doku.php?id=permissions:codes\" target=\"_blank\">this page</a>\n\t\t\t\t\t\t\tfor more information.") . "</p>"), new TableField("Permissions", "Permission", array("Code" => _t('SecurityAdmin.CODE', 'Code'), "Arg" => _t('SecurityAdmin.OPTIONALID', 'Optional ID')), array("Code" => "PermissionDropdownField", "Arg" => "TextField"), "GroupID", $id))));
         if (!Permission::check('EDIT_PERMISSIONS')) {
             $fields->removeFieldFromTab('Root', 'Permissions');
         }
         $memberList->setController($this);
         $memberList->setPermissions(array('show', 'edit', 'delete', 'export', 'add'));
         $memberList->setParentClass('Group');
         $memberList->setPopupCaption(_t('SecurityAdmin.VIEWUSER', 'View User'));
         $fields->push($idField = new HiddenField("ID"));
         $idField->setValue($id);
         $actions = new FieldSet(new FormAction('addmember', _t('SecurityAdmin.ADDMEMBER', 'Add Member')));
         $actions->push(new FormAction('save', _t('SecurityAdmin.SAVE', 'Save')));
         $form = new Form($this, "EditForm", $fields, $actions);
         $form->loadDataFrom($record);
         return $form;
     }
 }
Ejemplo n.º 7
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;
 }
 /**
  * Return the FieldSet used to edit a dynamic template in the CMS.
  */
 function getCMSFields()
 {
     $fileList = new DynamicTemplateFilesField("Files", "Files", $this);
     $titleField = $this->ID && $this->ID != "root" ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title");
     // delete files button
     if ($this->canEdit()) {
         $deleteButton = new InlineFormAction('deletemarked', _t('Folder.DELSELECTED', 'Delete selected files'), 'delete');
         $deleteButton->includeDefaultJS(false);
     } else {
         $deleteButton = new HiddenField('deletemarked');
     }
     // link file button
     if ($this->canEdit()) {
         $fileButtons = new CompositeField($linkFileButton = new InlineFormAction('linkfile', _t('DynamicTemplate.LINKFILE', 'Link file(s) from theme'), 'link'), $copyFileButton = new InlineFormAction('copyfile', _t('DynamicTemplate.COPYFILE', 'Copy file(s) from theme'), 'copy'), $newFileButton = new InlineFormAction('newfile', _t('DynamicTemplate.NEWFILE', 'New file'), 'newfile'));
         $linkFileButton->includeDefaultJS(false);
         $newFileButton->includeDefaultJS(false);
     } else {
         $fileButtons = new HiddenField('linkfile');
     }
     $propButtons = new CompositeField();
     //		$propButtons->push($exportButton = new InlineFormAction('exporttemplate', _t('DynamicTemplate.EXPORTTEMPLATE', 'Export'), 'export'));
     //		$exportButton->includeDefaultJS(false);
     //		if ($this->canEdit()) {
     //			$propButtons->push($saveButton = new InlineFormAction('savetemplate', _t('DynamicTemplate.SAVETEMPLATE', 'Save'), 'save'));
     //			$saveButton->includeDefaultJS(false);
     //		}
     if ($this->canDelete()) {
         $propButtons->push($deleteButton = new InlineFormAction('deletetemplate', _t('DynamicTemplate.DELETETEMPLATE', 'Delete'), 'delete'));
         $deleteButton->includeDefaultJS(false);
     }
     if (DynamicTemplateAdmin::tarball_available()) {
         $exportTarballButton = new InlineFormAction('exportastarball', _t('DynamicTemplate.EXPORT', 'Export as tarball'), 'exportastarball');
         $exportTarballButton->includeDefaultJS(false);
         $propButtons->push($exportTarballButton);
     }
     if (DynamicTemplateAdmin::zip_available()) {
         $exportZipButton = new InlineFormAction('exportaszip', _t('DynamicTemplate.EXPORT', 'Export as zip'), 'exportaszip');
         $exportZipButton->includeDefaultJS(false);
         $propButtons->push($exportZipButton);
     }
     $titleField = $this->ID && $this->ID != "root" ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title");
     if (!$this->canEdit()) {
         $titleField->setReadOnly(true);
     }
     $fields = new FieldSet(new HiddenField("Name"), new TabSet("Root", new Tab("Properties", _t('DynamicTemplate.PROPERTIESTAB', 'Properties'), $titleField, new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated')), $propButtons), new Tab("Files", _t('Folder.FILESTAB', "Files"), $fileList, $fileButtons, new HiddenField("FileIDs"), new HiddenField("DestFolderID")), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LabelField('UploadPrompt', _t('DynamicTemplate.UPLOADPROMPT', 'Upload files to your template. Uploads will automatically be added to the right place.')), new LiteralField("UploadIframe", $this->getUploadIframe()))), new HiddenField("ID"));
     if (!$this->canEdit()) {
         $fields->removeFieldFromTab("Root", "Upload");
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Ejemplo n.º 9
0
 /**
  * Returns a FieldSet with which to create the main 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.
  * 
  * See {@link getSettingsFields()} for a different set of fields
  * concerned with configuration aspects on the record, e.g. access control
  *
  * @return FieldSet The fields to be displayed in the CMS.
  */
 function getCMSFields()
 {
     require_once "forms/Form.php";
     // 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.");
     }
     $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'));
     }
     $fields = new FieldSet($rootTab = new TabSet("Root", $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 TextField("URLSegment", "URLSegment"), 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'))), $tabDependent = new Tab('Dependent', $dependentNote, $dependentTable)));
     // Conditional dependent pages tab
     if ($dependentPagesCount) {
         $tabDependent->setTitle(_t('SiteTree.TABDEPENDENT', "Dependent pages") . " ({$dependentPagesCount})");
     } else {
         $fields->removeFieldFromTab('Root', 'Dependent');
     }
     $tabMain->setTitle(_t('SiteTree.TABCONTENT', "Content"));
     $tabMeta->setTitle(_t('SiteTree.TABMETA', "Metadata"));
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.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.º 10
0
 /**
  * Return the FieldSet used to edit this folder in the CMS.
  * You can modify this fieldset by subclassing folder, or by creating a {@link DataObjectDecorator}
  * and implemeting updateCMSFields(FieldSet $fields) on that decorator.	
  */
 function getCMSFields()
 {
     $nameField = $this->ID > 0 ? new TextField("Name") : new HiddenField("Name");
     $fileList = new AssetTableField($this, "Files", "File", array("Title" => _t('Folder.TITLE', "Title"), "Filename" => _t('Folder.FILENAME', "Filename")), "");
     $fileList->setFolder($this);
     $fileList->setPopupCaption(_t('Folder.VIEWEDITASSET', "View/Edit Asset"));
     $nameField = $this->ID && $this->ID != "root" ? new TextField("Name", _t('Folder.TITLE')) : new HiddenField("Name");
     if ($this->canEdit()) {
         $deleteButton = new InlineFormAction('deletemarked', _t('Folder.DELSELECTED', 'Delete selected files'), 'delete');
         $deleteButton->includeDefaultJS(false);
     } else {
         $deleteButton = new HiddenField('deletemarked');
     }
     $fields = new FieldSet(new HiddenField("Title"), new TabSet("Root", new Tab("Files", _t('Folder.FILESTAB', "Files"), $nameField, $fileList, $deleteButton, new HiddenField("FileIDs"), new HiddenField("DestFolderID")), new Tab("Details", _t('Folder.DETAILSTAB', "Details"), new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("ClassName", _t('Folder.TYPE', 'Type')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated'))), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LiteralField("UploadIframe", $this->getUploadIframe())), new Tab("UnusedFiles", _t('Folder.UNUSEDFILESTAB', "Unused files"), new Folder_UnusedAssetsField($this))), new HiddenField("ID"));
     if (!$this->canEdit()) {
         $fields->removeFieldFromTab("Root", "Upload");
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }