author | Dan |
Wed, 24 Sep 2008 13:47:42 -0400 | |
changeset 54 | 6d8b9497e44b |
parent 0 | c63de9eb7045 |
permissions | -rw-r--r-- |
0
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
1 |
<?php |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
2 |
/** |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
3 |
* Smarty plugin |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
4 |
* @package Smarty |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
5 |
* @subpackage plugins |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
6 |
*/ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
7 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
8 |
/** |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
9 |
* Replace cached inserts with the actual results |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
10 |
* |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
11 |
* @param string $results |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
12 |
* @return string |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
13 |
*/ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
14 |
function smarty_core_process_cached_inserts($params, &$smarty) |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
15 |
{ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
16 |
preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis', |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
17 |
$params['results'], $match); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
18 |
list($cached_inserts, $insert_args) = $match; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
19 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
20 |
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
21 |
if ($smarty->debugging) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
22 |
$_params = array(); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
23 |
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
24 |
$debug_start_time = smarty_core_get_microtime($_params, $smarty); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
25 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
26 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
27 |
$args = unserialize($insert_args[$i]); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
28 |
$name = $args['name']; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
29 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
30 |
if (isset($args['script'])) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
31 |
$_params = array('resource_name' => $smarty->_dequote($args['script'])); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
32 |
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
33 |
if(!smarty_core_get_php_resource($_params, $smarty)) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
34 |
return false; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
35 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
36 |
$resource_type = $_params['resource_type']; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
37 |
$php_resource = $_params['php_resource']; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
38 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
39 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
40 |
if ($resource_type == 'file') { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
41 |
$smarty->_include($php_resource, true); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
42 |
} else { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
43 |
$smarty->_eval($php_resource); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
44 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
45 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
46 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
47 |
$function_name = $smarty->_plugins['insert'][$name][0]; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
48 |
if (empty($args['assign'])) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
49 |
$replace = $function_name($args, $smarty); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
50 |
} else { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
51 |
$smarty->assign($args['assign'], $function_name($args, $smarty)); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
52 |
$replace = ''; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
53 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
54 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
55 |
$params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i])); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
56 |
if ($smarty->debugging) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
57 |
$_params = array(); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
58 |
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
59 |
$smarty->_smarty_debug_info[] = array('type' => 'insert', |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
60 |
'filename' => 'insert_'.$name, |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
61 |
'depth' => $smarty->_inclusion_depth, |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
62 |
'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
63 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
64 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
65 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
66 |
return $params['results']; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
67 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
68 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
69 |
/* vim: set expandtab: */ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
70 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
71 |
?> |