function Form()
 {
     $form = new Form($this, 'Form', new FieldList(new EmailField('Email')), new FieldList(new FormAction('doSubmit')), new RequiredFields('Email'));
     // Disable CSRF protection for easier form submission handling
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * returns the form
  * @return Form
  */
 public function getGoogleSiteSearchForm($name = "GoogleSiteSearchForm")
 {
     $formIDinHTML = "Form_" . $name;
     if ($page = GoogleCustomSearchPage::get()->first()) {
         Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
         Requirements::javascript('googlecustomsearch/javascript/GoogleCustomSearch.js');
         $apiKey = Config::inst()->get("GoogleCustomSearchExt", "api_key");
         $cxKey = Config::inst()->get("GoogleCustomSearchExt", "cx_key");
         if ($apiKey && $cxKey) {
             Requirements::customScript("\n\t\t\t\t\t\tGoogleCustomSearch.apiKey = '" . $apiKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.cxKey = '" . $cxKey . "';\n\t\t\t\t\t\tGoogleCustomSearch.formSelector = '#" . $formIDinHTML . "';\n\t\t\t\t\t\tGoogleCustomSearch.inputFieldSelector = '#" . $formIDinHTML . "_search';\n\t\t\t\t\t\tGoogleCustomSearch.resultsSelector = '#" . $formIDinHTML . "_Results';\n\t\t\t\t\t", "GoogleCustomSearchExt");
             $form = new Form($this->owner, 'GoogleSiteSearchForm', new FieldList($searchField = new TextField('search'), $resultField = new LiteralField($name . "_Results", "<div id=\"" . $formIDinHTML . "_Results\"></div>")), new FieldList(new FormAction('doSearch', _t("GoogleCustomSearchExt.GO", "Full Results"))));
             $form->setFormMethod('GET');
             if ($page = GoogleCustomSearchPage::get()->first()) {
                 $form->setFormAction($page->Link());
             }
             $form->disableSecurityToken();
             $form->loadDataFrom($_GET);
             $searchField->setAttribute("autocomplete", "off");
             $form->setAttribute("autocomplete", "off");
             return $form;
         } else {
             user_error("You must set an API Key and a CX key in your configs to use the Google Custom Search Form", E_USER_NOTICE);
         }
     } else {
         user_error("You must create a GoogleCustomSearchPage first.", E_USER_NOTICE);
     }
 }
 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;
 }
 public function Form()
 {
     $fields = new FieldList(new TextField('Name'), new EmailField('Email'), new TextareaField('Content'));
     $actions = new FieldList(new FormAction('doSubmit', 'Submit'));
     $validator = new RequiredFields('Name', 'Content');
     $form = new Form($this, 'Form', $fields, $actions, $validator);
     $form->enableSpamProtection(array('protector' => 'AkismetSpamProtector', 'name' => 'IsSpam', 'mapping' => array('Content' => 'body', 'Name' => 'authorName', 'Email' => 'authorMail')));
     // Because we don't want to be testing this
     $form->disableSecurityToken();
     return $form;
 }
 function Form()
 {
     $query = $this->request->getVar("search");
     $fields = new FieldList(new TextField("search", "", $query));
     $actions = new FieldList($searchaction = new FormAction("index", "Search"));
     $searchaction->setFullAction(null);
     $form = new Form($this, "SearchForm", $fields, $actions);
     $form->setFormAction($this->Link());
     $form->setFormMethod("GET");
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * Return a form which sends the user to the first results page. If you want
  * to customize this form, use your own extension and apply that to the
  * page.
  *
  * @return Form
  */
 public function getGoogleSiteSearchForm()
 {
     if ($page = GoogleSiteSearchPage::get()->first()) {
         $label = Config::inst()->get('GoogleSiteSearchDefaultFormExtension', 'submit_button_label');
         $formLabel = Config::inst()->get('GoogleSiteSearchDefaultFormExtension', 'input_label');
         $form = new Form($this, 'GoogleSiteSearchForm', new FieldList(new TextField('Search', $formLabel)), new FieldList(new FormAction('doSearch', $label)));
         $form->setFormMethod('GET');
         $form->setFormAction($page->Link());
         $form->disableSecurityToken();
         $form->loadDataFrom($_GET);
         return $form;
     }
 }
 public function SearchForm()
 {
     $searchText = '';
     if ($this->request && $this->request->getVar('Search')) {
         $searchText = $this->request->getVar('Search');
     }
     $queryField = new TextField('Search', FALSE, $searchText);
     $queryField->setAttribute('placeholder', 'Search news');
     $fields = new FieldList($queryField);
     $actions = new FieldList(new FormAction('results', 'Search'));
     $form = new Form($this, 'SearchForm', $fields, $actions);
     $form->setFormMethod('get');
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * Show the "choose payment method" form
  */
 function ProcessForm()
 {
     $fields = new FieldList();
     // Create a dropdown select field for choosing gateway
     $supported_methods = PaymentProcessor::get_supported_methods();
     $source = array();
     foreach ($supported_methods as $methodName) {
         $methodConfig = PaymentFactory::get_factory_config($methodName);
         $source[$methodName] = $methodConfig['title'];
     }
     $fields->push(new DropDownField('PaymentMethod', 'Select Payment Method', $source));
     $actions = new FieldList(new FormAction('proceed', 'Proceed'));
     $processForm = new Form($this, 'ProcessForm', $fields, $actions);
     $processForm->disableSecurityToken();
     return $processForm;
 }
    /**
     * Return a {@link Form} instance allowing a user to
     * add images to the TinyMCE content editor.
     *  
     * @return Form
     */
    function ImageForm()
    {
        Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
        Requirements::javascript(EXTERNALCONTENT . "/javascript/external_tiny_mce_improvements.js");
        Requirements::css('cms/css/TinyMCEImageEnhancement.css');
        Requirements::javascript('cms/javascript/TinyMCEImageEnhancement.js');
        Requirements::javascript(THIRDPARTY_DIR . '/SWFUpload/SWFUpload.js');
        Requirements::javascript(CMS_DIR . '/javascript/Upload.js');
        $form = new Form($this->controller, "{$this->name}/ImageForm", new FieldSet(new LiteralField('Heading', '<h2><img src="cms/images/closeicon.gif" alt="' . _t('HtmlEditorField.CLOSE', 'close') . '" title="' . _t('HtmlEditorField.CLOSE', 'close') . '" />' . _t('HtmlEditorField.IMAGE', 'Image') . '</h2>'), new TreeDropdownField('FolderID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'), new LiteralField('AddFolderOrUpload', '<div style="clear:both;"></div><div id="AddFolderGroup" style="display: none">
						<a style="" href="#" id="AddFolder" class="link">' . _t('HtmlEditorField.CREATEFOLDER', 'Create Folder') . '</a>
						<input style="display: none; margin-left: 2px; width: 94px;" id="NewFolderName" class="addFolder" type="text">
						<a style="display: none;" href="#" id="FolderOk" class="link addFolder">' . _t('HtmlEditorField.OK', 'Ok') . '</a>
						<a style="display: none;" href="#" id="FolderCancel" class="link addFolder">' . _t('HtmlEditorField.FOLDERCANCEL', 'Cancel') . '</a>
					</div>
					<div id="PipeSeparator" style="display: none">|</div>
					<div id="UploadGroup" class="group" style="display: none; margin-top: 2px;">
						<a href="#" id="UploadFiles" class="link">' . _t('HtmlEditorField.UPLOAD', 'Upload') . '</a>
					</div>'), new TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')), new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'), new TextField('AltText', _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'), '', 80), new TextField('ImageTitle', _t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image')), new TextField('CaptionText', _t('HtmlEditorField.CAPTIONTEXT', 'Caption text')), new DropdownField('CSSClass', _t('HtmlEditorField.CSSCLASS', 'Alignment / style'), array('left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'), 'leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'), 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.'), 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.'))), new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'), new TextField('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), 100), new TextField('Height', " x " . _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'), 100))), new FieldSet(new FormAction('insertimage', _t('HtmlEditorField.BUTTONINSERTIMAGE', 'Insert image'))));
        $form->disableSecurityToken();
        $form->loadDataFrom($this);
        return $form;
    }
