/**
  * Adds token creation fields to CMS
  * 
  * @param FieldSet $fields
  * @return void
  */
 public function updateCMSFields(FieldSet &$fields)
 {
     // Only modify file objects with parent nodes
     if (!$this->owner instanceof Folder || !$this->owner->ID) {
         return;
     }
     // Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options
     if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) {
         return;
     }
     // Update Security Tab
     $secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security'));
     $secureFilesTab->push(new HeaderField(_t('SecureFiles.TOKENACCESSTITLE', 'Token Access')));
     if (!$this->owner->containsFiles()) {
         $secureFilesTab->push(new ReadonlyField('DummyTokenList', '', _t('SecureFiles.NOFILESINFOLDER', 'There are no files in this folder.')));
         return;
     }
     $secureFilesTab->push($tokenList = new ComplexTableField($this->owner, 'ContainedFileTokens', 'SecureFileAccessToken', null, null, "File.ParentID = '{$this->owner->ID}'", $sourceSort = null, "JOIN File ON FileID = File.ID"));
     $tokenList->setParentIdName('FolderID');
     $tokenList->setRelationAutoSetting(false);
     // Remove add link if there are no files in this folder
     if (!$this->owner->containsFiles()) {
         $tokenList->setPermissions(array('edit', 'delete'));
     }
 }
 public function updateCMSFields(FieldSet $fields)
 {
     $service = singleton('WorkflowService');
     if ($effective = $service->getDefinitionFor($this->owner)) {
         $effectiveTitle = $effective->Title;
     } else {
         $effectiveTitle = _t('WorkflowApplicable.NONE', '(none)');
     }
     $allDefinitions = array(_t('WorkflowApplicable.INHERIT', 'Inherit from parent'));
     if ($definitions = $service->getDefinitions()) {
         $allDefinitions += $definitions->map();
     }
     $tab = $fields->fieldByName('Root') ? 'Root.Workflow' : 'BottomRoot.Workflow';
     $applyWorkflowField = null;
     $fields->addFieldToTab($tab, new HeaderField('AppliedWorkflowHeader', _t('WorkflowApplicable.APPLIEDWORKFLOW', 'Applied Workflow')));
     if (Permission::check('APPLY_WORKFLOW')) {
         $fields->addFieldToTab($tab, new DropdownField('WorkflowDefinitionID', _t('WorkflowApplicable.DEFINITION', 'Applied Workflow'), $allDefinitions));
     }
     $fields->addFieldToTab($tab, new ReadonlyField('EffectiveWorkflow', _t('WorkflowApplicable.EFFECTIVE_WORKFLOW', 'Effective Workflow'), $effectiveTitle));
     $fields->addFieldToTab($tab, new HeaderField('WorkflowLogHeader', _t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log')));
     $fields->addFieldToTab($tab, $logTable = new ComplexTableField($this->owner, 'WorkflowLog', 'WorkflowInstance', null, 'getActionsSummaryFields', sprintf('"TargetClass" = \'%s\' AND "TargetID" = %d', $this->owner->class, $this->owner->ID)));
     $logTable->setRelationAutoSetting(false);
     $logTable->setPermissions(array('show'));
     $logTable->setPopupSize(760, 420);
 }
Пример #3
0
	/**
	 * Setup the CMS Fields for the User Defined Form
	 * 
	 * @return FieldSet
	 */
	public function getCMSFields() {
		$fields = parent::getCMSFields();

		// field editor
		$fields->addFieldToTab("Root.Content."._t('UserDefinedForm.FORM', 'Form'), new FieldEditor("Fields", 'Fields', "", $this ));
		
		// view the submissions
		$fields->addFieldToTab("Root.Content."._t('UserDefinedForm.SUBMISSIONS','Submissions'), new SubmittedFormReportField( "Reports", _t('UserDefinedForm.RECEIVED', 'Received Submissions'), "", $this ) );

		// who do we email on submission
		$emailRecipients = new ComplexTableField(
			$this,
	    	'EmailRecipients',
	    	'UserDefinedForm_EmailRecipient',
	    	array(
				'EmailAddress' => 'Email',
				'EmailSubject' => 'Subject',
				'EmailFrom' => 'From'
	    	),
	    	'getCMSFields_forPopup',
			"FormID = '$this->ID'"
		);
		$emailRecipients->setAddTitle(_t('UserDefinedForm.AEMAILRECIPIENT', 'A Email Recipient'));
		
		$fields->addFieldToTab("Root.Content."._t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'), $emailRecipients);
	
		// text to show on complete
		$onCompleteFieldSet = new FieldSet(
			new HtmlEditorField( "OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'),3,"",_t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage), $this )
		);
		
		$fields->addFieldsToTab("Root.Content."._t('UserDefinedForm.ONCOMPLETE','On complete'), $onCompleteFieldSet);
		
		return $fields;
	}
 function HasManyForm()
 {
     $team = DataObject::get_one('ComplexTableFieldTest_Team', "\"Name\" = 'The Awesome People'");
     $sponsorsField = new ComplexTableField($this, 'Sponsors', 'ComplexTableFieldTest_Sponsor', ComplexTableFieldTest_Sponsor::$summary_fields, 'getCMSFields');
     $sponsorsField->setParentClass('ComplexTableFieldTest_Team');
     $form = new Form($this, 'HasManyForm', new FieldSet(new HiddenField('ID', '', $team->ID), $sponsorsField), new FieldSet(new FormAction('doSubmit', 'Submit')));
     $form->disableSecurityToken();
     return $form;
 }
 function updateCMSFields(FieldSet &$fields)
 {
     if ($this->owner->ID && $this->owner->Code == strtolower(self::$main_group)) {
         $newMerchants = new ComplexTableField(Controller::has_curr() ? Controller::curr() : new Controller(), 'NewMembers', 'Member');
         $newMerchants->setCustomSourceItems(self::get_new_merchants());
         $fields->addFieldToTab('Root', new Tab(_t('MerchantGroupDOD.NEWMERCHANTS', 'New Merchants'), $newMerchants), 'Members');
         $fields->findOrMakeTab('Root.Members')->setTitle(_t('MerchantGroupDOD.ALLMERCHANTS', 'All Merchants'));
         $fields->removeByName('Title');
     }
 }
 /**
  * Ensure the fields on the add and edit forms for each option have the correct
  * {@link Attribute} ID set.
  * 
  * @see ComplexTableField::getFieldsFor()
  * @return FieldSet
  */
 function getFieldsFor($childData)
 {
     $detailFields = parent::getFieldsFor($childData);
     $detailFields->removeByName('AttributeID');
     $detailFields->push(new HiddenField('AttributeID', '', $this->attributeID));
     return $detailFields;
 }
Пример #7
0
 function FieldHolder()
 {
     $ret = parent::FieldHolder();
     Requirements::javascript(CMS_DIR . '/javascript/AssetTableField.js');
     Requirements::javascript('cms/javascript/ImageEditor/Activator.js');
     return $ret;
 }
	public function FieldHolder() {
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui-1.8rc3.custom.js');
		Requirements::javascript('orderable/javascript/OrderableComplexTableField.js');

		return parent::FieldHolder();
	}
 /**
  * @return string
  */
 public function FieldHolder()
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui-1.8rc3.custom.js');
     Requirements::javascript(DATALIST_MODULE . '/javascript/OrderableCTF.js');
     return parent::FieldHolder();
 }
Пример #10
0
 /**
  * @return FieldSet
  */
 function RootForm()
 {
     $memberList = new MemberTableField($this, "Members");
     // unset 'inlineadd' permission, we don't want inline addition
     $memberList->setPermissions(array('edit', 'delete', 'add'));
     $fields = new FieldList(new TabSet('Root', new Tab('Members', singleton('Member')->i18n_plural_name(), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the database')))), new Tab('Import', _t('SecurityAdmin.TABIMPORT', 'Import'), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="400px" border="0"></iframe>', $this->Link('groupimport'))))), new HiddenField('ID', false, 0));
     // Add roles editing interface
     if (Permission::check('APPLY_ROLES')) {
         $rolesCTF = new ComplexTableField($this, 'Roles', 'PermissionRole');
         $rolesCTF->setPermissions(array('add', 'edit', 'delete'));
         $rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
         $rolesTab->push(new LiteralField('RolesDescription', ''));
         $rolesTab->push($rolesCTF);
     }
     $actions = new FieldList(new FormAction('addmember', _t('SecurityAdmin.ADDMEMBER', 'Add Member')));
     $this->extend('updateRootFormFields', $fields, $actions);
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->addExtraClass('cms-edit-form');
     return $form;
 }
Пример #11
0
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $categories = DataObject::get("NewsletterCategory");
     $fields->addFieldsToTab('Root.Content.Newsletter', array(new TextField("Name", _t("Newsletter.Campaign.Name", "Name of the Newsletter Campaign")), new EmailField("SendFrom", _t("Newsletter.Campaign.SendFrom", "Send from eMail")), new TextField("TemplateFilename", _t("Newsletter.Campaign.TemplateFilename", "Name of template (no .ss)")), new TextField("BodyStyle", _t("Newsletter.Campaign.BodyStyle", "Body StyleSheet")), new TextField("ContentStyle", _t("Newsletter.Campaign.Content", "Content StyleSheet")), new TextField("LinkStyle", _t("Newsletter.Campaign.LinkStyle", "Style for every link [a]")), new TextField("ImageStyle", _t("Newsletter.Campaign.ImageStyle", "Style for every image [img]")), new TextField("ParagraphStyle", _t("Newsletter.Campaign.ParagraphStyle", "Style for every paragraph [p]")), new TextField("HeadingStyle", _t("Newsletter.Campaign.HeadingStyle", "Style for heading [h2]")), new TextField("HorizontalRuleStyle", _t("Newsletter.Campaign.HorizontalRuleStyle", "Style for every [hr]")), new TextField("TableStyle", _t("Newsletter.Campaign.TableStyle", "Style for every table [table]")), new TextField("TableCellAttribute", _t("Newsletter.Campaign.TabelCellAttribute", "[td] CellAtribute")), new TextField("TableCellStyle", _t("Newsletter.Campaign.Style", "[td] Stylesheet")), new DropdownField('NewsletterCategoryID', _t("Newsletter.Campaign.NewsletterCategory", "Belongs to this newsletter category"), $categories->toDropdownMap('ID', 'Title', 'Bitte Newsletterkategorie eintragen', true))));
     $tablefield = new ComplexTableField($controller = $this, $name = 'Recievers', 'NewsletterReciever', $fieldList = array('FirstName' => _t("Newsletter.Member.FirstName", "FirstName"), 'Surname' => _t("Newsletter.Member.Surname", "Surame"), 'Email' => _t("Newsletter.Member.Email", "eMail"), 'Send' => _t("Newsletter.Admin.MailSended", "eMail sended (0=no/1=yes)")), null, $sourceFilter = "NewsletterID = '{$this->ID}'");
     $tablefield->setPermissions(array("show", "edit", "delete"));
     $tablefield->setParentClass(false);
     $fields->addFieldToTab("Root.Content." . _t("Newsletter.Admin.RecieverList", "List of recievers"), $tablefield);
     //Blacklist
     $tablefield = new ComplexTableField($controller = $this, $name = 'Blacklist', 'NewsletterBlacklist', $fieldList = array('Email' => _t("Newsletter.Member.Email", "eMail"), 'NewsletterCategory.Title' => _t("Newsletter.NewsletterCategory", "Newsletter Category")), null, $sourceFilter = "NewsletterCategoryID = {$this->NewsletterCategoryID}");
     $tablefield->setPermissions(array("show", "edit", "delete", "add"));
     $tablefield->setParentClass(false);
     $fields->addFieldToTab("Root.Content." . _t("Newsletter.Admin.BlackList", "Blacklist"), $tablefield);
     //Subscribers
     $tablefield = new ComplexTableField($controller = $this, $name = 'Subscribers', 'NewsletterMember', $fieldList = array('Email' => _t("Newsletter.Member.Email", "eMail"), 'NewsletterCategory.Title' => _t("Newsletter.NewsletterCategory", "Newsletter Category")), null, $sourceFilter = "NewsletterCategoryID = {$this->NewsletterCategoryID}");
     $tablefield->setPermissions(array("show", "edit", "delete", "add"));
     $tablefield->setParentClass(false);
     $fields->addFieldToTab("Root.Content." . _t("Newsletter.Admin.Subscribers", "Subscribers"), $tablefield);
     return $fields;
 }
