function PopupForm()
 {
     $form = new Form($this, "{$this->name}/PopupForm", new FieldList($headerWrap = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', 'Edit Source'))), $codeField = new CodeEditorField('TinyMCESource', '')), new FieldList(ResetFormAction::create('cancel', 'Cancel')->addExtraClass('ss-ui-action-destructive')->setUseButtonTag(true), FormAction::create('update', 'Update')->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     $headerWrap->addExtraClass('CompositeField composite cms-content-header nolabel ');
     //	$contentComposite->addExtraClass('tinymce-codeeditor-field content');
     $codeField->addExtraClass('nolabel stacked');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-codeform cms-dialog-content');
     //	$this->extend('updateLinkForm', $form);
     return $form;
 }
 /**
  * Returns a form with all languages with languages already used appearing first.
  *
  * @return Form
  */
 function LangForm()
 {
     $member = Member::currentUser();
     //check to see if the current user can switch langs or not
     if (Permission::checkMember($member, 'VIEW_LANGS')) {
         $field = new LanguageDropdownField('Locale', _t('CMSMain.LANGUAGEDROPDOWNLABEL', 'Language'), array(), 'SiteTree', 'Locale-English', singleton('SiteTree'));
         $field->setValue(Translatable::get_current_locale());
     } else {
         // user doesn't have permission to switch langs
         // so just show a string displaying current language
         $field = new LiteralField('Locale', i18n::get_locale_name(Translatable::get_current_locale()));
     }
     $form = new Form($this->owner, 'LangForm', new FieldList($field), new FieldList(new FormAction('selectlang', _t('CMSMain_left.GO', 'Go'))));
     $form->unsetValidator();
     $form->addExtraClass('nostyle');
     return $form;
 }
 /**
  * @return Form
  */
 public function ImageForm()
 {
     Requirements::css('framework/admin/thirdparty/jquery-notice/jquery.notice.css');
     Requirements::css('framework/thirdparty/jquery-ui-themes/smoothness/jquery-ui.css');
     Requirements::css('framework/admin/thirdparty/chosen/chosen/chosen.css');
     Requirements::css('framework/thirdparty/jstree/themes/apple/style.css');
     Requirements::css('framework/css/TreeDropdownField.css');
     Requirements::css('framework/css/GridField.css');
     Requirements::css('framework/admin/css/screen.css');
     Requirements::css('site/css/cms.css');
     Requirements::css('dashboard/css/dashboard_icon.css');
     Requirements::css('userforms/css/FieldEditor.css');
     Requirements::css('cms/css/screen.css');
     Requirements::javascript('framework/thirdparty/jquery/jquery.js');
     Requirements::javascript('framework/thirdparty/jquery-ui/jquery-ui.js');
     Requirements::javascript('framework/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript('framework/thirdparty/jquery-cookie/jquery.cookie.js');
     Requirements::javascript('framework/javascript/GridField.js');
     Requirements::javascript('framework/admin/javascript/leaktools.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Layout.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.ActionTabSet.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Panel.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Tree.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Content.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.EditForm.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Menu.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.Preview.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.BatchActions.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.FieldHelp.js');
     Requirements::javascript('framework/admin/javascript/LeftAndMain.TreeDropdownField.js');
     Requirements::javascript('framework/javascript/lang/en.js');
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $form = new Form($this, "ImageForm", new FieldList($contentComposite = new CompositeField(new LiteralField('Step1', '<div class="step1">' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.SELECTIMAGE', 'Select Image')) . '</div>'), CloudinaryImageField::create('Image')->addExtraClass('markdown-popup'), new LiteralField('Step2', '<div class="step2">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.DETAILS', 'Details')) . '</div>'), NumericField::create('Width'), NumericField::create('Height'), TextField::create('AltText')->setTitle('Alter Text'))), new FieldList(FormAction::create('insert', _t('HtmlEditorField.BUTTONINSERTIMAGE', 'Insert Image'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     $contentComposite->addExtraClass('ss-insert-image content ss-insert-media');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->addExtraClass('markdownfield-form markdowneditorfield-imageform ');
     return $form;
 }
Example #4
0
 /**
  * Return a {@link Form} instance allowing a user to
  * add images and flash objects to the TinyMCE content editor.
  *  
  * @return Form
  */
 public function MediaForm()
 {
     // TODO Handle through GridState within field - currently this state set too late to be useful here (during
     // request handling)
     $parentID = $this->getAttachParentID();
     $fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(5), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fileField = new GridField('Files', false, null, $fileFieldConfig);
     $fileField->setList($this->getFiles($parentID));
     $fileField->setAttribute('data-selectable', true);
     $fileField->setAttribute('data-multiselect', true);
     $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('CMSThumbnail' => false, 'Name' => _t('File.Name')));
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $fromCMS = new CompositeField(new LiteralField('headerSelect', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.FindInFolder', 'Find in Folder')) . '</h4>'), $select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder')->setValue($parentID), $fileField);
     $fromCMS->addExtraClass('content ss-uploadfield');
     $select->addExtraClass('content-select');
     $fromWeb = new CompositeField(new LiteralField('headerURL', '<h4>' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia">' . _t('HtmlEditorField.BUTTONADDURL', 'Add url') . '</button>'));
     $remoteURL->addExtraClass('remoteurl');
     $fromWeb->addExtraClass('content ss-uploadfield');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
     $computerUploadField->setConfig('previewMaxWidth', 40);
     $computerUploadField->setConfig('previewMaxHeight', 30);
     $computerUploadField->addExtraClass('ss-assetuploadfield');
     $computerUploadField->removeExtraClass('ss-uploadfield');
     $computerUploadField->setTemplate('HtmlEditorField_UploadField');
     $computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
     $tabSet = new TabSet("MediaFormInsertMediaTabs", Tab::create('FromComputer', _t('HtmlEditorField.FROMCOMPUTER', 'From your computer'), $computerUploadField)->addExtraClass('htmleditorfield-from-computer'), Tab::create('FromWeb', _t('HtmlEditorField.FROMWEB', 'From the web'), $fromWeb)->addExtraClass('htmleditorfield-from-web'), Tab::create('FromCms', _t('HtmlEditorField.FROMCMS', 'From the CMS'), $fromCMS)->addExtraClass('htmleditorfield-from-cms'));
     $tabSet->addExtraClass('cms-tabset-primary');
     $allFields = new CompositeField($tabSet, new LiteralField('headerEdit', '<h4 class="field noborder header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.ADJUSTDETAILSDIMENSIONS', 'Details &amp; dimensions')) . '</h4>'), $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')));
     $allFields->addExtraClass('ss-insert-media');
     $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert Media')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update Media'))));
     $headings->addExtraClass('cms-content-header');
     $editComposite->addExtraClass('ss-assetuploadfield');
     $fields = new FieldList($headings, $allFields);
     $actions = new FieldList(FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))->addExtraClass('ss-ui-action-constructive media-insert')->setAttribute('data-icon', 'accept')->setUseButtonTag(true), FormAction::create('insertmedia', _t('HtmlEditorField.BUTTONUpdate', 'Update'))->addExtraClass('ss-ui-action-constructive media-update')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
     $form = new Form($this->controller, "{$this->name}/MediaForm", $fields, $actions);
     $form->unsetValidator();
     $form->disableSecurityToken();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
     // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
     // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
     // Allow other people to extend the fields being added to the imageform
     $this->extend('updateMediaForm', $form);
     return $form;
 }
 /**
  * Return a {@link Form} instance allowing a user to
  * add images and flash objects to the TinyMCE content editor.
  *
  * @return Form
  */
 public function MediaForm()
 {
     // TODO Handle through GridState within field - currently this state set too late to be useful here (during
     // request handling)
     $parentID = $this->getAttachParentID();
     $fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(7), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fileField = GridField::create('Files', false, null, $fileFieldConfig);
     $fileField->setList($this->getFiles($parentID));
     $fileField->setAttribute('data-selectable', true);
     $fileField->setAttribute('data-multiselect', true);
     $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => false, 'Title' => _t('File.Title'), 'Created' => singleton('File')->fieldLabel('Created')));
     $columns->setFieldCasting(array('Created' => 'SS_Datetime->Nice'));
     $fromCMS = new CompositeField($select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder')->setValue($parentID), $fileField);
     $fromCMS->addExtraClass('content ss-uploadfield htmleditorfield-from-cms');
     $select->addExtraClass('content-select');
     $URLDescription = _t('HtmlEditorField.URLDESCRIPTION', 'Insert videos and images from the web into your page simply by entering the URL of the file. Make sure you have the rights or permissions before sharing media directly from the web.<br /><br />Please note that files are not added to the file store of the CMS but embeds the file from its original location, if for some reason the file is no longer available in its original location it will no longer be viewable on this page.');
     $fromWeb = new CompositeField($description = new LiteralField('URLDescription', '<div class="url-description">' . $URLDescription . '</div>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button type="button" class="action ui-action-constructive ui-button field font-icon-plus add-url">' . _t('HtmlEditorField.BUTTONADDURL', 'Add url') . '</button>'));
     $remoteURL->addExtraClass('remoteurl');
     $fromWeb->addExtraClass('content ss-uploadfield htmleditorfield-from-web');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
     $computerUploadField->setConfig('previewMaxWidth', 40);
     $computerUploadField->setConfig('previewMaxHeight', 30);
     $computerUploadField->addExtraClass('ss-assetuploadfield htmleditorfield-from-computer');
     $computerUploadField->removeExtraClass('ss-uploadfield');
     $computerUploadField->setTemplate('HtmlEditorField_UploadField');
     $computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
     $defaultPanel = new CompositeField($computerUploadField, $fromCMS);
     $fromWebPanel = new CompositeField($fromWeb);
     $defaultPanel->addExtraClass('htmleditorfield-default-panel');
     $fromWebPanel->addExtraClass('htmleditorfield-web-panel');
     $allFields = new CompositeField($defaultPanel, $fromWebPanel, $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')));
     $allFields->addExtraClass('ss-insert-media');
     $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert media from')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update media'))));
     $headings->addExtraClass('cms-content-header');
     $editComposite->addExtraClass('ss-assetuploadfield');
     $fields = new FieldList($headings, $allFields);
     $form = new Form($this->controller, "{$this->name}/MediaForm", $fields, new FieldList());
     $form->unsetValidator();
     $form->disableSecurityToken();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
     // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
     // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
     // Allow other people to extend the fields being added to the imageform
     $this->extend('updateMediaForm', $form);
     return $form;
 }
 /**
  * @return Form
  */
 function BatchActionsForm()
 {
     $actions = $this->batchactions()->batchActionList();
     $actionsMap = array();
     foreach ($actions as $action) {
         $actionsMap[$action->Link] = $action->Title;
     }
     $form = new Form($this, 'BatchActionsForm', new FieldSet(new LiteralField('Intro', sprintf('<p><small>%s</small></p>', _t('CMSMain_left.ss.SELECTPAGESACTIONS', 'Select the pages that you want to change &amp; then click an action:'))), new HiddenField('csvIDs'), new DropdownField('Action', false, $actionsMap)), new FieldSet(new FormAction('submit', "Go")));
     $form->addExtraClass('actionparams');
     $form->unsetValidator();
     return $form;
 }
