• R/O
  • SSH
  • HTTPS

xoonips: Commit


Commit MetaInfo

Revision649 (tree)
Zeit2017-02-02 20:34:44
Autororrisroot

Log Message

add callback method to use cache utility.

Ändern Zusammenfassung

Diff

--- trunk/xoonips/xoops_trust_path/modules/xoonips/lib/Xoonips/Core/CacheUtils.php (revision 648)
+++ trunk/xoonips/xoops_trust_path/modules/xoonips/lib/Xoonips/Core/CacheUtils.php (revision 649)
@@ -103,6 +103,28 @@
103103 }
104104
105105 /**
106+ * output callback.
107+ *
108+ * @param int $mitme
109+ * @param string $etag
110+ * @param string $mime
111+ * @param callable $func
112+ * @param array $params
113+ */
114+ public static function outputCallback($mtime, $etag, $mime, $func, $params)
115+ {
116+ self::_prepareOutput();
117+ self::_outputCacheHeader($mtime, $etag);
118+ header('Content-Type: '.$mime);
119+ if (is_null($params)) {
120+ call_user_func($func);
121+ } else {
122+ call_user_func_array($func, $params);
123+ }
124+ self::_cleanupOutput();
125+ }
126+
127+ /**
106128 * download data.
107129 *
108130 * @param int $mtime
@@ -153,6 +175,35 @@
153175 }
154176
155177 /**
178+ * download callback.
179+ *
180+ * @param int $mtime
181+ * @param string $etag
182+ * @param string $mime
183+ * @param callable $func
184+ * @param array $params
185+ * @param string $fname
186+ * @param string $encoding
187+ */
188+ public static function downloadCallback($mtime, $etag, $mime, $func, $params, $fname, $encoding)
189+ {
190+ set_time_limit(0);
191+ if ($encoding != 'UTF-8') {
192+ $fname = StringUtils::convertEncoding($fname, 'UTF-8', $encoding, 'h');
193+ }
194+ self::_prepareOutput();
195+ self::_outputCacheHeader($mtime, $etag);
196+ header('Content-Type: '.$mime);
197+ header('Content-Disposition: attachment; filename*=UTF-8\'\''.rawurlencode($fname));
198+ if (is_null($params)) {
199+ call_user_func($func);
200+ } else {
201+ call_user_func_array($func, $params);
202+ }
203+ self::_cleanupOutput();
204+ }
205+
206+ /**
156207 * prepare output.
157208 */
158209 protected static function _prepareOutput()
Show on old repository browser