PageRenderTime 39ms CodeModel.GetById 11ms app.highlight 21ms RepoModel.GetById 1ms app.codeStats 0ms

/qeephp/library/q.php

http://enaj.googlecode.com/
PHP | 979 lines | 711 code | 24 blank | 244 comment | 25 complexity | c98c55761b5722d9405024c688dd6710 MD5 | raw file
  1<?php
  2// $Id: q.php 2361 2009-04-01 15:36:05Z dualface $
  3
  4/**
  5 * ?? QeePHP ??????????????
  6 *
  7 * @link http://qeephp.com/
  8 * @copyright Copyright (c) 2006-2009 Qeeyuan Inc. {@link http://www.qeeyuan.com}
  9 * @license New BSD License {@link http://qeephp.com/license/}
 10 * @version $Id: q.php 2361 2009-04-01 15:36:05Z dualface $
 11 * @package core
 12 */
 13
 14/**
 15 * QeePHP ?????????
 16 */
 17define('Q_DIR', dirname(__FILE__));
 18
 19/**
 20 * DIRECTORY_SEPARATOR ???
 21 */
 22define('DS', DIRECTORY_SEPARATOR);
 23
 24/**
 25 * CURRENT_TIMESTAMP ?????????????? time() ???
 26 */
 27define('CURRENT_TIMESTAMP', time());
 28
 29global $G_CLASS_FILES;
 30if (empty($G_CLASS_FILES))
 31{
 32    require Q_DIR . '/_config/qeephp_class_files.php';
 33}
 34
 35/**
 36 * ? Q ? QeePHP ?????????????????????
 37 *
 38 * ? Q ?? QeePHP ???????????
 39 *
 40 * -  ?????????
 41 * -  ????????????
 42 * -  ????????????????????
 43 * -  ???????
 44 * -  ???????
 45 *
 46 * @author YuLei Liao <liaoyulei@qeeyuan.com>
 47 * @version $Id: q.php 2361 2009-04-01 15:36:05Z dualface $
 48 * @package core
 49 */
 50class Q
 51{
 52    /**
 53     * ??????????
 54     */
 55    // ??????
 56    const RUN_MODE_DEVEL  = 'devel';
 57    // ??????
 58    const RUN_MODE_DEPLOY = 'deploy';
 59    // ????
 60    const RUN_MODE_TEST   = 'test';
 61
 62    /**
 63     * ?????
 64     *
 65     * @var array
 66     */
 67    private static $_objects = array();
 68
 69    /**
 70     * ?????
 71     *
 72     * @var array
 73     */
 74    private static $_class_path = array();
 75
 76    /**
 77     * ????????
 78     *
 79     * @var array
 80     */
 81    private static $_class_path_options = array();
 82
 83    /**
 84     * ??????
 85     *
 86     * @var array
 87     */
 88    private static $_ini = array();
 89
 90    /**
 91     * ?? QeePHP ???
 92     *
 93     * @return string QeePHP ???
 94     */
 95    static function version()
 96    {
 97        return '2.1';
 98    }
 99
100    /**
101     * ?????????
102     *
103     * $option ????????????
104     * ?????????????????? $default ???????
105     *
106     * @code php
107     * $option_value = Q::ini('my_option');
108     * @endcode
109     *
110     * ???????????????? $option ???“/”??????
111     *
112     * ??????? option_group ???????????????
113     * ???????? my_option ???????
114     *
115     * @code php
116     * // +--- option_group
117     * //   +-- my_option  = this is my_option
118     * //   +-- my_option2 = this is my_option2
119     * //   \-- my_option3 = this is my_option3
120     *
121     * // ?? option_group ?????? my_option ?
122     * // ???? this is my_option
123     * echo Q::ini('option_group/my_option');
124     * @endcode
125     *
126     * ???????????????????“/”??????????????????
127     *
128     * ??????????????? $option ????? '/' ???
129     *
130     * @code php
131     * // ??????????
132     * $all = Q::ini('/');
133     * @endcode
134     *
135     * @param string $option ?????????
136     * @param mixed $default ????????????????
137     *
138     * @return mixed ???????
139     */
140    static function ini($option, $default = null)
141    {
142        if ($option == '/') return self::$_ini;
143
144        if (strpos($option, '/') === false)
145        {
146            return array_key_exists($option, self::$_ini)
147                ? self::$_ini[$option]
148                : $default;
149        }
150
151        $parts = explode('/', $option);
152        $pos =& self::$_ini;
153        foreach ($parts as $part)
154        {
155            if (!isset($pos[$part])) return $default;
156            $pos =& $pos[$part];
157        }
158        return $pos;
159    }
160
161    /**
162     * ?????????
163     *
164     * ? $option ????????$option ???????????
165     * $data ???????????????
166     *
167     * @code php
168     * // ???????
169     * Q::changeIni('option_group/my_option2', 'new value');
170     * @endcode
171     *
172     * ?? $option ??????????????????
173     * ?? $option ???????????????????????????????
174     *
175     * @code php
176     * // ????????
177     * // +--- option_1 = old value
178     * // +--- option_group
179     * //   +-- option1 = old value
180     * //   +-- option2 = old value
181     * //   \-- option3 = old value
182     *
183     * // ???????
184     * $arr = array(
185     *      'option_1' => 'value 1',
186     *      'option_2' => 'value 2',
187     *      'option_group/option2' => 'new value',
188     * );
189     * Q::changeIni($arr);
190     *
191     * // ???
192     * // +--- option_1 = value 1
193     * // +--- option_2 = value 2
194     * // +--- option_group
195     * //   +-- option1 = old value
196     * //   +-- option2 = new value
197     * //   \-- option3 = old value
198     * @endcode
199     *
200     * ??????? Q::changeIni() ????????????????????
201     *
202     * ???????????????????????? Q::replaceIni() ???
203     *
204     * @param string|array $option ??????????????????????
205     * @param mixed $data ????????
206     */
207    static function changeIni($option, $data = null)
208    {
209        if (is_array($option))
210        {
211            foreach ($option as $key => $value)
212            {
213                self::changeIni($key, $value);
214            }
215            return;
216        }
217
218        if (!is_array($data))
219        {
220            if (strpos($option, '/') === false)
221            {
222                self::$_ini[$option] = $data;
223                return;
224            }
225
226            $parts = explode('/', $option);
227            $max = count($parts) - 1;
228            $pos =& self::$_ini;
229            for ($i = 0; $i <= $max; $i ++)
230            {
231                $part = $parts[$i];
232                if ($i < $max)
233                {
234                    if (!isset($pos[$part]))
235                    {
236                        $pos[$part] = array();
237                    }
238                    $pos =& $pos[$part];
239                }
240                else
241                {
242                    $pos[$part] = $data;
243                }
244            }
245        }
246        else
247        {
248            foreach ($data as $key => $value)
249            {
250                self::changeIni($option . '/' . $key, $value);
251            }
252        }
253    }
254
255    /**
256     * ????????
257     *
258     * Q::replaceIni() ????? Q::changeIni() ???
259     * ?? Q::replaceIni() ??????????????
260     * ???????????????????
261     *
262     * @code php
263     * // ????????
264     * // +--- option_1 = old value
265     * // +--- option_group
266     * //   +-- option1 = old value
267     * //   +-- option2 = old value
268     * //   \-- option3 = old value
269     *
270     * // ???????
271     * $arr = array(
272     *      'option_1' => 'value 1',
273     *      'option_2' => 'value 2',
274     *      'option_group/option2' => 'new value',
275     * );
276     * Q::replaceIni($arr);
277     *
278     * // ???
279     * // +--- option_1 = value 1
280     * // +--- option_2 = value 2
281     * // +--- option_group
282     * //   +-- option2 = new value
283     * @endcode
284     *
285     * ?????????????? Q::replaceIni() ? Q::changeIni() ??????
286     *
287     * ???? Q::replaceIni() ??? Q::changeIni() ????
288     * ???????? Q::replaceIni() ??? Q::changeIni()?
289     *
290     * @param string|array $option ??????????????????????
291     * @param mixed $data ????????
292     */
293    static function replaceIni($option, $data = null)
294    {
295        if (is_array($option))
296        {
297            self::$_ini = array_merge(self::$_ini, $option);
298        }
299        else
300        {
301            self::$_ini[$option] = $data;
302        }
303    }
304
305    /**
306     * ???????
307     *
308     * Q::cleanIni() ?????????????????
309     *
310     * @param mixed $option ?????????
311     */
312    static function cleanIni($option)
313    {
314        if (strpos($option, '/') === false)
315        {
316            unset(self::$_ini[$option]);
317        }
318        else
319        {
320            $parts = explode('/', $option);
321            $max = count($parts) - 1;
322            $pos =& self::$_ini;
323            for ($i = 0; $i <= $max; $i ++)
324            {
325                $part = $parts[$i];
326                if ($i < $max)
327                {
328                    if (!isset($pos[$part]))
329                    {
330                        $pos[$part] = array();
331                    }
332                    $pos =& $pos[$part];
333                }
334                else
335                {
336                    unset($pos[$part]);
337                }
338            }
339        }
340    }
341
342    /**
343     * ?????????????????????
344     *
345     * @code php
346     * Q::loadClass('Table_Posts');
347     * @endcode
348     *
349     * $dirs ???????? PATH_SEPARATOR ?????????
350     * ?????????????????
351     *
352     * @code php
353     * Q::loadClass('Table_Posts', array('/www/mysite/app', '/www/mysite/lib'));
354     * @endcode
355     *
356     * @param string $class_name ?????
357     * @param string|array $dirs ??????????
358     *
359     * @return string|boolean ??????????? false
360     */
361    static function loadClass($class_name, $dirs = null, $throw = true)
362    {
363        if (class_exists($class_name, false) || interface_exists($class_name, false))
364        {
365            return $class_name;
366        }
367
368        global $G_CLASS_FILES;
369        $class_name_l = strtolower($class_name);
370        if (isset($G_CLASS_FILES[$class_name_l]))
371        {
372            require Q_DIR . DS . $G_CLASS_FILES[$class_name_l];
373            return $class_name_l;
374        }
375
376        $filename = str_replace('_', DS, $class_name);
377        if ($filename != $class_name)
378        {
379            $dirname = dirname($filename);
380            if (!empty($dirs))
381            {
382	            if (!is_array($dirs))
383                {
384                    $dirs = explode(PATH_SEPARATOR, $dirs);
385                }
386            }
387            else
388            {
389                $dirs = self::$_class_path;
390            }
391            $filename = basename($filename) . '.php';
392            return self::loadClassFile($filename, $dirs, $class_name, $dirname, $throw);
393        }
394        else
395        {
396            return self::loadClassFile("{$filename}.php", self::$_class_path, $class_name, '', $throw);
397        }
398    }
399
400    /**
401     * ?????????
402     *
403     * ????? Q::loadClass() ??? QeePHP ??????? Q::import() ?????????
404     *
405     * ????Q::import() ?????????????
406     *
407     * ??????? Vendor_Smarty_Adapter???????????????? vendor/smarty/adapter.php?
408     * ???? Q::import() ?? Vendor_Smarty_Adapter ????????
409     * ???? vendor/smarty/adapter.php ?????
410     *
411     * @code php
412     * Q::import('/www/app');
413     * Q::loadClass('Vendor_Smarty_Adapter');
414     * // ???????? /www/app/vendor/smarty/adapter.php
415     * @endcode
416     *
417     * ?? QeePHP ?????????????????????????????????
418     * ???? import() ?????????
419     *
420     * @code php
421     * Q::import('/www/app/vendor', true);
422     * Q::loadClass('Zend_Mail');
423     * // ???????? /www/app/vendor/Zend/Mail.php
424     * @endcode
425     *
426     * @param string $dir ????????
427     * @param boolean $case_sensitive ?????????????????????
428     */
429    static function import($dir, $case_sensitive = false)
430    {
431        $real_dir = realpath($dir);
432        if ($real_dir)
433        {
434            $dir = rtrim($real_dir, '/\\');
435            if (!isset(self::$_class_path[$dir]))
436            {
437                self::$_class_path[$dir] = $dir;
438                self::$_class_path_options[$dir] = $case_sensitive;
439            }
440        }
441    }
442
443    /**
444     * ????????????????????
445     *
446     * ???? $dirs ????????????? $filename ????????
447     * ???????????? $class_name ???????
448     *
449     * ????????????????
450     *
451     * @code php
452     * Q::loadClassFile('Smarty.class.php', $dirs, 'Smarty');
453     * @endcode
454     *
455     * @param string $filename ???????????????
456     * @param string|array $dirs ???????
457     * @param string $class_name ?????
458     * @param string $dirname ??????????????
459     * @param string $throw ????????????
460     */
461    static function loadClassFile($filename, $dirs, $class_name, $dirname = '', $throw = true)
462    {
463        if (!is_array($dirs))
464        {
465            $dirs = explode(PATH_SEPARATOR, $dirs);
466        }
467        if ($dirname)
468        {
469            $filename = rtrim($dirname, '/\\') . DS . $filename;
470        }
471        $filename_l = strtolower($filename);
472
473        foreach ($dirs as $dir)
474        {
475            if (isset(self::$_class_path[$dir]))
476            {
477                $path = $dir . DS . (self::$_class_path_options[$dir] ? $filename : $filename_l);
478            }
479            else
480            {
481                $path = rtrim($dir, '/\\') . DS . $filename;
482            }
483
484            if (is_file($path))
485            {
486                require $path;
487                break;
488            }
489        }
490
491        // ????????????????????
492        if (!class_exists($class_name, false) && ! interface_exists($class_name, false))
493        {
494            if ($throw)
495            {
496                throw new Q_ClassNotDefinedException($class_name, $path);
497            }
498            return false;
499        }
500        return $class_name;
501    }
502
503    /**
504     * ???????
505     *
506     * ???? $dirs ????????????? $filename ????????
507     * ??????????? $throw ???????????
508     *
509     * ? PHP ??? require ? include ???Q::loadFile() ????????
510     *
511     * <ul>
512     *   <li>???????????????</li>
513     *   <li>?????????</li>
514     *   <li>?????????????</li>
515     * </ul>
516     *
517     * @code php
518     * Q::loadFile('my_file.php', $dirs);
519     * @endcode
520     *
521     * @param string $filename ???????????????
522     * @param array $dirs ???????
523     * @param boolean $throw ?????????????
524     *
525     * @return mixed
526     */
527    static function loadFile($filename, $dirs = null, $throw = true)
528    {
529        if (preg_match('/[^a-z0-9\-_.]/i', $filename))
530        {
531            throw new Q_IllegalFilenameException($filename);
532        }
533
534        if (is_null($dirs))
535        {
536            $dirs = array();
537        }
538        elseif (is_string($dirs))
539        {
540            $dirs = explode(PATH_SEPARATOR, $dirs);
541        }
542        foreach ($dirs as $dir)
543        {
544            $path = rtrim($dir, '\\/') . DS . $filename;
545            if (is_file($path)) return include $path;
546        }
547
548        if ($throw) throw new Q_FileNotFoundException($filename);
549        return false;
550    }
551
552    /**
553     * ???????????
554     *
555     * Q::singleton() ???????
556     *
557     * <ul>
558     *   <li>????????????????????????</li>
559     *   <li>??????????????</li>
560     *   <li>?????????????????????????</li>
561     *   <li>?????????????????????????</li>
562     *   <li>???????????</li>
563     * </ul>
564     *
565     * ?? Q::singleton() ?????????????????????????
566     *
567     * @code php
568     * // ??? A ????? My_Object
569     * $obj = Q::singleton('My_Object');
570     * ...
571     * ...
572     * // ??? B ????? My_Object
573     * $obj2 = Q::singleton('My_Object');
574     * // $obj ? $obj2 ?????????????????????????
575     * @endcode
576     *
577     * @param string $class_name ??????????
578     *
579     * @return object ??????
580     */
581    static function singleton($class_name)
582    {
583        $key = strtolower($class_name);
584        if (isset(self::$_objects[$key]))
585        {
586            return self::$_objects[$key];
587        }
588        self::loadClass($class_name);
589        return self::register(new $class_name(), $class_name);
590    }
591
592    /**
593     * ??????????????????
594     *
595     * ????????????????????????????????? Q::registry() ???????
596     * ????????????????????????????????
597     *
598     * @code php
599     * // ??????
600     * Q::register(new MyObject());
601     * .....
602     * // ??????
603     * $obj = Q::regitry('MyObject');
604     * @endcode
605     *
606     * ? $persistent ??? true ??????????????
607     * ?????????????? Q::registry() ????????????????????????
608     *
609     * ??????????????????????????????????
610     * ?????????????????????
611     *
612     * ???????????????????? object_persistent_provier ???
613     * ???????????????????
614     *
615     * @code php
616     * if (!Q::isRegistered('MyObject'))
617     * {
618     *      Q::register(new MyObject(), 'MyObject', true);
619     * }
620     * $app = Q::registry('MyObject');
621     * @endcode
622     *
623     * @param object $obj ??????
624     * @param string $name ???????
625     * @param boolean $persistent ?????????????
626     *
627     * @return object
628     */
629    static function register($obj, $name = null, $persistent = false)
630    {
631        if (!is_object($obj))
632        {
633            // LC_MSG: Type mismatch. $obj expected is object, actual is "%s".
634            throw new QException(__('Type mismatch. $obj expected is object, actual is "%s".',
635                                    gettype($obj)));
636        }
637
638        // TODO: ??? $persistent ?????
639        if (is_null($name))
640        {
641            $name = get_class($obj);
642        }
643        $name = strtolower($name);
644        self::$_objects[$name] = $obj;
645        return $obj;
646    }
647
648    /**
649     * ?????????????????????????????
650     *
651     * @code php
652     * // ??????
653     * Q::register(new MyObject(), 'obj1');
654     * .....
655     * // ??????
656     * $obj = Q::regitry('obj1');
657     * @endcode
658     *
659     * @param string $name ????????
660     *
661     * @return object ??????
662     */
663    static function registry($name)
664    {
665        $name = strtolower($name);
666        if (isset(self::$_objects[$name]))
667        {
668            return self::$_objects[$name];
669        }
670        // LC_MSG: No object is registered of name "%s".
671        throw new QException(__('No object is registered of name "%s".', $name));
672    }
673
674    /**
675     * ???????????????
676     *
677     * @param string $name ????????
678     *
679     * @return boolean ????????
680     */
681    static function isRegistered($name)
682    {
683        $name = strtolower($name);
684        return isset(self::$_objects[$name]);
685    }
686
687    /**
688     * ?????????????????????????? false
689     *
690     * ???????????????? ID??????????????? ID?
691     * ???? A ??? ID ? data-a???? B ??? ID ? data-b?
692     *
693     * ??????????????????????? ID????????????
694     *
695     * <ul>
696     *   <li>?????????????????? page?db ??</li>
697     *   <li>??????????????????????????????? ID?</li>
698     * </ul>
699     *
700     * ????????? ID ????? page.news.1?db.members.userid?
701     *
702     * Q::cache() ???? $policy ?????????????????
703     * ????????????????????????
704     *
705     * $backend_class ???????????????????? QCache_File?QCache_APC ??
706     *
707     * @code php
708     * $data = Q::cache($cache_id);
709     * if ($data === false)
710     * {
711     *     $data = ....
712     *     Q::writeCache($cache_id, $data);
713     * }
714     * @endcode
715     *
716     * @param string $id ??? ID
717     * @param array $policy ????
718     * @param string $backend_class ????????
719     *
720     * @return mixed ????????????? false
721     */
722    static function cache($id, array $policy = null, $backend_class = null)
723    {
724        static $obj = null;
725
726        if (is_null($backend_class))
727        {
728            if (is_null($obj))
729            {
730                $obj = self::singleton(self::ini('runtime_cache_backend'));
731            }
732            return $obj->get($id, $policy);
733        }
734        else
735        {
736            $cache = self::singleton($backend_class);
737            return $cache->get($id, $policy);
738        }
739    }
740
741    /**
742     * ????????????????
743     *
744     * $data ????????????? $data ?????????????????? serialize ??? true?
745     * $policy ????????????????????????????????????
746     *
747     * ????? Q::cache()?
748     *
749     * @param string $id ??? ID
750     * @param mixed $data ??????
751     * @param array $policy ????
752     * @param string $backend_class ????????
753     */
754    static function writeCache($id, $data, array $policy = null, $backend_class = null)
755    {
756        static $obj = null;
757
758        if (is_null($backend_class))
759        {
760            if (is_null($obj))
761            {
762                $obj = self::singleton(self::ini('runtime_cache_backend'));
763            }
764            $obj->set($id, $data, $policy);
765        }
766        else
767        {
768            $cache = self::singleton($backend_class);
769            $cache->set($id, $data, $policy);
770        }
771    }
772
773    /**
774     * ?????????
775     *
776     * ?????????????????????????????????????
777     * ????????????????????????????????????????????
778     *
779     * @code php
780     * Q::cleanCache($cache_id);
781     * @endcode
782     *
783     * @param string $id ??? ID
784     * @param array $policy ????
785     * @param string $backend_class ????????
786     */
787    static function cleanCache($id, array $policy = null, $backend_class = null)
788    {
789        static $obj = null;
790
791        if (is_null($backend_class))
792        {
793            if (is_null($obj))
794            {
795                $obj = self::singleton(self::ini('runtime_cache_backend'));
796            }
797            $obj->remove($id, $policy);
798        }
799        else
800        {
801            $cache = self::singleton($backend_class);
802            $cache->remove($id, $policy);
803        }
804    }
805
806    /**
807     * ??????????????????????
808     *
809     * $input ?????????????“,”?????????????????
810     * ?????????????? trim() ????????????????????????
811     *
812     * ?????????????“item1, item2, item3” ????????????
813     *
814     * @code php
815     * $input = 'item1, item2, item3';
816     * $output = Q::normalize($input);
817     * // $output ?????????????
818     * // $output = array(
819     * //   'item1',
820     * //   'item2',
821     * //   'item3',
822     * // );
823     *
824     * $input = 'item1|item2|item3';
825     * // ?????????????
826     * $output = Q::normalize($input, '|');
827     * @endcode
828     *
829     * @param array|string $input ???????????
830     * @param string $delimiter ??????????
831     *
832     * @return array ?????
833     */
834    static function normalize($input, $delimiter = ',')
835    {
836        if (!is_array($input))
837        {
838            $input = explode($delimiter, $input);
839        }
840        $input = array_map('trim', $input);
841        return array_filter($input, 'strlen');
842    }
843
844    /**
845     * ????????????
846     *
847     * ?? Q::control() ?????????????????????????
848     *
849     * @param string $type ???????????
850     * @param string $id ??ID
851     * @param array $attrs ???????????
852     *
853     * @return QUI_Control_Abstract ???????????
854     */
855    static function control($type, $id = null, array $attrs = null)
856    {
857        $id = (empty($id)) ? strtolower($type) : strtolower($id);
858        if (!is_array($attrs)) $attrs = array();
859        $class_name = 'Control_' . ucfirst(strtolower($type));
860        return new $class_name($id, $attrs);
861    }
862
863    /**
864     * ?? QeePHP ????????????????
865     *
866     * @param string $class_name
867     */
868    static function autoload($class_name)
869    {
870        self::loadClass($class_name, null, false);
871    }
872
873    /**
874     * ????????????????
875     *
876     * ????? Zend Framework?
877     *
878     * @param string $class ??????????
879     * @param boolean $enabled ????????
880     */
881    static function registerAutoload($class = 'Q', $enabled = true)
882    {
883        if (!function_exists('spl_autoload_register'))
884        {
885            require_once Q_DIR . '/core/exception.php';
886            throw new QException('spl_autoload does not exist in this PHP installation');
887        }
888
889        if ($enabled === true)
890        {
891            spl_autoload_register(array($class, 'autoload'));
892        }
893        else
894        {
895            spl_autoload_unregister(array($class, 'autoload'));
896        }
897    }
898
899}
900
901/**
902 * QeePHP ????????????
903 *
904 * ???????? QTranslate ??????????
905 *
906 * @return $msg
907 */
908function __()
909{
910    $args = func_get_args();
911    $msg = array_shift($args);
912    $language = strtolower(Q::ini('error_language'));
913    $messages = Q::loadFile('lc_messages.php', Q_DIR . '/_lang/' . $language, false);
914    if (isset($messages[$msg]))
915    {
916        $msg = $messages[$msg];
917    }
918    array_unshift($args, $msg);
919    return call_user_func_array('sprintf', $args);
920}
921
922/**
923 * ?? HTML ???????? htmlspecialchars()
924 *
925 * @param string $text
926 *
927 * @return string
928 */
929function h($text)
930{
931    return htmlspecialchars($text);
932}
933
934function nl2p($text)
935{
936	$ps = split("(\r\n)+|\n+", trim($text));
937	$ret = "";
938	foreach($ps as $p){
939		$ret .= "<p>$p</p>\n";
940	}
941	return $ret;
942}
943
944/**
945 * QDebug::dump() ???????????????
946 *
947 * @param mixed $vars ??????
948 * @param string $label ??????????
949 * @param boolean $return ????????
950 *
951 * @return string
952 */
953function dump($vars, $label = null, $return = false)
954{
955    return QDebug::dump($vars, $label, $return);
956}
957
958/**
959 * QContext::url() ???????????? URL ??
960 *
961 * url() ????????????? QContext::url() ????????
962 *
963 * @param string $udi UDI ???
964 * @param array|string $params ??????
965 * @param string $route_name ???
966 * @param array $opts ?????? URL ???
967 *
968 * @return string ??? URL ??
969 */
970function url($udi, $params = null, $route_name = null, array $opts = null)
971{
972    return QContext::instance()->url($udi, $params, $route_name, $opts);
973}
974
975/**
976 * ?????????
977 */
978Q::registerAutoload();
979