Пример #12
0
 /**
  * Setup the CMS Fields for the User Defined Form
  * 
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // define tabs
     $fields->findOrMakeTab('Root.Content.Form', _t('UserDefinedForm.FORM', 'Form'));
     $fields->findOrMakeTab('Root.Content.EmailRecipients', _t('UserDefinedForm.EMAILRECIPIENTS', 'Email Recipients'));
     $fields->findOrMakeTab('Root.Content.OnComplete', _t('UserDefinedForm.ONCOMPLETE', 'On Complete'));
     $fields->findOrMakeTab('Root.Content.Submissions', _t('UserDefinedForm.SUBMISSIONS', 'Submissions'));
     // field editor
     $fields->addFieldToTab("Root.Content.Form", new FieldEditor("Fields", 'Fields', "", $this));
     // view the submissions
     $fields->addFieldToTab("Root.Content.Submissions", new CheckboxField('DisableSaveSubmissions', _t('UserDefinedForm.SAVESUBMISSIONS', "Disable Saving Submissions to Server")));
     $fields->addFieldToTab("Root.Content.Submissions", new SubmittedFormReportField("Reports", _t('UserDefinedForm.RECEIVED', 'Received Submissions'), "", $this));
     // who do we email on submission
     $emailRecipients = new ComplexTableField($this, 'EmailRecipients', 'UserDefinedForm_EmailRecipient', array('EmailAddress' => _t('UserDefinedForm.EMAILADDRESS', 'Email'), 'EmailSubject' => _t('UserDefinedForm.EMAILSUBJECT', 'Subject'), 'EmailFrom' => _t('UserDefinedForm.EMAILFROM', 'From')), 'getCMSFields_forPopup', "\"FormID\" = '{$this->ID}'");
     $emailRecipients->setAddTitle(_t('UserDefinedForm.AEMAILRECIPIENT', 'A Email Recipient'));
     $fields->addFieldToTab("Root.Content.EmailRecipients", $emailRecipients);
     // text to show on complete
     $onCompleteFieldSet = new FieldSet(new HtmlEditorField("OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'), 3, "", _t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage), $this));
     $fields->addFieldsToTab("Root.Content.OnComplete", $onCompleteFieldSet);
     return $fields;
 }
 public function getCMSFields()
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
     Requirements::javascript('eventmanagement/javascript/RegisterableEventCms.js');
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Content.Tickets', array(new HeaderField('TicketTypesHeader', $this->fieldLabel('TicketTypesHeader')), new ComplexTableField($this, 'Tickets', 'EventTicket')));
     $generators = ClassInfo::implementorsOf('EventRegistrationTicketGenerator');
     if ($generators) {
         foreach ($generators as $generator) {
             $instance = new $generator();
             $generators[$generator] = $instance->getGeneratorTitle();
         }
         $fields->addFieldsToTab('Root.Content.Tickets', array(new HeaderField('TicketGeneratorHeader', 'Ticket Generator'), new LiteralField('TicketGeneratorNone', '<p>The ticket ' . 'generator is used to generate a ticket file for the ' . 'user to download and print to bring to the event.</p>'), new DropdownField('TicketGenerator', '', $generators, null, null, '(none)')));
     }
     $changeFields = singleton('RegisterableDateTime')->fieldLabels(false);
     $fields->addFieldsToTab('Root.Content.Registration', array(new HeaderField('RegistrationSettingsHeader', $this->fieldLabel('RegistrationSettingsHeader')), new CheckboxField('OneRegPerEmail', $this->fieldLabel('OneRegPerEmail')), new CheckboxField('RequireLoggedIn', $this->fieldLabel('RequireLoggedIn')), new NumericField('RegistrationTimeLimit', $this->fieldLabel('RegistrationTimeLimit')), new HeaderField('EmailSettingsHeader', $this->fieldLabel('EmailSettingsHeader')), new CheckboxField('RegEmailConfirm', $this->fieldLabel('RegEmailConfirm')), new TextField('EmailConfirmMessage', $this->fieldLabel('EmailConfirmMessage')), new NumericField('ConfirmTimeLimit', $this->fieldLabel('ConfirmTimeLimit')), new TextField('AfterConfirmTitle', $this->fieldLabel('AfterConfirmTitle')), new HtmlEditorField('AfterConfirmContent', $this->fieldLabel('AfterConfirmContent'), 5), new CheckboxField('UnRegEmailConfirm', $this->fieldLabel('UnRegEmailConfirm')), new TextField('AfterConfUnregTitle', $this->fieldLabel('AfterConfUnregTitle')), new HtmlEditorField('AfterConfUnregContent', $this->fieldLabel('AfterConfUnregContent'), 5), new CheckboxField('EmailNotifyChanges', $this->fieldLabel('EmailNotifyChanges')), new CheckboxSetField('NotifyChangeFields', $this->fieldLabel('NotifyChangeFields'), $changeFields)));
     $fields->addFieldsToTab('Root.Content.AfterRegistration', array(new TextField('AfterRegTitle', $this->fieldLabel('AfterRegTitle')), new HtmlEditorField('AfterRegContent', $this->fieldLabel('AfterRegContent'))));
     $fields->addFieldsToTab('Root.Content.AfterUnregistration', array(new TextField('AfterUnregTitle', $this->fieldLabel('AfterUnregTitle')), new HtmlEditorField('AfterUnregContent', $this->fieldLabel('AfterUnregContent'))));
     $registrations = new ComplexTableField($this, 'Registrations', 'EventRegistration', null, null, '"Status" = \'Valid\' AND "Time"."EventID" = ' . $this->ID, null, 'INNER JOIN "CalendarDateTime" AS "Time" ON "Time"."ID" = "TimeID"');
     $registrations->setTemplate('EventRegistrationComplexTableField');
     $registrations->setPermissions(array('show', 'print', 'export'));
     $canceled = new ComplexTableField($this, 'Registations', 'EventRegistration', null, null, '"Status" = \'Canceled\' AND "Time"."EventID" = ' . $this->ID, null, 'INNER JOIN "CalendarDateTime" AS "Time" ON "Time"."ID" = "TimeID"');
     $canceled->setTemplate('EventRegistrationComplexTableField');
     $canceled->setPermissions(array('show', 'print', 'export'));
     $fields->addFieldToTab('Root', new Tab('Registrations'), 'Behaviour');
     $fields->addFieldsToTab('Root.Registrations', array(new HeaderField('RegistrationsHeader', $this->fieldLabel('Registrations')), $registrations, new ToggleCompositeField('CanceledRegistrations', 'Canceled Registrations', $canceled)));
     if ($this->RegEmailConfirm) {
         $unconfirmed = new ComplexTableField($this, 'UnconfirmedRegistations', 'EventRegistration', null, null, '"Status" = \'Unconfirmed\' AND "Time"."EventID" = ' . $this->ID, null, 'INNER JOIN "CalendarDateTime" AS "Time" ON "Time"."ID" = "TimeID"');
         $unconfirmed->setPermissions(array('show', 'print', 'export'));
         $unconfirmed->setTemplate('EventRegistrationComplexTableField');
         $fields->addFieldToTab('Root.Registrations', new ToggleCompositeField('UnconfirmedRegistrations', 'Unconfirmed Registrations', $unconfirmed));
     }
     // Add a tab allowing admins to invite people from, as well as view
     // people who have been invited.
     $fields->addFieldToTab('Root', new Tab('Invitations'), 'Behaviour');
     $fields->addFieldsToTab('Root.Invitations', array(new HeaderField('InvitationsHeader', $this->fieldLabel('InvitationsHeader')), new EventInvitationField($this, 'Invitations')));
     return $fields;
 }
Пример #14
0
 function __construct($controller, $name, $sourceClass, $mode, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "Created DESC", $sourceJoin = "")
 {
     $this->mode = $mode;
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     $this->Markable = true;
     $this->setPageSize(15);
     // search
     $search = isset($_REQUEST['CommentSearch']) ? Convert::raw2sql($_REQUEST['CommentSearch']) : null;
     if (!empty($_REQUEST['CommentSearch'])) {
         $this->sourceFilter[] = "( `Name` LIKE '%{$search}%' OR `Comment` LIKE '%{$search}%')";
     }
     Requirements::javascript('cms/javascript/CommentTableField.js');
 }
	function LastLink() {
		$link = parent::LastLink();
		if($link && isset($_REQUEST['FileSearch'])) {
			return $link . '&FileSearch=' . $_REQUEST['FileSearch'];
		}
		return $link;
	}
 function updateCMSFields(&$fields)
 {
     if ($this->owner->MasterPageID) {
         $fields->insertFirst(new HeaderField('This page\'s content is copied from a master page: ' . $this->owner->MasterPage()->Title, 2));
     }
     // replace readonly link prefix
     $subsite = $this->owner->Subsite();
     if ($subsite && $subsite->ID) {
         $baseUrl = 'http://' . $subsite->domain() . '/';
         $fields->removeByName('BaseUrlLabel');
         $fields->addFieldToTab('Root.Content.Metadata', new LabelField('BaseUrlLabel', $baseUrl), 'URLSegment');
     }
     $relatedCount = 0;
     $reverse = $this->ReverseRelated();
     if ($reverse) {
         $relatedCount += $reverse->Count();
     }
     $normalRelated = $this->NormalRelated();
     if ($normalRelated) {
         $relatedCount += $normalRelated->Count();
     }
     $tabName = $relatedCount ? 'Related (' . $relatedCount . ')' : 'Related';
     $tab = $fields->findOrMakeTab('Root.Related', $tabName);
     // Related pages
     $tab->push(new LiteralField('RelatedNote', '<p>You can list pages here that are related to this page.<br />When this page is updated, you will get a reminder to check whether these related pages need to be updated as well.</p>'));
     $tab->push($related = new ComplexTableField($this, 'RelatedPages', 'RelatedPageLink', array('RelatedPageAdminLink' => 'Page', 'AbsoluteLink' => 'URL')));
     // The 'show' link doesn't provide any useful info
     $related->setPermissions(array('add', 'edit', 'delete'));
     if ($reverse) {
         $text = '<p>In addition, this page is marked as related by the following pages: </p><p>';
         foreach ($reverse as $rpage) {
             $text .= $rpage->RelatedPageAdminLink(true) . " - " . $rpage->AbsoluteLink(true) . "<br />\n";
         }
         $text .= '</p>';
         $tab->push(new LiteralField('ReverseRelated', $text));
     }
     $virtualPagesTable = new SubsiteAgnosticTableListField('VirtualPageTracking', 'SiteTree', array('Title' => 'Title', 'AbsoluteLink' => 'URL', 'Subsite.Title' => 'Subsite'), '"CopyContentFromID" = ' . $this->owner->ID, '');
     $virtualPagesTable->setFieldFormatting(array('Title' => '<a href=\\"admin/show/$ID\\">$Title</a>'));
     $virtualPagesTable->setPermissions(array('show', 'export'));
     if ($tab = $fields->fieldByName('Root.VirtualPages')) {
         $tab->removeByName('VirtualPageTracking');
         $tab->push($virtualPagesTable);
     } else {
         if ($virtualPagesTable->TotalCount()) {
             $virtualPagesNote = new LiteralField('BackLinksNote', '<p>' . _t('SiteTree.VIRTUALPAGESLINKING', 'The following virtual pages pull from this page:') . '</p>');
             $fields->fieldByName('Root')->push($tabVirtualPages = new Tab('VirtualPages', $virtualPagesNote, $virtualPagesTable));
         }
     }
 }
Пример #17
0
 function FieldHolder()
 {
     $ret = parent::FieldHolder();
     Requirements::javascript(CMS_DIR . '/javascript/MemberTableField.js');
     Requirements::javascript(CMS_DIR . "/javascript/MemberTableField_popup.js");
     return $ret;
 }
 function FieldHolder()
 {
     $ret = parent::FieldHolder();
     Requirements::javascript(CMS_DIR . '/javascript/CommentTableField.js');
     return $ret;
 }
	function Title() {
		return $this->addTitle ? $this->addTitle : parent::Title();
	}
Пример #20
0
	function __construct($controller, $name, $group, $members = null, $hidePassword = true, $pageLimit = 10) {
		if($group) {
			if(is_object($group)) {
				$this->group = $group;
			} elseif(is_numeric($group)) {
				$this->group = DataObject::get_by_id('Group', $group);
			}
		} else if(is_numeric($_REQUEST['ctf'][$this->Name()]["ID"])) {
			$this->group = DataObject::get_by_id('Group', $_REQUEST['ctf'][$this->Name()]["ID"]);
		}

		$sourceClass = $this->stat('data_class');
		$SNG_member = singleton($this->stat('data_class'));

		foreach(self::$addedPermissions as $permission) {
			array_push($this->permissions, $permission);
		}

		$fieldList = array(
			"FirstName" => _t('MemberTableField.FIRSTNAME', 'Firstname'),
			"Surname" => _t('MemberTableField.SURNAME', 'Surname'),
			"Email" => _t('MemberTableField.EMAIL', 'Email')
		);
		
		$memberDbFields = $SNG_member->db();
		$csvFieldList = array();

		foreach($memberDbFields as $field => $dbFieldType) {
			$csvFieldList[$field] = $field;
		}
		
		foreach(self::$addedFields as $key => $value) {
			$fieldList[$key] = $value;
		}

		if(!$hidePassword) {
			$fieldList["SetPassword"] = "******"; 
		}

		// Legacy: Use setCustomSourceItems() instead.
		if($members) {
			$this->customSourceItems = $this->memberListWithGroupID($members, $group);
		}

		$this->hidePassword = $hidePassword;

		parent::__construct($controller, $name, $sourceClass, $fieldList);

		Requirements::javascript(CMS_DIR . '/javascript/MemberTableField.js');
		Requirements::javascript(CMS_DIR . "/javascript/MemberTableField_popup.js");
		
		// search
		$SQL_search = isset($_REQUEST['MemberSearch']) ? Convert::raw2sql($_REQUEST['MemberSearch']) : null;
		if(!empty($_REQUEST['MemberSearch'])) {
			$searchFilters = array();
			foreach($SNG_member->searchableFields() as $fieldName => $fieldSpec) {
				if(strpos($fieldName,'.') === false) $searchFilters[] = "`$fieldName` LIKE '%{$SQL_search}%'";
			}
			$this->sourceFilter[] = '(' . implode(' OR ', $searchFilters) . ')';
		}

		// filter by groups
		// TODO Not implemented yet
		if(isset($_REQUEST['ctf'][$this->Name()]['GroupID']) && is_numeric($_REQUEST['ctf'][$this->Name()]['GroupID'])) {
			$this->sourceFilter[] = "`GroupID`='{$_REQUEST['ctf'][$this->Name()]['GroupID']}'";
		}

		$this->sourceJoin = " INNER JOIN `Group_Members` ON `MemberID` = `Member`.`ID`";
		$this->setFieldListCsv($csvFieldList);
		$this->setPageSize($this->stat('page_size'));
	}
Пример #21
0
 function __construct($controller, $name, $group, $members = null, $hidePassword = true, $pageLimit = 10)
 {
     if ($group) {
         if (is_object($group)) {
             $this->group = $group;
         } else {
             if (is_numeric($group)) {
                 $this->group = DataObject::get_by_id('Group', $group);
             }
         }
     } else {
         if (is_numeric($_REQUEST['ctf'][$this->Name()]["ID"])) {
             $this->group = DataObject::get_by_id('Group', $_REQUEST['ctf'][$this->Name()]["ID"]);
         }
     }
     $sourceClass = $this->stat("data_class");
     foreach (self::$addedPermissions as $permission) {
         array_push($this->permissions, $permission);
     }
     $fieldList = array("FirstName" => _t('MemberTableField.FIRSTNAME', 'Firstname'), "Surname" => _t('MemberTableField.SURNAME', 'Surname'), "Email" => _t('MemberTableField.EMAIL', 'Email'));
     $csvFieldList = $fieldList;
     foreach (self::$addedCsvFields as $key => $value) {
         $csvFieldList[$key] = $value;
     }
     foreach (self::$addedFields as $key => $value) {
         $fieldList[$key] = $value;
     }
     if (!$hidePassword) {
         $fieldList["SetPassword"] = "******";
     }
     if (isset($_REQUEST['ctf']['childID']) && ($memberID = $_REQUEST['ctf']['childID'])) {
         $SNG_member = DataObject::get_by_id($this->stat("data_class"), $_REQUEST['ctf']['childID']);
     } else {
         $SNG_member = singleton(Object::getCustomClass($this->stat("data_class")));
     }
     $detailFormFields = $SNG_member->getCMSFields();
     $this->detailFormValidator = $SNG_member->getValidator();
     $this->pageSize = $pageLimit;
     // Legacy: Use setCustomSourceItems() instead.
     if ($members) {
         $this->customSourceItems = $this->memberListWithGroupID($members, $group);
     }
     $this->hidePassword = $hidePassword;
     parent::__construct($controller, $name, $sourceClass, $fieldList);
     Requirements::javascript('cms/javascript/MemberTableField.js');
     // construct the filter and sort
     if (isset($_REQUEST['MemberOrderByField'])) {
         $this->sourceSort = '`' . Convert::raw2sql($_REQUEST['MemberOrderByField']) . '`' . Convert::raw2sql($_REQUEST['MemberOrderByOrder']);
     }
     // search
     $SQL_search = isset($_REQUEST['MemberSearch']) ? Convert::raw2sql($_REQUEST['MemberSearch']) : null;
     if (!empty($_REQUEST['MemberSearch'])) {
         $searchFilters = array();
         foreach ($SNG_member->stat('searchable_fields') as $fieldName => $fieldSpec) {
             $searchFilters[] = "`{$fieldName}` LIKE '%{$SQL_search}%'";
         }
         $this->sourceFilter[] = '(' . implode(' OR ', $searchFilters) . ')';
     }
     // filter by groups
     // TODO Not implemented yet
     if (isset($_REQUEST['ctf'][$this->Name()]['GroupID']) && is_numeric($_REQUEST['ctf'][$this->Name()]['GroupID'])) {
         $this->sourceFilter[] = "`GroupID`='{$_REQUEST['ctf'][$this->Name()]['GroupID']}'";
     } elseif ($this->group) {
         //$this->sourceFilter[] = "`GroupID`='{$this->group->ID}'";
         // If the table is not clean (without duplication), the  total and navigation wil not work well, so uncheck the big line below
         $this->sourceFilter[] = "`Group_Members`.`ID` IN (SELECT `ID` FROM `Group_Members` WHERE `GroupID`='{$this->group->ID}' GROUP BY `MemberID` HAVING MIN(`ID`))";
     }
     $this->sourceJoin = " INNER JOIN `Group_Members` ON `MemberID`=`Member`.`ID`";
     $this->setFieldListCsv($csvFieldList);
 }
Пример #22
0
 function AddForm()
 {
     $form = parent::AddForm();
     // Set default groups - also implemented in MemberTableField_Popup::__construct()
     if ($this->group) {
         $groupsField = $form->Fields()->dataFieldByName('Groups');
         // TODO Needs to be a string value (not int) because of TreeMultiselectField->getItems(),
         // see http://open.silverstripe.org/ticket/5836
         if ($groupsField) {
             $groupsField->setValue((string) $this->group->ID);
         }
     }
     return $form;
 }
Пример #23
0
	/**
	 * Gets the form fields as defined through the metadata
	 * on {@link $obj} and the custom parameters passed to FormScaffolder.
	 * Depending on those parameters, the fields can be used in ajax-context,
	 * contain {@link TabSet}s etc.
	 * 
	 * @return FieldSet
	 */
	public function getFieldSet() {
		$fields = new FieldSet();
		
		// tabbed or untabbed
		if($this->tabbed) {
			$fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
			$mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
		}
		
		// add database fields
		foreach($this->obj->db() as $fieldName => $fieldType) {
			if($this->restrictFields && !in_array($fieldName, $this->restrictFields)) continue;
			
			// @todo Pass localized title
			if($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
				$fieldClass = $this->fieldClasses[$fieldName];
				$fieldObject = new $fieldClass($fieldName);
			} else {
				$fieldObject = $this->obj->dbObject($fieldName)->scaffoldFormField(null, $this->getParamsArray());
			}
			$fieldObject->setTitle($this->obj->fieldLabel($fieldName));
			if($this->tabbed) {
				$fields->addFieldToTab("Root.Main", $fieldObject);
			} else {
				$fields->push($fieldObject);
			}
		}
		
		// add has_one relation fields
		if($this->obj->has_one()) {
			foreach($this->obj->has_one() as $relationship => $component) {
				if($this->restrictFields && !in_array($relationship, $this->restrictFields)) continue;
				$hasOneField = $this->obj->dbObject("{$relationship}ID")->scaffoldFormField(null, $this->getParamsArray());
				$hasOneField->setTitle($this->obj->fieldLabel($relationship));
				if($this->tabbed) {
					$fields->addFieldToTab("Root.Main", $hasOneField);
				} else {
					$fields->push($hasOneField);
				}
			}
		}
		
		// only add relational fields if an ID is present
		if($this->obj->ID) {
			// add has_many relation fields
			if($this->obj->has_many() && ($this->includeRelations === true || isset($this->includeRelations['has_many']))) {
				foreach($this->obj->has_many() as $relationship => $component) {
					if($this->tabbed) {
						$relationTab = $fields->findOrMakeTab(
							"Root.$relationship", 
							$this->obj->fieldLabel($relationship)
						);
					}
					$relationshipFields = singleton($component)->summaryFields();
					$foreignKey = $this->obj->getComponentJoinField($relationship);
					$ctf = new ComplexTableField(
						$this,
						$relationship,
						$component,
						$relationshipFields,
						"getCMSFields", 
						"$foreignKey = " . $this->obj->ID
					);
					$ctf->setPermissions(TableListField::permissions_for_object($component));
					if($this->tabbed) {
						$fields->addFieldToTab("Root.$relationship", $ctf);
					} else {
						$fields->push($ctf);
					}
				}
			}

			if($this->obj->many_many() && ($this->includeRelations === true || isset($this->includeRelations['many_many']))) {
				foreach($this->obj->many_many() as $relationship => $component) {
					if($this->tabbed) {
						$relationTab = $fields->findOrMakeTab(
							"Root.$relationship", 
							$this->obj->fieldLabel($relationship)
						);
					}

					$relationshipFields = singleton($component)->summaryFields();
					$filterWhere = $this->obj->getManyManyFilter($relationship, $component);
					$filterJoin = $this->obj->getManyManyJoin($relationship, $component);
					$ctf =  new ComplexTableField(
						$this,
						$relationship,
						$component,
						$relationshipFields,
						"getCMSFields", 
						$filterWhere,
						'', 
						$filterJoin
					);
					$ctf->setPermissions(TableListField::permissions_for_object($component));
					$ctf->popupClass = "ScaffoldingComplexTableField_Popup";
					if($this->tabbed) {
						$fields->addFieldToTab("Root.$relationship", $ctf);
					} else {
						$fields->push($ctf);
					}
				}
			}
		}
		
		return $fields;
	}