Example #7
0
 /**
  * @return Form
  */
 function BatchActionsForm()
 {
     $actions = $this->batchactions()->batchActionList();
     $actionsMap = array('-1' => _t('LeftAndMain.DropdownBatchActionsDefault', 'Actions'));
     foreach ($actions as $action) {
         $actionsMap[$action->Link] = $action->Title;
     }
     $form = new Form($this, 'BatchActionsForm', new FieldList(new HiddenField('csvIDs'), DropdownField::create('Action', false, $actionsMap)->setAttribute('autocomplete', 'off')), new FieldList(new FormAction('submit', _t('Form.SubmitBtnLabel', "Go"))));
     $form->addExtraClass('cms-batch-actions nostyle');
     $form->unsetValidator();
     return $form;
 }
 /**
  * Calls {@link DataObject->getCMSFields()}
  *
  * @param Int $id
  * @param FieldList $fields
  * @return Form
  */
 public function ItemEditForm($id = null, $fields = null)
 {
     if ($this->record) {
         $className = $this->getItemClassName();
         $record = null;
         if ($id && is_numeric($id)) {
             $record = DataObject::get_by_id($className, (int) $id);
         } else {
             if (!empty($_REQUEST['RecordID'])) {
                 $record = DataObject::get_by_id($className, (int) $_REQUEST['RecordID']);
             } else {
                 if (!empty($_REQUEST['ID'])) {
                     $record = DataObject::get_by_id($className, (int) $_REQUEST['ID']);
                 } else {
                     if ($this->_idField) {
                         $record = DataObject::get_by_id($className, (int) $this->_idField);
                     } else {
                         if ($id = $this->getSessionID()) {
                             $record = DataObject::get_by_id($className, $id);
                         }
                     }
                 }
             }
         }
         if (!$record) {
             $record = new $className();
         }
         $fields = $fields ? $fields : $record->getCMSFields();
         if ($fields == null) {
             user_error("getCMSFields() returned null  - it should return a FieldList object.\n                                        Perhaps you forgot to put a return statement at the end of your method?", E_USER_ERROR);
         }
         if ($record->hasMethod('getAllCMSActions')) {
             $actions = $record->getAllCMSActions();
         } else {
             $actions = $record->getCMSActions();
             // add default actions if none are defined
             if (!$actions || !$actions->Count()) {
                 if ($record->hasMethod('canEdit') && $record->canEdit()) {
                     $actions->push(FormAction::create('save', _t('CMSMain.SAVE', 'Save'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'));
                 }
                 if ($record->hasMethod('canDelete') && $record->canDelete() && $record->exists()) {
                     $actions->push(FormAction::create('delete', _t('ModelAdmin.DELETE', 'Delete'))->addExtraClass('ss-ui-action-destructive'));
                 }
             }
         }
         // Use <button> to allow full jQuery UI styling
         $actionsFlattened = $actions->dataFields();
         if ($actionsFlattened) {
             foreach ($actionsFlattened as $action) {
                 $action->setUseButtonTag(true);
             }
         }
         $form = new Form($this, "ItemEditForm", $fields, $actions);
         $form->addExtraClass('cms-edit-form ContentRelationshipEditor_Form');
         $form->setAttribute('data-pjax-fragment', 'CurrentForm');
         // Set this if you want to split up tabs into a separate header row
         // if($form->Fields()->hasTabset()) {
         // 	$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
         // }
         // Add a default or custom validator.
         // @todo Currently the default Validator.js implementation
         //  adds javascript to the document body, meaning it won't
         //  be included properly if the associated fields are loaded
         //  through ajax. This means only serverside validation
         //  will kick in for pages+validation loaded through ajax.
         //  This will be solved by using less obtrusive javascript validation
         //  in the future, see http://open.silverstripe.com/ticket/2915 and
         //  http://open.silverstripe.com/ticket/3386
         if ($record->hasMethod('getCMSValidator')) {
             $validator = $record->getCMSValidator();
             // The clientside (mainly LeftAndMain*.js) rely on ajax responses
             // which can be evaluated as javascript, hence we need
             // to override any global changes to the validation handler.
             $form->setValidator($validator);
         } else {
             $form->unsetValidator();
         }
         if ($record->hasMethod('canEdit') && !$record->canEdit()) {
             $readonlyFields = $form->Fields()->makeReadonly();
             $form->setFields($readonlyFields);
         }
         if ($record->exists()) {
             //rename to recordID so it doesn't conflict with CMSMain/LeftAndMain
             $fields->push(new HiddenField('RecordID', 'RecordID', $record->ID));
             //store in session so we can use for subfields
             $this->setSessionID($record->ID);
         }
         $form->loadDataFrom($record);
         //echo $form->getRecord()->ID;exit;
         $form->setFormAction($this->Link('ItemEditForm'));
         return $form;
     }
     return false;
 }
 /**
  * Return a {@link Form} instance allowing a user to
  * add links in the TinyMCE content editor.
  *  
  * @return Form
  */
 function LinkForm()
 {
     $siteTree = new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle', true);
     // mimic the SiteTree::getMenuTitle(), which is bypassed when the search is performed
     $siteTree->setSearchFunction(array($this, 'siteTreeSearchCallback'));
     $form = new Form($this->controller, "{$this->name}/LinkForm", new FieldSet(new LiteralField('Heading', sprintf('<h3>%s</h3>', _t('HtmlEditorField.LINK', 'Link'))), $contentComposite = new CompositeField(new OptionsetField('LinkType', _t('HtmlEditorField.LINKTO', 'Link to'), array('internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('HtmlEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'))), $siteTree, new TextField('external', _t('HtmlEditorField.URL', 'URL'), 'http://'), new EmailField('email', _t('HtmlEditorField.EMAIL', 'Email address')), new TreeDropdownField('file', _t('HtmlEditorField.FILE', 'File'), 'File', 'Filename', 'Title', true), new TextField('Anchor', _t('HtmlEditorField.ANCHORVALUE', 'Anchor')), new TextField('LinkText', _t('HtmlEditorField.LINKTEXT', 'Link text')), new TextField('Description', _t('HtmlEditorField.LINKDESCR', 'Link description')), new CheckboxField('TargetBlank', _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?')), new HiddenField('Locale', null, $this->controller->Locale))), new FieldSet(new FormAction('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link')), new FormAction('remove', _t('HtmlEditorField.BUTTONREMOVELINK', 'Remove link'))));
     $contentComposite->addExtraClass('content');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $this->extend('updateLinkForm', $form);
     return $form;
 }
Example #10
0
	/**
	 * Return a {@link Form} instance allowing a user to
	 * add images and flash objects to the TinyMCE content editor.
	 *  
	 * @return Form
	 */
	function MediaForm() {
		// TODO Handle through GridState within field - currently this state set too late to be useful here (during request handling)
		$parentID = $this->controller->getRequest()->requestVar('ParentID');

		$fileFieldConfig = GridFieldConfig::create();
		$fileFieldConfig->addComponent(new GridFieldSortableHeader());
		$fileFieldConfig->addComponent(new GridFieldFilterHeader());
		$fileFieldConfig->addComponent(new GridFieldDataColumns());
		$fileFieldConfig->addComponent(new GridFieldPaginator(5));
		$fileField = new GridField('Files', false, null, $fileFieldConfig);
		$fileField->setList($this->getFiles($parentID));
		$fileField->setAttribute('data-selectable', true);
		$fileField->setAttribute('data-multiselect', true);
		$columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
		$columns->setDisplayFields(array(
			'CMSThumbnail' => false,
			'Name' => _t('File.Name'),
		));
		
		$numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span><strong class="title">%s</strong></span>';

		$fromCMS = new CompositeField(
			new LiteralField('headerSelect', '<h4 class="field header-select">' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.Find', 'Find')) . '</h4>'),
				$selectComposite = new CompositeField(
					new TreeDropdownField('ParentID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'),
					$fileField
				)
		);

		$fromCMS->addExtraClass('content');
		$selectComposite->addExtraClass('content-select');

		Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
		$computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
		$computerUploadField->setConfig('previewMaxWidth', 40);
		$computerUploadField->setConfig('previewMaxHeight', 30);
		$computerUploadField->addExtraClass('ss-assetuploadfield');
		$computerUploadField->removeExtraClass('ss-uploadfield');
		$computerUploadField->setTemplate('HtmlEditorField_UploadField');
		$computerUploadField->setFolderName(Upload::$uploads_folder);

		$tabSet = new TabSet(
			"MediaFormInsertImageTabs",
			new Tab(
				_t('HtmlEditorField.FROMCOMPUTER','From your computer'),
				$computerUploadField
			),
			new Tab(
				_t('HtmlEditorField.FROMCMS','From the CMS'),
				$fromCMS
			)
		);

		$allFields = new CompositeField(
			$tabSet,
			new LiteralField('headerEdit', '<h4 class="field header-edit">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.EditDetails', 'Edit details')) . '</h4>'),
			$editComposite = new CompositeField(
				new LiteralField('contentEdit', '<div class="content-edit"></div>')
			)
		);

		$fields = new FieldList(
			new LiteralField(
				'Heading',
				sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTIMAGE', 'Insert Image')).
				sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateIMAGE', 'Update Image'))
			),
			$allFields
		);
		
		$actions = new FieldList(
			FormAction::create('insertimage', _t('HtmlEditorField.BUTTONINSERT', 'Insert'))
				->addExtraClass('ss-ui-action-constructive image-insert')
				->setAttribute('data-icon', 'accept')
				->setUseButtonTag(true),
			FormAction::create('insertimage', _t('HtmlEditorField.BUTTONUpdate', 'Update'))
				->addExtraClass('ss-ui-action-constructive image-update')
				->setAttribute('data-icon', 'accept')
				->setUseButtonTag(true)
		);

		$form = new Form(
			$this->controller,
			"{$this->name}/MediaForm",
			$fields,
			$actions
		);
		

		$form->unsetValidator();
		$form->disableSecurityToken();
		$form->loadDataFrom($this);
		$form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
		// TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
		// $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));

		// Allow other people to extend the fields being added to the imageform 
		$this->extend('updateMediaForm', $form);
		
		return $form;
	}
 /**
  * Builds a Form that mirrors the parent editForm, but with an extra field to collect the ChangeSet ID
  *
  * @param DataObject $object The object we're going to be adding to whichever ChangeSet is chosen
  * @return Form
  */
 public function Form($object)
 {
     $inChangeSets = array_unique(ChangeSetItem::get_for_object($object)->column('ChangeSetID'));
     $changeSets = $this->getAvailableChangeSets()->map();
     $campaignDropdown = DropdownField::create('Campaign', '', $changeSets);
     $campaignDropdown->setEmptyString(_t('Campaigns.AddToCampaign', 'Select a Campaign'));
     $campaignDropdown->addExtraClass('noborder');
     $campaignDropdown->setDisabledItems($inChangeSets);
     $fields = new FieldList([$campaignDropdown, HiddenField::create('ID', null, $this->data['ID']), HiddenField::create('ClassName', null, $this->data['ClassName'])]);
     $form = new Form($this->editForm->getController(), $this->editForm->getName(), new FieldList($header = new CompositeField(new LiteralField('Heading', sprintf('<h3>%s</h3>', _t('Campaigns.AddToCampaign', 'Add To Campaign')))), $content = new CompositeField($fields)), new FieldList($action = AddToCampaignHandler_FormAction::create()));
     $header->addExtraClass('add-to-campaign__header');
     $content->addExtraClass('add-to-campaign__content');
     $action->addExtraClass('add-to-campaign__action');
     $form->setHTMLID('Form_EditForm_AddToCampaign');
     $form->unsetValidator();
     $form->loadDataFrom($this->data);
     $form->addExtraClass('add-to-campaign__form');
     return $form;
 }
 /**
  * Version select form. Main interface between selecting versions to view 
  * and comparing multiple versions.
  *  
  * Because we can reload the page directly to a compare view (history/compare/1/2/3)
  * this form has to adapt to those parameters as well. 
  *
  * @return Form
  */
 function VersionsForm()
 {
     $id = $this->currentPageID();
     $page = $this->getRecord($id);
     $versionsHtml = '';
     $action = $this->request->param('Action');
     $versionID = $this->request->param('VersionID');
     $otherVersionID = $this->request->param('OtherVersionID');
     $showUnpublishedChecked = 0;
     $compareModeChecked = $action == "compare";
     if ($page) {
         $versions = $page->allVersions();
         $versionID = !$versionID ? $page->Version : $versionID;
         if ($versions) {
             foreach ($versions as $k => $version) {
                 $active = false;
                 if ($version->Version == $versionID || $version->Version == $otherVersionID) {
                     $active = true;
                     if (!$version->WasPublished) {
                         $showUnpublishedChecked = 1;
                     }
                 }
                 $version->Active = $active;
             }
         }
         $vd = new ViewableData();
         $versionsHtml = $vd->customise(array('Versions' => $versions))->renderWith('CMSPageHistoryController_versions');
     }
     $fields = new FieldList(new CheckboxField('ShowUnpublished', _t('CMSPageHistoryController.SHOWUNPUBLISHED', 'Show unpublished versions'), $showUnpublishedChecked), new CheckboxField('CompareMode', _t('CMSPageHistoryController.COMPAREMODE', 'Compare mode (select two)'), $compareModeChecked), new LiteralField('VersionsHtml', $versionsHtml), $hiddenID = new HiddenField('ID', false, ""));
     $actions = new FieldList(new FormAction('doCompare', _t('CMSPageHistoryController.COMPAREVERSIONS', 'Compare Versions')), new FormAction('doShowVersion', _t('CMSPageHistoryController.SHOWVERSION', 'Show Version')));
     // Use <button> to allow full jQuery UI styling
     foreach ($actions->dataFields() as $action) {
         $action->setUseButtonTag(true);
     }
     $form = new Form($this, 'VersionsForm', $fields, $actions);
     $form->loadDataFrom($this->request->requestVars());
     $hiddenID->setValue($id);
     $form->unsetValidator();
     $form->addExtraClass('cms-versions-form')->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));
     return $form;
 }
Example #13
0
 /**
  * @return Form
  */
 function VersionsForm()
 {
     $pageID = $this->request->requestVar('ID') ? $this->request->requestVar('ID') : $this->currentPageID();
     $page = $this->getRecord($pageID);
     if ($page) {
         $versions = $page->allVersions($this->request->requestVar('ShowUnpublished') ? "" : "\"SiteTree\".\"WasPublished\" = 1");
         // inject link to cms
         if ($versions) {
             foreach ($versions as $k => $version) {
                 $version->CMSLink = sprintf('%s/%s/%s', $this->Link('getversion'), $version->ID, $version->Version);
             }
         }
         $vd = new ViewableData();
         $versionsHtml = $vd->customise(array('Versions' => $versions))->renderWith('CMSMain_versions');
     } else {
         $versionsHtml = '';
     }
     $form = new Form($this, 'VersionsForm', new FieldSet(new CheckboxField('ShowUnpublished', _t('CMSMain_left.ss.SHOWUNPUB', 'Show unpublished versions')), new LiteralField('VersionsHtml', $versionsHtml), new HiddenField('ID', false, $pageID), new HiddenField('Locale', false, $this->Locale)), new FieldSet(new FormAction('versions', _t('CMSMain.BTNREFRESH', 'Refresh')), new FormAction('compareversions', _t('CMSMain.BTNCOMPAREVERSIONS', 'Compare Versions'))));
     $form->loadDataFrom($this->request->requestVars());
     $form->setFormMethod('GET');
     $form->unsetValidator();
     return $form;
 }
 public function LinkForm()
 {
     //        echo 'ssss';die();
     $siteTree = new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle', true);
     // mimic the SiteTree::getMenuTitle(), which is bypassed when the search is performed
     $siteTree->setSearchFunction(array($this, 'siteTreeSearchCallback'));
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $form = new Form($this->controller, "{$this->name}/LinkForm", new FieldList($headerWrap = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.LINK', 'Insert Link')))), $contentComposite = new CompositeField(new OptionsetField('LinkType', sprintf($numericLabelTmpl, '1', _t('MarkdownEditorField.LINKTO', 'Link to')), array('internal' => _t('MarkdownEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('MarkdownEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('MarkdownEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('MarkdownEditorField.LINKEMAIL', 'Email address')), 'internal'), new LiteralField('Step2', '<div class="step2">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.DETAILS', 'Details')) . '</div>'), $siteTree, new TextField('external', _t('MarkdownEditorField.URL', 'URL'), 'http://'), new EmailField('email', _t('MarkdownEditorField.EMAIL', 'Email address')), new TreeDropdownField('file', _t('MarkdownEditorField.FILE', 'File'), 'File', 'ID', 'Title', true), new TextField('Anchor', _t('MarkdownEditorField.ANCHORVALUE', 'Anchor')), new TextField('LinkText', _t('MarkdownEditorField.LINKTEXT', 'Link text')), new TextField('Description', _t('MarkdownEditorField.LINKDESCR', 'Link title')), new CheckboxField('TargetBlank', _t('MarkdownEditorField.LINKOPENNEWWIN', 'Open link in a new window?')), new HiddenField('Locale', null, $this->controller->Locale))), new FieldList(FormAction::create('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     $headerWrap->addExtraClass('CompositeField composite cms-content-header nolabel ');
     $contentComposite->addExtraClass('ss-insert-link content');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->addExtraClass('markdownfield-form markdowneditorfield-linkform cms-dialog-content');
     $this->extend('updateLinkForm', $form);
     return $form;
 }
Example #15
0
 /**
  * Returns a placeholder form, used by {@link getEditForm()} if no record is selected.
  * Our javascript logic always requires a form to be present in the CMS interface.
  * 
  * @return Form
  */
 function EmptyForm()
 {
     $form = new Form($this, "EditForm", new FieldSet(new HeaderField('WelcomeHeader', $this->getApplicationName()), new LiteralField('WelcomeText', sprintf('<p id="WelcomeMessage">%s %s. %s</p>', _t('LeftAndMain_right.ss.WELCOMETO', 'Welcome to'), $this->getApplicationName(), _t('CHOOSEPAGE', 'Please choose an item from the left.')))), new FieldSet());
     $form->unsetValidator();
     return $form;
 }
 /**
  * @return Form
  */
 public function BatchActionsForm()
 {
     $actions = $this->batchactions()->batchActionList();
     $actionsMap = array('-1' => _t('LeftAndMain.DropdownBatchActionsDefault', 'Choose an action...'));
     // Placeholder action
     foreach ($actions as $action) {
         $actionsMap[$action->Link] = $action->Title;
     }
     $form = new Form($this, 'BatchActionsForm', new FieldList(new HiddenField('csvIDs'), DropdownField::create('Action', false, $actionsMap)->setAttribute('autocomplete', 'off')->setAttribute('data-placeholder', _t('LeftAndMain.DropdownBatchActionsDefault', 'Choose an action...'))), new FieldList(new FormAction('submit', _t('Form.SubmitBtnLabel', "Go"))));
     $form->addExtraClass('cms-batch-actions form--no-dividers');
     $form->unsetValidator();
     $this->extend('updateBatchActionsForm', $form);
     return $form;
 }
Example #17
0
 public function CalendarFilterForm()
 {
     $start_date = $this->start_date;
     if ($this->end_date === null || !$this->end_date instanceof sfDate || $this->view == "default") {
         $end_date = $start_date;
     } else {
         $end_date = $this->end_date;
     }
     $form = new Form($this, 'CalendarFilterForm', $this->getModel()->getFilterFields(), new FieldSet(new FormAction('doCalendarFilter', _t('Calendar.FILTER', 'Filter'))));
     $form_data = array('StartMonth' => $start_date->format('m'), 'StartDay' => $start_date->format('d'), 'StartYear' => $start_date->format('Y'), 'EndMonth' => $end_date->format('m'), 'EndDay' => $end_date->format('d'), 'EndYear' => $end_date->format('Y'));
     if ($filters = Calendar::getCleanFilters()) {
         foreach ($filters as $key => $value) {
             $form_data["filter[" . $key . "]"] = $value;
         }
     }
     $form->loadDataFrom($form_data);
     $form->unsetValidator();
     return $form;
 }
    function getEPayForm()
    {
        Requirements::javascript("http://www.epay.dk/js/standardwindow.js");
        Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
        $customscript = <<<JS
\t\t\tjQuery(document).ready(function(\$) {\t\t\t\t
\t\t\t\t\$("form#ePay").submit(function(){
\t\t\t\t\topen_ePay_window();
\t\t\t\t\treturn false;
\t\t\t\t});
\t\t\t\t
\t\t\t});\t
JS;
        if (Director::isLive()) {
            $customscript .= <<<JS
\t\t\t\tjQuery(document).ready(function(\$) {
\t\t\t\t\topen_ePay_window(); //enable for auto-submit
\t\t\t\t\t\$("form#ePay").hide();
\t\t\t\t});\t
JS;
        }
        Requirements::customScript($customscript, 'epayinit');
        $controller = new EpaydkPayment_Controller();
        //http://tech.epay.dk/ePay-Payment-Window-technical-documentation_9.html
        $fields = new FieldSet(new HiddenField('merchantnumber', 'Merchant Number', self::$merchant_number), new HiddenField('orderid', 'Order ID', $this->ID), new HiddenField('currency', 'Currency', self::$supported_currencies[$this->Amount->Currency]['code']), new HiddenField('amount', 'Amount', $this->Amount->Amount * 100), new HiddenField('language', 'Language', self::$language), new HiddenField('accepturl', 'Accept URL', Director::absoluteBaseURL() . $controller->Link('accept')), new HiddenField('declineurl', 'Decline URL', Director::absoluteBaseURL() . $controller->Link('decline')), new HiddenField('callbackurl', 'Callback URL', Director::absoluteBaseURL() . $controller->Link('callback')), new HiddenField('instantcallback', 'Instant Callback', 1), new HiddenField('instantcapture', 'Instant Capture', 1), new HiddenField('windowstate', 'Window State', 2), new HiddenField('ownreceipt', 'Own Receipt', 1));
        //custom configs
        if (self::$md5key) {
            $md5data = $this->generateMD5();
            $fields->push(new HiddenField('md5key', 'MD5 Key', $md5data));
        }
        if (self::$limit_card_types) {
            $fields->push(new HiddenField('cardtype', 'Card Type', self::$limit_card_types));
        }
        if (self::$add_fee) {
            $fields->push(new HiddenField('addfee', 'Add Fee', 1));
        }
        if (self::$auth_sms) {
            $fields->push(new HiddenField('authsms', 'Auth SMS', self::$auth_sms));
        }
        if (self::$auth_mail) {
            $fields->push(new HiddenField('authmail', 'Auth Mail', self::$auth_mail));
        }
        if (self::$google_tracker) {
            $fields->push(new HiddenField('googletracker', 'Google Tracker', self::$google_tracker));
        }
        if (self::$use3d) {
            $fields->push(new HiddenField('use3D', 'Use 3D', self::$use3d));
        }
        $actions = new FieldSet($openwindow = new FormAction('openwindow', _t('EpaydkPayment.OPENPAYMENTWINDOW', 'Open the ePay Payment Window')));
        $form = new Form($controller, 'ePay', $fields, $actions);
        $form->setHTMLID('ePay');
        $form->setFormAction(self::$submit_url);
        $form->unsetValidator();
        $form->disableSecurityToken();
        return $form;
    }