Example #10
0
 /**
  * @param SS_HTTPRequest $request
  * @return Form
  */
 public function getPostSnapshotForm(SS_HTTPRequest $request)
 {
     // Performs canView permission check by limiting visible projects
     $project = $this->getCurrentProject();
     if (!$project) {
         return $this->project404Response();
     }
     if (!$project->canUploadArchive()) {
         return new SS_HTTPResponse("Not allowed to upload", 401);
     }
     // Framing an environment as a "group of people with download access"
     // makes more sense to the user here, while still allowing us to enforce
     // environment specific restrictions on downloading the file later on.
     $envs = $project->DNEnvironmentList()->filterByCallback(function ($item) {
         return $item->canUploadArchive();
     });
     $envsMap = array();
     foreach ($envs as $env) {
         $envsMap[$env->ID] = $env->Name;
     }
     $form = new Form($this, 'PostSnapshotForm', new FieldList(DropdownField::create('Mode', 'What does this file contain?', DNDataArchive::get_mode_map()), DropdownField::create('EnvironmentID', 'Initial ownership of the file', $envsMap)), new FieldList($action = new FormAction('doPostSnapshot', "Submit request")), new RequiredFields('File'));
     $action->addExtraClass('btn');
     $form->disableSecurityToken();
     $form->addExtraClass('fields-wide');
     // Tweak the action so it plays well with our fake URL structure.
     $form->setFormAction($project->Link() . '/PostSnapshotForm');
     return $form;
 }
