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


PHP ZurmoHtml::fileField方法代码示例

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


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

示例1: run

 public function run()
 {
     $id = $this->getId();
     $jsonEncodedExistingFiles = CJSON::encode($this->existingFiles);
     if ($this->allowMultipleUpload) {
         $sendAction = null;
         $addLabel = ZurmoHtml::tag('strong', array('class' => 'add-label'), Zurmo::t('Core', 'Add Files'));
     } else {
         $sendAction = "\$('#{$this->formName}').find('.files > tbody').children().remove();";
         $addLabel = ZurmoHtml::tag('strong', array('class' => 'add-label'), Zurmo::t('Core', 'Add File'));
     }
     $this->registerScriptForLogoFileElement($id, $sendAction, $jsonEncodedExistingFiles);
     $htmlOptions = array('id' => $this->inputId);
     $html = '<div id="fileUpload' . $id . '">';
     $html .= '<div class="fileupload-buttonbar clearfix">';
     $html .= '<div class="addfileinput-button"><span>Y</span>' . $addLabel;
     $html .= ZurmoHtml::fileField($this->inputName, null, $htmlOptions);
     $html .= '</div>' . self::renderMaxSizeContent($this->maxSize, $this->showMaxSize);
     $html .= '</div><div class="fileupload-content"><table class="files"><tbody></tbody></table></div></div>';
     $html .= $this->makeUploadRowScriptContent();
     $html .= $this->makeDownloadRowScriptContent();
     echo $html;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:23,代码来源:LogoFileUpload.php

示例2: run

    public function run()
    {
        $id = $this->getId();
        $jsonEncodedExistingFiles = CJSON::encode($this->existingFiles);
        if ($this->allowMultipleUpload) {
            $sendAction = null;
            $addLabel = $this->getAddLabel();
        } else {
            $sendAction = "\$('#{$this->formName}').find('.files > tbody').children().remove();";
            $addLabel = $this->getAddLabel();
        }
        // Begin Not Coding Standard
        $javaScript = <<<EOD
\$(function () {
    'use strict';

    // Initialize the jQuery File Upload widget:
    \$('#fileUpload{$id}').fileupload({
        dataType: 'json',
        url: '{$this->uploadUrl}',
        autoUpload: true,
        sequentialUploads: true,
        maxFileSize: {$this->maxSize},
        dropZone: \$('#dropzone{$id}'),
        uploadTemplateId: '{$this->getUploadTemplateId()}',
        downloadTemplateId: '{$this->getDownloadTemplateId()}',
        {$this->renderParamForInit('formData')}
        add: function (e, data) {
            {$this->beforeUploadAction}
            {$sendAction}
            var that = \$(this).data('fileupload');
            that._adjustMaxNumberOfFiles(-data.files.length);
            data.isAdjusted = true;
            data.isValidated = that._validate(data.files);
            data.context = that._renderUpload(data.files)
                .appendTo(\$(this).find('.files')).fadeIn(function () {
                    // Fix for IE7 and lower:
                    \$(this).show();
                    \$(this).makeOrRemoveTogglableSpinner(true, '#'+'fileUpload{$id}');
                }).data('data', data);
            if ((that.options.autoUpload || data.autoUpload) &&
                    data.isValidated) {
                data.jqXHR = data.submit();
            }
        }
    });
    // Open download dialogs via iframes,
    // to prevent aborting current uploads:
    \$('#fileUpload{$id} .files a:not([target^=_blank])').live('click', function (e) {
        e.preventDefault();
        \$('<iframe style="display:none;"></iframe>')
            .prop('src', this.href)
            .appendTo('body');
    });
    \$('.fileupload-buttonbar').removeClass('ui-widget-header ui-corner-top');
    \$('.fileupload-content').removeClass('ui-widget-content ui-corner-bottom');
    \$('#fileUpload{$id}').bind('fileuploaddestroy', function (e, data) {
            {$this->afterDeleteAction}

    });
    \$('#fileUpload{$id}').bind('fileuploadalways', function (e, data) {
        if (data == undefined || data.result == undefined ||
          ((data.result[0] != undefined && data.result[0].error != undefined) || data.result.error != undefined))
        {
            setTimeout(function () {
               \$('#{$this->formName}').find('.files > tbody').children(':last').fadeOut('slow', function() { \$(this).remove();});
               {$this->afterDeleteAction}
            }, 1000);
        }
    });
    \$('#fileUpload{$id}').bind('done', function (e, data) { {$this->onSuccessAction} });
    //load existing files
    var existingFiles = {$jsonEncodedExistingFiles};
    var fu = \$('#fileUpload{$id}').data('fileupload');
    fu._adjustMaxNumberOfFiles(-existingFiles.length);
    fu._renderDownload(existingFiles)
        .appendTo(\$('#fileUpload{$id} .files'))
        .fadeIn(function () {
            // Fix for IE7 and lower:
            \$(this).show();
    });
});

EOD;
        // End Not Coding Standard
        Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $javaScript);
        $htmlOptions = array('id' => $this->inputId);
        if ($this->allowMultipleUpload) {
            $htmlOptions['multiple'] = 'multiple';
        }
        $html = '<div id="dropzone' . $id . '">' . $this->getDropZoneContent() . '</div>';
        $html .= '<div id="fileUpload' . $id . '">';
        $html .= '<div class="fileupload-buttonbar clearfix">';
        $html .= '<div class="addfileinput-button"><span>Y</span>' . $addLabel;
        $html .= ZurmoHtml::fileField($this->inputName, null, $htmlOptions);
        $html .= '</div>' . self::renderMaxSizeContent($this->maxSize, $this->showMaxSize);
        $html .= '</div><div class="fileupload-content"><table class="files"><tbody></tbody></table></div></div>';
        $html .= $this->makeUploadRowScriptContent();
        $html .= $this->makeDownloadRowScriptContent();
        echo $html;
//.........这里部分代码省略.........
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:101,代码来源:FileUpload.php


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