当前位置: 首页>>代码示例>>PHP>>正文


PHP FileField::getValidator方法代码示例

本文整理汇总了PHP中FileField::getValidator方法的典型用法代码示例。如果您正苦于以下问题:PHP FileField::getValidator方法的具体用法?PHP FileField::getValidator怎么用?PHP FileField::getValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileField的用法示例。


在下文中一共展示了FileField::getValidator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
         $helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>');
         $importer = new MemberCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js');
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:25,代码来源:MemberImportForm.php

示例2: __construct

    public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
    {
        if (!$fields) {
            $helpHtml = _t('GroupImportForm.Help1', '<p>Import one or more groups in <em>CSV</em> format (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
            $helpHtml .= _t('GroupImportForm.Help2', '<div class="advanced">
	<h4>Advanced usage</h4>
	<ul>
	<li>Allowed columns: <em>%s</em></li>
	<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the 
	imported file</li>
	<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>
	<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not
	cleared.</li>
	</ul>
</div>');
            $importer = new GroupCsvBulkLoader();
            $importSpec = $importer->getImportSpec();
            $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
            $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
            $fileField->getValidator()->setAllowedExtensions(array('csv'));
        }
        if (!$actions) {
            $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
            $action->addExtraClass('ss-ui-button');
            $actions = new FieldList($action);
        }
        if (!$validator) {
            $validator = new RequiredFields('CsvFile');
        }
        parent::__construct($controller, $name, $fields, $actions, $validator);
        $this->addExtraClass('cms');
        $this->addExtraClass('import-form');
    }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:33,代码来源:GroupImportForm.php

示例3: CreateHeatmapForm

 public function CreateHeatmapForm()
 {
     $includeWatermark = array("1" => "Yes,Include Watermark", "0" => "No,Remove Watermark");
     $fields = new FieldList($imageField = new FileField('OriginalImage', 'Upload an Image File'), new LiteralField('UploadInfo', 'Acceptable images are jpg or png, 500-1600 pixels wide by 500-1200 pixels height.<hr>'), new OptionsetField('IncludeWatermark', 'Include Watermark?', $includeWatermark, 1));
     $imageField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
     $imageField->setAttribute('class', 'jfilestyle');
     $imageField->setAttribute('data-buttonText', "<img src='themes/attwiz/images/button-create-heatmap-browse.jpg'></img>");
     $imageField->setAttribute('data-placeholder', 'No file selected..');
     // Create action
     $actions = new FieldList($submit = new FormAction('processCreateHeatmap', ''));
     $submit->setAttribute('src', 'themes/attwiz/images/button-create-heatmap-blue-bg.jpg');
     // Create action
     $validator = new RequiredFields('OriginalImage', 'IncludeWatermark');
     return new Form($this, 'CreateHeatmapForm', $fields, $actions, $validator);
 }
开发者ID:hemant-chakka,项目名称:awss,代码行数:15,代码来源:CreateHeatmap.php

示例4: __construct

 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('ExcelGroupImportForm.Help1', '<p><a href="{link}">Download sample file</a></p>', array('link' => $controller->Link('downloadsample/Group')));
         $helpHtml .= _t('ExcelGroupImportForm.Help2', '<ul>' . '<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the ' . 'imported file</li>' . '<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>' . '<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not ' . 'cleared.</li>' . '</ul>');
         $importer = new GroupCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $extensions = array('csv', 'xls', 'xlsx', 'ods', 'txt');
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('File', _t('ExcelGroupImportForm.FileFieldLabel', 'File <small><br/>(allowed extensions: {extensions})</small>', array('extensions' => implode(', ', $extensions)))));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('ExcelGroupImportForm.BtnImport', 'Import from file'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('File');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
开发者ID:lekoala,项目名称:silverstripe-excel-import-export,代码行数:24,代码来源:ExcelGroupImportForm.php

示例5: __construct

 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('ExcelMemberImportForm.Help1', '<p><a href="{link}">Download sample file</a></p>', array('link' => $controller->Link('downloadsample/Member')));
         $helpHtml .= _t('ExcelMemberImportForm.Help2', '<ul>' . '<li>Existing users are matched by their unique <em>Email</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>');
         $importer = new MemberCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $extensions = array('csv', 'xls', 'xlsx', 'ods', 'txt');
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('File', _t('ExcelMemberImportForm.FileFieldLabel', 'File <small><br/>(allowed extensions: {extensions})</small>', array('extensions' => implode(', ', $extensions)))));
         $fileField->getValidator()->setAllowedExtensions(ExcelImportExport::getValidExtensions());
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('ExcelMemberImportForm.BtnImport', 'Import from file'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('File');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
开发者ID:lekoala,项目名称:silverstripe-excel-import-export,代码行数:24,代码来源:ExcelMemberImportForm.php

示例6: FieldList

 function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('TemplateImportForm.Help1');
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('TemplateFile', _t('DynamicTemplateAdmin_TemplateImportForm.FileFieldLabel', 'Template File <small>(Allowed extensions: *.tar.gz, .zip)</small>')));
         $fileField->getValidator()->setAllowedExtensions(array('gz', 'zip'));
     }
     if (!$actions) {
         $actions = new FieldList($importAction = new FormAction('doImport', _t('DynamicTemplateAdmin_TemplateImportForm.BtnImport', 'Import')));
     }
     $importAction->addExtraClass('ss-ui-button');
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
开发者ID:helpfulrobot,项目名称:silverstripe-dynamictemplate,代码行数:18,代码来源:DynamicTemplateAdmin.php

