public function updateCMSFields(FieldSet $fields)
 {
     $fields->replaceField('TrackedLinks', $tracked = new TableListField('LinkViews', 'NewsletterLinkView', null, '"NewsletterID" = ' . $this->owner->ID, '"Created" DESC'));
     $tracked->setPermissions(array('show', 'export'));
     $viewers = new TableListField('Views', 'NewsletterView', null, '"NewsletterID" = ' . $this->owner->ID, '"Created" DESC');
     $viewers->setPermissions(array('show', 'export'));
     $fields->addFieldsToTab('Root.ViewedBy', array(new LiteralField('ViewsNote', '<p>The viewed by list may not be ' . 'accurate, as many email clients block images used for ' . 'tracking by default.</p>'), $viewers));
 }
 /**
  * Returns a FieldSet with which to create the CMS editing form.
  * You can use the extend() method of FieldSet to create customised forms for your other
  * data objects.
  *
  * @param Controller
  * @return FieldSet
  */
 function getCMSFields($controller = null)
 {
     $group = DataObject::get_by_id("Group", $this->Parent()->GroupID);
     $sentReport = $this->renderWith("Newsletter_SentStatusReport");
     $previewLink = Director::absoluteBaseURL() . 'admin/newsletter/preview/' . $this->ID;
     $ret = new FieldSet(new TabSet("Root", $mailTab = new Tab(_t('Newsletter.NEWSLETTER', 'Newsletter'), new TextField("Subject", _t('Newsletter.SUBJECT', 'Subject'), $this->Subject), new HtmlEditorField("Content", _t('Newsletter.CONTENT', 'Content')), new LiteralField('PreviewNewsletter', "<p><a href=\"{$previewLink}\" target=\"_blank\">" . _t('PREVIEWNEWSLETTER', 'Preview this newsletter') . "</a></p>")), $sentToTab = new Tab(_t('Newsletter.SENTREPORT', 'Sent Status Report'), new LiteralField("SentStatusReport", $sentReport)), $tracked = new Tab('TrackedLinks', $trackedTable = new TableListField('TrackedLinks', 'Newsletter_TrackedLink', array('Original' => 'Link', 'Visits' => 'Visits'), '"NewsletterID" = ' . $this->ID, '"Visits" DESC'))));
     $tracked->setTitle(_t('Newsletter.TRACKEDLINKS', 'Tracked Links'));
     $trackedTable->setPermissions(array('show'));
     if ($this->Status != 'Draft') {
         $mailTab->push(new ReadonlyField("SentDate", _t('Newsletter.SENTAT', 'Sent at'), $this->SentDate));
     }
     $this->extend("updateCMSFields", $ret);
     return $ret;
 }
 /**
  * Return a {@link ComplexTableField} that shows
  * all Order instances that are current.
  *
  * "Current" means all Orders that don't have a
  * Status property of "Complete" or "Cancelled".
  *
  * @return ComplexTableField
  */
 function getReportField()
 {
     // Get the fields used for the table columns
     $fields = Order::$table_overview_fields;
     // Add some fields specific to this report
     $fields['Invoice'] = '';
     $fields['Print'] = '';
     $table = new TableListField('Orders', 'Order', $fields);
     // Customise the SQL query for Order, because we don't want it querying
     // all the fields. Invoice and Printed are dummy fields that just have some
     // text in them, which would be automatically queried if we didn't specify
     // a custom query.
     $query = singleton('Order')->buildSQL("\"Order\".\"Status\" NOT IN ('Complete', 'Cancelled')", '"Order"."Created" DESC');
     $query->groupby[] = '"Order"."Created"';
     $table->setCustomQuery($query);
     // Set the links to the Invoice and Print fields allowing a user to view
     // another template for viewing an Order instance
     $table->setFieldFormatting(array('Invoice' => '<a href=\\"OrderReport_Popup/invoice/$ID\\">Invoice</a>', 'Print' => '<a target=\\"_blank\\" href=\\"OrderReport_Popup/index/$ID?print=1\\">Print</a>'));
     $table->setFieldCasting(array('Created' => 'Date', 'Total' => 'Currency->Nice'));
     $table->setPermissions(array('edit', 'show', 'export', 'delete'));
     return $table;
 }
