Changeset 1278
- Timestamp:
- 11/08/07 20:18:04 (1 year ago)
- Files:
-
- devel/lib/templates.php (modified) (2 diffs)
- devel/mod/blog/default_template.php (modified) (1 diff)
- devel/mod/commentwall/lib.php (modified) (1 diff)
- devel/mod/community/default_template.php (modified) (1 diff)
- devel/mod/contenttoolbar/default_template.php (modified) (1 diff)
- devel/mod/friend/default_template.php (modified) (1 diff)
- devel/mod/generic_comments/lib.php (modified) (1 diff)
- devel/mod/widget/init.php (modified) (1 diff)
- devel/units/templates/default_template.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
devel/lib/templates.php
r1251 r1278 681 681 $template_name = $t; 682 682 } 683 684 // TODO: Load templates on demand with backward compatibility 685 templates_load_context($parameter['context']); 683 686 684 687 // Grab the template content … … 1506 1509 } 1507 1510 1511 /** 1512 * Adds new template context 1513 * @param string $context Context identificator 1514 * @param string $tpl Template path relative to dirroot or inline template 1515 * @param bool $is_file Template is file or inline 1516 * @param bool $override To override existing context 1517 */ 1518 function templates_add_context($context, $tpl, $is_file=true, $override=false) { 1519 // TODO: this function should go int mod's? 1520 global $template, $template_files, $CFG; 1521 1522 if (!isset($template)) $template = array(); 1523 if (!isset($template_files)) $template_files = array(); 1524 1525 if (!empty($context)) { 1526 // clean file path string 1527 if ($is_file) { 1528 // FIXME: backward compatiblity, allow templatesroot full path 1529 if (substr_count($tpl, $CFG->templatesroot) > 0) { 1530 $file_path = $tpl; 1531 } else { 1532 //$file_path = $CFG->dirroot . clean_filename($tpl); 1533 // clean_filename replaces / directory separator 1534 $file_path = $CFG->dirroot . $tpl; 1535 } 1536 } 1537 1538 if ($is_file) { 1539 if ($override) { 1540 $template_files[$context] = array(); 1541 } 1542 1543 $template_files[$context][] = $file_path; 1544 } else { 1545 // inline template, backwards compatibility 1546 if (!$override && isset($template[$context])) { 1547 // append to existing context 1548 $template[$context] .= $tpl; 1549 } else { 1550 $template[$context] = $tpl; 1551 } 1552 } 1553 } 1554 } 1555 1556 /** 1557 * Load context if template is file 1558 * @param string $context Context identificator 1559 */ 1560 function templates_load_context($context) { 1561 // TOOD: review check 1562 // currently check if starts with $CFG->dirrot and is file readable 1563 global $template, $template_files, $CFG; 1564 1565 static $loaded; 1566 1567 if (!isset($loaded)) $loaded = array(); 1568 if (!isset($template)) $template = array(); 1569 if (!isset($template_files)) $template_files = array(); 1570 1571 if (!isset($loaded[$context])) { 1572 if (isset($template_files[$context])) { 1573 if (!isset($template[$context])) { 1574 $template[$context] = ''; 1575 } 1576 1577 // load templates from files 1578 foreach ($template_files[$context] as $k => $tpl) { 1579 // TODO: check again if is readable? 1580 $template[$context] .= @file_get_contents($tpl); 1581 //print_object('Loaded: ' . $tpl); 1582 } 1583 } else { 1584 // do nothing if not file 1585 } 1586 1587 $loaded[$context] = true; 1588 } 1589 } 1508 1590 1509 1591 ?> devel/mod/blog/default_template.php
r1079 r1278 47 47 ); 48 48 49 $template['weblogpost'] = file_get_contents(dirname(__FILE__)."/templates/blog_post.html");50 $template['weblogcomments'] = file_get_contents(dirname(__FILE__)."/templates/blog_comments.html");51 $template['weblogcomment'] = file_get_contents(dirname(__FILE__)."/templates/blog_comment.html");49 templates_add_context('weblogpost', 'mod/blog/templates/blog_post.html'); 50 templates_add_context('weblogcomments', 'mod/blog/templates/blog_comments.html'); 51 templates_add_context('weblogcomment', 'mod/blog/templates/blog_comment.html'); 52 52 ?> devel/mod/commentwall/lib.php
r1277 r1278 19 19 20 20 // Define some templates 21 $template['commentwallobject'] = file_get_contents($CFG->dirroot . "mod/commentwall/template");22 $template['commentwallfooter'] = file_get_contents($CFG->dirroot . "mod/commentwall/footer");23 $template['css'] .= file_get_contents($CFG->dirroot . "mod/commentwall/css");21 templates_add_context('commentwallobject', 'mod/commentwall/template'); 22 templates_add_context('commentwallfooter', 'mod/commentwall/footer'); 23 templates_add_context('css', 'mod/commentwall/css'); 24 24 25 25 // Set up the database devel/mod/community/default_template.php
r1080 r1278 53 53 ); 54 54 55 $template["community_members"] = "<div id=\"networktable\"><table width=\"80%\" cellspacing=\"5\"><tr>{{members}}</tr></table></div>";56 $template["community_member"] = file_get_contents(dirname(__FILE__)."/templates/community_member_view.html");57 $template["community_membership"] = file_get_contents(dirname(__FILE__)."/templates/community_membership_view.html");58 $template["community_create"] = file_get_contents(dirname(__FILE__)."/templates/community_create.html");55 templates_add_context('community_members', "<div id=\"networktable\"><table width=\"80%\" cellspacing=\"5\"><tr>{{members}}</tr></table></div>", false); 56 templates_add_context('community_member', 'mod/community/templates/community_member_view.html'); 57 templates_add_context('community_membership', 'mod/community/templates/community_membership_view.html'); 58 templates_add_context('community_create', 'mod/community/templates/community_create.html'); 59 59 60 60 ?> devel/mod/contenttoolbar/default_template.php
r1081 r1278 40 40 ); 41 41 42 $template["contenttoolbar"] = file_get_contents(dirname(__FILE__)."/templates/contenttoolbar.html");43 $template["video_wizard"] = file_get_contents(dirname(__FILE__)."/templates/video_wizard.html");42 templates_add_context('contenttoolbar', 'mod/contenttoolbar/templates/contenttoolbar.html'); 43 templates_add_context('video_wizard', 'mod/contenttoolbar/templates/video_wizard.html'); 44 44 ?> devel/mod/friend/default_template.php
r1248 r1278 31 31 ); 32 32 33 $template['friends_friends'] = "<div id=\"networktable\"><table width=\"80%\" cellspacing=\"5\"><tr>{{friends}}</tr></table></div>";34 $template['friends_friend'] = file_get_contents(dirname(__FILE__)."/templates/friends_friend.html");33 templates_add_context('friends_friends', "<div id=\"networktable\"><table width=\"80%\" cellspacing=\"5\"><tr>{{friends}}</tr></table></div>", false); 34 templates_add_context('friends_friend', 'mod/friend/templates/friends_friend.html'); 35 35 ?> devel/mod/generic_comments/lib.php
r1185 r1278 30 30 river_register_friendlyname_hook('file::file', 'generic_comments_get_friendly_name'); 31 31 } 32 $template['embeddedcomments'] = file_get_contents($CFG->dirroot . "mod/generic_comments/comments"); 33 $template['embeddedcomment'] = file_get_contents($CFG->dirroot . "mod/generic_comments/comment"); 34 35 $template['css'] .= file_get_contents($CFG->dirroot . "mod/generic_comments/css"); 32 templates_add_context('embeddedcomments', 'mod/generic_comments/comments'); 33 templates_add_context('embeddedcomment', 'mod/generic_comments/comment'); 34 templates_add_context('css', 'mod/generic_comments/css', true, false); 36 35 37 36 } devel/mod/widget/init.php
r1030 r1278 2 2 3 3 global $CFG, $template; 4 $template['css'] .= file_get_contents($CFG->dirroot . "mod/widget/css");4 templates_add_context('css', 'mod/widget/css'); 5 5 6 6 ?> devel/units/templates/default_template.php
r1110 r1278 13 13 ); 14 14 15 $template['css'] = file_get_contents($CFG->templatesroot . "Default_Template/css");15 templates_add_context('css', $CFG->templatesroot . 'Default_Template/css'); 16 16 17 17 $template_definition[] = array( … … 30 30 ); 31 31 32 $template['pageshell'] = file_get_contents($CFG->templatesroot . "Default_Template/pageshell");33 34 $template['frontpage_loggedout'] = file_get_contents($CFG->templatesroot . "Default_Template/frontpage_loggedout");35 $template['frontpage_loggedin'] = file_get_contents($CFG->templatesroot . "Default_Template/frontpage_loggedin");32 templates_add_context('pageshell', $CFG->templatesroot . 'Default_Template/pageshell'); 33 34 templates_add_context('frontpage_loggedout', $CFG->templatesroot . 'Default_Template/frontpage_loggedout'); 35 templates_add_context('frontpage_loggedin', $CFG->templatesroot . 'Default_Template/frontpage_loggedin'); 36 36 37 37 $template_definition[] = array(