示例7: ImagePickerForm

 public function ImagePickerForm()
 {
     $fields = FieldList::create(new OptionsetField($name = "Type", $title = "Image source", $source = array("new" => "Upload from your computer", "existing" => "Existing image in the file system"), $value = "new"), $ff = new FileField('NewImage', 'Upload image'), new TextField('ExistingImage', 'Search by filename'), new TextField('Title', 'Title'), new LiteralField('UploadingIcon', '<div id="uploadingIcon" style="display:none"><img src="simplewiki/images/loading.gif" /></div>'));
     $ff->getValidator()->setAllowedMaxFileSize(3145728);
     // 3mb
     $actions = FieldList::create();
     return new Form($this, "ImagePickerForm", $fields, $actions);
 }
开发者ID:nyeholt,项目名称:silverstripe-simplewiki,代码行数:8,代码来源:WikiPage.php

示例8: updateCMSFields

 function updateCMSFields(FieldList $fields)
 {
     $allForums = DataObject::get('Forum');
     $fields->removeByName('ModeratedForums');
     $fields->addFieldToTab('Root.ModeratedForums', new CheckboxSetField('ModeratedForums', _t('ForumRole.MODERATEDFORUMS', 'Moderated forums'), $allForums->exists() ? $allForums->map('ID', 'Title') : array()));
     $suspend = $fields->dataFieldByName('SuspendedUntil');
     $suspend->setConfig('showcalendar', true);
     if (Permission::checkMember($this->owner->ID, "ACCESS_FORUM")) {
         $avatarField = new FileField('Avatar', _t('ForumRole.UPLOADAVATAR', 'Upload avatar'));
         $avatarField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $fields->addFieldToTab('Root.Forum', $avatarField);
         $fields->addFieldToTab('Root.Forum', new DropdownField("ForumRank", _t('ForumRole.FORUMRANK', "User rating"), array("Community Member" => _t('ForumRole.COMMEMBER'), "Administrator" => _t('ForumRole.ADMIN', 'Administrator'), "Moderator" => _t('ForumRole.MOD', 'Moderator'))));
         $fields->addFieldToTab('Root.Forum', $this->owner->dbObject('ForumStatus')->scaffoldFormField());
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-forum,代码行数:15,代码来源:ForumRole.php

示例9: ImportFromClientForm

 /**
  * Form used for importing data from the client
  * @return {Form} Form to be used in the popup
  */
 public function ImportFromClientForm()
 {
     if (!Permission::check('ADMIN')) {
         Security::permissionFailure($this);
         return;
     }
     $uploadField = new FileField('ImportFile', _t('CodeBank.EXPORT_FILE', '_Client Export File'));
     $uploadField->getValidator()->setAllowedExtensions(array('cbexport'));
     File::config()->allowed_extensions = array('cbexport');
     $fields = new FieldList(new LiteralField('ImportWarning', '<p class="message warning">' . _t('CodeBank.IMPORT_DATA_WARNING', '_Warning clicking import will erase all snippets in the database, it is recommended you backup your database before proceeding') . '</p>'), new TabSet('Root', new Tab('Main', $uploadField, new CheckboxField('AppendData', _t('CodeBank.APPEND_IMPORT', '_Import and Append Data (keep your existing data however appending may cause duplicates)')))));
     $actions = new FieldList(FormAction::create('doImportData', _t('CodeBank.IMPORT', '_Import'))->addExtraClass('ss-ui-button ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true));
     $validator = new RequiredFields('ImportFile');
     $form = new Form($this, 'ImportFromClientForm', $fields, $actions, $validator);
     $form->addExtraClass('member-profile-form');
     return $form;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:20,代码来源:CodeBankSettings.php


注:本文中的FileField::getValidator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。