Example #11
0
 function SearchForm()
 {
     // get all page types in a dropdown-compatible format
     $pageTypes = SiteTree::page_type_classes();
     array_unshift($pageTypes, 'All');
     $pageTypes = array_combine($pageTypes, $pageTypes);
     asort($pageTypes);
     // get all filter instances
     $filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
     $filterMap = array();
     // remove base class
     array_shift($filters);
     // add filters to map
     foreach ($filters as $filter) {
         $filterMap[$filter] = call_user_func(array($filter, 'title'));
     }
     // ensure that 'all pages' filter is on top position
     uasort($filterMap, create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;'));
     $fields = new FieldSet(new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')), $dateGroup = new FieldGroup($dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FilterDateFrom', 'from')), $dateTo = new DateField('LastEditedTo', _t('CMSSearch.FilterDateFrom', 'to'))), new DropdownField('FilterClass', _t('CMSMain.SearchTreeFormPagesDropdown', 'Pages'), $filterMap), new DropdownField('ClassName', _t('CMSMain.PAGETYPEOPT', 'Page Type', PR_MEDIUM, 'Dropdown for limiting search to a page type'), $pageTypes, null, null, _t('CMSMain.PAGETYPEANYOPT', 'Any')));
     $dateGroup->subfieldParam = 'FieldHolder';
     $dateFrom->setConfig('showcalendar', true);
     $dateTo->setConfig('showcalendar', true);
     $actions = new FieldSet($resetAction = new ResetFormAction('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')), $searchAction = new FormAction('doSearch', _t('CMSMain_left.ss.SEARCH', 'Search')));
     $resetAction->addExtraClass('ss-ui-action-minor');
     $form = new Form($this, 'SearchForm', $fields, $actions);
     $form->setFormMethod('GET');
     $form->disableSecurityToken();
     $form->unsetValidator();
     return $form;
 }
 public function TestForm()
 {
     $page = AdvancedWidgetEditorTest_FakePage::get()->first();
     $form = new Form($this, 'TestForm', new FieldList(new AdvancedWidgetAreaEditor('SideBar')), new FieldList(new FormAction('doSave', 'Save')));
     $form->loadDataFrom($page);
     $form->disableSecurityToken();
     return $form;
 }
Example #13
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;
	}
    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;
    }
