Changeset 1107:3943962d69b8 for inc/public
- Timestamp:
- 02/27/13 11:48:32 (13 years ago)
- Branch:
- sexy
- Parents:
- 880:02c78f56f430 (diff), 1105:ce855d61f9ce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- inc/public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/public/class.dc.template.php
r851 r1107 68 68 $this->addValue('BlogMetaRobots',array($this,'BlogMetaRobots')); 69 69 70 70 71 # Entries 71 72 $this->addBlock('DateFooter',array($this,'DateFooter')); … … 122 123 $this->addValue('SysSearchString',array($this,'SysSearchString')); 123 124 $this->addValue('SysSelfURI',array($this,'SysSelfURI')); 125 126 # Generic 127 $this->addValue('else',array($this,'GenericElse')); 124 128 } 125 129 … … 305 309 $p[2] = '0'; # cut_string 306 310 $p[3] = '0'; # lower_case 307 $p[4] = '0'; # upper_case 311 $p[4] = '0'; # upper_case or capitalize 308 312 309 313 $p[0] = (integer) (!empty($attr['encode_xml']) || !empty($attr['encode_html'])); … … 316 320 $p[3] = (integer) !empty($attr['lower_case']); 317 321 $p[4] = (integer) !empty($attr['upper_case']); 322 $p[4] = (!empty($attr['capitalize']) ? 2 : $p[4]); 318 323 319 324 return "context::global_filter(%s,".implode(",",$p).",'".addslashes($this->current_tag)."')"; … … 397 402 } 398 403 399 public function getAge($attr)404 public static function getAge($attr) 400 405 { 401 406 if (isset($attr['age']) && preg_match('/^(\-[0-9]+|last).*$/i',$attr['age'])) { … … 819 824 return "<?php echo context::robotsPolicy(\$core->blog->settings->system->robots_policy,'".$robots."'); ?>"; 820 825 } 826 827 821 828 822 829 /* Entries -------------------------------------------- */ … … 965 972 selected (0|1) #IMPLIED -- post is selected (value : 1) or not (value : 0) 966 973 has_attachment (0|1) #IMPLIED -- post has attachments (value : 1) or not (value : 0) (see Attachment plugin for code) 974 republished (0|1) #IMPLIED -- post has been updated since publication (value : 1) or not (value : 0) 967 975 operator (and|or) #IMPLIED -- combination of conditions, if more than 1 specifiec (default: and) 968 976 url CDATA #IMPLIED -- post has given url … … 1012 1020 } 1013 1021 1022 if (isset($attr['republished'])) { 1023 $sign = (boolean) $attr['republished'] ? '' : '!'; 1024 $if[] = $sign.'(boolean)$_ctx->posts->isRepublished()'; 1025 } 1026 1014 1027 $this->core->callBehavior('tplIfConditions','EntryIf',$attr,$content,$if); 1015 1028 … … 1199 1212 size (sq|t|s|m|o) #IMPLIED -- Image size to extract 1200 1213 class CDATA #IMPLIED -- Class to add on image tag 1214 1201 1215 > 1202 1216 */ … … 1205 1219 $size = !empty($attr['size']) ? $attr['size'] : ''; 1206 1220 $class = !empty($attr['class']) ? $attr['class'] : ''; 1207 $with_category = !empty($attr['with_category']) ? 'true' : 'false';1208 1221 1209 1222 return "<?php echo context::EntryFirstImageHelper('".addslashes($size)."','".addslashes($class)."'); ?>"; … … 1588 1601 current_mode CDATA #IMPLIED -- tests if current URL mode is the one given in parameter 1589 1602 has_tpl CDATA #IMPLIED -- tests if a named template exists 1590 has_tag CDATA #IMPLIED -- tests if a named template tag exists (see Tag plugin for code)1603 has_tag CDATA #IMPLIED -- tests if a named template block or value exists 1591 1604 blog_id CDATA #IMPLIED -- tests if current blog ID is the one given in parameter 1592 1605 operator (and|or) #IMPLIED -- combination of conditions, if more than 1 specifiec (default: and) … … 1636 1649 } 1637 1650 1651 if (isset($attr['has_tag'])) { 1652 $sign = 'true'; 1653 if (substr($attr['has_tag'],0,1) == '!') { 1654 $sign = 'false'; 1655 $attr['has_tag'] = substr($attr['has_tag'],1); 1656 } 1657 $if[] = "\$core->tpl->tagExists('".addslashes($attr['has_tag'])."') === ".$sign; 1658 } 1659 1638 1660 if (isset($attr['blog_id'])) { 1639 1661 $sign = ''; … … 1680 1702 1681 1703 /*dtd 1682 <!ELEMENT tpl:Sys IfFormError - O -- Form error -->1704 <!ELEMENT tpl:SysFormError - O -- Form error --> 1683 1705 */ 1684 1706 public function SysFormError($attr) … … 1706 1728 $f = $this->getFilters($attr); 1707 1729 return '<?php echo '.sprintf($f,'http::getSelfURI()').'; ?>'; 1730 } 1731 1732 /*dtd 1733 <!ELEMENT tpl:else - O -- else: statement --> 1734 */ 1735 public function GenericElse($attr) 1736 { 1737 return '<?php else: ?>'; 1708 1738 } 1709 1739 } -
inc/public/class.dc.template.php
r980 r1107 32 32 $this->core =& $core; 33 33 34 # Transitional tags35 $this->addValue('EntryTrackbackCount',array($this,'EntryPingCount'));36 $this->addValue('EntryTrackbackData',array($this,'EntryPingData'));37 $this->addValue('EntryTrackbackLink',array($this,'EntryPingLink'));38 39 34 # l10n 40 35 $this->addValue('lang',array($this,'l10n')); … … 73 68 $this->addValue('BlogMetaRobots',array($this,'BlogMetaRobots')); 74 69 75 # Categories 76 $this->addBlock('Categories',array($this,'Categories')); 77 $this->addBlock('CategoriesHeader',array($this,'CategoriesHeader')); 78 $this->addBlock('CategoriesFooter',array($this,'CategoriesFooter')); 79 $this->addBlock('CategoryIf',array($this,'CategoryIf')); 80 $this->addBlock('CategoryFirstChildren',array($this,'CategoryFirstChildren')); 81 $this->addBlock('CategoryParents',array($this,'CategoryParents')); 82 $this->addValue('CategoryFeedURL',array($this,'CategoryFeedURL')); 83 $this->addValue('CategoryURL',array($this,'CategoryURL')); 84 $this->addValue('CategoryShortURL',array($this,'CategoryShortURL')); 85 $this->addValue('CategoryDescription',array($this,'CategoryDescription')); 86 $this->addValue('CategoryTitle',array($this,'CategoryTitle')); 87 $this->addValue('CategoryEntriesCount',array($this,'CategoryEntriesCount')); 88 89 # Comments 90 $this->addBlock('Comments',array($this,'Comments')); 91 $this->addValue('CommentAuthor',array($this,'CommentAuthor')); 92 $this->addValue('CommentAuthorDomain',array($this,'CommentAuthorDomain')); 93 $this->addValue('CommentAuthorLink',array($this,'CommentAuthorLink')); 94 $this->addValue('CommentAuthorMailMD5',array($this,'CommentAuthorMailMD5')); 95 $this->addValue('CommentAuthorURL',array($this,'CommentAuthorURL')); 96 $this->addValue('CommentContent',array($this,'CommentContent')); 97 $this->addValue('CommentDate',array($this,'CommentDate')); 98 $this->addValue('CommentTime',array($this,'CommentTime')); 99 $this->addValue('CommentEmail',array($this,'CommentEmail')); 100 $this->addValue('CommentEntryTitle',array($this,'CommentEntryTitle')); 101 $this->addValue('CommentFeedID',array($this,'CommentFeedID')); 102 $this->addValue('CommentID',array($this,'CommentID')); 103 $this->addBlock('CommentIf',array($this,'CommentIf')); 104 $this->addValue('CommentIfFirst',array($this,'CommentIfFirst')); 105 $this->addValue('CommentIfMe',array($this,'CommentIfMe')); 106 $this->addValue('CommentIfOdd',array($this,'CommentIfOdd')); 107 $this->addValue('CommentIP',array($this,'CommentIP')); 108 $this->addValue('CommentOrderNumber',array($this,'CommentOrderNumber')); 109 $this->addBlock('CommentsFooter',array($this,'CommentsFooter')); 110 $this->addBlock('CommentsHeader',array($this,'CommentsHeader')); 111 $this->addValue('CommentPostURL',array($this,'CommentPostURL')); 112 $this->addBlock('IfCommentAuthorEmail',array($this,'IfCommentAuthorEmail')); 113 $this->addValue('CommentHelp',array($this,'CommentHelp')); 114 115 # Comment preview 116 $this->addBlock('IfCommentPreview',array($this,'IfCommentPreview')); 117 $this->addValue('CommentPreviewName',array($this,'CommentPreviewName')); 118 $this->addValue('CommentPreviewEmail',array($this,'CommentPreviewEmail')); 119 $this->addValue('CommentPreviewSite',array($this,'CommentPreviewSite')); 120 $this->addValue('CommentPreviewContent',array($this,'CommentPreviewContent')); 121 $this->addValue('CommentPreviewCheckRemember',array($this,'CommentPreviewCheckRemember')); 122 70 123 71 # Entries 124 72 $this->addBlock('DateFooter',array($this,'DateFooter')); … … 135 83 $this->addValue('EntryAuthorURL',array($this,'EntryAuthorURL')); 136 84 $this->addValue('EntryBasename',array($this,'EntryBasename')); 137 $this->addValue('EntryCategory',array($this,'EntryCategory'));138 $this->addBlock('EntryCategoriesBreadcrumb',array($this,'EntryCategoriesBreadcrumb'));139 $this->addValue('EntryCategoryID',array($this,'EntryCategoryID'));140 $this->addValue('EntryCategoryURL',array($this,'EntryCategoryURL'));141 $this->addValue('EntryCategoryShortURL',array($this,'EntryCategoryShortURL'));142 $this->addValue('EntryCommentCount',array($this,'EntryCommentCount'));143 85 $this->addValue('EntryContent',array($this,'EntryContent')); 144 86 $this->addValue('EntryDate',array($this,'EntryDate')); … … 152 94 $this->addValue('EntryLang',array($this,'EntryLang')); 153 95 $this->addBlock('EntryNext',array($this,'EntryNext')); 154 $this->addValue('EntryPingCount',array($this,'EntryPingCount'));155 $this->addValue('EntryPingData',array($this,'EntryPingData'));156 $this->addValue('EntryPingLink',array($this,'EntryPingLink'));157 96 $this->addBlock('EntryPrevious',array($this,'EntryPrevious')); 158 97 $this->addValue('EntryTitle',array($this,'EntryTitle')); … … 175 114 $this->addValue('PaginationURL',array($this,'PaginationURL')); 176 115 177 # Trackbacks178 $this->addValue('PingBlogName',array($this,'PingBlogName'));179 $this->addValue('PingContent',array($this,'PingContent'));180 $this->addValue('PingDate',array($this,'PingDate'));181 $this->addValue('PingEntryTitle',array($this,'PingEntryTitle'));182 $this->addValue('PingFeedID',array($this,'PingFeedID'));183 $this->addValue('PingID',array($this,'PingID'));184 $this->addValue('PingIfFirst',array($this,'PingIfFirst'));185 $this->addValue('PingIfOdd',array($this,'PingIfOdd'));186 $this->addValue('PingIP',array($this,'PingIP'));187 $this->addValue('PingNoFollow',array($this,'PingNoFollow'));188 $this->addValue('PingOrderNumber',array($this,'PingOrderNumber'));189 $this->addValue('PingPostURL',array($this,'PingPostURL'));190 $this->addBlock('Pings',array($this,'Pings'));191 $this->addBlock('PingsFooter',array($this,'PingsFooter'));192 $this->addBlock('PingsHeader',array($this,'PingsHeader'));193 $this->addValue('PingTime',array($this,'PingTime'));194 $this->addValue('PingTitle',array($this,'PingTitle'));195 $this->addValue('PingAuthorURL',array($this,'PingAuthorURL'));196 197 116 # System 198 117 $this->addValue('SysBehavior',array($this,'SysBehavior')); 199 118 $this->addBlock('SysIf',array($this,'SysIf')); 200 $this->addBlock('SysIfCommentPublished',array($this,'SysIfCommentPublished'));201 $this->addBlock('SysIfCommentPending',array($this,'SysIfCommentPending'));202 119 $this->addBlock('SysIfFormError',array($this,'SysIfFormError')); 203 120 $this->addValue('SysFeedSubtitle',array($this,'SysFeedSubtitle')); … … 435 352 'date' => 'post_dt', 436 353 'id' => 'post_id', 437 'comment' => 'nb_comment',438 'trackback' => 'nb_trackback'439 ),440 'comment' => array(441 'author' => 'comment_author',442 'date' => 'comment_dt',443 'id' => 'comment_id'444 354 ) 445 355 ); … … 535 445 <!ATTLIST tpl:Archives 536 446 type (day|month|year) #IMPLIED -- Get days, months or years, default to month -- 537 category CDATA #IMPLIED -- Get dates of given category --538 447 no_context (1|0) #IMPLIED -- Override context information 539 448 order (asc|desc) #IMPLIED -- Sort asc or desc -- … … 550 459 } 551 460 552 if (isset($attr['category'])) {553 $p .= "\$params['cat_url'] = '".addslashes($attr['category'])."';\n";554 }555 556 461 if (isset($attr['post_type'])) { 557 462 $p .= "\$params['post_type'] = '".addslashes($attr['post_type'])."';\n"; … … 560 465 if (isset($attr['post_lang'])) { 561 466 $p .= "\$params['post_lang'] = '".addslashes($attr['post_lang'])."';\n"; 562 }563 564 if (empty($attr['no_context']) && !isset($attr['category']))565 {566 $p .=567 'if ($_ctx->exists("categories")) { '.568 "\$params['cat_id'] = \$_ctx->categories->cat_id; ".569 "}\n";570 467 } 571 468 … … 928 825 } 929 826 930 /* Categories ----------------------------------------- */931 932 /*dtd933 <!ELEMENT tpl:Categories - - -- Categories loop -->934 */935 public function Categories($attr,$content)936 {937 $p = "if (!isset(\$params)) \$params = array();\n";938 939 if (isset($attr['url'])) {940 $p .= "\$params['cat_url'] = '".addslashes($attr['url'])."';\n";941 }942 943 if (!empty($attr['post_type'])) {944 $p .= "\$params['post_type'] = '".addslashes($attr['post_type'])."';\n";945 }946 947 if (!empty($attr['level'])) {948 $p .= "\$params['level'] = ".(integer) $attr['level'].";\n";949 }950 951 $res = "<?php\n";952 $res .= $p;953 $res .= $this->core->callBehavior("templatePrepareParams",954 array("tag" => "Categories","method" => "blog::getCategories"),955 $attr,$content);956 $res .= '$_ctx->categories = $core->blog->getCategories($params);'."\n";957 $res .= "?>\n";958 $res .= '<?php while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; unset($params); ?>';959 960 return $res;961 }962 963 /*dtd964 <!ELEMENT tpl:CategoriesHeader - - -- First Categories result container -->965 */966 public function CategoriesHeader($attr,$content)967 {968 return969 "<?php if (\$_ctx->categories->isStart()) : ?>".970 $content.971 "<?php endif; ?>";972 }973 974 /*dtd975 <!ELEMENT tpl:CategoriesFooter - - -- Last Categories result container -->976 */977 public function CategoriesFooter($attr,$content)978 {979 return980 "<?php if (\$_ctx->categories->isEnd()) : ?>".981 $content.982 "<?php endif; ?>";983 }984 985 /*dtd986 <!ELEMENT tpl:CategoryIf - - -- tests on current entry -->987 <!ATTLIST tpl:CategoryIf988 url CDATA #IMPLIED -- category has given url989 has_entries (0|1) #IMPLIED -- post is the first post from list (value : 1) or not (value : 0)990 has_description (0|1) #IMPLIED -- category has description (value : 1) or not (value : 0)991 >992 */993 public function CategoryIf($attr,$content)994 {995 $if = new ArrayObject();996 $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&';997 998 if (isset($attr['url'])) {999 $url = addslashes(trim($attr['url']));1000 if (substr($url,0,1) == '!') {1001 $url = substr($url,1);1002 $if[] = '($_ctx->categories->cat_url != "'.$url.'")';1003 } else {1004 $if[] = '($_ctx->categories->cat_url == "'.$url.'")';1005 }1006 }1007 1008 if (isset($attr['has_entries'])) {1009 $sign = (boolean) $attr['has_entries'] ? '>' : '==';1010 $if[] = '$_ctx->categories->nb_post '.$sign.' 0';1011 }1012 1013 if (isset($attr['has_description'])) {1014 $sign = (boolean) $attr['has_description'] ? '!=' : '==';1015 $if[] = '$_ctx->categories->cat_desc '.$sign.' ""';1016 }1017 1018 $this->core->callBehavior('tplIfConditions','CategoryIf',$attr,$content,$if);1019 1020 if (count($if) != 0) {1021 return '<?php if('.implode(' '.$operator.' ', (array) $if).') : ?>'.$content.'<?php endif; ?>';1022 } else {1023 return $content;1024 }1025 }1026 1027 /*dtd1028 <!ELEMENT tpl:CategoryFirstChildren - - -- Current category first children loop -->1029 */1030 public function CategoryFirstChildren($attr,$content)1031 {1032 return1033 "<?php\n".1034 '$_ctx->categories = $core->blog->getCategoryFirstChildren($_ctx->categories->cat_id);'."\n".1035 'while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; ?>';1036 }1037 1038 /*dtd1039 <!ELEMENT tpl:CategoryParents - - -- Current category parents loop -->1040 */1041 public function CategoryParents($attr,$content)1042 {1043 return1044 "<?php\n".1045 '$_ctx->categories = $core->blog->getCategoryParents($_ctx->categories->cat_id);'."\n".1046 'while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; ?>';1047 }1048 1049 /*dtd1050 <!ELEMENT tpl:CategoryFeedURL - O -- Category feed URL -->1051 <!ATTLIST tpl:CategoryFeedURL1052 type (rss2|atom) #IMPLIED -- feed type (default : rss2)1053 >1054 */1055 public function CategoryFeedURL($attr)1056 {1057 $type = !empty($attr['type']) ? $attr['type'] : 'atom';1058 1059 if (!preg_match('#^(rss2|atom)$#',$type)) {1060 $type = 'atom';1061 }1062 1063 $f = $this->getFilters($attr);1064 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("feed","category/".'.1065 '$_ctx->categories->cat_url."/'.$type.'")').'; ?>';1066 }1067 1068 /*dtd1069 <!ELEMENT tpl:CategoryURL - O -- Category URL (complete iabsolute URL, including blog URL) -->1070 */1071 public function CategoryURL($attr)1072 {1073 $f = $this->getFilters($attr);1074 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("category",'.1075 '$_ctx->categories->cat_url)').'; ?>';1076 }1077 1078 /*dtd1079 <!ELEMENT tpl:CategoryShortURL - O -- Category short URL (relative URL, from /category/) -->1080 */1081 public function CategoryShortURL($attr)1082 {1083 $f = $this->getFilters($attr);1084 return '<?php echo '.sprintf($f,'$_ctx->categories->cat_url').'; ?>';1085 }1086 1087 /*dtd1088 <!ELEMENT tpl:CategoryDescription - O -- Category description -->1089 */1090 public function CategoryDescription($attr)1091 {1092 $f = $this->getFilters($attr);1093 return '<?php echo '.sprintf($f,'$_ctx->categories->cat_desc').'; ?>';1094 }1095 1096 /*dtd1097 <!ELEMENT tpl:CategoryTitle - O -- Category title -->1098 */1099 public function CategoryTitle($attr)1100 {1101 $f = $this->getFilters($attr);1102 return '<?php echo '.sprintf($f,'$_ctx->categories->cat_title').'; ?>';1103 }1104 827 1105 /*dtd1106 <!ELEMENT tpl:CategoryEntriesCount - O -- Category number of entries -->1107 */1108 public function CategoryEntriesCount($attr)1109 {1110 $f = $this->getFilters($attr);1111 return '<?php echo '.sprintf($f,'$_ctx->categories->nb_post').'; ?>';1112 }1113 828 1114 829 /* Entries -------------------------------------------- */ … … 1118 833 lastn CDATA #IMPLIED -- limit number of results to specified value 1119 834 author CDATA #IMPLIED -- get entries for a given user id 1120 category CDATA #IMPLIED -- get entries for specific categories only (multiple comma-separated categories can be specified. Use "!" as prefix to exclude a category)1121 no_category CDATA #IMPLIED -- get entries without category1122 835 no_context (1|0) #IMPLIED -- Override context information 1123 836 sortby (title|selected|author|date|id) #IMPLIED -- specify entries sort criteria (default : date) (multiple comma-separated sortby can be specified. Use "?asc" or "?desc" as suffix to provide an order for each sorby) … … 1158 871 } 1159 872 1160 if (isset($attr['category'])) {1161 $p .= "\$params['cat_url'] = '".addslashes($attr['category'])."';\n";1162 $p .= "context::categoryPostParam(\$params);\n";1163 }1164 1165 if (isset($attr['no_category']) && $attr['no_category']) {1166 $p .= "@\$params['sql'] .= ' AND P.cat_id IS NULL ';\n";1167 $p .= "unset(\$params['cat_url']);\n";1168 }1169 1170 873 if (!empty($attr['type'])) { 1171 874 $p .= "\$params['post_type'] = preg_split('/\s*,\s*/','".addslashes($attr['type'])."',-1,PREG_SPLIT_NO_EMPTY);\n"; … … 1183 886 'if ($_ctx->exists("users")) { '. 1184 887 "\$params['user_id'] = \$_ctx->users->user_id; ". 1185 "}\n";1186 }1187 1188 if (!isset($attr['category']) && (!isset($attr['no_category']) || !$attr['no_category']))1189 {1190 $p .=1191 'if ($_ctx->exists("categories")) { '.1192 "\$params['cat_id'] = \$_ctx->categories->cat_id; ".1193 888 "}\n"; 1194 889 } … … 1271 966 <!ATTLIST tpl:EntryIf 1272 967 type CDATA #IMPLIED -- post has a given type (default: "post") 1273 category CDATA #IMPLIED -- post has a given category1274 968 first (0|1) #IMPLIED -- post is the first post from list (value : 1) or not (value : 0) 1275 969 odd (0|1) #IMPLIED -- post is in an odd position (value : 1) or not (value : 0) … … 1277 971 extended (0|1) #IMPLIED -- post has an excerpt (value : 1) or not (value : 0) 1278 972 selected (0|1) #IMPLIED -- post is selected (value : 1) or not (value : 0) 1279 has_category (0|1) #IMPLIED -- post has a category (value : 1) or not (value : 0)1280 973 has_attachment (0|1) #IMPLIED -- post has attachments (value : 1) or not (value : 0) (see Attachment plugin for code) 1281 comments_active (0|1) #IMPLIED -- comments are active for this post (value : 1) or not (value : 0)1282 pings_active (0|1) #IMPLIED -- trackbacks are active for this post (value : 1) or not (value : 0)1283 show_comments (0|1) #IMPLIED -- there are comments for this post (value : 1) or not (value : 0)1284 show_pings (0|1) #IMPLIED -- there are trackbacks for this post (value : 1) or not (value : 0)1285 974 republished (0|1) #IMPLIED -- post has been updated since publication (value : 1) or not (value : 0) 1286 975 operator (and|or) #IMPLIED -- combination of conditions, if more than 1 specifiec (default: and) … … 1292 981 $if = new ArrayObject(); 1293 982 $extended = null; 1294 $hascategory = null;1295 983 1296 984 $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&'; … … 1312 1000 } 1313 1001 1314 if (isset($attr['category'])) {1315 $category = addslashes(trim($attr['category']));1316 if (substr($category,0,1) == '!') {1317 $category = substr($category,1);1318 $if[] = '($_ctx->posts->cat_url != "'.$category.'")';1319 } else {1320 $if[] = '($_ctx->posts->cat_url == "'.$category.'")';1321 }1322 }1323 1324 1002 if (isset($attr['first'])) { 1325 1003 $sign = (boolean) $attr['first'] ? '=' : '!'; … … 1342 1020 } 1343 1021 1344 if (isset($attr['has_category'])) {1345 $sign = (boolean) $attr['has_category'] ? '' : '!';1346 $if[] = $sign.'$_ctx->posts->cat_id';1347 }1348 1349 if (isset($attr['comments_active'])) {1350 $sign = (boolean) $attr['comments_active'] ? '' : '!';1351 $if[] = $sign.'$_ctx->posts->commentsActive()';1352 }1353 1354 if (isset($attr['pings_active'])) {1355 $sign = (boolean) $attr['pings_active'] ? '' : '!';1356 $if[] = $sign.'$_ctx->posts->trackbacksActive()';1357 }1358 1359 if (isset($attr['has_comment'])) {1360 $sign = (boolean) $attr['has_comment'] ? '' : '!';1361 $if[] = $sign.'$_ctx->posts->hasComments()';1362 }1363 1364 if (isset($attr['has_ping'])) {1365 $sign = (boolean) $attr['has_ping'] ? '' : '!';1366 $if[] = $sign.'$_ctx->posts->hasTrackbacks()';1367 }1368 1369 if (isset($attr['show_comments'])) {1370 if ((boolean) $attr['show_comments']) {1371 $if[] = '($_ctx->posts->hasComments() || $_ctx->posts->commentsActive())';1372 } else {1373 $if[] = '(!$_ctx->posts->hasComments() && !$_ctx->posts->commentsActive())';1374 }1375 }1376 1377 if (isset($attr['show_pings'])) {1378 if ((boolean) $attr['show_pings']) {1379 $if[] = '($_ctx->posts->hasTrackbacks() || $_ctx->posts->trackbacksActive())';1380 } else {1381 $if[] = '(!$_ctx->posts->hasTrackbacks() && !$_ctx->posts->trackbacksActive())';1382 }1383 }1384 1385 1022 if (isset($attr['republished'])) { 1386 1023 $sign = (boolean) $attr['republished'] ? '' : '!'; … … 1392 1029 if (count($if) != 0) { 1393 1030 return '<?php if('.implode(' '.$operator.' ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; 1394 } else { 1031 } /* 1032 else { 1033 // Nothing in if statement => do not display content... 1395 1034 return $content; 1396 1035 } 1036 */ 1397 1037 } 1398 1038 … … 1559 1199 1560 1200 /*dtd 1561 <!ELEMENT tpl:EntryCategory - O -- Entry category (full name) -->1562 */1563 public function EntryCategory($attr)1564 {1565 $f = $this->getFilters($attr);1566 return '<?php echo '.sprintf($f,'$_ctx->posts->cat_title').'; ?>';1567 }1568 1569 /*dtd1570 <!ELEMENT tpl:EntryCategoriesBreadcrumb - - -- Current entry parents loop (without last one) -->1571 */1572 public function EntryCategoriesBreadcrumb($attr,$content)1573 {1574 return1575 "<?php\n".1576 '$_ctx->categories = $core->blog->getCategoryParents($_ctx->posts->cat_id);'."\n".1577 'while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; ?>';1578 }1579 1580 /*dtd1581 <!ELEMENT tpl:EntryCategoryID - O -- Entry category ID -->1582 */1583 public function EntryCategoryID($attr)1584 {1585 $f = $this->getFilters($attr);1586 return '<?php echo '.sprintf($f,'$_ctx->posts->cat_id').'; ?>';1587 }1588 1589 /*dtd1590 <!ELEMENT tpl:EntryCategoryURL - O -- Entry category URL -->1591 */1592 public function EntryCategoryURL($attr)1593 {1594 $f = $this->getFilters($attr);1595 return '<?php echo '.sprintf($f,'$_ctx->posts->getCategoryURL()').'; ?>';1596 }1597 1598 /*dtd1599 <!ELEMENT tpl:EntryCategoryShortURL - O -- Entry category short URL (relative URL, from /category/) -->1600 */1601 public function EntryCategoryShortURL($attr)1602 {1603 $f = $this->getFilters($attr);1604 return '<?php echo '.sprintf($f,'$_ctx->posts->cat_url').'; ?>';1605 }1606 1607 1608 /*dtd1609 1201 <!ELEMENT tpl:EntryFeedID - O -- Entry feed ID --> 1610 1202 */ … … 1620 1212 size (sq|t|s|m|o) #IMPLIED -- Image size to extract 1621 1213 class CDATA #IMPLIED -- Class to add on image tag 1622 with_category (1|0) #IMPLIED -- Search in entry category description if present (default 0) 1623 no_tag (1|0) #IMPLIED -- Return image URL without HTML tag (default 0) 1624 content_only (1|0) #IMPLIED -- Search in content entry only, not in excerpt (default 0) 1625 cat_only (1|0) #IMPLIED -- Search in category description only (default 0) 1214 1626 1215 > 1627 1216 */ … … 1630 1219 $size = !empty($attr['size']) ? $attr['size'] : ''; 1631 1220 $class = !empty($attr['class']) ? $attr['class'] : ''; 1632 $with_category = !empty($attr['with_category']) ? 1 : 0; 1633 $no_tag = !empty($attr['no_tag']) ? 1 : 0; 1634 $content_only = !empty($attr['content_only']) ? 1 : 0; 1635 $cat_only = !empty($attr['cat_only']) ? 1 : 0; 1636 1637 return "<?php echo context::EntryFirstImageHelper('".addslashes($size)."',".$with_category.",'".addslashes($class)."',". 1638 $no_tag.",".$content_only.",".$cat_only."); ?>"; 1221 1222 return "<?php echo context::EntryFirstImageHelper('".addslashes($size)."','".addslashes($class)."'); ?>"; 1639 1223 } 1640 1224 … … 1665 1249 <!ELEMENT tpl:EntryNext - - -- Next entry block --> 1666 1250 <!ATTLIST tpl:EntryNext 1667 restrict_to_category (0|1) #IMPLIED -- find next post in the same category (default: 0)1668 1251 restrict_to_lang (0|1) #IMPLIED -- find next post in the same language (default: 0) 1669 1252 > … … 1803 1386 } 1804 1387 1805 /*dtd1806 <!ELEMENT tpl:EntryCommentCount - O -- Number of comments for entry -->1807 <!ATTLIST tpl:EntryCommentCount1808 none CDATA #IMPLIED -- text to display for "no comment" (default: no comment)1809 one CDATA #IMPLIED -- text to display for "one comment" (default: one comment)1810 more CDATA #IMPLIED -- text to display for "more comments" (default: %s comments, %s is replaced by the number of comment)1811 count_all CDATA #IMPLIED -- count comments and trackbacks1812 >1813 */1814 public function EntryCommentCount($attr)1815 {1816 $none = 'no comment';1817 $one = 'one comment';1818 $more = '%d comments';1819 1820 if (isset($attr['none'])) {1821 $none = addslashes($attr['none']);1822 }1823 if (isset($attr['one'])) {1824 $one = addslashes($attr['one']);1825 }1826 if (isset($attr['more'])) {1827 $more = addslashes($attr['more']);1828 }1829 1830 if (empty($attr['count_all'])) {1831 $operation = '$_ctx->posts->nb_comment';1832 } else {1833 $operation = '($_ctx->posts->nb_comment + $_ctx->posts->nb_trackback)';1834 }1835 1836 return1837 "<?php if (".$operation." == 0) {\n".1838 " printf(__('".$none."'),".$operation.");\n".1839 "} elseif (".$operation." == 1) {\n".1840 " printf(__('".$one."'),".$operation.");\n".1841 "} else {\n".1842 " printf(__('".$more."'),".$operation.");\n".1843 "} ?>";1844 }1845 1846 /*dtd1847 <!ELEMENT tpl:EntryPingCount - O -- Number of trackbacks for entry -->1848 <!ATTLIST tpl:EntryPingCount1849 none CDATA #IMPLIED -- text to display for "no ping" (default: no ping)1850 one CDATA #IMPLIED -- text to display for "one ping" (default: one ping)1851 more CDATA #IMPLIED -- text to display for "more pings" (default: %s trackbacks, %s is replaced by the number of pings)1852 >1853 */1854 public function EntryPingCount($attr)1855 {1856 $none = 'no trackback';1857 $one = 'one trackback';1858 $more = '%d trackbacks';1859 1860 if (isset($attr['none'])) {1861 $none = addslashes($attr['none']);1862 }1863 if (isset($attr['one'])) {1864 $one = addslashes($attr['one']);1865 }1866 if (isset($attr['more'])) {1867 $more = addslashes($attr['more']);1868 }1869 1870 return1871 "<?php if (\$_ctx->posts->nb_trackback == 0) {\n".1872 " printf(__('".$none."'),(integer) \$_ctx->posts->nb_trackback);\n".1873 "} elseif (\$_ctx->posts->nb_trackback == 1) {\n".1874 " printf(__('".$one."'),(integer) \$_ctx->posts->nb_trackback);\n".1875 "} else {\n".1876 " printf(__('".$more."'),(integer) \$_ctx->posts->nb_trackback);\n".1877 "} ?>";1878 }1879 1880 /*dtd1881 <!ELEMENT tpl:EntryPingData - O -- Display trackback RDF information -->1882 */1883 public function EntryPingData($attr)1884 {1885 return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackData(); } ?>\n";1886 }1887 1888 /*dtd1889 <!ELEMENT tpl:EntryPingLink - O -- Entry trackback link -->1890 */1891 public function EntryPingLink($attr)1892 {1893 return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackLink(); } ?>\n";1894 }1895 1896 1388 /* Languages -------------------------------------- */ 1897 1389 /*dtd … … 2081 1573 } 2082 1574 2083 /* Comments --------------------------------------- */2084 /*dtd2085 <!ELEMENT tpl:Comments - - -- Comments container -->2086 <!ATTLIST tpl:Comments2087 with_pings (0|1) #IMPLIED -- include trackbacks in request2088 lastn CDATA #IMPLIED -- restrict the number of entries2089 no_context (1|0) #IMPLIED -- Override context information2090 sortby (title|selected|author|date|id) #IMPLIED -- specify comments sort criteria (default : date) (multiple comma-separated sortby can be specified. Use "?asc" or "?desc" as suffix to provide an order for each sorby)2091 order (desc|asc) #IMPLIED -- result ordering (default: asc)2092 age CDATA #IMPLIED -- retrieve comments by maximum age (ex: -2 days, last month, last week)2093 >2094 */2095 public function Comments($attr,$content)2096 {2097 $p = "";2098 if (empty($attr['with_pings'])) {2099 $p .= "\$params['comment_trackback'] = false;\n";2100 }2101 2102 $lastn = 0;2103 if (isset($attr['lastn'])) {2104 $lastn = abs((integer) $attr['lastn'])+0;2105 }2106 2107 if ($lastn > 0) {2108 $p .= "\$params['limit'] = ".$lastn.";\n";2109 } else {2110 $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n";2111 }2112 2113 if (empty($attr['no_context']))2114 {2115 $p .=2116 "if (\$_ctx->posts !== null) { ".2117 "\$params['post_id'] = \$_ctx->posts->post_id; ".2118 "\$core->blog->withoutPassword(false);\n".2119 "}\n";2120 $p .=2121 'if ($_ctx->exists("categories")) { '.2122 "\$params['cat_id'] = \$_ctx->categories->cat_id; ".2123 "}\n";2124 2125 $p .=2126 'if ($_ctx->exists("langs")) { '.2127 "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ".2128 "}\n";2129 }2130 2131 if (!isset($attr['order'])) {2132 $attr['order'] = 'asc';2133 }2134 2135 $p .= "\$params['order'] = '".$this->getSortByStr($attr,'comment')."';\n";2136 2137 if (isset($attr['no_content']) && $attr['no_content']) {2138 $p .= "\$params['no_content'] = true;\n";2139 }2140 2141 if (isset($attr['age'])) {2142 $age = $this->getAge($attr);2143 $p .= !empty($age) ? "@\$params['sql'] .= ' AND P.post_dt > \'".$age."\'';\n" : '';2144 }2145 2146 $res = "<?php\n";2147 $res .= $this->core->callBehavior("templatePrepareParams",2148 array("tag" => "Comments","method" => "blog::getComments"),2149 $attr,$content);2150 $res .= $p;2151 $res .= '$_ctx->comments = $core->blog->getComments($params); unset($params);'."\n";2152 $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n";2153 2154 if (!empty($attr['with_pings'])) {2155 $res .= '$_ctx->pings = $_ctx->comments;'."\n";2156 }2157 2158 $res .= "?>\n";2159 2160 $res .=2161 '<?php while ($_ctx->comments->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->comments = null; ?>';2162 2163 return $res;2164 }2165 2166 /*dtd2167 <!ELEMENT tpl:CommentAuthor - O -- Comment author -->2168 */2169 public function CommentAuthor($attr)2170 {2171 $f = $this->getFilters($attr);2172 return '<?php echo '.sprintf($f,"\$_ctx->comments->comment_author").'; ?>';2173 }2174 2175 /*dtd2176 <!ELEMENT tpl:CommentAuthorDomain - O -- Comment author website domain -->2177 */2178 public function CommentAuthorDomain($attr)2179 {2180 return '<?php echo preg_replace("#^http(?:s?)://(.+?)/.*$#msu",\'$1\',$_ctx->comments->comment_site); ?>';2181 }2182 2183 /*dtd2184 <!ELEMENT tpl:CommentAuthorLink - O -- Comment author link -->2185 */2186 public function CommentAuthorLink($attr)2187 {2188 $f = $this->getFilters($attr);2189 return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorLink()').'; ?>';2190 }2191 2192 /*dtd2193 <!ELEMENT tpl:CommentAuthorMailMD5 - O -- Comment author email MD5 sum -->2194 */2195 public function CommentAuthorMailMD5($attr)2196 {2197 return '<?php echo md5($_ctx->comments->comment_email) ; ?>';2198 }2199 2200 /*dtd2201 <!ELEMENT tpl:CommentAuthorURL - O -- Comment author URL -->2202 */2203 public function CommentAuthorURL($attr)2204 {2205 $f = $this->getFilters($attr);2206 return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorURL()').'; ?>';2207 }2208 2209 /*dtd2210 <!ELEMENT tpl:CommentContent - O -- Comment content -->2211 <!ATTLIST tpl:CommentContent2212 absolute_urls (0|1) #IMPLIED -- convert URLS to absolute urls2213 >2214 */2215 public function CommentContent($attr)2216 {2217 $urls = '0';2218 if (!empty($attr['absolute_urls'])) {2219 $urls = '1';2220 }2221 2222 $f = $this->getFilters($attr);2223 return '<?php echo '.sprintf($f,'$_ctx->comments->getContent('.$urls.')').'; ?>';2224 }2225 2226 /*dtd2227 <!ELEMENT tpl:CommentDate - O -- Comment date -->2228 <!ATTLIST tpl:CommentDate2229 format CDATA #IMPLIED -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified)2230 iso8601 CDATA #IMPLIED -- if set, tells that date format is ISO 86012231 rfc822 CDATA #IMPLIED -- if set, tells that date format is RFC 8222232 upddt CDATA #IMPLIED -- if set, uses the comment update time2233 >2234 */2235 public function CommentDate($attr)2236 {2237 $format = '';2238 if (!empty($attr['format'])) {2239 $format = addslashes($attr['format']);2240 }2241 2242 $iso8601 = !empty($attr['iso8601']);2243 $rfc822 = !empty($attr['rfc822']);2244 $type = (!empty($attr['upddt']) ? 'upddt' : '');2245 2246 $f = $this->getFilters($attr);2247 2248 if ($rfc822) {2249 return '<?php echo '.sprintf($f,"\$_ctx->comments->getRFC822Date('".$type."')").'; ?>';2250 } elseif ($iso8601) {2251 return '<?php echo '.sprintf($f,"\$_ctx->comments->getISO8601Date('".$type."')").'; ?>';2252 } else {2253 return '<?php echo '.sprintf($f,"\$_ctx->comments->getDate('".$format."','".$type."')").'; ?>';2254 }2255 }2256 2257 /*dtd2258 <!ELEMENT tpl:CommentTime - O -- Comment date -->2259 <!ATTLIST tpl:CommentTime2260 format CDATA #IMPLIED -- time format2261 upddt CDATA #IMPLIED -- if set, uses the comment update time2262 >2263 */2264 public function CommentTime($attr)2265 {2266 $format = '';2267 if (!empty($attr['format'])) {2268 $format = addslashes($attr['format']);2269 }2270 $type = (!empty($attr['upddt']) ? 'upddt' : '');2271 2272 $f = $this->getFilters($attr);2273 return '<?php echo '.sprintf($f,"\$_ctx->comments->getTime('".$format."','".$type."')").'; ?>';2274 }2275 2276 /*dtd2277 <!ELEMENT tpl:CommentEmail - O -- Comment author email -->2278 <!ATTLIST tpl:CommentEmail2279 spam_protected (0|1) #IMPLIED -- protect email from spam (default: 1)2280 >2281 */2282 public function CommentEmail($attr)2283 {2284 $p = 'true';2285 if (isset($attr['spam_protected']) && !$attr['spam_protected']) {2286 $p = 'false';2287 }2288 2289 $f = $this->getFilters($attr);2290 return '<?php echo '.sprintf($f,"\$_ctx->comments->getEmail(".$p.")").'; ?>';2291 }2292 2293 /*dtd2294 <!ELEMENT tpl:CommentEntryTitle - O -- Title of the comment entry -->2295 */2296 public function CommentEntryTitle($attr)2297 {2298 $f = $this->getFilters($attr);2299 return '<?php echo '.sprintf($f,'$_ctx->comments->post_title').'; ?>';2300 }2301 2302 /*dtd2303 <!ELEMENT tpl:CommentFeedID - O -- Comment feed ID -->2304 */2305 public function CommentFeedID($attr)2306 {2307 $f = $this->getFilters($attr);2308 return '<?php echo '.sprintf($f,'$_ctx->comments->getFeedID()').'; ?>';2309 }2310 2311 /*dtd2312 <!ELEMENT tpl:CommentID - O -- Comment ID -->2313 */2314 public function CommentID($attr)2315 {2316 return '<?php echo $_ctx->comments->comment_id; ?>';2317 }2318 2319 /*dtd2320 <!ELEMENT tpl:CommentIf - - -- test container for comments -->2321 <!ATTLIST tpl:CommentIf2322 is_ping (0|1) #IMPLIED -- test if comment is a trackback (value : 1) or not (value : 0)2323 >2324 */2325 public function CommentIf($attr,$content)2326 {2327 $if = array();2328 $is_ping = null;2329 2330 if (isset($attr['is_ping'])) {2331 $sign = (boolean) $attr['is_ping'] ? '' : '!';2332 $if[] = $sign.'$_ctx->comments->comment_trackback';2333 }2334 2335 $this->core->callBehavior('tplIfConditions','CommentIf',$attr,$content,$if);2336 2337 if (count($if) != 0) {2338 return '<?php if('.implode(' && ', (array) $if).') : ?>'.$content.'<?php endif; ?>';2339 } else {2340 return $content;2341 }2342 }2343 2344 /*dtd2345 <!ELEMENT tpl:CommentIfFirst - O -- displays value if comment is the first one -->2346 <!ATTLIST tpl:CommentIfFirst2347 return CDATA #IMPLIED -- value to display in case of success (default: first)2348 >2349 */2350 public function CommentIfFirst($attr)2351 {2352 $ret = isset($attr['return']) ? $attr['return'] : 'first';2353 $ret = html::escapeHTML($ret);2354 2355 return2356 '<?php if ($_ctx->comments->index() == 0) { '.2357 "echo '".addslashes($ret)."'; } ?>";2358 }2359 2360 /*dtd2361 <!ELEMENT tpl:CommentIfMe - O -- displays value if comment is the from the entry author -->2362 <!ATTLIST tpl:CommentIfMe2363 return CDATA #IMPLIED -- value to display in case of success (default: me)2364 >2365 */2366 public function CommentIfMe($attr)2367 {2368 $ret = isset($attr['return']) ? $attr['return'] : 'me';2369 $ret = html::escapeHTML($ret);2370 2371 return2372 '<?php if ($_ctx->comments->isMe()) { '.2373 "echo '".addslashes($ret)."'; } ?>";2374 }2375 2376 /*dtd2377 <!ELEMENT tpl:CommentIfOdd - O -- displays value if comment is at an odd position -->2378 <!ATTLIST tpl:CommentIfOdd2379 return CDATA #IMPLIED -- value to display in case of success (default: odd)2380 >2381 */2382 public function CommentIfOdd($attr)2383 {2384 $ret = isset($attr['return']) ? $attr['return'] : 'odd';2385 $ret = html::escapeHTML($ret);2386 2387 return2388 '<?php if (($_ctx->comments->index()+1)%2) { '.2389 "echo '".addslashes($ret)."'; } ?>";2390 }2391 2392 /*dtd2393 <!ELEMENT tpl:CommentIP - O -- Comment author IP -->2394 */2395 public function CommentIP($attr)2396 {2397 return '<?php echo $_ctx->comments->comment_ip; ?>';2398 }2399 2400 /*dtd2401 <!ELEMENT tpl:CommentOrderNumber - O -- Comment order in page -->2402 */2403 public function CommentOrderNumber($attr)2404 {2405 return '<?php echo $_ctx->comments->index()+1; ?>';2406 }2407 2408 /*dtd2409 <!ELEMENT tpl:CommentsFooter - - -- Last comments result container -->2410 */2411 public function CommentsFooter($attr,$content)2412 {2413 return2414 "<?php if (\$_ctx->comments->isEnd()) : ?>".2415 $content.2416 "<?php endif; ?>";2417 }2418 2419 /*dtd2420 <!ELEMENT tpl:CommentsHeader - - -- First comments result container -->2421 */2422 public function CommentsHeader($attr,$content)2423 {2424 return2425 "<?php if (\$_ctx->comments->isStart()) : ?>".2426 $content.2427 "<?php endif; ?>";2428 }2429 2430 /*dtd2431 <!ELEMENT tpl:CommentPostURL - O -- Comment Entry URL -->2432 */2433 public function CommentPostURL($attr)2434 {2435 $f = $this->getFilters($attr);2436 return '<?php echo '.sprintf($f,'$_ctx->comments->getPostURL()').'; ?>';2437 }2438 2439 /*dtd2440 <!ELEMENT tpl:IfCommentAuthorEmail - - -- Container displayed if comment author email is set -->2441 */2442 public function IfCommentAuthorEmail($attr,$content)2443 {2444 return2445 "<?php if (\$_ctx->comments->comment_email) : ?>".2446 $content.2447 "<?php endif; ?>";2448 }2449 2450 /*dtd2451 <!ELEMENT tpl:CommentHelp - 0 -- Comment syntax mini help -->2452 */2453 public function CommentHelp($attr,$content)2454 {2455 return2456 "<?php if (\$core->blog->settings->system->wiki_comments) {\n".2457 " echo __('Comments can be formatted using a simple wiki syntax.');\n".2458 "} else {\n".2459 " echo __('HTML code is displayed as text and web addresses are automatically converted.');\n".2460 "} ?>";2461 }2462 2463 /* Comment preview -------------------------------- */2464 /*dtd2465 <!ELEMENT tpl:IfCommentPreview - - -- Container displayed if comment is being previewed -->2466 */2467 public function IfCommentPreview($attr,$content)2468 {2469 return2470 '<?php if ($_ctx->comment_preview !== null && $_ctx->comment_preview["preview"]) : ?>'.2471 $content.2472 '<?php endif; ?>';2473 }2474 2475 /*dtd2476 <!ELEMENT tpl:CommentPreviewName - O -- Author name for the previewed comment -->2477 */2478 public function CommentPreviewName($attr)2479 {2480 $f = $this->getFilters($attr);2481 return '<?php echo '.sprintf($f,'$_ctx->comment_preview["name"]').'; ?>';2482 }2483 2484 /*dtd2485 <!ELEMENT tpl:CommentPreviewEmail - O -- Author email for the previewed comment -->2486 */2487 public function CommentPreviewEmail($attr)2488 {2489 $f = $this->getFilters($attr);2490 return '<?php echo '.sprintf($f,'$_ctx->comment_preview["mail"]').'; ?>';2491 }2492 2493 /*dtd2494 <!ELEMENT tpl:CommentPreviewSite - O -- Author site for the previewed comment -->2495 */2496 public function CommentPreviewSite($attr)2497 {2498 $f = $this->getFilters($attr);2499 return '<?php echo '.sprintf($f,'$_ctx->comment_preview["site"]').'; ?>';2500 }2501 2502 /*dtd2503 <!ELEMENT tpl:CommentPreviewContent - O -- Content of the previewed comment -->2504 <!ATTLIST tpl:CommentPreviewContent2505 raw (0|1) #IMPLIED -- display comment in raw content2506 >2507 */2508 public function CommentPreviewContent($attr)2509 {2510 $f = $this->getFilters($attr);2511 2512 if (!empty($attr['raw'])) {2513 $co = '$_ctx->comment_preview["rawcontent"]';2514 } else {2515 $co = '$_ctx->comment_preview["content"]';2516 }2517 2518 return '<?php echo '.sprintf($f,$co).'; ?>';2519 }2520 2521 /*dtd2522 <!ELEMENT tpl:CommentPreviewCheckRemember - O -- checkbox attribute for "remember me" (same value as before preview) -->2523 */2524 public function CommentPreviewCheckRemember($attr)2525 {2526 return2527 "<?php if (\$_ctx->comment_preview['remember']) { echo ' checked=\"checked\"'; } ?>";2528 }2529 2530 /* Trackbacks ------------------------------------- */2531 /*dtd2532 <!ELEMENT tpl:PingBlogName - O -- Trackback blog name -->2533 */2534 public function PingBlogName($attr)2535 {2536 $f = $this->getFilters($attr);2537 return '<?php echo '.sprintf($f,'$_ctx->pings->comment_author').'; ?>';2538 }2539 2540 /*dtd2541 <!ELEMENT tpl:PingContent - O -- Trackback content -->2542 */2543 public function PingContent($attr)2544 {2545 $f = $this->getFilters($attr);2546 return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackContent()').'; ?>';2547 }2548 2549 /*dtd2550 <!ELEMENT tpl:PingDate - O -- Trackback date -->2551 <!ATTLIST tpl:PingDate2552 format CDATA #IMPLIED -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified)2553 iso8601 CDATA #IMPLIED -- if set, tells that date format is ISO 86012554 rfc822 CDATA #IMPLIED -- if set, tells that date format is RFC 8222555 upddt CDATA #IMPLIED -- if set, uses the comment update time2556 >2557 */2558 public function PingDate($attr,$type='')2559 {2560 $format = '';2561 if (!empty($attr['format'])) {2562 $format = addslashes($attr['format']);2563 }2564 2565 $iso8601 = !empty($attr['iso8601']);2566 $rfc822 = !empty($attr['rfc822']);2567 $type = (!empty($attr['upddt']) ? 'upddt' : '');2568 2569 $f = $this->getFilters($attr);2570 2571 if ($rfc822) {2572 return '<?php echo '.sprintf($f,"\$_ctx->pings->getRFC822Date('".$type."')").'; ?>';2573 } elseif ($iso8601) {2574 return '<?php echo '.sprintf($f,"\$_ctx->pings->getISO8601Date('".$type."')").'; ?>';2575 } else {2576 return '<?php echo '.sprintf($f,"\$_ctx->pings->getDate('".$format."','".$type."')").'; ?>';2577 }2578 }2579 2580 /*dtd2581 <!ELEMENT tpl:PingTime - O -- Trackback date -->2582 <!ATTLIST tpl:PingTime2583 format CDATA #IMPLIED -- time format2584 upddt CDATA #IMPLIED -- if set, uses the comment update time2585 >2586 */2587 public function PingTime($attr)2588 {2589 $format = '';2590 if (!empty($attr['format'])) {2591 $format = addslashes($attr['format']);2592 }2593 $type = (!empty($attr['upddt']) ? 'upddt' : '');2594 2595 $f = $this->getFilters($attr);2596 return '<?php echo '.sprintf($f,"\$_ctx->pings->getTime('".$format."','".$type."')").'; ?>';2597 }2598 2599 /*dtd2600 <!ELEMENT tpl:PingEntryTitle - O -- Trackback entry title -->2601 */2602 public function PingEntryTitle($attr)2603 {2604 $f = $this->getFilters($attr);2605 return '<?php echo '.sprintf($f,'$_ctx->pings->post_title').'; ?>';2606 }2607 2608 /*dtd2609 <!ELEMENT tpl:PingFeedID - O -- Trackback feed ID -->2610 */2611 public function PingFeedID($attr)2612 {2613 $f = $this->getFilters($attr);2614 return '<?php echo '.sprintf($f,'$_ctx->pings->getFeedID()').'; ?>';2615 }2616 2617 /*dtd2618 <!ELEMENT tpl:PingID - O -- Trackback ID -->2619 */2620 public function PingID($attr)2621 {2622 return '<?php echo $_ctx->pings->comment_id; ?>';2623 }2624 2625 /*dtd2626 <!ELEMENT tpl:PingIfFirst - O -- displays value if trackback is the first one -->2627 <!ATTLIST tpl:PingIfFirst2628 return CDATA #IMPLIED -- value to display in case of success (default: first)2629 >2630 */2631 public function PingIfFirst($attr)2632 {2633 $ret = isset($attr['return']) ? $attr['return'] : 'first';2634 $ret = html::escapeHTML($ret);2635 2636 return2637 '<?php if ($_ctx->pings->index() == 0) { '.2638 "echo '".addslashes($ret)."'; } ?>";2639 }2640 2641 /*dtd2642 <!ELEMENT tpl:PingIfOdd - O -- displays value if trackback is at an odd position -->2643 <!ATTLIST tpl:PingIfOdd2644 return CDATA #IMPLIED -- value to display in case of success (default: odd)2645 >2646 */2647 public function PingIfOdd($attr)2648 {2649 $ret = isset($attr['return']) ? $attr['return'] : 'odd';2650 $ret = html::escapeHTML($ret);2651 2652 return2653 '<?php if (($_ctx->pings->index()+1)%2) { '.2654 "echo '".addslashes($ret)."'; } ?>";2655 }2656 2657 /*dtd2658 <!ELEMENT tpl:PingIP - O -- Trackback author IP -->2659 */2660 public function PingIP($attr)2661 {2662 return '<?php echo $_ctx->pings->comment_ip; ?>';2663 }2664 2665 /*dtd2666 <!ELEMENT tpl:PingNoFollow - O -- displays 'rel="nofollow"' if set in blog -->2667 */2668 public function PingNoFollow($attr)2669 {2670 return2671 '<?php if($core->blog->settings->system->comments_nofollow) { '.2672 'echo \' rel="nofollow"\';'.2673 '} ?>';2674 }2675 2676 /*dtd2677 <!ELEMENT tpl:PingOrderNumber - O -- Trackback order in page -->2678 */2679 public function PingOrderNumber($attr)2680 {2681 return '<?php echo $_ctx->pings->index()+1; ?>';2682 }2683 2684 /*dtd2685 <!ELEMENT tpl:PingPostURL - O -- Trackback Entry URL -->2686 */2687 public function PingPostURL($attr)2688 {2689 $f = $this->getFilters($attr);2690 return '<?php echo '.sprintf($f,'$_ctx->pings->getPostURL()').'; ?>';2691 }2692 2693 /*dtd2694 <!ELEMENT tpl:Pings - - -- Trackbacks container -->2695 <!ATTLIST tpl:Pings2696 with_pings (0|1) #IMPLIED -- include trackbacks in request2697 lastn CDATA #IMPLIED -- restrict the number of entries2698 no_context (1|0) #IMPLIED -- Override context information2699 order (desc|asc) #IMPLIED -- result ordering (default: asc)2700 >2701 */2702 public function Pings($attr,$content)2703 {2704 $p =2705 "if (\$_ctx->posts !== null) { ".2706 "\$params['post_id'] = \$_ctx->posts->post_id; ".2707 "\$core->blog->withoutPassword(false);\n".2708 "}\n";2709 2710 $p .= "\$params['comment_trackback'] = true;\n";2711 2712 $lastn = 0;2713 if (isset($attr['lastn'])) {2714 $lastn = abs((integer) $attr['lastn'])+0;2715 }2716 2717 if ($lastn > 0) {2718 $p .= "\$params['limit'] = ".$lastn.";\n";2719 } else {2720 $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n";2721 }2722 2723 if (empty($attr['no_context']))2724 {2725 $p .=2726 'if ($_ctx->exists("categories")) { '.2727 "\$params['cat_id'] = \$_ctx->categories->cat_id; ".2728 "}\n";2729 2730 $p .=2731 'if ($_ctx->exists("langs")) { '.2732 "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ".2733 "}\n";2734 }2735 2736 $order = 'asc';2737 if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) {2738 $order = $attr['order'];2739 }2740 2741 $p .= "\$params['order'] = 'comment_dt ".$order."';\n";2742 2743 if (isset($attr['no_content']) && $attr['no_content']) {2744 $p .= "\$params['no_content'] = true;\n";2745 }2746 2747 $res = "<?php\n";2748 $res .= $p;2749 $res .= $this->core->callBehavior("templatePrepareParams",2750 array("tag" => "Pings","method" => "blog::getComments"),2751 $attr,$content);2752 $res .= '$_ctx->pings = $core->blog->getComments($params); unset($params);'."\n";2753 $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n";2754 $res .= "?>\n";2755 2756 $res .=2757 '<?php while ($_ctx->pings->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->pings = null; ?>';2758 2759 return $res;2760 }2761 2762 /*dtd2763 <!ELEMENT tpl:PingsFooter - - -- Last trackbacks result container -->2764 */2765 public function PingsFooter($attr,$content)2766 {2767 return2768 "<?php if (\$_ctx->pings->isEnd()) : ?>".2769 $content.2770 "<?php endif; ?>";2771 }2772 2773 /*dtd2774 <!ELEMENT tpl:PingsHeader - - -- First trackbacks result container -->2775 */2776 public function PingsHeader($attr,$content)2777 {2778 return2779 "<?php if (\$_ctx->pings->isStart()) : ?>".2780 $content.2781 "<?php endif; ?>";2782 }2783 2784 /*dtd2785 <!ELEMENT tpl:PingTitle - O -- Trackback title -->2786 */2787 public function PingTitle($attr)2788 {2789 $f = $this->getFilters($attr);2790 return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackTitle()').'; ?>';2791 }2792 2793 /*dtd2794 <!ELEMENT tpl:PingAuthorURL - O -- Trackback author URL -->2795 */2796 public function PingAuthorURL($attr)2797 {2798 $f = $this->getFilters($attr);2799 return '<?php echo '.sprintf($f,'$_ctx->pings->getAuthorURL()').'; ?>';2800 }2801 2802 1575 # System 2803 1576 /*dtd … … 2823 1596 <!ELEMENT tpl:SysIf - - -- System settings tester container --> 2824 1597 <!ATTLIST tpl:SysIf 2825 categories (0|1) #IMPLIED -- test if categories are set in current context (value : 1) or not (value : 0)2826 1598 posts (0|1) #IMPLIED -- test if posts are set in current context (value : 1) or not (value : 0) 2827 1599 blog_lang CDATA #IMPLIED -- tests if blog language is the one given in parameter … … 2831 1603 has_tag CDATA #IMPLIED -- tests if a named template block or value exists 2832 1604 blog_id CDATA #IMPLIED -- tests if current blog ID is the one given in parameter 2833 comments_active (0|1) #IMPLIED -- test if comments are enabled blog-wide2834 pings_active (0|1) #IMPLIED -- test if trackbacks are enabled blog-wide2835 wiki_comments (0|1) #IMPLIED -- test if wiki syntax is enabled for comments2836 1605 operator (and|or) #IMPLIED -- combination of conditions, if more than 1 specifiec (default: and) 2837 1606 > … … 2843 1612 2844 1613 $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&'; 2845 2846 if (isset($attr['categories'])) {2847 $sign = (boolean) $attr['categories'] ? '!' : '=';2848 $if[] = '$_ctx->categories '.$sign.'== null';2849 }2850 1614 2851 1615 if (isset($attr['posts'])) { … … 2903 1667 } 2904 1668 2905 if (isset($attr['comments_active'])) {2906 $sign = (boolean) $attr['comments_active'] ? '' : '!';2907 $if[] = $sign.'$core->blog->settings->system->allow_comments';2908 }2909 2910 if (isset($attr['pings_active'])) {2911 $sign = (boolean) $attr['pings_active'] ? '' : '!';2912 $if[] = $sign.'$core->blog->settings->system->allow_trackbacks';2913 }2914 2915 if (isset($attr['wiki_comments'])) {2916 $sign = (boolean) $attr['wiki_comments'] ? '' : '!';2917 $if[] = $sign.'$core->blog->settings->system->wiki_comments';2918 }2919 2920 1669 if (isset($attr['search_count']) && 2921 1670 preg_match('/^((=|!|>|<)=|(>|<))\s*[0-9]+$/',trim($attr['search_count']))) { … … 2930 1679 return $content; 2931 1680 } 2932 }2933 2934 /*dtd2935 <!ELEMENT tpl:SysIfCommentPublished - - -- Container displayed if comment has been published -->2936 */2937 public function SysIfCommentPublished($attr,$content)2938 {2939 return2940 '<?php if (!empty($_GET[\'pub\'])) : ?>'.2941 $content.2942 '<?php endif; ?>';2943 }2944 2945 /*dtd2946 <!ELEMENT tpl:SysIfCommentPending - - -- Container displayed if comment is pending after submission -->2947 */2948 public function SysIfCommentPending($attr,$content)2949 {2950 return2951 '<?php if (isset($_GET[\'pub\']) && $_GET[\'pub\'] == 0) : ?>'.2952 $content.2953 '<?php endif; ?>';2954 1681 } 2955 1682 -
inc/public/lib.tpl.context.php
r852 r1107 127 127 $str = self::lower_case($str); 128 128 } elseif ($upper_case) { 129 $str = self::upper_case($str); 129 if ($upper_case == 2) { 130 $str = self::capitalize($str); 131 } else { 132 $str = self::upper_case($str); 133 } 130 134 } 131 135 … … 160 164 { 161 165 return mb_strtoupper($str); 166 } 167 168 public static function capitalize($str) 169 { 170 if ($str != '') { 171 $str[0] = mb_strtoupper($str[0]); 172 } 173 return $str; 162 174 } 163 175 … … 314 326 return $str; 315 327 } 316 317 return preg_replace(array_keys($GLOBALS['__smilies']),array_values($GLOBALS['__smilies']),$str); 318 } 319 328 329 # Process part adapted from SmartyPants engine (J. Gruber et al.) : 330 331 $tokens = self::tokenizeHTML($str); 332 $result = ''; 333 $in_pre = 0; # Keep track of when we're inside <pre> or <code> tags. 334 335 foreach ($tokens as $cur_token) { 336 if ($cur_token[0] == "tag") { 337 # Don't mess with quotes inside tags. 338 $result .= $cur_token[1]; 339 if (preg_match('@<(/?)(?:pre|code|kbd|script|math)[\s>]@', $cur_token[1], $matches)) { 340 $in_pre = isset($matches[1]) && $matches[1] == '/' ? 0 : 1; 341 } 342 } else { 343 $t = $cur_token[1]; 344 if (!$in_pre) { 345 $t = preg_replace(array_keys($GLOBALS['__smilies']),array_values($GLOBALS['__smilies']),$t); 346 } 347 $result .= $t; 348 } 349 } 350 351 return $result; 352 } 353 354 private static function tokenizeHTML($str) 355 { 356 # Function from SmartyPants engine (J. Gruber et al.) 357 # 358 # Parameter: String containing HTML markup. 359 # Returns: An array of the tokens comprising the input 360 # string. Each token is either a tag (possibly with nested, 361 # tags contained therein, such as <a href="<MTFoo>">, or a 362 # run of text between tags. Each element of the array is a 363 # two-element array; the first is either 'tag' or 'text'; 364 # the second is the actual value. 365 # 366 # 367 # Regular expression derived from the _tokenize() subroutine in 368 # Brad Choate's MTRegex plugin. 369 # <http://www.bradchoate.com/past/mtregex.php> 370 # 371 $index = 0; 372 $tokens = array(); 373 374 $match = '(?s:<!(?:--.*?--\s*)+>)|'. # comment 375 '(?s:<\?.*?\?>)|'. # processing instruction 376 # regular tags 377 '(?:<[/!$]?[-a-zA-Z0-9:]+\b(?>[^"\'>]+|"[^"]*"|\'[^\']*\')*>)'; 378 379 $parts = preg_split("{($match)}", $str, -1, PREG_SPLIT_DELIM_CAPTURE); 380 381 foreach ($parts as $part) { 382 if (++$index % 2 && $part != '') 383 $tokens[] = array('text', $part); 384 else 385 $tokens[] = array('tag', $part); 386 } 387 return $tokens; 388 } 389 320 390 } 321 391 ?> -
inc/public/lib.tpl.context.php
r975 r1107 172 172 } 173 173 return $str; 174 }175 176 public static function categoryPostParam(&$p)177 {178 $not = substr($p['cat_url'],0,1) == '!';179 if ($not) {180 $p['cat_url'] = substr($p['cat_url'],1);181 }182 183 $p['cat_url'] = preg_split('/\s*,\s*/',$p['cat_url'],-1,PREG_SPLIT_NO_EMPTY);184 185 foreach ($p['cat_url'] as &$v)186 {187 if ($not) {188 $v .= ' ?not';189 }190 if ($GLOBALS['_ctx']->exists('categories') && preg_match('/#self/',$v)) {191 $v = preg_replace('/#self/',$GLOBALS['_ctx']->categories->cat_url,$v);192 } elseif ($GLOBALS['_ctx']->exists('posts') && preg_match('/#self/',$v)) {193 $v = preg_replace('/#self/',$GLOBALS['_ctx']->posts->cat_url,$v);194 }195 }196 174 } 197 175 … … 410 388 } 411 389 412 413 # First post image helpers414 public static function EntryFirstImageHelper($size,$with_category,$class="",$no_tag=false,$content_only=false,$cat_only=false)415 {416 global $core, $_ctx;417 418 $media = new dcMedia($core);419 $sizes = implode('|',array_keys($media->thumb_sizes)).'|o';420 if (!preg_match('/^'.$sizes.'$/',$size)) {421 $size = 's';422 }423 $p_url = $core->blog->settings->system->public_url;424 $p_site = preg_replace('#^(.+?//.+?)/(.*)$#','$1',$core->blog->url);425 $p_root = $core->blog->public_path;426 427 $pattern = '(?:'.preg_quote($p_site,'/').')?'.preg_quote($p_url,'/');428 $pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|jpeg|gif|png))"[^>]+/msui',$pattern);429 430 $src = '';431 $alt = '';432 433 # We first look in post content434 if (!$cat_only && $_ctx->posts)435 {436 $subject = ($content_only ? '' : $_ctx->posts->post_excerpt_xhtml).$_ctx->posts->post_content_xhtml;437 if (preg_match_all($pattern,$subject,$m) > 0)438 {439 foreach ($m[1] as $i => $img) {440 if (($src = self::ContentFirstImageLookup($p_root,$img,$size)) !== false) {441 $dirname = str_replace('\\', '/', dirname($img));442 $src = $p_url.($dirname != '/' ? $dirname : '').'/'.$src;443 if (preg_match('/alt="([^"]+)"/',$m[0][$i],$malt)) {444 $alt = $malt[1];445 }446 break;447 }448 }449 }450 }451 452 # No src, look in category description if available453 if (!$src && $with_category && $_ctx->categories)454 {455 if (preg_match_all($pattern,$_ctx->categories->cat_desc,$m) > 0)456 {457 foreach ($m[1] as $i => $img) {458 if (($src = self::ContentFirstImageLookup($p_root,$img,$size)) !== false) {459 $dirname = str_replace('\\', '/', dirname($img));460 $src = $p_url.($dirname != '/' ? $dirname : '').'/'.$src;461 if (preg_match('/alt="([^"]+)"/',$m[0][$i],$malt)) {462 $alt = $malt[1];463 }464 break;465 }466 }467 };468 }469 470 if ($src) {471 if ($no_tag) {472 return $src;473 } else {474 return '<img alt="'.$alt.'" src="'.$src.'" class="'.$class.'" />';475 }476 }477 }478 479 private static function ContentFirstImageLookup($root,$img,$size)480 {481 global $core;482 483 # Get base name and extension484 $info = path::info($img);485 $base = $info['base'];486 487 $media = new dcMedia($core);488 $sizes = implode('|',array_keys($media->thumb_sizes));489 if (preg_match('/^\.(.+)_('.$sizes.')$/',$base,$m)) {490 $base = $m[1];491 }492 493 $res = false;494 if ($size != 'o' && file_exists($root.'/'.$info['dirname'].'/.'.$base.'_'.$size.'.jpg'))495 {496 $res = '.'.$base.'_'.$size.'.jpg';497 }498 else499 {500 $f = $root.'/'.$info['dirname'].'/'.$base;501 if (file_exists($f.'.'.$info['extension'])) {502 $res = $base.'.'.$info['extension'];503 } elseif (file_exists($f.'.jpg')) {504 $res = $base.'.jpg';505 } elseif (file_exists($f.'.jpeg')) {506 $res = $base.'.jpeg';507 } elseif (file_exists($f.'.png')) {508 $res = $base.'.png';509 } elseif (file_exists($f.'.gif')) {510 $res = $base.'.gif';511 } elseif (file_exists($f.'.JPG')) {512 $res = $base.'.JPG';513 } elseif (file_exists($f.'.JPEG')) {514 $res = $base.'.JPEG';515 } elseif (file_exists($f.'.PNG')) {516 $res = $base.'.PNG';517 } elseif (file_exists($f.'.GIF')) {518 $res = $base.'.GIF';519 }520 }521 522 if ($res) {523 return $res;524 }525 return false;526 }527 390 } 528 391 ?> -
inc/public/prepend.php
r852 r1107 33 33 __('The following error was encountered while trying to read the database:').'</p><ul><li>'.$e->getMessage().'</li></ul>' : 34 34 __('Something went wrong while trying to read the database.') 35 , 20);35 ,620); 36 36 } 37 37 } … … 40 40 __error(__('Blog is not defined.') 41 41 ,__('Did you change your Blog ID?') 42 , 30);42 ,630); 43 43 } 44 44 … … 47 47 __error(__('Blog is offline.') 48 48 ,__('This blog is offline. Please try again later.') 49 , 70);49 ,670); 50 50 } 51 51 … … 57 57 __error(__('Can\'t create template files.') 58 58 ,$e->getMessage() 59 , 40);59 ,640); 60 60 } 61 61 … … 102 102 'path in your blog configuration. Please check theme_path value in '. 103 103 'about:config module or reinstall default theme. ('.$__theme.')') 104 , 50);104 ,650); 105 105 } 106 106 … … 147 147 __error($e->getMessage() 148 148 ,__('Something went wrong while loading template file for your blog.') 149 ,6 0);149 ,660); 150 150 } 151 151 ?> -
inc/public/prepend.php
r921 r1107 49 49 ,670); 50 50 } 51 52 # Loading media53 try {54 $core->media = new dcMedia($core);55 } catch (Exception $e) {}56 51 57 52 # Creating template context
Note: See TracChangeset
for help on using the changeset viewer.