Changeset 16150
- Timestamp:
- 03/10/09 21:21:58 (4 years ago)
- Files:
-
- plugins/pkPersistentFileUploadPlugin/trunk/README (modified) (1 diff)
- plugins/pkPersistentFileUploadPlugin/trunk/lib/form (added)
- plugins/pkPersistentFileUploadPlugin/trunk/lib/form/pkPersistentFileUploadIframeForm.class.php (added)
- plugins/pkPersistentFileUploadPlugin/trunk/lib/validator/pkValidatorFilePersistent.class.php (modified) (1 diff)
- plugins/pkPersistentFileUploadPlugin/trunk/lib/widget/pkWidgetFormInputFilePersistent.class.php (modified) (3 diffs)
- plugins/pkPersistentFileUploadPlugin/trunk/modules (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/README (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/actions (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/actions/actions.class.php (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/lib (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/lib/.BasepkPersistentFileUploadActions.class.php.swp (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/lib/BasepkPersistentFileUploadActions.class.php (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/templates (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/templates/.iframeSuccess.php.swp (added)
- plugins/pkPersistentFileUploadPlugin/trunk/modules/pkPersistentFileUpload/templates/iframeSuccess.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/pkPersistentFileUploadPlugin/trunk/README
r15684 r16150 224 224 You can reach Tom at [tom@punkave.com](mailto:punkave.com). 225 225 226 ## TODO 227 228 Finish support for individual iframes, allowing progress display and 229 simultaneous uploads and eliminating the need for the main display 230 to be an iframe in order to achieve progress display. It's a good idea but it 231 doesn't work yet. 232 226 233 ## Changelog 227 234 plugins/pkPersistentFileUploadPlugin/trunk/lib/validator/pkValidatorFilePersistent.class.php
r16004 r16150 213 213 } 214 214 215 static public function setFileInfo($persistid, $data) 216 { 217 if (!self::validPersistId($persistid)) 218 { 219 // Roll our eyes at the hackers 220 return false; 221 } 222 $persistentDir = self::getPersistentDir(); 223 $infoPath = "$persistentDir/$persistid.data"; 224 file_put_contents($infoPath, serialize($data)); 225 return true; 226 } 215 227 static public function validPersistId($persistid) 216 228 { plugins/pkPersistentFileUploadPlugin/trunk/lib/widget/pkWidgetFormInputFilePersistent.class.php
r16005 r16150 28 28 29 29 $this->addOption('type', 'file'); 30 $this->addOption('iframe', null); 31 $this->addOption('progress', null); 32 $this->addOption('iframe-content', null); 30 33 $this->addOption('existing-html', false); 31 34 $this->addOption('image-preview', null); 35 $this->addOption('persistid', null); 32 36 $this->setOption('needs_multipart', true); 33 37 } … … 50 54 { 51 55 $exists = false; 52 if (isset($value['persistid']) && strlen($value['persistid'])) 56 if ($this->hasOption('persistid')) 57 { 58 $persistid = $this->getOption('persistid'); 59 } 60 elseif (isset($value['persistid']) && strlen($value['persistid'])) 53 61 { 54 62 $persistid = $value['persistid']; 63 } 64 if (isset($persistid)) 65 { 55 66 $info = pkValidatorFilePersistent::getFileInfo($persistid); 56 if ( $info)67 if (isset($info['tmp_name'])) 57 68 { 58 69 $exists = true; … … 107 118 $imagePreview['height']); 108 119 } 109 $result .= "<img src='$url' />"; 120 if ($this->getOption('iframe-content')) 121 { 122 // This is not security related, it just forces a refresh 123 $salt = time(); 124 $salted = "$url?$salt"; 125 $result .= "<script>pkPersistentFileUploadUpdatePreview(json_encode($persistid), json_encode($salted));</script>"; 126 } 127 else 128 { 129 $result .= "<img id='pk-persistent-upload-preview-$persistid' src='" . json_encode($url) . " />"; 130 } 110 131 } 111 132 $result .= $this->getOption('existing-html'); 112 133 } 113 return $result . 114 $this->renderTag('input', 115 array_merge( 134 else 135 { 136 if ($this->hasOption('image-preview') && $this->hasOption('iframe')) 137 { 138 $result .= "<img id='pk-persistent-upload-preview-$persistid' style='display: none' />"; 139 } 140 } 141 if ($this->getOption('iframe')) 142 { 143 $iframe = $this->getOption('iframe'); 144 if (isset($iframe['width'])) 145 { 146 $width = $iframe['width']; 147 } 148 else 149 { 150 $width = 400; 151 } 152 if (isset($iframe['height'])) 153 { 154 $height = $iframe['height']; 155 } 156 else 157 { 158 $height = 50; 159 } 160 $result .= "<iframe class='pk-persistent-upload-iframe' id='pk-persistent-upload-iframe-$persistid' width='$width' height='$height' src='" . url_for("pkPersistentFileUpload/iframe?persistid=$persistid") . "'></iframe>"; 161 // We continue to build the result string as the fallback for a 162 // device that doesn't do iframes 163 $info = pkValidatorFilePersistent::getFileInfo($persistid); 164 if ($info === false) 165 { 166 // That's OK, it's just the first pass 167 $info = array(); 168 } 169 // We need these so we can render it correctly from the 170 // action in the iframe 171 $info['options'] = $this->getOptions(); 172 $info['attributes'] = $this->getAttributes(); 173 pkValidatorFilePersistent::setFileInfo($persistid, $info); 174 if ($this->hasOption('progress')) 175 { 176 $result .= "<div class='pk-persistent-upload-progress' id='pk-persistent-upload-progress-$persistid'>"; 177 { 178 $result .= $this->getOption('progress'); 179 } 180 $result .= "</div>"; 181 } 182 } 183 else 184 { 185 $result .= 186 $this->renderTag('input', 187 array_merge( 188 array( 189 'type' => $this->getOption('type'), 190 'name' => $name . '[newfile]'), 191 $attributes)); 192 $result .= 193 $this->renderTag('input', 116 194 array( 117 'type' => $this->getOption('type'), 118 'name' => $name . '[newfile]'), 119 $attributes)) . 120 $this->renderTag('input', 121 array( 122 'type' => 'hidden', 123 'name' => $name . '[persistid]', 124 'value' => $persistid)); 195 'type' => 'hidden', 196 'name' => $name . '[persistid]', 197 'value' => $persistid)); 198 } 199 return $result; 125 200 } 126 127 201 }