Example #15
0
 /**
  * @return Form
  */
 public function SearchForm()
 {
     $context = $this->getSearchContext();
     $form = new Form($this, "SearchForm", $context->getSearchFields(), new FieldList(Object::create('FormAction', 'search', _t('MemberTableField.APPLY_FILTER', 'Apply Filter'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clearsearch', _t('ModelAdmin.RESET', 'Reset'))->setUseButtonTag(true)), new RequiredFields());
     $form->setFormMethod('get');
     $form->setFormAction($this->Link($this->sanitiseClassName($this->modelClass)));
     $form->addExtraClass('cms-search-form');
     $form->disableSecurityToken();
     $form->loadDataFrom($this->request->getVars());
     $this->extend('updateSearchForm', $form);
     return $form;
 }
Example #16
0
 /**
  * Returns a form for filtering of files and assets gridfield.
  * Result filtering takes place in {@link getList()}.
  *
  * @return Form
  * @see AssetAdmin.js
  */
 public function SearchForm()
 {
     $folder = $this->currentPage();
     $context = $this->getSearchContext();
     $fields = $context->getSearchFields();
     $actions = new FieldList(FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Apply Filter'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.RESET', 'Reset')));
     $form = new Form($this, 'filter', $fields, $actions);
     $form->setFormMethod('GET');
     $form->setFormAction(Controller::join_links($this->Link('show'), $folder->ID));
     $form->addExtraClass('cms-search-form');
     $form->loadDataFrom($this->getRequest()->getVars());
     $form->disableSecurityToken();
     // This have to match data-name attribute on the gridfield so that the javascript selectors work
     $form->setAttribute('data-gridfield', 'File');
     return $form;
 }
Example #17
0
 public function Form()
 {
     $form = new Form($this, 'Form', new FieldList(new EmailField('Email')), new FieldList(new FormAction('doSubmit')));
     $form->setFormMethod('POST');
     $form->setStrictFormMethodCheck(true);
     $form->disableSecurityToken();
     // Disable CSRF protection for easier form submission handling
     return $form;
 }
 public function RegistryFilterForm()
 {
     $singleton = $this->dataRecord->getDataSingleton();
     if (!$singleton) {
         return;
     }
     $fields = $singleton->getSearchFields();
     // Add the sort information.
     $vars = $this->getRequest()->getVars();
     $fields->merge(new FieldList(new HiddenField('Sort', 'Sort', !$vars || empty($vars['Sort']) ? 'ID' : $vars['Sort']), new HiddenField('Dir', 'Dir', !$vars || empty($vars['Dir']) ? 'ASC' : $vars['Dir'])));
     $actions = new FieldList(FormAction::create('doRegistryFilter')->setTitle('Filter')->addExtraClass('btn btn-primary primary'), FormAction::create('doRegistryFilterReset')->setTitle('Clear')->addExtraClass('btn'));
     $form = new Form($this, 'RegistryFilterForm', $fields, $actions);
     $form->loadDataFrom($this->request->getVars());
     $form->disableSecurityToken();
     $form->setFormMethod('get');
     return $form;
 }
Example #19
0
 /**
  * Construct the deployment form
  * 
  * @param SS_HTTPRequest $request
  * @return Form
  */
 public function getDeployForm(SS_HTTPRequest $request)
 {
     // Performs canView permission check by limiting visible projects
     $project = $this->getCurrentProject();
     if (!$project) {
         return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404);
     }
     // Performs canView permission check by limiting visible projects
     $environment = $this->getCurrentEnvironment($project);
     if (!$environment) {
         return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404);
     }
     if (!$environment->canDeploy()) {
         return new SS_HTTPResponse("Not allowed to deploy", 401);
     }
     if (!$project->repoExists()) {
         $literalField = new LiteralField('noRepoWarning', '<strong>The GIT repository is for the time being not available.</strong>');
         return Form::create($this, 'DeployForm', new FieldList($literalField), new FieldList());
     }
     $branches = array();
     foreach ($project->DNBranchList() as $branch) {
         $sha = $branch->SHA();
         $name = $branch->Name();
         $branches[$sha] = $name . ' (' . substr($sha, 0, 8) . ', ' . $branch->LastUpdated()->TimeDiff() . ' old)';
     }
     $tags = array();
     foreach ($project->DNTagList()->setLimit(null) as $tag) {
         $sha = $tag->SHA();
         $name = $tag->Name();
         $tags[$sha] = $name . ' (' . substr($sha, 0, 8) . ', ' . $tag->Created()->TimeDiff() . ' old)';
     }
     $tags = array_reverse($tags);
     $redeploy = array();
     foreach ($project->DNEnvironmentList() as $dnEnvironment) {
         $envName = $dnEnvironment->Name;
         foreach ($dnEnvironment->DeployHistory() as $deploy) {
             $sha = $deploy->SHA;
             if (!isset($redeploy[$envName])) {
                 $redeploy[$envName] = array();
             }
             if (!isset($redeploy[$envName][$sha])) {
                 $redeploy[$envName][$sha] = substr($sha, 0, 8) . ' (deployed ' . $deploy->obj('LastEdited')->Ago() . ')';
             }
         }
     }
     $releaseMethods = array();
     if ($tags) {
         $releaseMethods[] = new SelectionGroup_Item('Tag', new DropdownField('Tag', '', $tags), 'Deploy a tagged release');
     }
     if ($branches) {
         $releaseMethods[] = new SelectionGroup_Item('Branch', new DropdownField('Branch', '', $branches), 'Deploy the latest version of a branch');
     }
     if ($redeploy) {
         $releaseMethods[] = new SelectionGroup_Item('Redeploy', new GroupedDropdownField('Redeploy', '', $redeploy), 'Redeploy a release that was previously deployed (to any environment)');
     }
     $releaseMethods[] = new SelectionGroup_Item('SHA', new Textfield('SHA', 'Please specify the full SHA'), 'Deploy a specific SHA');
     $field = new SelectionGroup('SelectRelease', $releaseMethods);
     $field->setValue('Tag');
     $form = new Form($this, 'DeployForm', new FieldList($field), new FieldList($deployAction = new FormAction('doDeploy', "Deploy to " . $environment->Name)));
     $deployAction->addExtraClass('btn');
     $form->disableSecurityToken();
     // Tweak the action so it plays well with our fake URL structure.
     $form->setFormAction($request->getURL() . '/DeployForm');
     return $form;
 }
 /**
  * Create Extension search form based on type of Extension.
  *
  * @return boolean $form
  */
 public function extensionSearch()
 {
     $context = singleton('ExtensionData')->getCustomSearchContext();
     $fields = $context->getSearchFields();
     $form = new Form($this, "extensionSearch", $fields, new FieldList(new FormAction('doSearch', "Search {$this->extensionType}")));
     $form->setFormMethod('GET');
     $form->disableSecurityToken();
     return $form;
 }
