XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
flashuploader.php
Go to the documentation of this file.
1 <?php
2 // $Id: flashuploader.php 999 2012-07-02 03:53:17Z i.bitcero $
3 // --------------------------------------------------------------
4 // Red México Common Utilities
5 // A framework for Red México Modules
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: i.bitcero@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
12 {
13  private $settings = array();
14  public $name = '';
23  public function __construct($name, $url, $settings = array()){
24  // Generate settings for uploadify
25  $this->settings = array(
26  'swf' => RMCURL.'/include/uploadify.swf',
27  'uploader' => $url,
28  'auto' => false,
29  'buttonClass' => '',
30  'buttonCursor' => 'hand',
31  'buttonImage' => null,
32  'buttonText' => __('Select Files','rmcommon'),
33  'checkExisting' => false,
34  'debug' => false,
35  'fileObjName' => 'Filedata',
36  'fileSizeLimit' => '512KB',
37  'fileTypeDesc' => __('All Files','rmcommon'),
38  'fileTypeExts' => '*.*',
39  'formData' => array(),
40  'height' => 30,
41  'method' => 'post',
42  'multi' => true,
43  'overrideEvents' => '',
44  'preventCaching' => true,
45  'progressData' => 'percentage',
46  'queueID' => false,
47  'queueSizeLimit' => 100,
48  'removeCompleted' => true,
49  'removeTimeout' => 2,
50  'requeueErrors' => false,
51  'successTimeout' => 30,
52  'uploadLimit' => 999,
53  'width' => 120,
54  'onCancel' => '',
55  'onClearQueue' => '',
56  'onDestroy' => '',
57  'onDialogClose' => '',
58  'onDialogOpen' => '',
59  'onDisable' => '',
60  'onEnable' => '',
61  'onFallback' => '',
62  'onInit' => '',
63  'onQueueComplete' => '',
64  'onSelect' => '',
65  'onSelectError' => '',
66  'onSWFReady' => '',
67  'onUploadComplete' => '',
68  'onUploadError' => '',
69  'onUploadProgress' => '',
70  'onUploadStart' => '',
71  'onUploadSuccess' => ''
72  );
73 
74  foreach ($settings as $key => $value){
75  if (!isset($this->settings[$key])) continue;
76  $this->settings[$key] = $value;
77  }
78 
79  $this->name = $name;
80 
81  }
82 
83  public function add_setting($name, $value){
84 
85  $convert = array(
86  'scriptData' => 'formData',
87  'onComplete' => 'onUploadComplete',
88  'onAllComplete' => 'onQueueComplete',
89  'fileExt' => 'fileTypeExts',
90  'fileDesc' => 'fileTypeDesc',
91  'buttonImg' => 'buttonImage',
92  'fileDataName' => 'fileObjName',
93  'checkScript' => 'checkExisting',
94  'sizeLimit' => 'fileSizeLimit',
95  'onOpen' => 'onDialogOpen',
96  'onError' => 'onUploadError',
97  'onProgress' => 'onUploadProgress'
98  );
99 
100  if(isset($convert[$name])) $name = $convert[$name];
101 
102  if (!isset($this->settings[$name])) return false;
103  $this->settings[$name] = $value;
104  return true;
105 
106  }
107 
108  public function get_setting($name){
109  if (!isset($this->settings[$name])) return false;
110 
111  return $this->settings[$name];
112  }
113 
119  public function add_settings($settings){
120  foreach ($settings as $key => $value){
121  if (!isset($this->settings[$key])) continue;
122  $this->settings[$key] = $value;
123  }
124  }
125 
126  public function settings(){
127  return $this->settings;
128  }
129 
130  public function render(){
131 
132  RMTemplate::get()->add_local_script('swfobject.js', 'rmcommon', 'include');
133  RMTemplate::get()->add_local_script('jquery.uploadify.js', 'rmcommon', 'include');
134  RMTemplate::get()->add_style('uploadify.css', 'rmcommon');
135 
136  ob_start();
137  include RMTemplate::get()->get_template('uploadify.js.php', 'module', 'rmcommon');
138  $script = ob_get_clean();
139  return $script;
140  }
141 }