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


PHP FileField::Field方法代码示例

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


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

示例1: Field

 public function Field($properties = array())
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/ssui.core.js');
     Requirements::add_i18n_javascript(FRAMEWORK_DIR . '/javascript/lang');
     Requirements::combine_files('uploadfield.js', array(THIRDPARTY_DIR . '/javascript-templates/tmpl.js', THIRDPARTY_DIR . '/javascript-loadimage/load-image.js', THIRDPARTY_DIR . '/jquery-fileupload/jquery.iframe-transport.js', THIRDPARTY_DIR . '/jquery-fileupload/cors/jquery.xdr-transport.js', THIRDPARTY_DIR . '/jquery-fileupload/jquery.fileupload.js', THIRDPARTY_DIR . '/jquery-fileupload/jquery.fileupload-ui.js', FRAMEWORK_DIR . '/javascript/UploadField_uploadtemplate.js', FRAMEWORK_DIR . '/javascript/UploadField_downloadtemplate.js', FRAMEWORK_DIR . '/javascript/UploadField.js'));
     Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
     // TODO hmmm, remove it?
     Requirements::css(FRAMEWORK_DIR . '/css/UploadField.css');
     // Calculated config as per jquery.fileupload-ui.js
     $allowedMaxFileNumber = $this->getAllowedMaxFileNumber();
     $config = array('url' => $this->Link('upload'), 'urlSelectDialog' => $this->Link('select'), 'urlAttach' => $this->Link('attach'), 'urlFileExists' => $this->link('fileexists'), 'acceptFileTypes' => '.+$', 'maxNumberOfFiles' => $allowedMaxFileNumber ? $allowedMaxFileNumber - count($this->getItemIDs()) : null, 'replaceFile' => $this->getUpload()->getReplaceFile());
     // Validation: File extensions
     if ($allowedExtensions = $this->getAllowedExtensions()) {
         $config['acceptFileTypes'] = '(\\.|\\/)(' . implode('|', $allowedExtensions) . ')$';
         $config['errorMessages']['acceptFileTypes'] = _t('File.INVALIDEXTENSIONSHORT', 'Extension is not allowed');
     }
     // Validation: File size
     if ($allowedMaxFileSize = $this->getValidator()->getAllowedMaxFileSize()) {
         $config['maxFileSize'] = $allowedMaxFileSize;
         $config['errorMessages']['maxFileSize'] = _t('File.TOOLARGESHORT', 'File size exceeds {size}', array('size' => File::format_size($config['maxFileSize'])));
     }
     // Validation: Number of files
     if ($allowedMaxFileNumber) {
         if ($allowedMaxFileNumber > 1) {
             $config['errorMessages']['maxNumberOfFiles'] = _t('UploadField.MAXNUMBEROFFILESSHORT', 'Can only upload {count} files', array('count' => $allowedMaxFileNumber));
         } else {
             $config['errorMessages']['maxNumberOfFiles'] = _t('UploadField.MAXNUMBEROFFILESONE', 'Can only upload one file');
         }
     }
     // add overwrite warning error message to the config object sent to Javascript
     if ($this->getOverwriteWarning()) {
         $config['errorMessages']['overwriteWarning'] = _t('UploadField.OVERWRITEWARNING', 'File with the same name already exists');
     }
     $mergedConfig = array_merge($config, $this->ufConfig);
     return parent::Field(array('configString' => str_replace('"', """, Convert::raw2json($mergedConfig)), 'config' => new ArrayData($mergedConfig), 'multiple' => $allowedMaxFileNumber !== 1));
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:39,代码来源:UploadField.php

示例2: Field

 public function Field($properties = array())
 {
     $this->setAttribute('data-icon', $this->getConfig('dataIcon'));
     $this->setAttribute('data-input', $this->getConfig('dataInput'));
     $this->setAttribute('data-ButtonName', $this->getConfig('dataButtonName'));
     $this->setAttribute('data-size', $this->getConfig('dataSize'));
     $this->setAttribute('data-IconName', $this->getConfig('dataIconName'));
     // Set Button Title
     $this->setAttribute('data-buttonText', _t('BootstrapFileField.CHOOSEFILE', 'BootstrapFileField.CHOOSEFILE'));
     // Overwrite Button Title
     if ($this->button_title) {
         $this->setAttribute('data-buttonText', $this->button_title);
     }
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.min.js');
     Requirements::javascript('bootstrap_extra_fields/javascript/bootstrap-filestyle.min.js');
     // Fetch the Field Record
     if ($this->form) {
         $record = $this->form->getRecord();
     }
     $fieldName = $this->name;
     if (isset($record) && $record) {
         $fileField = $record->{$fieldName}();
         if ($fileField && $fileField->exists()) {
             if ($fileField->hasMethod('Thumbnail') && $fileField->Thumbnail()) {
                 $Image = $fileField->Thumbnail()->getTag();
             } else {
                 if ($fileField->CMSThumbnail()) {
                     $Image = $fileField->CMSThumbnail();
                 } else {
                     $Image = false;
                 }
             }
         } else {
             $Image = false;
         }
     } else {
         $Image = false;
     }
     $properties = array_merge($properties, array('MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize(), 'Image' => $Image));
     return parent::Field($properties);
 }
开发者ID:EduardMa,项目名称:silverstripe-bootstrap_extra_fields,代码行数:41,代码来源:BootstrapFileField.php

示例3: Field

 public function Field($properties = array())
 {
     return parent::Field($properties);
 }
开发者ID:helpfulrobot,项目名称:chitosystems-bootstrap-fields,代码行数:4,代码来源:BootstrapImageField.php

示例4: Field

 public function Field($properties = array())
 {
     // Fetch the Field Record
     if ($this->form) {
         $record = $this->form->getRecord();
     }
     $fieldName = $this->name;
     if (isset($record) && $record) {
         $imageField = $record->{$fieldName}();
         if ($imageField && $imageField->exists()) {
             if ($imageField->hasMethod('Thumbnail') && $imageField->Thumbnail()) {
                 $Image = $imageField->Thumbnail()->getURL();
             } else {
                 if ($imageField->CMSThumbnail()) {
                     $Image = $imageField->CMSThumbnail()->getURL();
                 } else {
                     $Image = false;
                 }
             }
         } else {
             $Image = false;
         }
     } else {
         $Image = false;
     }
     $properties = array_merge($properties, array('MaxFileSize' => $this->getValidator()->getAllowedMaxFileSize(), 'Image' => $Image));
     return parent::Field($properties);
 }
开发者ID:helpfulrobot,项目名称:andrelohmann-silverstripe-legacyfields,代码行数:28,代码来源:SimpleImageField.php


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