Example #21
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;
 }
 function NewsletterNavigatorForm()
 {
     $fields = new FieldSet(new EmailField("Email"));
     $actions = new FieldSet(new FormAction("send_to", _t("Newsletter.Campaign.SendTestTo", "Send testmail to")));
     $form = new Form($this, "NewsletterNavigatorForm", $fields, $actions);
     $form->disableSecurityToken();
     return $form;
 }
 public function SearchForm()
 {
     $searchText = $this->GetSearchTerm() ?: "";
     $queryType = $this->GetSearchType() ?: "";
     $category = $this->GetCategory() ?: "";
     $searchField = new TextField('Search', "Search youtube for:", $searchText);
     $searchField->setAttribute('placeholder', "Type here");
     $fields = new FieldList(new DropdownField('queryType', "Search type:", array('relevance' => 'All Videos', 'viewcount' => 'Most Viewed Videos', 'date' => 'Most recent', 'rating' => 'Top rated'), $queryType), new DropdownField('category', "Category:", $this->GetCategories(), $category), $searchField);
     $action = new FormAction('YouTubeSearchResults', _t('SearchForm.GO', 'Go'));
     $action->addExtraClass('btn btn-default btn-search');
     $action->useButtonTag = true;
     $action->setButtonContent('<i class="fa fa-search"></i><span class="text-hide">Search</span>');
     $actions = new FieldList($action);
     $form = new Form($this, 'YouTubeSearchForm', $fields, $actions);
     $form->setFormMethod('GET');
     $form->setFormAction($this->Link() . "");
     $form->disableSecurityToken();
     return $form;
 }