Пример #24
0
 function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter = "", $sourceSort = "", $sourceJoin = "")
 {
     parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
     $this->sourceSort = "Title";
     $this->Markable = true;
 }
 /**
  * @return FieldSet
  */
 public function getWorkflowCMSFields()
 {
     $fields = new FieldSet();
     $diffLinkTitle = _t('SiteTreeCMSWorkflow.DIFFERENCESLINK', 'Show differences to live');
     // list all closed requests
     $fields->push(new HeaderField('WorkflowClosedRequestsHeader', _t('SiteTreeCMSWorkflow.CLOSEDREQUESTSHEADER', 'Closed Requests')));
     $closedRequests = $this->ClosedWorkflowRequests();
     // $_REQUEST['showqueries']=1;
     $closedRequestsTF = new ComplexTableField($this, 'ClosedWorkflowRequests', 'WorkflowRequest', array('Created' => singleton('WorkflowRequest')->fieldLabel('Created'), 'StatusDescription' => singleton('WorkflowRequest')->fieldLabel('Status'), 'Author.Title' => singleton('WorkflowRequest')->fieldLabel('Author'), 'DiffLinkToLastPublished' => _t('SiteTreeCMSWorkflow.DIFFERENCESCOLUMN', 'Differences')));
     $closedRequestsTF->setPermissions(array('show'));
     $closedRequestsTF->setFieldFormatting(array("DiffLinkToLastPublished" => '<a href=\\"$value\\" target=\\"_blank\\" class=\\"externallink\\">' . $diffLinkTitle . '</a>'));
     $closedRequestsTF->setFieldCasting(array('Created' => 'SS_Datetime->Full'));
     $closedRequestsTF->setCustomSourceItems($closedRequests);
     $fields->push($closedRequestsTF);
     return $fields;
 }
 /**
  */
 public function getCMSFields()
 {
     $fields = new FieldSet(new TabSet('Root'));
     $cmsUsers = Member::mapInCMSGroups()->getItems();
     if ($cmsUsers && $cmsUsers->count()) {
         $cmsUsers = $cmsUsers->map();
     } else {
         $cmsUsers = array();
     }
     $fields->addFieldToTab('Root.Main', new TextField('Title', _t('WorkflowDefinition.TITLE', 'Title')));
     $fields->addFieldToTab('Root.Main', new TextareaField('Description', _t('WorkflowDefinition.DESCRIPTION', 'Description')));
     $fields->addFieldToTab('Root.Main', new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Users'), $cmsUsers));
     $fields->addFieldToTab('Root.Main', new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Groups'), 'Group'));
     if (class_exists('AbstractQueuedJob')) {
         $before = _t('WorkflowDefinition.SENDREMINDERDAYSBEFORE', 'Send reminder email after ');
         $after = _t('WorkflowDefinition.SENDREMINDERDAYSAFTER', ' days without action.');
         $fields->addFieldToTab('Root.Main', new FieldGroup(_t('WorkflowDefinition.REMINDEREMAIL', 'Reminder Email'), new LabelField('ReminderEmailBefore', $before), new NumericField('RemindDays', ''), new LabelField('ReminderEmailAfter', $after)));
     }
     if ($this->ID && Permission::check('VIEW_ACTIVE_WORKFLOWS')) {
         $fields->addFieldToTab('Root.ActiveInstances', $active = new ComplexTableField($this, 'Instances', 'WorkflowInstance', array('Title' => 'Title', 'Target.Title' => 'Target Title', 'WorkflowStatus' => 'Status', 'CurrentAction.Title' => 'Current Action', 'LastEdited' => 'Last Actioned'), 'getInstanceManagementFields', '"WorkflowStatus" IN (\'Active\', \'Paused\')', '"LastEdited" DESC'));
         if (Permission::check('REASSIGN_ACTIVE_WORKFLOWS')) {
             $active->setPermissions(array('show', 'edit'));
         } else {
             $active->setPermissions(array('show'));
         }
         $fields->addFieldToTab('Root.Completed', $complete = new ComplexTableField($this, 'CompletedInstances', 'WorkflowInstance', array('Title' => 'Title', 'Target.Title' => 'Target Title', 'WorkflowStatus' => 'Status', 'CurrentAction.Title' => 'Current Action', 'LastEdited' => 'Last Actioned'), 'getActionsSummaryFields', '"WorkflowStatus" IN (\'Complete\', \'Cancelled\')', '"LastEdited" DESC'));
         $complete->setPermissions(array('show'));
     }
     return $fields;
 }
Пример #27
0
 /**
  * Standard SS function
  * @return FieldSet
  **/
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldFromTab('Root.Content.Messages.Messages.Actions', "ProceedToCheckoutLabel");
     $fields->removeFieldFromTab('Root.Content.Messages.Messages.Actions', "ContinueShoppingLabel");
     $fields->removeFieldFromTab('Root.Content.Messages.Messages.Actions', "ContinuePageID");
     $fields->removeFieldFromTab('Root.Content.Messages.Messages.Actions', "LoadOrderLinkLabel");
     $fields->removeFieldFromTab('Root.Content.Messages.Messages.Actions', "CurrentOrderLinkLabel");
     $fields->removeFieldFromTab('Root.Content.Messages.Messages.Actions', "SaveOrderLinkLabel");
     $fields->removeFieldFromTab('Root.Content.Messages.Messages.Actions', "DeleteOrderLinkLabel");
     $termsPageIDField = new OptionalTreeDropdownField('TermsPageID', _t("CheckoutPage.TERMSANDCONDITIONSPAGE", "Terms and conditions page (if any - to remove, delete message below)"), 'SiteTree');
     $fields->addFieldToTab('Root.Content.Process', $termsPageIDField);
     $fields->addFieldToTab('Root.Content.Process', new TextField('TermsAndConditionsMessage', _t("CheckoutPage.TERMSANDCONDITIONSMESSAGE", "Terms and conditions page message (shown if the user does not tick the box) - leave blank to allow customer to proceed without ticking the box")));
     $fields->addFieldToTab('Root.Content.Process', new CheckboxField('HasCheckoutSteps', _t("CheckoutPage.HASCHECKOUTSTEPS", "Checkout Process in Steps")));
     $fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('InvitationToCompleteOrder', _t("CheckoutPage.INVITATIONTOCOMPLETEORDER", 'Invitation to complete order ... shown when the customer can do a regular checkout'), $row = 4));
     //The Content field has a slightly different meaning for the Checkout Page.
     $fields->removeFieldFromTab('Root.Content.Main', "Content");
     $fields->addFieldToTab('Root.Content.Messages.Messages.AlwaysVisible', new HtmlEditorField('Content', _t("CheckoutPage.CONTENT", 'General note - always visible on the checkout page'), 7, 7));
     if (DataObject::get_one("OrderModifier_Descriptor")) {
         $orderModifierDescriptionField = new ComplexTableField($this, _t("CheckoutPage.ORDERMODIFIERDESCRIPTMESSAGES", "Messages relating to order form extras (e.g. tax or shipping)"), "OrderModifier_Descriptor");
         $orderModifierDescriptionField->setRelationAutoSetting(false);
         $orderModifierDescriptionField->setTitle(_t("CheckoutPage.ORDERMODIFIERDESCRIPTMESSAGES", "Messages relating to order form extras (e.g. tax or shipping)"));
         $orderModifierDescriptionField->setPermissions(array("show", "edit"));
         $fields->addFieldToTab('Root.Content.Messages.Messages.OrderExtras', $orderModifierDescriptionField);
     }
     if (DataObject::get_one("CheckoutPage_StepDescription")) {
         $checkoutStepDescriptionField = new ComplexTableField($this, _t("CheckoutPage.CHECKOUTSTEPESCRIPTIONS", "Checkout Step Descriptions"), "CheckoutPage_StepDescription");
         $checkoutStepDescriptionField->setRelationAutoSetting(false);
         $checkoutStepDescriptionField->setTitle(_t("CheckoutPage.CHECKOUTSTEPESCRIPTIONS", "Checkout Step Descriptions"));
         $checkoutStepDescriptionField->setPermissions(array("show", "edit"));
         $fields->addFieldToTab('Root.Content.Messages.Messages.CheckoutSteps', $checkoutStepDescriptionField);
     }
     return $fields;
 }