Exemple #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(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;
 }
Exemple #5
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;
 }
 public function updateCMSFields(FieldSet $fields)
 {
     $fields->removeByName('Hash');
     $fields->replaceField('ViewedMembers', $members = new TableListField('ViewedMembers', 'Member', array('Name' => 'Name', 'Email' => 'Email'), '"Newsletter_TrackedLinkID" = ' . $this->owner->ID, null, 'LEFT JOIN "Newsletter_TrackedLink_ViewedMembers" ON "MemberID" = "Member"."ID"'));
     $members->setPermissions(array('show'));
 }
Exemple #7
0
	/**
	 * Return a field, such as a {@link ComplexTableField} that is
	 * used to show and manipulate data relating to this report.
	 * 
	 * Generally, you should override {@link columns()} and {@link records()} to make your report,
	 * but if they aren't sufficiently flexible, then you can override this method.
	 *
	 * @return FormField subclass
	 */
	function getReportField() {
		$columnTitles = array();
		$fieldFormatting = array();
		$csvFieldFormatting = array();
		$fieldCasting = array();
		
		// Parse the column information
		foreach($this->columns() as $source => $info) {
			if(is_string($info)) $info = array('title' => $info);
			
			if(isset($info['formatting'])) $fieldFormatting[$source] = $info['formatting'];
			if(isset($info['csvFormatting'])) $csvFieldFormatting[$source] = $info['csvFormatting'];
			if(isset($info['casting'])) $fieldCasting[$source] = $info['casting'];
			$columnTitles[$source] = isset($info['title']) ? $info['title'] : $source;
		}
		
		// To do: implement pagination
		$query = $this->sourceQuery($_REQUEST);
			
		$tlf = new TableListField('ReportContent', $this->dataClass(), $columnTitles);
		$tlf->setCustomQuery($query);
		$tlf->setShowPagination(true);
		$tlf->setPageSize(50);
		$tlf->setPermissions(array('export', 'print'));
		
		// Hack to figure out if we are printing
		if (isset($_REQUEST['url']) && array_pop(explode('/', $_REQUEST['url'])) == 'printall') {
			$tlf->setTemplate('SSReportTableField');
		}
		
		if($fieldFormatting) $tlf->setFieldFormatting($fieldFormatting);
		if($csvFieldFormatting) $tlf->setCSVFieldFormatting($csvFieldFormatting);
		if($fieldCasting) $tlf->setFieldCasting($fieldCasting);

		return $tlf;
	}
 function BacklinkTable()
 {
     $dependentColumns = array('Title' => 'Title', 'Subsite.Title' => 'Subsite', 'AbsoluteLink' => 'URL', 'DependentLinkType' => 'Link type');
     if (!class_exists('Subsite')) {
         unset($dependentColumns['Subsite.Title']);
     }
     $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('DependentPagesOnExpiry', 'SiteTree', $dependentColumns);
     $dependentTable->setCustomSourceItems($this->owner->DependentPages(false));
     $dependentTable->setFieldFormatting(array('Title' => '<a href=\\"admin/show/$ID\\">$Title</a>', 'AbsoluteLink' => '<a href=\\"$value\\">$value</a>'));
     $dependentTable->setPermissions(array('show', 'export'));
     return $dependentTable;
 }
 /**
  * Return a TableListField for viewing the related
  * BrokenLink records through the one-to-many relation.
  *
  * @return TableListField
  */
 public function brokenLinksTable()
 {
     // Get a singleton instance of BrokenLink
     $SNG_brokenLink = singleton('BrokenLink');
     // Set up the TableListField, for viewing BrokenLink
     // records that have the current LinkCheckRun ID
     $table = new TableListField('BrokenLinks', 'BrokenLink', $SNG_brokenLink->tableOverviewFields(), "\"LinkCheckRunID\" = {$this->ID}");
     $table->setFieldFormatting(array('PageTitle' => '<a href=\\"admin/show/$PageID\\">$PageTitle</a>', 'Link' => '<a href=\\"$Link\\">$Link</a>'));
     // Set permissions (we don't want to allow adding)
     $table->setPermissions(array('export'));
     $table->setPageSize(20);
     $table->setShowPagination(true);
     return $table;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertBefore(new LiteralField('Title', "<h2>Order #{$this->ID} - " . $this->dbObject('Created')->Nice() . " - " . $this->Member()->getName() . "</h2>"), 'Root');
     $fieldsAndTabsToBeRemoved = self::get_shipping_fields();
     $fieldsAndTabsToBeRemoved[] = 'Printed';
     $fieldsAndTabsToBeRemoved[] = 'MemberID';
     $fieldsAndTabsToBeRemoved[] = 'Attributes';
     $fieldsAndTabsToBeRemoved[] = 'SessionID';
     foreach ($fieldsAndTabsToBeRemoved as $field) {
         $fields->removeByName($field);
     }
     $htmlSummary = $this->renderWith("Order");
     $printlabel = !$this->Printed ? "Print Invoice" : "Print Invoice Again";
     //TODO: i18n
     $fields->addFieldsToTab('Root.Main', array(new LiteralField("PrintInvoice", '<p class="print"><a href="OrderReport_Popup/index/' . $this->ID . '?print=1" onclick="javascript: window.open(this.href, \'print_order\', \'toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1,width=800,height=600,left = 50,top = 50\'); return false;">' . $printlabel . '</a></p>')));
     $fields->addFieldToTab('Root.Main', new LiteralField('MainDetails', $htmlSummary));
     //TODO: re-introduce this when order status logs have some meaningful purpose
     $fields->removeByName('OrderStatusLogs');
     $orderItemsTable = new TableListField("OrderItems", "OrderItem", OrderItem::$summary_fields, "\"OrderID\" = " . $this->ID, "\"Created\" ASC", null);
     $orderItemsTable->setPermissions(array("view"));
     $orderItemsTable->setPageSize(10000);
     $orderItemsTable->addSummary("Total", array("Total" => array("sum", "Currency->Nice")));
     $fields->addFieldToTab('Root.Items', $orderItemsTable);
     $modifierTable = new TableListField("OrderModifiers", "OrderModifier", OrderModifier::$summary_fields, "\"OrderID\" = " . $this->ID . "", "\"Type\", \"Amount\" ASC, \"Created\" ASC", null);
     $modifierTable->setPermissions(array("view"));
     $modifierTable->setPageSize(10000);
     $fields->addFieldToTab('Root.Extras', $modifierTable);
     if ($m = $this->Member()) {
         $lastv = new TextField("MemberLastLogin", "Last login", $m->dbObject('LastVisited')->Nice());
         $fields->addFieldToTab('Root.Customer', $lastv->performReadonlyTransformation());
         //TODO: this should be scaffolded instead, or come from something like $member->getCMSFields();
         $fields->addFieldToTab('Root.Customer', new LiteralField("MemberSummary", $m->renderWith("Order_Member")));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Exemple #11
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;
	}
Exemple #12
0
	function getReferrerTableListField() {
		$tf = new TableListField(
			'Referrers',
			'Referrer',
			array(
				'URL' => 'URL',
				'IsExternal' => 'External?',
				'ReferrerCount' => 'Count'
			)
		);
		$tf->setShowPagination(true);
		$tf->setFieldFormatting(array(
			'URL' => '<a href=\"$URL\">$URL</a>'
		));
		$tf->setFieldCasting(array(
			'IsExternal' => 'Boolean->Nice'
		));
		$tf->setPermissions(array(
			'show','export'
		));
		$query = $this->getComponentsQuery(
			'Referrers',
			null, // filter
			'ReferrerCount DESC' // sort
		);
		$query->groupby('`Referrer`.`URL`');
		$query->select[] = 'COUNT(*) AS ReferrerCount';
		$tf->setCustomQuery($query);
		return $tf;
	}