Example #24
0
 function FlashForm()
 {
     $form = new Form($this->controller, "{$this->name}/FlashForm", new FieldSet(new LiteralField('Heading', '<h2><img src="cms/images/closeicon.gif" alt="' . _t('HtmlEditorField.CLOSE', 'close') . '" title="' . _t('HtmlEditorField.CLOSE', 'close') . '" />' . _t('HtmlEditorField.FLASH', 'Flash') . '</h2>'), new TreeDropdownField("FolderID", _t('HtmlEditorField.FOLDER'), "Folder"), new TextField('getflashSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')), new ThumbnailStripField("Flash", "FolderID", "getflash"), new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', "Dimensions"), new TextField("Width", _t('HtmlEditorField.IMAGEWIDTHPX', "Width"), 100), new TextField("Height", "x " . _t('HtmlEditorField.IMAGEHEIGHTPX', "Height"), 100))), new FieldSet(new FormAction("insertflash", _t('HtmlEditorField.BUTTONINSERTFLASH', 'Insert Flash'))));
     $form->disableSecurityToken();
     $form->loadDataFrom($this);
     $form->disableSecurityToken();
     $this->extend('updateFlashForm', $form);
     return $form;
 }
Example #25
0
 /**
  * Return the form object shown in the uploadiframe.
  */
 function UploadForm()
 {
     $form = new Form($this, 'UploadForm', new FieldSet(new HiddenField("ID", "", $this->currentPageID()), new HiddenField("FolderID", "", $this->currentPageID()), new HiddenField("action_doUpload", "", "1"), new FileField("Files[0]", _t('AssetAdmin.CHOOSEFILE', 'Choose file: ')), new LiteralField('UploadButton', "\n\t\t\t\t<input type=\"submit\" value=\"" . _t('AssetAdmin.UPLOAD', 'Upload Files Listed Below') . "\" name=\"action_upload\" id=\"Form_UploadForm_action_upload\" class=\"action\" />\n\t\t\t"), new LiteralField('MultifileCode', "\n\t\t\t\t<p>" . _t('AssetAdmin.FILESREADY', 'Files ready to upload:') . "</p>\n\t\t\t\t<div id=\"Form_UploadForm_FilesList\"></div>\n\t\t\t")), new FieldSet());
     // Makes ajax easier
     $form->disableSecurityToken();
     return $form;
 }
 function Form()
 {
     $form = new Form($this, 'Form', new FieldSet(new EmailField('Email'), new TextField('SomeRequiredField'), new CheckboxSetField('Boxes', null, array('1' => 'one', '2' => 'two'))), new FieldSet(new FormAction('doSubmit')), new RequiredFields('Email', 'SomeRequiredField'));
     // Disable CSRF protection for easier form submission handling
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * Get a search form for a single {@link DataObject} subclass.
  * 
  * @return Form
  */
 public function SearchForm()
 {
     $context = singleton($this->modelClass)->getDefaultSearchContext();
     $fields = $context->getSearchFields();
     $columnSelectionField = $this->ColumnSelectionField();
     $fields->push($columnSelectionField);
     $validator = new RequiredFields();
     $validator->setJavascriptValidationHandler('none');
     $form = new Form($this, "SearchForm", $fields, new FieldSet(new FormAction('search', _t('MemberTableField.SEARCH', 'Search')), $clearAction = new ResetFormAction('clearsearch', _t('ModelAdmin.CLEAR_SEARCH', 'Clear Search'))), $validator);
     //$form->setFormAction(Controller::join_links($this->Link(), "search"));
     $form->setFormMethod('get');
     $form->setHTMLID("Form_SearchForm_" . $this->modelClass);
     $form->disableSecurityToken();
     $clearAction->useButtonTag = true;
     $clearAction->addExtraClass('minorAction');
     return $form;
 }
Example #28
0
 /**
  * Form used to filter the sitetree. It can only be used via javascript for now.
  * 
  * @return Form
  */
 function SearchTreeForm()
 {
     // get all page types in a dropdown-compatible format
     $pageTypes = SiteTree::page_type_classes();
     array_unshift($pageTypes, 'All');
     $pageTypes = array_combine($pageTypes, $pageTypes);
     asort($pageTypes);
     // get all filter instances
     $filters = ClassInfo::subclassesFor('CMSSiteTreeFilter');
     $filterMap = array();
     // remove base class
     array_shift($filters);
     // add filters to map
     foreach ($filters as $filter) {
         $filterMap[$filter] = call_user_func(array($filter, 'title'));
     }
     // ensure that 'all pages' filter is on top position
     uasort($filterMap, create_function('$a,$b', 'return ($a == "CMSSiteTreeFilter_Search") ? 1 : -1;'));
     $showDefaultFields = array();
     $form = new Form($this, 'SearchTreeForm', new FieldSet($showDefaultFields[] = new DropdownField('FilterClass', _t('CMSMain.SearchTreeFormPagesDropdown', 'Pages'), $filterMap), $showDefaultFields[] = new TextField('Title', _t('CMSMain.TITLEOPT', 'Title')), new TextField('Content', 'Text'), new DateField('EditedSince', _t('CMSMain_left.ss.EDITEDSINCE', 'Edited Since')), new DropdownField('ClassName', 'Page Type', $pageTypes, null, null, 'Any'), new TextField('MenuTitle', _t('CMSMain.MENUTITLEOPT', 'Navigation Label')), new TextField('Status', _t('CMSMain.STATUSOPT', 'Status')), new TextField('MetaDescription', _t('CMSMain.METADESCOPT', 'Description')), new TextField('MetaKeywords', _t('CMSMain.METAKEYWORDSOPT', 'Keywords'))), new FieldSet(new ResetFormAction('clear', _t('CMSMain_left.ss.CLEAR', 'Clear')), new FormAction('doSearchTree', _t('CMSMain_left.ss.SEARCH', 'Search'))));
     $form->setFormMethod('GET');
     $form->disableSecurityToken();
     $form->unsetValidator();
     foreach ($showDefaultFields as $f) {
         $f->addExtraClass('show-default');
     }
     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;
 }
Example #30
0
 /**
  * Return the form object shown in the uploadiframe.
  */
 function UploadForm()
 {
     $form = new Form($this, 'UploadForm', new FieldSet(new HiddenField("ID", "", $this->currentPageID()), new HiddenField("action_doUpload", "", "1"), new FileField("Files[0]", _t('AssetAdmin.CHOOSEFILE', 'Choose file ')), new LiteralField('UploadButton', "\n\t\t\t\t<input type='submit' value='" . _t('AssetAdmin.UPLOAD', 'Upload Files Listed Below') . "' name='action_upload' id='Form_UploadForm_action_upload' class='action' />\n\t\t\t"), new LiteralField('MultifileCode', "\n\t\t\t\t<p>" . _t('AssetAdmin.FILESREADY', 'Files ready to upload:') . "</p>\n\t\t\t\t<div id='Form_UploadForm_FilesList'></div>\n\t\t\t\t<script>\n\t\t\t\t\tvar multi_selector = new MultiSelector(\$('Form_UploadForm_FilesList'), null, \$('Form_UploadForm_action_upload'));\n\t\t\t\t\tmulti_selector.addElement(\$('Form_UploadForm_Files-0'));\n                    new window.top.document.CMSMain_upload();\n\t\t\t\t</script>\n\t\t\t")), new FieldSet());
     // Makes ajax easier
     $form->disableSecurityToken();
     return $form;
 }