Пример #28
0
    /**
     * STANDARD SILVERSTRIPE STUFF
     * broken up into submitted and not (yet) submitted
     **/
    function getCMSFields()
    {
        $fields = parent::getCMSFields();
        if ($this->exists()) {
            $submitted = $this->IsSubmitted() ? true : false;
            if ($submitted) {
                $this->tryToFinaliseOrder();
            } else {
                $this->init(true);
            }
            if ($submitted) {
                $this->fieldsAndTabsToBeRemoved[] = "CustomerOrderNote";
            } else {
                $this->fieldsAndTabsToBeRemoved[] = "Emails";
            }
            foreach ($this->fieldsAndTabsToBeRemoved as $field) {
                $fields->removeByName($field);
            }
            //$fields->insertBefore(new LiteralField('Title',"<h2>".$this->Title()."</h2>"),'Root');
            $fields->insertAfter(new Tab("Next", new HeaderField("MyOrderStepHeader", _t("Order.CURRENTSTATUS", "Current Status")), $this->OrderStepField(), new HeaderField("OrderStepNextStepHeader", _t("Order.ACTIONNEXTSTEP", "Action Next Step"), 1), new LiteralField("OrderStepNextStepHeaderExtra", "<p><strong>" . _t("Order.NEEDTOREFRESH", "If you have made any changes to the order then you will have to refresh or save this record to see up-to-date options here.") . "</strong></p>"), new LiteralField("ActionNextStepManually", "<br /><br /><br /><h3>" . _t("Order.MANUALSTATUSCHANGE", "Manual Status Change") . "</h3>")), "Main");
            if ($submitted) {
                $htmlSummary = $this->renderWith("Order");
                $fields->addFieldToTab('Root.Main', new LiteralField('MainDetails', $htmlSummary));
                $paymentsTable = new HasManyComplexTableField($this, "Payments", "Payment", null, null, "\"OrderID\" = " . $this->ID . "", "\"Created\" ASC", null);
                $paymentsTable->setPageSize(20);
                $paymentsTable->addSummary(_t("Order.TOTAL", "Total"), array("Total" => array("sum", "Currency->Nice")));
                if ($this->IsPaid()) {
                    $paymentsTable->setPermissions(array('export', 'show'));
                } else {
                    $paymentsTable->setPermissions(array('edit', 'delete', 'export', 'show'));
                }
                $paymentsTable->setShowPagination(false);
                $paymentsTable->setRelationAutoSetting(true);
                $fields->addFieldToTab('Root.Payments', $paymentsTable);
                $fields->addFieldToTab("Root.Payments", new ReadOnlyField("TotalPaid", _t("Order.TOTALPAID", "Total Paid"), $this->getTotalPaid()));
                $fields->addFieldToTab("Root.Payments", new ReadOnlyField("TotalOutstanding", _t("Order.TOTALOUTSTANDING", "Total Outstanding"), $this->getTotalOutstanding()));
                if ($this->canPay()) {
                    $link = EcommercePaymentController::make_payment_link($this->ID);
                    $js = "window.open(this.href, 'payment', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=800,height=600'); return false;";
                    $header = _t("Order.MAKEPAYMENT", "make payment");
                    $label = _t("Order.MAKEADDITIONALPAYMENTNOW", "make additional payment now");
                    $linkHTML = '<a href="' . $link . '" onclick="' . $js . '">' . $label . '</a>';
                    $fields->addFieldToTab("Root.Payments", new HeaderField("MakeAdditionalPaymentHeader", $header, 3));
                    $fields->addFieldToTab("Root.Payments", new LiteralField("MakeAdditionalPayment", $linkHTML));
                }
                //member
                if ($member = $this->Member()) {
                    $fields->addFieldToTab('Root.Customer', new LiteralField("MemberDetails", $member->getEcommerceFieldsForCMSAsString()));
                }
                $cancelledField = $fields->dataFieldByName("CancelledByID");
                $fields->removeByName("CancelledByID");
                $fields->addFieldToTab("Root.Cancellation", $cancelledField);
                $oldOrderStatusLogs = new ComplexTableField($this, $name = "OldOrderStatusLogs", $sourceClass = "OrderStatusLog", $fieldList = null, $detailFormFields = null, $sourceFilter = "\"OrderID\" = " . $this->ID, $sourceSort = "", $sourceJoin = "");
                $oldOrderStatusLogs->setPermissions(array("show"));
                $fields->addFieldToTab('Root.Log', $oldOrderStatusLogs);
                $submissionLog = $this->SubmissionLog();
                if ($submissionLog) {
                    $fields->addFieldToTab('Root.Log', new ReadonlyField('SequentialOrderNumber', _t("Order.SEQUENTIALORDERNUMBER", "Sequential order number for submitted orders (e.g. 1,2,3,4,5...)"), $submissionLog->SequentialOrderNumber));
                }
            } else {
                $msg = sprintf(_t("Order.NOSUBMITTEDYET", 'No details are shown here as this order has not been submitted yet.
						You can %1$s to submit it... NOTE: For this, you will be logged in as the customer and logged out as (shop)admin .'), '<a href="' . $this->RetrieveLink() . '" target="_blank">load this order</a>');
                $fields->addFieldToTab('Root.Main', new LiteralField('MainDetails', '<p>' . $msg . '</p>'));
                $orderItemsTable = new HasManyComplexTableField($this, "Attributes", "OrderItem", null, null, "\"OrderID\" = " . $this->ID . "", "\"Created\" ASC", null);
                $orderItemsTable->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd', "show"));
                $orderItemsTable->setShowPagination(false);
                $orderItemsTable->setRelationAutoSetting(true);
                $orderItemsTable->addSummary(_t("Order.TOTAL", "Total"), array("Total" => array("sum", "Currency->Nice")));
                $fields->addFieldToTab('Root.Items', $orderItemsTable);
                $modifierTable = new ComplexTableField($this, "OrderModifiers", "OrderModifier", null, null, "\"OrderID\" = " . $this->ID . "", "\"Created\" ASC", null);
                $modifierTable->setPermissions(array('edit', 'delete', 'export', 'show'));
                $modifierTable->setPageSize(100);
                $fields->addFieldToTab('Root.Extras', $modifierTable);
                //MEMBER STUFF
                $specialOptionsArray = array();
                if ($this->MemberID) {
                    $specialOptionsArray[0] = _t("Order.SELECTCUSTOMER", "-- - Remover Customer -- -");
                    $specialOptionsArray[$this->MemberID] = _t("Order.LEAVEWITHCURRENTCUSTOMER", "- Leave with current customer: ") . $this->Member()->getTitle();
                } elseif ($currentMember = Member::currentUser()) {
                    $specialOptionsArray[0] = _t("Order.SELECTCUSTOMER", "-- - Select Customers -- -");
                    $currentMemberID = $currentMember->ID;
                    $specialOptionsArray[$currentMemberID] = _t("Order.ASSIGNTHISORDERTOME", "- Assign this order to me: ") . $currentMember->getTitle();
                }
                //MEMBER FIELD!!!!!!!
                $memberArray = $specialOptionsArray + EcommerceRole::list_of_customers();
                $fields->addFieldToTab("Root.Main", new DropdownField("MemberID", _t("Order.SELECTCUSTOMER", "Select Cutomer"), $memberArray), "CustomerOrderNote");
                $memberArray = null;
            }
            $fields->addFieldToTab('Root.Addresses', new HeaderField("BillingAddressHeader", _t("Order.BILLINGADDRESS", "Billing Address")));
            $billingAddressObject = $this->CreateOrReturnExistingAddress("BillingAddress");
            $billingAddressField = new HasOneComplexTableField($this, "BillingAddress", "BillingAddress", null, null, "\"BillingAddress\".\"ID\" = " . $this->BillingAddressID, "\"Created\" ASC", null);
            if (!$this->BillingAddressID) {
                $billingAddressField->setPermissions(array('edit', 'add', 'inlineadd', 'show'));
            } elseif ($this->canEdit()) {
                $billingAddressField->setPermissions(array('edit', 'show'));
            } else {
                $billingAddressField->setPermissions(array('export', 'show'));
            }
            //DO NOT ADD!
            //$billingAddressField->setRelationAutoSetting(true);
            //$billingAddress->setShowPagination(false);
            $fields->addFieldToTab('Root.Addresses', $billingAddressField);
            if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
                $fields->addFieldToTab('Root.Addresses', new HeaderField("ShippingAddressHeader", _t("Order.SHIPPINGADDRESS", "Shipping Address")));
                $fields->addFieldToTab('Root.Addresses', new CheckboxField("UseShippingAddress", _t("Order.USESEPERATEADDRESS", "Use seperate shipping address?")));
                if ($this->UseShippingAddress) {
                    $shippinggAddressObject = $this->CreateOrReturnExistingAddress("ShippingAddress");
                    $shippingAddressField = new HasOneComplexTableField($this, "ShippingAddress", "ShippingAddress", null, null, "\"ShippingAddress\".\"ID\" = " . $this->ShippingAddressID, "\"Created\" ASC", null);
                    if (!$this->ShippingAddressID) {
                        $shippingAddressField->setPermissions(array('edit', 'add', 'inlineadd', 'show'));
                    } elseif ($this->canEdit()) {
                        $shippingAddressField->setPermissions(array('edit', 'show'));
                    } else {
                        $shippingAddressField->setPermissions(array('export', 'show'));
                    }
                    //DO NOT ADD
                    //$shippingAddress->setRelationAutoSetting(true);
                    $fields->addFieldToTab('Root.Addresses', $shippingAddressField);
                }
            }
            $this->MyStep()->addOrderStepFields($fields, $this);
            $fields->addFieldToTab("Root.Next", new LiteralField("StatusIDExplanation", _t("Order.STATUSIDEXPLANATION", "You can not manually update the status of an order.")));
            $fields->addFieldToTab("Root.Currency", new NumericField("ExchangeRate ", _t("Order.EXCHANGERATE", "Exchange Rate")));
            $fields->addFieldToTab("Root.Currency", new DropdownField("CurrencyUsedID ", _t("Order.CurrencyUsed", "Currency Used"), DataObject::get("EcommerceCurrency"), EcommerceCurrency::default_currency_id()));
        } else {
            $fields->removeByName("Main");
            $firstStep = DataObject::get_one("OrderStep");
            $msg = _t("Order.VERYFIRSTSTEP", "The first step in creating an order is to save (<i>add</i>) it.");
            $fields->addFieldToTab("Root.Next", new LiteralField("VeryFirstStep", "<p>" . $msg . "</p>"));
            if ($firstStep) {
                $fields->addFieldToTab("Root.Next", new HiddenField("StatusID", $firstStep->ID, $firstStep->ID));
            }
        }
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
    /**
     * Set some CMS fields for managing Product images, Variations, Options, Attributes etc.
     * 
     * @see Page::getCMSFields()
     * @return FieldSet
     */
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        //Gallery
        $manager = new ComplexTableField($this, 'Images', 'ProductImage', array('SummaryOfImage' => 'Thumbnail', 'Caption' => 'Caption'), 'getCMSFields_forPopup');
        $manager->setPopupSize(650, 400);
        $fields->addFieldToTab("Root.Content.Gallery", new HeaderField('GalleryHeading', 'Add images for this product, the first image will be used as a thumbnail', 3));
        $fields->addFieldToTab("Root.Content.Gallery", $manager);
        //Product fields
        $amountField = new MoneyField('Amount', 'Amount');
        $amountField->setAllowedCurrencies(self::$allowed_currency);
        $fields->addFieldToTab('Root.Content.Main', $amountField, 'Content');
        //Stock level field
        $level = $this->StockLevel()->Level;
        $fields->addFieldToTab('Root.Content.Main', new StockField('Stock', null, $level, $this), 'Content');
        //Product categories
        $fields->addFieldToTab("Root.Content.Categories", new HeaderField('CategoriesHeading', 'Select categories you would like this product to appear in', 3));
        $categoryAlert = <<<EOS
<p class="message good">
Please 'Save' after you have finished changing categories if you would like to set the order of this product
in each category.
</p>
EOS;
        $fields->addFieldToTab("Root.Content.Categories", new LiteralField('CategoryAlert', $categoryAlert));
        /*
        $manager = new BelongsManyManyComplexTableField(
          $this,
          'ProductCategories',
          'ProductCategory',
          array(),
          'getCMSFields_forPopup',
          '',
          '"Title" ASC'
        );
        $manager->setPageSize(20);
        $manager->setPermissions(array());
        $fields->addFieldToTab("Root.Content.Categories", $manager);
        */
        $categoriesField = new CategoriesField('ProductCategories', false, 'ProductCategory');
        $fields->addFieldToTab("Root.Content.Categories", $categoriesField);
        //Attributes selection
        $anyAttribute = DataObject::get_one('Attribute');
        if ($anyAttribute && $anyAttribute->exists()) {
            $tablefield = new ManyManyComplexTableField($this, 'Attributes', 'Attribute', array('Title' => 'Title', 'Label' => 'Label', 'Description' => 'Description'), 'getCMSFields');
            $tablefield->setPermissions(array());
            $fields->addFieldToTab("Root.Content.Attributes", new HeaderField('AttributeHeading', 'Select attributes for this product', 3));
            $attributeHelp = <<<EOS
<p class="ProductHelp">
Once attributes are selected don't forget to save. 
Always make sure there are options for each attribute and variations which are enabled and have 
an option selected for each attribute.
</p>
EOS;
            $fields->addFieldToTab("Root.Content.Attributes", new LiteralField('AttributeHelp', $attributeHelp));
            $attributeAlert = <<<EOS
<p id="AttributeAlert" class="message good">
Please 'Save' after you have finished changing attributes and check that product variations are correct.
</p>
EOS;
            $fields->addFieldToTab("Root.Content.Attributes", new LiteralField('AttributeAlert', $attributeAlert));
            $fields->addFieldToTab("Root.Content.Attributes", $tablefield);
        }
        //Options selection
        $attributes = $this->Attributes();
        if ($attributes && $attributes->exists()) {
            //Remove the stock level field if there are variations, each variation has a stock field
            $fields->removeByName('Stock');
            $variationFieldList = array();
            $fields->addFieldToTab("Root.Content", new TabSet('Options'));
            $fields->addFieldToTab("Root.Content", new Tab('Variations'));
            foreach ($attributes as $attribute) {
                $variationFieldList['AttributeValue_' . $attribute->ID] = $attribute->Title;
                //TODO refactor, this is a really dumb place to be writing default options probably
                //If there aren't any existing options for this attribute on this product,
                //populate with the default options
                $defaultOptions = DataObject::get('Option', "ProductID = 0 AND AttributeID = {$attribute->ID}");
                $existingOptions = DataObject::get('Option', "ProductID = {$this->ID} AND AttributeID = {$attribute->ID}");
                if (!$existingOptions || !$existingOptions->exists()) {
                    if ($defaultOptions && $defaultOptions->exists()) {
                        foreach ($defaultOptions as $option) {
                            $newOption = $option->duplicate(false);
                            $newOption->ProductID = $this->ID;
                            $newOption->write();
                        }
                    }
                }
                $attributeTabName = str_replace(' ', '', $attribute->Title);
                $fields->addFieldToTab("Root.Content.Options", new Tab($attributeTabName));
                $manager = new OptionComplexTableField($this, $attribute->Title, 'Option', array('Title' => 'Title'), 'getCMSFields_forPopup', "AttributeID = {$attribute->ID}");
                $manager->setAttributeID($attribute->ID);
                $fields->addFieldToTab("Root.Content.Options." . $attributeTabName, $manager);
            }
            $variationFieldList = array_merge($variationFieldList, singleton('Variation')->summaryFields());
            $manager = new VariationComplexTableField($this, 'Variations', 'Variation', $variationFieldList, 'getCMSFields_forPopup');
            if (class_exists('SWS_Xero_Item_Decorator')) {
                $manager->setPopupSize(500, 650);
            }
            $fields->addFieldToTab("Root.Content.Variations", $manager);
        }
        //Product ordering
        $categories = $this->ProductCategories();
        if ($categories && $categories->exists()) {
            $fields->addFieldToTab("Root.Content", new Tab('Order'));
            $fields->addFieldToTab("Root.Content.Order", new HeaderField('OrderHeading', 'Set the order of this product in each of it\'s categories', 3));
            $orderHelp = <<<EOS
<p class="ProductHelp">
Products with higher order numbers in each category will appear further at the front of 
that category.
</p>
EOS;
            $fields->addFieldToTab("Root.Content.Order", new LiteralField('OrderHelp', $orderHelp));
            foreach ($categories as $category) {
                $categoryTitle = $category->Title;
                $categoryID = $category->ID;
                $productID = $this->ID;
                $sql = <<<EOS
SELECT "ProductOrder" 
FROM  "ProductCategory_Products" 
WHERE "ProductCategoryID" = {$categoryID} 
AND "ProductID" = {$productID} 
EOS;
                $query = DB::query($sql);
                $order = $query->value();
                $val = $order ? $order : 0;
                $fields->addFieldToTab('Root.Content.Order', new TextField("CategoryOrder[{$categoryID}]", "Order in {$categoryTitle} Category", $val));
            }
        }
        //Ability to edit fields added to CMS here
        $this->extend('updateProductCMSFields', $fields);
        if (file_exists(BASE_PATH . '/swipestripe') && ShopSettings::get_license_key() == null) {
            $fields->addFieldToTab("Root.Content.Main", new LiteralField("SwipeStripeLicenseWarning", '<p class="message warning">
					 Warning: You have SwipeStripe installed without a license key. 
					 Please <a href="http://swipestripe.com" target="_blank">purchase a license key here</a> before this site goes live.
				</p>'), "Title");
        }
        return $fields;
    }
	public function LastLink()
	{
		$pageSize = ($this->TotalCount() % $this->pageSize > 0) ? $this->TotalCount() % $this->pageSize : $this->pageSize;
		$start = $this->TotalCount() - $pageSize;
		return parent::LastLink() ? $this->RelativeLink(array('start' => $start)) : false;
	}