Exemplo n.º 1
0
 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');
 }
    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');
    }
Exemplo n.º 3
0
 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);
 }
 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');
 }
 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');
 }
 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');
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 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());
     }
 }
 /**
  * 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;
 }