~ubuntu-branches/ubuntu/natty/moodle/natty

« back to all changes in this revision

Viewing changes to lib/smarty/core/core.write_compiled_include.php

  • Committer: Bazaar Package Importer
  • Author(s): Tomasz Muras
  • Date: 2010-10-30 12:19:28 UTC
  • mfrom: (1.1.12 upstream) (3.1.10 squeeze)
  • Revision ID: james.westby@ubuntu.com-20101030121928-qzobi6mctpnk4dif
Tags: 1.9.9.dfsg2-2
* Added Romanian translation
* Updated Japanese translation (closes: #596820)
* Backporting security fixes from Moodle 1.9.10 (closes: #601384)
   - Updated embedded CAS to 1.1.3
   - Added patch for MDL-24523:
     clean_text() not filtering text in markdown format
   - Added patch for MDL-24810 and upgraded customized HTML Purifier to 4.2.0 
   - Added patch for MDL-24258:
     students can delete their forum posts later than $CFG->maxeditingtime 
     under certain conditions
   - Added patch for MDL-23377:
     Can't delete quiz attempts in course without enrolled students

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/**
3
 
 * Smarty plugin
4
 
 * @package Smarty
5
 
 * @subpackage plugins
6
 
 */
7
 
 
8
 
/**
9
 
 * Extract non-cacheable parts out of compiled template and write it
10
 
 *
11
 
 * @param string $compile_path
12
 
 * @param string $template_compiled
13
 
 * @param integer $template_timestamp
14
 
 * @return boolean
15
 
 */
16
 
 
17
 
function smarty_core_write_compiled_include($params, &$smarty)
18
 
{
19
 
    $_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
20
 
    $_tag_end   = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
21
 
 
22
 
    preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
23
 
                   $params['compiled_content'], $_match_source, PREG_SET_ORDER);
24
 
 
25
 
    // no nocache-parts found: done
26
 
    if (count($_match_source)==0) return;
27
 
 
28
 
    // convert the matched php-code to functions
29
 
    $_include_compiled = "<?php /* funky header here */\n\n";
30
 
 
31
 
    $_compile_path = $params['include_file_path'];
32
 
 
33
 
    $smarty->_cache_serials[$_compile_path] = $params['cache_serial'];
34
 
    $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
35
 
 
36
 
    $_include_compiled .= $params['plugins_code'];
37
 
    $_include_compiled .= "<?php";
38
 
    for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
39
 
        $_match =& $_match_source[$_i];
40
 
        $_include_compiled .= "
41
 
function _smarty_tplfunc_$_match[2]_$_match[3](&\$this)
42
 
{
43
 
$_match[4]
44
 
}
45
 
 
46
 
";
47
 
    }
48
 
    $_include_compiled .= "\n\n?>\n";
49
 
 
50
 
    $_params = array('filename' => $_compile_path,
51
 
                     'contents' => $_include_compiled, 'create_dirs' => true);
52
 
 
53
 
    require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
54
 
    smarty_core_write_file($_params, $smarty);
55
 
    return true;
56
 
}
57
 
 
58
 
 
59
 
?>