| 1 | <?php | 
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
| 3 | # | 
|---|
| 4 | # This file is part of Dotclear 2. | 
|---|
| 5 | # | 
|---|
| 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear | 
|---|
| 7 | # Licensed under the GPL version 2.0 license. | 
|---|
| 8 | # See LICENSE file or | 
|---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 
|---|
| 10 | # | 
|---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- | 
|---|
| 12 | if (!defined('DC_RC_PATH')) { return; } | 
|---|
| 13 |  | 
|---|
| 14 | class dcTemplate extends template | 
|---|
| 15 | { | 
|---|
| 16 |      private $core; | 
|---|
| 17 |      private $current_tag; | 
|---|
| 18 |       | 
|---|
| 19 |      protected $unknown_value_handler = null; | 
|---|
| 20 |      protected $unknown_block_handler = null; | 
|---|
| 21 |       | 
|---|
| 22 |      function __construct($cache_dir,$self_name,$core) | 
|---|
| 23 |      { | 
|---|
| 24 |           parent::__construct($cache_dir,$self_name); | 
|---|
| 25 |            | 
|---|
| 26 |           $this->remove_php = !$core->blog->settings->system->tpl_allow_php; | 
|---|
| 27 |           $this->use_cache = $core->blog->settings->system->tpl_use_cache; | 
|---|
| 28 |            | 
|---|
| 29 |           $this->tag_block = '<tpl:(\w+)(?:(\s+.*?)>|>)((?:[^<]|<(?!/?tpl:\1)|(?R))*)</tpl:\1>'; | 
|---|
| 30 |           $this->tag_value = '{{tpl:(\w+)(\s(.*?))?}}'; | 
|---|
| 31 |            | 
|---|
| 32 |           $this->core =& $core; | 
|---|
| 33 |            | 
|---|
| 34 |           # Transitional tags | 
|---|
| 35 |           $this->addValue('EntryTrackbackCount',array($this,'EntryPingCount')); | 
|---|
| 36 |           $this->addValue('EntryTrackbackData',array($this,'EntryPingData')); | 
|---|
| 37 |           $this->addValue('EntryTrackbackLink',array($this,'EntryPingLink')); | 
|---|
| 38 |            | 
|---|
| 39 |           # l10n | 
|---|
| 40 |           $this->addValue('lang',array($this,'l10n')); | 
|---|
| 41 |            | 
|---|
| 42 |           # Loops test tags | 
|---|
| 43 |           $this->addBlock('LoopPosition',array($this,'LoopPosition')); | 
|---|
| 44 |            | 
|---|
| 45 |           # Archives | 
|---|
| 46 |           $this->addBlock('Archives',array($this,'Archives')); | 
|---|
| 47 |           $this->addBlock('ArchivesHeader',array($this,'ArchivesHeader')); | 
|---|
| 48 |           $this->addBlock('ArchivesFooter',array($this,'ArchivesFooter')); | 
|---|
| 49 |           $this->addBlock('ArchivesYearHeader',array($this,'ArchivesYearHeader')); | 
|---|
| 50 |           $this->addBlock('ArchivesYearFooter',array($this,'ArchivesYearFooter')); | 
|---|
| 51 |           $this->addValue('ArchiveDate',array($this,'ArchiveDate')); | 
|---|
| 52 |           $this->addBlock('ArchiveNext',array($this,'ArchiveNext')); | 
|---|
| 53 |           $this->addBlock('ArchivePrevious',array($this,'ArchivePrevious')); | 
|---|
| 54 |           $this->addValue('ArchiveEntriesCount',array($this,'ArchiveEntriesCount')); | 
|---|
| 55 |           $this->addValue('ArchiveURL',array($this,'ArchiveURL')); | 
|---|
| 56 |            | 
|---|
| 57 |           # Blog | 
|---|
| 58 |           $this->addValue('BlogArchiveURL',array($this,'BlogArchiveURL')); | 
|---|
| 59 |           $this->addValue('BlogCopyrightNotice',array($this,'BlogCopyrightNotice')); | 
|---|
| 60 |           $this->addValue('BlogDescription',array($this,'BlogDescription')); | 
|---|
| 61 |           $this->addValue('BlogEditor',array($this,'BlogEditor')); | 
|---|
| 62 |           $this->addValue('BlogFeedID',array($this,'BlogFeedID')); | 
|---|
| 63 |           $this->addValue('BlogFeedURL',array($this,'BlogFeedURL')); | 
|---|
| 64 |           $this->addValue('BlogRSDURL',array($this,'BlogRSDURL')); | 
|---|
| 65 |           $this->addValue('BlogName',array($this,'BlogName')); | 
|---|
| 66 |           $this->addValue('BlogLanguage',array($this,'BlogLanguage')); | 
|---|
| 67 |           $this->addValue('BlogThemeURL',array($this,'BlogThemeURL')); | 
|---|
| 68 |           $this->addValue('BlogUpdateDate',array($this,'BlogUpdateDate')); | 
|---|
| 69 |           $this->addValue('BlogID',array($this,'BlogID')); | 
|---|
| 70 |           $this->addValue('BlogURL',array($this,'BlogURL')); | 
|---|
| 71 |           $this->addValue('BlogPublicURL',array($this,'BlogPublicURL')); | 
|---|
| 72 |           $this->addValue('BlogQmarkURL',array($this,'BlogQmarkURL')); | 
|---|
| 73 |           $this->addValue('BlogMetaRobots',array($this,'BlogMetaRobots')); | 
|---|
| 74 |            | 
|---|
| 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 |            | 
|---|
| 123 |           # Entries | 
|---|
| 124 |           $this->addBlock('DateFooter',array($this,'DateFooter')); | 
|---|
| 125 |           $this->addBlock('DateHeader',array($this,'DateHeader')); | 
|---|
| 126 |           $this->addBlock('Entries',array($this,'Entries')); | 
|---|
| 127 |           $this->addBlock('EntriesFooter',array($this,'EntriesFooter')); | 
|---|
| 128 |           $this->addBlock('EntriesHeader',array($this,'EntriesHeader')); | 
|---|
| 129 |           $this->addValue('EntryExcerpt',array($this,'EntryExcerpt')); | 
|---|
| 130 |           $this->addValue('EntryAuthorCommonName',array($this,'EntryAuthorCommonName')); | 
|---|
| 131 |           $this->addValue('EntryAuthorDisplayName',array($this,'EntryAuthorDisplayName')); | 
|---|
| 132 |           $this->addValue('EntryAuthorEmail',array($this,'EntryAuthorEmail')); | 
|---|
| 133 |           $this->addValue('EntryAuthorID',array($this,'EntryAuthorID')); | 
|---|
| 134 |           $this->addValue('EntryAuthorLink',array($this,'EntryAuthorLink')); | 
|---|
| 135 |           $this->addValue('EntryAuthorURL',array($this,'EntryAuthorURL')); | 
|---|
| 136 |           $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 |           $this->addValue('EntryContent',array($this,'EntryContent')); | 
|---|
| 144 |           $this->addValue('EntryDate',array($this,'EntryDate')); | 
|---|
| 145 |           $this->addValue('EntryFeedID',array($this,'EntryFeedID')); | 
|---|
| 146 |           $this->addValue('EntryFirstImage',array($this,'EntryFirstImage')); | 
|---|
| 147 |           $this->addValue('EntryID',array($this,'EntryID')); | 
|---|
| 148 |           $this->addBlock('EntryIf',array($this,'EntryIf')); | 
|---|
| 149 |           $this->addValue('EntryIfFirst',array($this,'EntryIfFirst')); | 
|---|
| 150 |           $this->addValue('EntryIfOdd',array($this,'EntryIfOdd')); | 
|---|
| 151 |           $this->addValue('EntryIfSelected',array($this,'EntryIfSelected')); | 
|---|
| 152 |           $this->addValue('EntryLang',array($this,'EntryLang')); | 
|---|
| 153 |           $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 |           $this->addBlock('EntryPrevious',array($this,'EntryPrevious')); | 
|---|
| 158 |           $this->addValue('EntryTitle',array($this,'EntryTitle')); | 
|---|
| 159 |           $this->addValue('EntryTime',array($this,'EntryTime')); | 
|---|
| 160 |           $this->addValue('EntryURL',array($this,'EntryURL')); | 
|---|
| 161 |            | 
|---|
| 162 |           # Languages | 
|---|
| 163 |           $this->addBlock('Languages',array($this,'Languages')); | 
|---|
| 164 |           $this->addBlock('LanguagesHeader',array($this,'LanguagesHeader')); | 
|---|
| 165 |           $this->addBlock('LanguagesFooter',array($this,'LanguagesFooter')); | 
|---|
| 166 |           $this->addValue('LanguageCode',array($this,'LanguageCode')); | 
|---|
| 167 |           $this->addBlock('LanguageIfCurrent',array($this,'LanguageIfCurrent')); | 
|---|
| 168 |           $this->addValue('LanguageURL',array($this,'LanguageURL')); | 
|---|
| 169 |            | 
|---|
| 170 |           # Pagination | 
|---|
| 171 |           $this->addBlock('Pagination',array($this,'Pagination')); | 
|---|
| 172 |           $this->addValue('PaginationCounter',array($this,'PaginationCounter')); | 
|---|
| 173 |           $this->addValue('PaginationCurrent',array($this,'PaginationCurrent')); | 
|---|
| 174 |           $this->addBlock('PaginationIf',array($this,'PaginationIf')); | 
|---|
| 175 |           $this->addValue('PaginationURL',array($this,'PaginationURL')); | 
|---|
| 176 |            | 
|---|
| 177 |           # Trackbacks | 
|---|
| 178 |           $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 |           # System | 
|---|
| 198 |           $this->addValue('SysBehavior',array($this,'SysBehavior')); | 
|---|
| 199 |           $this->addBlock('SysIf',array($this,'SysIf')); | 
|---|
| 200 |           $this->addBlock('SysIfCommentPublished',array($this,'SysIfCommentPublished')); | 
|---|
| 201 |           $this->addBlock('SysIfCommentPending',array($this,'SysIfCommentPending')); | 
|---|
| 202 |           $this->addBlock('SysIfFormError',array($this,'SysIfFormError')); | 
|---|
| 203 |           $this->addValue('SysFeedSubtitle',array($this,'SysFeedSubtitle')); | 
|---|
| 204 |           $this->addValue('SysFormError',array($this,'SysFormError')); | 
|---|
| 205 |           $this->addValue('SysPoweredBy',array($this,'SysPoweredBy')); | 
|---|
| 206 |           $this->addValue('SysSearchString',array($this,'SysSearchString')); | 
|---|
| 207 |           $this->addValue('SysSelfURI',array($this,'SysSelfURI')); | 
|---|
| 208 |      } | 
|---|
| 209 |       | 
|---|
| 210 |      public function getData($________) | 
|---|
| 211 |      { | 
|---|
| 212 |           # --BEHAVIOR-- tplBeforeData | 
|---|
| 213 |           if ($this->core->hasBehavior('tplBeforeData')) | 
|---|
| 214 |           { | 
|---|
| 215 |                self::$_r = $this->core->callBehavior('tplBeforeData',$this->core); | 
|---|
| 216 |                if (self::$_r) { | 
|---|
| 217 |                     return self::$_r; | 
|---|
| 218 |                } | 
|---|
| 219 |           } | 
|---|
| 220 |            | 
|---|
| 221 |           parent::getData($________); | 
|---|
| 222 |            | 
|---|
| 223 |           # --BEHAVIOR-- tplAfterData | 
|---|
| 224 |           if ($this->core->hasBehavior('tplAfterData')) { | 
|---|
| 225 |                $this->core->callBehavior('tplAfterData',$this->core,self::$_r); | 
|---|
| 226 |           } | 
|---|
| 227 |            | 
|---|
| 228 |           return self::$_r; | 
|---|
| 229 |      } | 
|---|
| 230 |       | 
|---|
| 231 |      protected function compileFile($file) | 
|---|
| 232 |      { | 
|---|
| 233 |           $fc = file_get_contents($file); | 
|---|
| 234 |            | 
|---|
| 235 |           $this->compile_stack[] = $file; | 
|---|
| 236 |            | 
|---|
| 237 |           # Remove every PHP tags | 
|---|
| 238 |           if ($this->remove_php) | 
|---|
| 239 |           { | 
|---|
| 240 |                $fc = preg_replace('/<\?(?=php|=|\s).*?\?>/ms','',$fc); | 
|---|
| 241 |           } | 
|---|
| 242 |            | 
|---|
| 243 |           # Transform what could be considered as PHP short tags | 
|---|
| 244 |           $fc = preg_replace('/(<\?(?!php|=|\s))(.*?)(\?>)/ms', | 
|---|
| 245 |           '<?php echo "$1"; ?>$2<?php echo "$3"; ?>',$fc); | 
|---|
| 246 |            | 
|---|
| 247 |           # Remove template comments <!-- #... --> | 
|---|
| 248 |           $fc = preg_replace('/(^\s*)?<!-- #(.*?)-->/ms','',$fc); | 
|---|
| 249 |            | 
|---|
| 250 |           # Lexer part : split file into small pieces | 
|---|
| 251 |           # each array entry will be either a tag or plain text | 
|---|
| 252 |           $blocks = preg_split( | 
|---|
| 253 |                '#(<tpl:\w+[^>]*>)|(</tpl:\w+>)|({{tpl:\w+[^}]*}})#msu',$fc,-1, | 
|---|
| 254 |                PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); | 
|---|
| 255 |            | 
|---|
| 256 |           # Next : build semantic tree from tokens. | 
|---|
| 257 |           $rootNode = new tplNode(); | 
|---|
| 258 |           $node = $rootNode; | 
|---|
| 259 |           $errors = array(); | 
|---|
| 260 |           foreach ($blocks as $id => $block) { | 
|---|
| 261 |                $isblock = preg_match('#<tpl:(\w+)(?:(\s+.*?)>|>)|</tpl:(\w+)>|{{tpl:(\w+)(\s(.*?))?}}#ms',$block,$match); | 
|---|
| 262 |                if ($isblock == 1) { | 
|---|
| 263 |                     if (substr($match[0],1,1) == '/') { | 
|---|
| 264 |                          // Closing tag, check if it matches current opened node | 
|---|
| 265 |                          $tag = $match[3]; | 
|---|
| 266 |                          if (($node instanceof tplNodeBlock) && $node->getTag() == $tag) { | 
|---|
| 267 |                               $node->setClosing(); | 
|---|
| 268 |                               $node = $node->getParent(); | 
|---|
| 269 |                          } else { | 
|---|
| 270 |                               // Closing tag does not match opening tag | 
|---|
| 271 |                               // Search if it closes a parent tag | 
|---|
| 272 |                               $search = $node; | 
|---|
| 273 |                               while($search->getTag() != 'ROOT' && $search->getTag() != $tag) { | 
|---|
| 274 |                                    $search = $search->getParent(); | 
|---|
| 275 |                               } | 
|---|
| 276 |                               if ($search->getTag() == $tag) { | 
|---|
| 277 |                                    $errors[] = sprintf( | 
|---|
| 278 |                                         __('Did not find closing tag for block <tpl:%s>. Content has been ignored.'), | 
|---|
| 279 |                                         html::escapeHTML($node->getTag())); | 
|---|
| 280 |                                    $search->setClosing(); | 
|---|
| 281 |                                    $node = $search->getParent(); | 
|---|
| 282 |                               } else { | 
|---|
| 283 |                                    $errors[]=sprintf( | 
|---|
| 284 |                                         __('Unexpected closing tag </tpl:%s> found.'), | 
|---|
| 285 |                                         $tag);; | 
|---|
| 286 |                               } | 
|---|
| 287 |                          } | 
|---|
| 288 |                     } elseif (substr($match[0],0,1) == '{') { | 
|---|
| 289 |                          // Value tag | 
|---|
| 290 |                          $tag = $match[4]; | 
|---|
| 291 |                          $str_attr = ''; | 
|---|
| 292 |                          $attr = array(); | 
|---|
| 293 |                          if (isset($match[6])) { | 
|---|
| 294 |                               $str_attr = $match[6]; | 
|---|
| 295 |                               $attr = $this->getAttrs($match[6]); | 
|---|
| 296 |                          } | 
|---|
| 297 |                          $node->addChild(new tplNodeValue($tag,$attr,$str_attr)); | 
|---|
| 298 |                     } else { | 
|---|
| 299 |                          // Opening tag, create new node and dive into it | 
|---|
| 300 |                          $tag = $match[1]; | 
|---|
| 301 |                          $newnode = new tplNodeBlock($tag,isset($match[2])?$this->getAttrs($match[2]):array()); | 
|---|
| 302 |                          $node->addChild($newnode); | 
|---|
| 303 |                          $node = $newnode; | 
|---|
| 304 |                     } | 
|---|
| 305 |                } else { | 
|---|
| 306 |                     // Simple text | 
|---|
| 307 |                     $node->addChild(new tplNodeText($block)); | 
|---|
| 308 |                } | 
|---|
| 309 |           } | 
|---|
| 310 |            | 
|---|
| 311 |           if (($node instanceof tplNodeBlock) && !$node->isClosed()) { | 
|---|
| 312 |                $errors[] = sprintf( | 
|---|
| 313 |                     __('Did not find closing tag for block <tpl:%s>. Content has been ignored.'), | 
|---|
| 314 |                     html::escapeHTML($node->getTag())); | 
|---|
| 315 |           } | 
|---|
| 316 |            | 
|---|
| 317 |           $err = ""; | 
|---|
| 318 |           if (count($errors) > 0) { | 
|---|
| 319 |                $err = "\n\n<!-- \n". | 
|---|
| 320 |                     __('WARNING: the following errors have been found while parsing template file :'). | 
|---|
| 321 |                     "\n * ". | 
|---|
| 322 |                     join("\n * ",$errors). | 
|---|
| 323 |                     "\n -->\n"; | 
|---|
| 324 |           } | 
|---|
| 325 |            | 
|---|
| 326 |           return $rootNode->compile($this).$err; | 
|---|
| 327 |      } | 
|---|
| 328 |      | 
|---|
| 329 |      public function compileBlockNode($tag,$attr,$content) | 
|---|
| 330 |      { | 
|---|
| 331 |           $this->current_tag = $tag; | 
|---|
| 332 |           $attr = new ArrayObject($attr); | 
|---|
| 333 |           # --BEHAVIOR-- templateBeforeBlock | 
|---|
| 334 |           $res = $this->core->callBehavior('templateBeforeBlock',$this->core,$this->current_tag,$attr); | 
|---|
| 335 |            | 
|---|
| 336 |           # --BEHAVIOR-- templateInsideBlock | 
|---|
| 337 |           $this->core->callBehavior('templateInsideBlock',$this->core,$this->current_tag,$attr,array(&$content)); | 
|---|
| 338 |            | 
|---|
| 339 |           if (isset($this->blocks[$this->current_tag])) { | 
|---|
| 340 |                $res .= call_user_func($this->blocks[$this->current_tag],$attr,$content); | 
|---|
| 341 |           } elseif ($this->unknown_block_handler != null) { | 
|---|
| 342 |                $res .= call_user_func($this->unknown_block_handler,$this->current_tag,$attr,$content); | 
|---|
| 343 |           } | 
|---|
| 344 |            | 
|---|
| 345 |           # --BEHAVIOR-- templateAfterBlock | 
|---|
| 346 |           $res .= $this->core->callBehavior('templateAfterBlock',$this->core,$this->current_tag,$attr); | 
|---|
| 347 |            | 
|---|
| 348 |           return $res; | 
|---|
| 349 |      } | 
|---|
| 350 |       | 
|---|
| 351 |      public function compileValueNode($tag,$attr,$str_attr) | 
|---|
| 352 |      { | 
|---|
| 353 |           $this->current_tag = $tag; | 
|---|
| 354 |            | 
|---|
| 355 |           $attr = new ArrayObject($attr); | 
|---|
| 356 |           # --BEHAVIOR-- templateBeforeValue | 
|---|
| 357 |           $res = $this->core->callBehavior('templateBeforeValue',$this->core,$this->current_tag,$attr); | 
|---|
| 358 |            | 
|---|
| 359 |           if (isset($this->values[$this->current_tag])) { | 
|---|
| 360 |                $res .= call_user_func($this->values[$this->current_tag],$attr,ltrim($str_attr)); | 
|---|
| 361 |           } elseif ($this->unknown_value_handler != null) { | 
|---|
| 362 |                $res .= call_user_func($this->unknown_value_handler,$this->current_tag,$attr,$str_attr); | 
|---|
| 363 |           } | 
|---|
| 364 |          | 
|---|
| 365 |           # --BEHAVIOR-- templateAfterValue | 
|---|
| 366 |           $res .= $this->core->callBehavior('templateAfterValue',$this->core,$this->current_tag,$attr); | 
|---|
| 367 |            | 
|---|
| 368 |           return $res; | 
|---|
| 369 |      } | 
|---|
| 370 |      | 
|---|
| 371 |      public function setUnknownValueHandler($callback) | 
|---|
| 372 |      { | 
|---|
| 373 |           if (is_callable($callback)) { | 
|---|
| 374 |                $this->unknown_value_handler = $callback; | 
|---|
| 375 |           } | 
|---|
| 376 |      } | 
|---|
| 377 |      | 
|---|
| 378 |      public function setUnknownBlockHandler($callback) | 
|---|
| 379 |      { | 
|---|
| 380 |           if (is_callable($callback)) { | 
|---|
| 381 |                $this->unknown_block_handler = $callback; | 
|---|
| 382 |           } | 
|---|
| 383 |      } | 
|---|
| 384 |      | 
|---|
| 385 |      public function getFilters($attr) | 
|---|
| 386 |      { | 
|---|
| 387 |           $p[0] = '0';   # encode_xml | 
|---|
| 388 |           $p[1] = '0';   # remove_html | 
|---|
| 389 |           $p[2] = '0';   # cut_string | 
|---|
| 390 |           $p[3] = '0';   # lower_case | 
|---|
| 391 |           $p[4] = '0';   # upper_case | 
|---|
| 392 |            | 
|---|
| 393 |           $p[0] = (integer) (!empty($attr['encode_xml']) || !empty($attr['encode_html'])); | 
|---|
| 394 |           $p[1] = (integer) !empty($attr['remove_html']); | 
|---|
| 395 |            | 
|---|
| 396 |           if (!empty($attr['cut_string']) && (integer) $attr['cut_string'] > 0) { | 
|---|
| 397 |                $p[2] = (integer) $attr['cut_string']; | 
|---|
| 398 |           } | 
|---|
| 399 |            | 
|---|
| 400 |           $p[3] = (integer) !empty($attr['lower_case']); | 
|---|
| 401 |           $p[4] = (integer) !empty($attr['upper_case']); | 
|---|
| 402 |            | 
|---|
| 403 |           return "context::global_filter(%s,".implode(",",$p).",'".addslashes($this->current_tag)."')"; | 
|---|
| 404 |      } | 
|---|
| 405 |       | 
|---|
| 406 |      public static function getOperator($op) | 
|---|
| 407 |      { | 
|---|
| 408 |           switch (strtolower($op)) | 
|---|
| 409 |           { | 
|---|
| 410 |                case 'or': | 
|---|
| 411 |                case '||': | 
|---|
| 412 |                     return '||'; | 
|---|
| 413 |                case 'and': | 
|---|
| 414 |                case '&&': | 
|---|
| 415 |                default: | 
|---|
| 416 |                     return '&&'; | 
|---|
| 417 |           } | 
|---|
| 418 |      } | 
|---|
| 419 |       | 
|---|
| 420 |      public function getSortByStr($attr,$table = null) | 
|---|
| 421 |      { | 
|---|
| 422 |           $res = array(); | 
|---|
| 423 |            | 
|---|
| 424 |           $default_order = 'desc'; | 
|---|
| 425 |            | 
|---|
| 426 |           $default_alias = array( | 
|---|
| 427 |                'post' => array( | 
|---|
| 428 |                     'title' => 'post_title', | 
|---|
| 429 |                     'selected' => 'post_selected', | 
|---|
| 430 |                     'author' => 'user_id', | 
|---|
| 431 |                     'date' => 'post_dt', | 
|---|
| 432 |                     'id' => 'post_id', | 
|---|
| 433 |                     'comment' => 'nb_comment', | 
|---|
| 434 |                     'trackback' => 'nb_trackback' | 
|---|
| 435 |                ), | 
|---|
| 436 |                'comment' => array( | 
|---|
| 437 |                     'author' => 'comment_author', | 
|---|
| 438 |                     'date' => 'comment_dt', | 
|---|
| 439 |                     'id' => 'comment_id' | 
|---|
| 440 |                ) | 
|---|
| 441 |           ); | 
|---|
| 442 |            | 
|---|
| 443 |           $alias = new ArrayObject(); | 
|---|
| 444 |            | 
|---|
| 445 |           # --BEHAVIOR-- templateCustomSortByAlias | 
|---|
| 446 |           $this->core->callBehavior('templateCustomSortByAlias',$alias); | 
|---|
| 447 |            | 
|---|
| 448 |           $alias = $alias->getArrayCopy(); | 
|---|
| 449 |            | 
|---|
| 450 |           if (is_array($alias)) { | 
|---|
| 451 |                foreach ($alias as $k => $v) { | 
|---|
| 452 |                     if (!is_array($v)) { | 
|---|
| 453 |                          $alias[$k] = array(); | 
|---|
| 454 |                     } | 
|---|
| 455 |                     if (!is_array($v)) { | 
|---|
| 456 |                          $default_alias[$k] = array(); | 
|---|
| 457 |                     } | 
|---|
| 458 |                     $default_alias[$k] = array_merge($default_alias[$k],$alias[$k]); | 
|---|
| 459 |                } | 
|---|
| 460 |           } | 
|---|
| 461 |            | 
|---|
| 462 |           if (!array_key_exists($table,$default_alias)) { | 
|---|
| 463 |                return implode(', ',$res); | 
|---|
| 464 |           } | 
|---|
| 465 |            | 
|---|
| 466 |           if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) { | 
|---|
| 467 |                $default_order = $attr['order']; | 
|---|
| 468 |           } | 
|---|
| 469 |           if (isset($attr['sortby'])) { | 
|---|
| 470 |                $sorts = explode(',',$attr['sortby']); | 
|---|
| 471 |                foreach ($sorts as $k => $sort) { | 
|---|
| 472 |                     $order = $default_order; | 
|---|
| 473 |                     if (preg_match('/([a-z]*)\s*\?(desc|asc)$/i',$sort,$matches)) { | 
|---|
| 474 |                          $sort = $matches[1]; | 
|---|
| 475 |                          $order = $matches[2]; | 
|---|
| 476 |                     } | 
|---|
| 477 |                     if (array_key_exists($sort,$default_alias[$table])) { | 
|---|
| 478 |                          array_push($res,$default_alias[$table][$sort].' '.$order); | 
|---|
| 479 |                     } | 
|---|
| 480 |                } | 
|---|
| 481 |           } | 
|---|
| 482 |            | 
|---|
| 483 |           if (count($res) === 0) { | 
|---|
| 484 |                array_push($res,$default_alias[$table]['date'].' '.$default_order); | 
|---|
| 485 |           } | 
|---|
| 486 |            | 
|---|
| 487 |           return implode(', ',$res); | 
|---|
| 488 |      } | 
|---|
| 489 |       | 
|---|
| 490 |      public function getAge($attr) | 
|---|
| 491 |      { | 
|---|
| 492 |           if (isset($attr['age']) && preg_match('/^(\-[0-9]+|last).*$/i',$attr['age'])) { | 
|---|
| 493 |                if (($ts = strtotime($attr['age'])) !== false) { | 
|---|
| 494 |                     return dt::str('%Y-%m-%d %H:%m:%S',$ts); | 
|---|
| 495 |                } | 
|---|
| 496 |           } | 
|---|
| 497 |           return ''; | 
|---|
| 498 |      } | 
|---|
| 499 |       | 
|---|
| 500 |      /* TEMPLATE FUNCTIONS | 
|---|
| 501 |      ------------------------------------------------------- */ | 
|---|
| 502 |       | 
|---|
| 503 |      public function l10n($attr,$str_attr) | 
|---|
| 504 |      { | 
|---|
| 505 |           # Normalize content | 
|---|
| 506 |           $str_attr = preg_replace('/\s+/x',' ',$str_attr); | 
|---|
| 507 |            | 
|---|
| 508 |           return "<?php echo __('".str_replace("'","\\'",$str_attr)."'); ?>"; | 
|---|
| 509 |      } | 
|---|
| 510 |       | 
|---|
| 511 |      public function LoopPosition($attr,$content) | 
|---|
| 512 |      { | 
|---|
| 513 |           $start = isset($attr['start']) ? (integer) $attr['start'] : '0'; | 
|---|
| 514 |           $length = isset($attr['length']) ? (integer) $attr['length'] : 'null'; | 
|---|
| 515 |           $even = isset($attr['even']) ? (integer) (boolean) $attr['even'] : 'null'; | 
|---|
| 516 |            | 
|---|
| 517 |           if ($start > 0) { | 
|---|
| 518 |                $start--; | 
|---|
| 519 |           } | 
|---|
| 520 |            | 
|---|
| 521 |           return | 
|---|
| 522 |           '<?php if ($_ctx->loopPosition('.$start.','.$length.','.$even.')) : ?>'. | 
|---|
| 523 |           $content. | 
|---|
| 524 |           "<?php endif; ?>"; | 
|---|
| 525 |      } | 
|---|
| 526 |       | 
|---|
| 527 |       | 
|---|
| 528 |      /* Archives ------------------------------------------- */ | 
|---|
| 529 |      /*dtd | 
|---|
| 530 |      <!ELEMENT tpl:Archives - - -- Archives dates loop --> | 
|---|
| 531 |      <!ATTLIST tpl:Archives | 
|---|
| 532 |      type      (day|month|year)    #IMPLIED  -- Get days, months or years, default to month -- | 
|---|
| 533 |      category  CDATA               #IMPLIED  -- Get dates of given category -- | 
|---|
| 534 |      no_context (1|0)              #IMPLIED  -- Override context information | 
|---|
| 535 |      order     (asc|desc)          #IMPLIED  -- Sort asc or desc -- | 
|---|
| 536 |      post_type CDATA               #IMPLIED  -- Get dates of given type of entries, default to post -- | 
|---|
| 537 |      post_lang CDATA          #IMPLIED  -- Filter on the given language | 
|---|
| 538 |      > | 
|---|
| 539 |      */ | 
|---|
| 540 |      public function Archives($attr,$content) | 
|---|
| 541 |      { | 
|---|
| 542 |           $p = "if (!isset(\$params)) \$params = array();\n"; | 
|---|
| 543 |           $p .= "\$params['type'] = 'month';\n"; | 
|---|
| 544 |           if (isset($attr['type'])) { | 
|---|
| 545 |                $p .= "\$params['type'] = '".addslashes($attr['type'])."';\n"; | 
|---|
| 546 |           } | 
|---|
| 547 |            | 
|---|
| 548 |           if (isset($attr['category'])) { | 
|---|
| 549 |                $p .= "\$params['cat_url'] = '".addslashes($attr['category'])."';\n"; | 
|---|
| 550 |           } | 
|---|
| 551 |          | 
|---|
| 552 |           if (isset($attr['post_type'])) { | 
|---|
| 553 |                $p .= "\$params['post_type'] = '".addslashes($attr['post_type'])."';\n"; | 
|---|
| 554 |           } | 
|---|
| 555 |          | 
|---|
| 556 |           if (isset($attr['post_lang'])) { | 
|---|
| 557 |                $p .= "\$params['post_lang'] = '".addslashes($attr['post_lang'])."';\n"; | 
|---|
| 558 |           } | 
|---|
| 559 |            | 
|---|
| 560 |           if (empty($attr['no_context']) && !isset($attr['category'])) | 
|---|
| 561 |           { | 
|---|
| 562 |                $p .= | 
|---|
| 563 |                'if ($_ctx->exists("categories")) { '. | 
|---|
| 564 |                     "\$params['cat_id'] = \$_ctx->categories->cat_id; ". | 
|---|
| 565 |                "}\n"; | 
|---|
| 566 |           } | 
|---|
| 567 |            | 
|---|
| 568 |           $order = 'desc'; | 
|---|
| 569 |           if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) { | 
|---|
| 570 |                $p .= "\$params['order'] = '".$attr['order']."';\n "; | 
|---|
| 571 |           } | 
|---|
| 572 |            | 
|---|
| 573 |           $res = "<?php\n"; | 
|---|
| 574 |           $res .= $p; | 
|---|
| 575 |           $res .= $this->core->callBehavior("templatePrepareParams",  | 
|---|
| 576 |                array("tag" => "Archives","method" => "blog::getDates"),  | 
|---|
| 577 |                $attr,$content); | 
|---|
| 578 |           $res .= '$_ctx->archives = $core->blog->getDates($params); unset($params);'."\n"; | 
|---|
| 579 |           $res .= "?>\n"; | 
|---|
| 580 |            | 
|---|
| 581 |           $res .= | 
|---|
| 582 |           '<?php while ($_ctx->archives->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->archives = null; ?>'; | 
|---|
| 583 |            | 
|---|
| 584 |           return $res; | 
|---|
| 585 |      } | 
|---|
| 586 |       | 
|---|
| 587 |      /*dtd | 
|---|
| 588 |      <!ELEMENT tpl:ArchivesHeader - - -- First archives result container --> | 
|---|
| 589 |      */ | 
|---|
| 590 |      public function ArchivesHeader($attr,$content) | 
|---|
| 591 |      { | 
|---|
| 592 |           return | 
|---|
| 593 |           "<?php if (\$_ctx->archives->isStart()) : ?>". | 
|---|
| 594 |           $content. | 
|---|
| 595 |           "<?php endif; ?>"; | 
|---|
| 596 |      } | 
|---|
| 597 |       | 
|---|
| 598 |      /*dtd | 
|---|
| 599 |      <!ELEMENT tpl:ArchivesFooter - - -- Last archives result container --> | 
|---|
| 600 |      */ | 
|---|
| 601 |      public function ArchivesFooter($attr,$content) | 
|---|
| 602 |      { | 
|---|
| 603 |           return | 
|---|
| 604 |           "<?php if (\$_ctx->archives->isEnd()) : ?>". | 
|---|
| 605 |           $content. | 
|---|
| 606 |           "<?php endif; ?>"; | 
|---|
| 607 |      } | 
|---|
| 608 |       | 
|---|
| 609 |      /*dtd | 
|---|
| 610 |      <!ELEMENT tpl:ArchivesYearHeader - - -- First result of year in archives container --> | 
|---|
| 611 |      */ | 
|---|
| 612 |      public function ArchivesYearHeader($attr,$content) | 
|---|
| 613 |      { | 
|---|
| 614 |           return | 
|---|
| 615 |           "<?php if (\$_ctx->archives->yearHeader()) : ?>". | 
|---|
| 616 |           $content. | 
|---|
| 617 |           "<?php endif; ?>"; | 
|---|
| 618 |      } | 
|---|
| 619 |       | 
|---|
| 620 |      /*dtd | 
|---|
| 621 |      <!ELEMENT tpl:ArchivesYearFooter - - -- Last result of year in archives container --> | 
|---|
| 622 |      */ | 
|---|
| 623 |      public function ArchivesYearFooter($attr,$content) | 
|---|
| 624 |      { | 
|---|
| 625 |           return | 
|---|
| 626 |           "<?php if (\$_ctx->archives->yearFooter()) : ?>". | 
|---|
| 627 |           $content. | 
|---|
| 628 |           "<?php endif; ?>"; | 
|---|
| 629 |      } | 
|---|
| 630 |       | 
|---|
| 631 |      /*dtd | 
|---|
| 632 |      <!ELEMENT tpl:ArchiveDate - O -- Archive result date --> | 
|---|
| 633 |      <!ATTLIST tpl:ArchiveDate | 
|---|
| 634 |      format    CDATA     #IMPLIED  -- Date format (Default %B %Y) -- | 
|---|
| 635 |      > | 
|---|
| 636 |      */ | 
|---|
| 637 |      public function ArchiveDate($attr) | 
|---|
| 638 |      { | 
|---|
| 639 |           $format = '%B %Y'; | 
|---|
| 640 |           if (!empty($attr['format'])) { | 
|---|
| 641 |                $format = addslashes($attr['format']); | 
|---|
| 642 |           } | 
|---|
| 643 |            | 
|---|
| 644 |           $f = $this->getFilters($attr); | 
|---|
| 645 |           return '<?php echo '.sprintf($f,"dt::dt2str('".$format."',\$_ctx->archives->dt)").'; ?>'; | 
|---|
| 646 |      } | 
|---|
| 647 |       | 
|---|
| 648 |      /*dtd | 
|---|
| 649 |      <!ELEMENT tpl:ArchiveEntriesCount - O -- Current archive result number of entries --> | 
|---|
| 650 |      */ | 
|---|
| 651 |      public function ArchiveEntriesCount($attr) | 
|---|
| 652 |      { | 
|---|
| 653 |           $f = $this->getFilters($attr); | 
|---|
| 654 |           return '<?php echo '.sprintf($f,'$_ctx->archives->nb_post').'; ?>'; | 
|---|
| 655 |      } | 
|---|
| 656 |       | 
|---|
| 657 |      /*dtd | 
|---|
| 658 |      <!ELEMENT tpl:ArchiveNext - - -- Next archive result container --> | 
|---|
| 659 |      <!ATTLIST tpl:ArchiveNext | 
|---|
| 660 |      type      (day|month|year)    #IMPLIED  -- Get days, months or years, default to month -- | 
|---|
| 661 |      post_type CDATA               #IMPLIED  -- Get dates of given type of entries, default to post -- | 
|---|
| 662 |      post_lang CDATA          #IMPLIED  -- Filter on the given language | 
|---|
| 663 |      > | 
|---|
| 664 |      */ | 
|---|
| 665 |      public function ArchiveNext($attr,$content) | 
|---|
| 666 |      { | 
|---|
| 667 |           $p = "if (!isset(\$params)) \$params = array();\n"; | 
|---|
| 668 |           $p .= "\$params['type'] = 'month';\n"; | 
|---|
| 669 |           if (isset($attr['type'])) { | 
|---|
| 670 |                $p .= "\$params['type'] = '".addslashes($attr['type'])."';\n"; | 
|---|
| 671 |           } | 
|---|
| 672 |            | 
|---|
| 673 |           if (isset($attr['post_type'])) { | 
|---|
| 674 |                $p .= "\$params['post_type'] = '".addslashes($attr['post_type'])."';\n"; | 
|---|
| 675 |           } | 
|---|
| 676 |            | 
|---|
| 677 |           if (isset($attr['post_lang'])) { | 
|---|
| 678 |                $p .= "\$params['post_lang'] = '".addslashes($attr['post_lang'])."';\n"; | 
|---|
| 679 |           } | 
|---|
| 680 |          | 
|---|
| 681 |           $p .= "\$params['next'] = \$_ctx->archives->dt;"; | 
|---|
| 682 |            | 
|---|
| 683 |           $res = "<?php\n"; | 
|---|
| 684 |           $res .= $p; | 
|---|
| 685 |           $res .= $this->core->callBehavior("templatePrepareParams", | 
|---|
| 686 |                array("tag" => "ArchiveNext","method" => "blog::getDates"),  | 
|---|
| 687 |                $attr, $content); | 
|---|
| 688 |           $res .= '$_ctx->archives = $core->blog->getDates($params); unset($params);'."\n"; | 
|---|
| 689 |           $res .= "?>\n"; | 
|---|
| 690 |            | 
|---|
| 691 |           $res .= | 
|---|
| 692 |           '<?php while ($_ctx->archives->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->archives = null; ?>'; | 
|---|
| 693 |            | 
|---|
| 694 |           return $res; | 
|---|
| 695 |      } | 
|---|
| 696 |       | 
|---|
| 697 |      /*dtd | 
|---|
| 698 |      <!ELEMENT tpl:ArchivePrevious - - -- Previous archive result container --> | 
|---|
| 699 |      <!ATTLIST tpl:ArchivePrevious | 
|---|
| 700 |      type      (day|month|year)    #IMPLIED  -- Get days, months or years, default to month -- | 
|---|
| 701 |      post_type CDATA               #IMPLIED  -- Get dates of given type of entries, default to post -- | 
|---|
| 702 |      post_lang CDATA          #IMPLIED  -- Filter on the given language | 
|---|
| 703 |      > | 
|---|
| 704 |      */ | 
|---|
| 705 |      public function ArchivePrevious($attr,$content) | 
|---|
| 706 |      { | 
|---|
| 707 |           $p = 'if (!isset($params)) $params = array();'; | 
|---|
| 708 |           $p .= "\$params['type'] = 'month';\n"; | 
|---|
| 709 |           if (isset($attr['type'])) { | 
|---|
| 710 |                $p .= "\$params['type'] = '".addslashes($attr['type'])."';\n"; | 
|---|
| 711 |           } | 
|---|
| 712 |            | 
|---|
| 713 |           if (isset($attr['post_type'])) { | 
|---|
| 714 |                $p .= "\$params['post_type'] = '".addslashes($attr['post_type'])."';\n"; | 
|---|
| 715 |           } | 
|---|
| 716 |          | 
|---|
| 717 |           if (isset($attr['post_lang'])) { | 
|---|
| 718 |                $p .= "\$params['post_lang'] = '".addslashes($attr['post_lang'])."';\n"; | 
|---|
| 719 |           } | 
|---|
| 720 |          | 
|---|
| 721 |           $p .= "\$params['previous'] = \$_ctx->archives->dt;"; | 
|---|
| 722 |            | 
|---|
| 723 |           $res = "<?php\n"; | 
|---|
| 724 |           $res .= $this->core->callBehavior("templatePrepareParams", | 
|---|
| 725 |                array("tag" => "ArchivePrevious","method" => "blog::getDates"),  | 
|---|
| 726 |                $attr, $content); | 
|---|
| 727 |           $res .= $p; | 
|---|
| 728 |           $res .= '$_ctx->archives = $core->blog->getDates($params); unset($params);'."\n"; | 
|---|
| 729 |           $res .= "?>\n"; | 
|---|
| 730 |            | 
|---|
| 731 |           $res .= | 
|---|
| 732 |           '<?php while ($_ctx->archives->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->archives = null; ?>'; | 
|---|
| 733 |            | 
|---|
| 734 |           return $res; | 
|---|
| 735 |      } | 
|---|
| 736 |       | 
|---|
| 737 |      /*dtd | 
|---|
| 738 |      <!ELEMENT tpl:ArchiveURL - O -- Current archive result URL --> | 
|---|
| 739 |      */ | 
|---|
| 740 |      public function ArchiveURL($attr) | 
|---|
| 741 |      { | 
|---|
| 742 |           $f = $this->getFilters($attr); | 
|---|
| 743 |           return '<?php echo '.sprintf($f,'$_ctx->archives->url($core)').'; ?>'; | 
|---|
| 744 |      } | 
|---|
| 745 |       | 
|---|
| 746 |       | 
|---|
| 747 |      /* Blog ----------------------------------------------- */ | 
|---|
| 748 |      /*dtd | 
|---|
| 749 |      <!ELEMENT tpl:BlogArchiveURL - O -- Blog Archives URL --> | 
|---|
| 750 |      */ | 
|---|
| 751 |      public function BlogArchiveURL($attr) | 
|---|
| 752 |      { | 
|---|
| 753 |           $f = $this->getFilters($attr); | 
|---|
| 754 |           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("archive")').'; ?>'; | 
|---|
| 755 |      } | 
|---|
| 756 |       | 
|---|
| 757 |      /*dtd | 
|---|
| 758 |      <!ELEMENT tpl:BlogCopyrightNotice - O -- Blog copyrght notices --> | 
|---|
| 759 |      */ | 
|---|
| 760 |      public function BlogCopyrightNotice($attr) | 
|---|
| 761 |      { | 
|---|
| 762 |           $f = $this->getFilters($attr); | 
|---|
| 763 |           return '<?php echo '.sprintf($f,'$core->blog->settings->system->copyright_notice').'; ?>'; | 
|---|
| 764 |      } | 
|---|
| 765 |       | 
|---|
| 766 |      /*dtd | 
|---|
| 767 |      <!ELEMENT tpl:BlogDescription - O -- Blog Description --> | 
|---|
| 768 |      */ | 
|---|
| 769 |      public function BlogDescription($attr) | 
|---|
| 770 |      { | 
|---|
| 771 |           $f = $this->getFilters($attr); | 
|---|
| 772 |           return '<?php echo '.sprintf($f,'$core->blog->desc').'; ?>'; | 
|---|
| 773 |      } | 
|---|
| 774 |       | 
|---|
| 775 |      /*dtd | 
|---|
| 776 |      <!ELEMENT tpl:BlogEditor - O -- Blog Editor --> | 
|---|
| 777 |      */ | 
|---|
| 778 |      public function BlogEditor($attr) | 
|---|
| 779 |      { | 
|---|
| 780 |           $f = $this->getFilters($attr); | 
|---|
| 781 |           return '<?php echo '.sprintf($f,'$core->blog->settings->system->editor').'; ?>'; | 
|---|
| 782 |      } | 
|---|
| 783 |       | 
|---|
| 784 |      /*dtd | 
|---|
| 785 |      <!ELEMENT tpl:BlogFeedID - O -- Blog Feed ID --> | 
|---|
| 786 |      */ | 
|---|
| 787 |      public function BlogFeedID($attr) | 
|---|
| 788 |      { | 
|---|
| 789 |           $f = $this->getFilters($attr); | 
|---|
| 790 |           return '<?php echo '.sprintf($f,'"urn:md5:".$core->blog->uid').'; ?>'; | 
|---|
| 791 |      } | 
|---|
| 792 |       | 
|---|
| 793 |      /*dtd | 
|---|
| 794 |      <!ELEMENT tpl:BlogFeedURL - O -- Blog Feed URL --> | 
|---|
| 795 |      <!ATTLIST tpl:BlogFeedURL | 
|---|
| 796 |      type (rss2|atom)    #IMPLIED  -- feed type (default : rss2) | 
|---|
| 797 |      > | 
|---|
| 798 |      */ | 
|---|
| 799 |      public function BlogFeedURL($attr) | 
|---|
| 800 |      { | 
|---|
| 801 |           $type = !empty($attr['type']) ? $attr['type'] : 'atom'; | 
|---|
| 802 |            | 
|---|
| 803 |           if (!preg_match('#^(rss2|atom)$#',$type)) { | 
|---|
| 804 |                $type = 'atom'; | 
|---|
| 805 |           } | 
|---|
| 806 |            | 
|---|
| 807 |           $f = $this->getFilters($attr); | 
|---|
| 808 |           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("feed","'.$type.'")').'; ?>'; | 
|---|
| 809 |      } | 
|---|
| 810 |       | 
|---|
| 811 |      /*dtd | 
|---|
| 812 |      <!ELEMENT tpl:BlogName - O -- Blog Name --> | 
|---|
| 813 |      */ | 
|---|
| 814 |      public function BlogName($attr) | 
|---|
| 815 |      { | 
|---|
| 816 |           $f = $this->getFilters($attr); | 
|---|
| 817 |           return '<?php echo '.sprintf($f,'$core->blog->name').'; ?>'; | 
|---|
| 818 |      } | 
|---|
| 819 |       | 
|---|
| 820 |      /*dtd | 
|---|
| 821 |      <!ELEMENT tpl:BlogLanguage - O -- Blog Language --> | 
|---|
| 822 |      */ | 
|---|
| 823 |      public function BlogLanguage($attr) | 
|---|
| 824 |      { | 
|---|
| 825 |           $f = $this->getFilters($attr); | 
|---|
| 826 |           return '<?php echo '.sprintf($f,'$core->blog->settings->system->lang').'; ?>'; | 
|---|
| 827 |      } | 
|---|
| 828 |       | 
|---|
| 829 |      /*dtd | 
|---|
| 830 |      <!ELEMENT tpl:BlogThemeURL - O -- Blog's current Themei URL --> | 
|---|
| 831 |      */ | 
|---|
| 832 |      public function BlogThemeURL($attr) | 
|---|
| 833 |      { | 
|---|
| 834 |           $f = $this->getFilters($attr); | 
|---|
| 835 |           return '<?php echo '.sprintf($f,'$core->blog->settings->system->themes_url."/".$core->blog->settings->system->theme').'; ?>'; | 
|---|
| 836 |      } | 
|---|
| 837 |      | 
|---|
| 838 |      /*dtd | 
|---|
| 839 |      <!ELEMENT tpl:BlogPublicURL - O -- Blog Public directory URL --> | 
|---|
| 840 |      */ | 
|---|
| 841 |      public function BlogPublicURL($attr) | 
|---|
| 842 |      { | 
|---|
| 843 |           $f = $this->getFilters($attr); | 
|---|
| 844 |           return '<?php echo '.sprintf($f,'$core->blog->settings->system->public_url').'; ?>'; | 
|---|
| 845 |      } | 
|---|
| 846 |       | 
|---|
| 847 |      /*dtd | 
|---|
| 848 |      <!ELEMENT tpl:BlogUpdateDate - O -- Blog last update date --> | 
|---|
| 849 |      <!ATTLIST tpl:BlogUpdateDate | 
|---|
| 850 |      format    CDATA     #IMPLIED  -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified) | 
|---|
| 851 |      iso8601   CDATA     #IMPLIED  -- if set, tells that date format is ISO 8601 | 
|---|
| 852 |      rfc822    CDATA     #IMPLIED  -- if set, tells that date format is RFC 822 | 
|---|
| 853 |      > | 
|---|
| 854 |      */ | 
|---|
| 855 |      public function BlogUpdateDate($attr) | 
|---|
| 856 |      { | 
|---|
| 857 |           $format = ''; | 
|---|
| 858 |           if (!empty($attr['format'])) { | 
|---|
| 859 |                $format = addslashes($attr['format']); | 
|---|
| 860 |           } else { | 
|---|
| 861 |                $format = '%Y-%m-%d %H:%M:%S'; | 
|---|
| 862 |           } | 
|---|
| 863 |            | 
|---|
| 864 |           $iso8601 = !empty($attr['iso8601']); | 
|---|
| 865 |           $rfc822 = !empty($attr['rfc822']); | 
|---|
| 866 |            | 
|---|
| 867 |           $f = $this->getFilters($attr); | 
|---|
| 868 |            | 
|---|
| 869 |           if ($rfc822) { | 
|---|
| 870 |                return '<?php echo '.sprintf($f,"dt::rfc822(\$core->blog->upddt,\$core->blog->settings->system->blog_timezone)").'; ?>'; | 
|---|
| 871 |           } elseif ($iso8601) { | 
|---|
| 872 |                return '<?php echo '.sprintf($f,"dt::iso8601(\$core->blog->upddt,\$core->blog->settings->system->blog_timezone)").'; ?>'; | 
|---|
| 873 |           } else { | 
|---|
| 874 |                return '<?php echo '.sprintf($f,"dt::str('".$format."',\$core->blog->upddt)").'; ?>'; | 
|---|
| 875 |           } | 
|---|
| 876 |      } | 
|---|
| 877 |       | 
|---|
| 878 |      /*dtd | 
|---|
| 879 |      <!ELEMENT tpl:BlogID - 0 -- Blog ID --> | 
|---|
| 880 |      */ | 
|---|
| 881 |      public function BlogID($attr) | 
|---|
| 882 |      { | 
|---|
| 883 |           $f = $this->getFilters($attr); | 
|---|
| 884 |           return '<?php echo '.sprintf($f,'$core->blog->id').'; ?>'; | 
|---|
| 885 |      } | 
|---|
| 886 |       | 
|---|
| 887 |      /*dtd | 
|---|
| 888 |      <!ELEMENT tpl:BlogRSDURL - O -- Blog RSD URL --> | 
|---|
| 889 |      */ | 
|---|
| 890 |      public function BlogRSDURL($attr) | 
|---|
| 891 |      { | 
|---|
| 892 |           $f = $this->getFilters($attr); | 
|---|
| 893 |           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor(\'rsd\')').'; ?>'; | 
|---|
| 894 |      } | 
|---|
| 895 |       | 
|---|
| 896 |      /*dtd | 
|---|
| 897 |      <!ELEMENT tpl:BlogURL - O -- Blog URL --> | 
|---|
| 898 |      */ | 
|---|
| 899 |      public function BlogURL($attr) | 
|---|
| 900 |      { | 
|---|
| 901 |           $f = $this->getFilters($attr); | 
|---|
| 902 |           return '<?php echo '.sprintf($f,'$core->blog->url').'; ?>'; | 
|---|
| 903 |      } | 
|---|
| 904 |       | 
|---|
| 905 |      /*dtd | 
|---|
| 906 |      <!ELEMENT tpl:BlogQmarkURL - O -- Blog URL, ending with a question mark --> | 
|---|
| 907 |      */ | 
|---|
| 908 |      public function BlogQmarkURL($attr) | 
|---|
| 909 |      { | 
|---|
| 910 |           $f = $this->getFilters($attr); | 
|---|
| 911 |           return '<?php echo '.sprintf($f,'$core->blog->getQmarkURL()').'; ?>'; | 
|---|
| 912 |      } | 
|---|
| 913 |       | 
|---|
| 914 |      /*dtd | 
|---|
| 915 |      <!ELEMENT tpl:BlogMetaRobots - O -- Blog meta robots tag definition, overrides robots_policy setting --> | 
|---|
| 916 |      <!ATTLIST tpl:BlogMetaRobots | 
|---|
| 917 |      robots    CDATA     #IMPLIED  -- can be INDEX,FOLLOW,NOINDEX,NOFOLLOW,ARCHIVE,NOARCHIVE | 
|---|
| 918 |      > | 
|---|
| 919 |      */ | 
|---|
| 920 |      public function BlogMetaRobots($attr) | 
|---|
| 921 |      { | 
|---|
| 922 |           $robots = isset($attr['robots']) ? addslashes($attr['robots']) : ''; | 
|---|
| 923 |           return "<?php echo context::robotsPolicy(\$core->blog->settings->system->robots_policy,'".$robots."'); ?>"; | 
|---|
| 924 |      } | 
|---|
| 925 |       | 
|---|
| 926 |      /* Categories ----------------------------------------- */ | 
|---|
| 927 |       | 
|---|
| 928 |      /*dtd | 
|---|
| 929 |      <!ELEMENT tpl:Categories - - -- Categories loop --> | 
|---|
| 930 |      */ | 
|---|
| 931 |      public function Categories($attr,$content) | 
|---|
| 932 |      { | 
|---|
| 933 |           $p = "if (!isset(\$params)) \$params = array();\n"; | 
|---|
| 934 |            | 
|---|
| 935 |           if (isset($attr['url'])) { | 
|---|
| 936 |                $p .= "\$params['cat_url'] = '".addslashes($attr['url'])."';\n"; | 
|---|
| 937 |           } | 
|---|
| 938 |            | 
|---|
| 939 |           if (!empty($attr['post_type'])) { | 
|---|
| 940 |                $p .= "\$params['post_type'] = '".addslashes($attr['post_type'])."';\n"; | 
|---|
| 941 |           } | 
|---|
| 942 |            | 
|---|
| 943 |           if (!empty($attr['level'])) { | 
|---|
| 944 |                $p .= "\$params['level'] = ".(integer) $attr['level'].";\n"; | 
|---|
| 945 |           } | 
|---|
| 946 |            | 
|---|
| 947 |           $res = "<?php\n"; | 
|---|
| 948 |           $res .= $p; | 
|---|
| 949 |           $res .= $this->core->callBehavior("templatePrepareParams",  | 
|---|
| 950 |                array("tag" => "Categories","method" => "blog::getCategories"),  | 
|---|
| 951 |                $attr,$content); | 
|---|
| 952 |           $res .= '$_ctx->categories = $core->blog->getCategories($params);'."\n"; | 
|---|
| 953 |           $res .= "?>\n"; | 
|---|
| 954 |           $res .= '<?php while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; unset($params); ?>'; | 
|---|
| 955 |            | 
|---|
| 956 |           return $res; | 
|---|
| 957 |      } | 
|---|
| 958 |       | 
|---|
| 959 |      /*dtd | 
|---|
| 960 |      <!ELEMENT tpl:CategoriesHeader - - -- First Categories result container --> | 
|---|
| 961 |      */ | 
|---|
| 962 |      public function CategoriesHeader($attr,$content) | 
|---|
| 963 |      { | 
|---|
| 964 |           return | 
|---|
| 965 |           "<?php if (\$_ctx->categories->isStart()) : ?>". | 
|---|
| 966 |           $content. | 
|---|
| 967 |           "<?php endif; ?>"; | 
|---|
| 968 |      } | 
|---|
| 969 |       | 
|---|
| 970 |      /*dtd | 
|---|
| 971 |      <!ELEMENT tpl:CategoriesFooter - - -- Last Categories result container --> | 
|---|
| 972 |      */ | 
|---|
| 973 |      public function CategoriesFooter($attr,$content) | 
|---|
| 974 |      { | 
|---|
| 975 |           return | 
|---|
| 976 |           "<?php if (\$_ctx->categories->isEnd()) : ?>". | 
|---|
| 977 |           $content. | 
|---|
| 978 |           "<?php endif; ?>"; | 
|---|
| 979 |      } | 
|---|
| 980 |       | 
|---|
| 981 |      /*dtd | 
|---|
| 982 |      <!ELEMENT tpl:CategoryIf - - -- tests on current entry --> | 
|---|
| 983 |      <!ATTLIST tpl:CategoryIf | 
|---|
| 984 |      url       CDATA     #IMPLIED  -- category has given url | 
|---|
| 985 |      has_entries    (0|1)     #IMPLIED  -- post is the first post from list (value : 1) or not (value : 0) | 
|---|
| 986 |      has_description     (0|1)     #IMPLIED  -- category has description (value : 1) or not (value : 0)  | 
|---|
| 987 |      > | 
|---|
| 988 |      */ | 
|---|
| 989 |      public function CategoryIf($attr,$content) | 
|---|
| 990 |      { | 
|---|
| 991 |           $if = new ArrayObject(); | 
|---|
| 992 |           $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&'; | 
|---|
| 993 |            | 
|---|
| 994 |           if (isset($attr['url'])) { | 
|---|
| 995 |                $url = addslashes(trim($attr['url'])); | 
|---|
| 996 |                if (substr($url,0,1) == '!') { | 
|---|
| 997 |                     $url = substr($url,1); | 
|---|
| 998 |                     $if[] = '($_ctx->categories->cat_url != "'.$url.'")'; | 
|---|
| 999 |                } else { | 
|---|
| 1000 |                     $if[] = '($_ctx->categories->cat_url == "'.$url.'")'; | 
|---|
| 1001 |                } | 
|---|
| 1002 |           } | 
|---|
| 1003 |            | 
|---|
| 1004 |           if (isset($attr['has_entries'])) { | 
|---|
| 1005 |                $sign = (boolean) $attr['has_entries'] ? '>' : '=='; | 
|---|
| 1006 |                $if[] = '$_ctx->categories->nb_post '.$sign.' 0'; | 
|---|
| 1007 |           } | 
|---|
| 1008 |            | 
|---|
| 1009 |           if (isset($attr['has_description'])) {  | 
|---|
| 1010 |                $sign = (boolean) $attr['has_description'] ? '!=' : '==';  | 
|---|
| 1011 |                $if[] = '$_ctx->categories->cat_desc '.$sign.' ""';  | 
|---|
| 1012 |           }  | 
|---|
| 1013 |            | 
|---|
| 1014 |           $this->core->callBehavior('tplIfConditions','CategoryIf',$attr,$content,$if); | 
|---|
| 1015 |            | 
|---|
| 1016 |           if (count($if) != 0) { | 
|---|
| 1017 |                return '<?php if('.implode(' '.$operator.' ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; | 
|---|
| 1018 |           } else { | 
|---|
| 1019 |                return $content; | 
|---|
| 1020 |           } | 
|---|
| 1021 |      } | 
|---|
| 1022 |       | 
|---|
| 1023 |      /*dtd | 
|---|
| 1024 |      <!ELEMENT tpl:CategoryFirstChildren - - -- Current category first children loop --> | 
|---|
| 1025 |      */ | 
|---|
| 1026 |      public function CategoryFirstChildren($attr,$content) | 
|---|
| 1027 |      { | 
|---|
| 1028 |           return | 
|---|
| 1029 |           "<?php\n". | 
|---|
| 1030 |           '$_ctx->categories = $core->blog->getCategoryFirstChildren($_ctx->categories->cat_id);'."\n". | 
|---|
| 1031 |           'while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; ?>'; | 
|---|
| 1032 |      } | 
|---|
| 1033 |       | 
|---|
| 1034 |      /*dtd | 
|---|
| 1035 |      <!ELEMENT tpl:CategoryParents - - -- Current category parents loop --> | 
|---|
| 1036 |      */ | 
|---|
| 1037 |      public function CategoryParents($attr,$content) | 
|---|
| 1038 |      { | 
|---|
| 1039 |           return | 
|---|
| 1040 |           "<?php\n". | 
|---|
| 1041 |           '$_ctx->categories = $core->blog->getCategoryParents($_ctx->categories->cat_id);'."\n". | 
|---|
| 1042 |           'while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; ?>'; | 
|---|
| 1043 |      } | 
|---|
| 1044 |       | 
|---|
| 1045 |      /*dtd | 
|---|
| 1046 |      <!ELEMENT tpl:CategoryFeedURL - O -- Category feed URL --> | 
|---|
| 1047 |      <!ATTLIST tpl:CategoryFeedURL | 
|---|
| 1048 |      type (rss2|atom)    #IMPLIED  -- feed type (default : rss2) | 
|---|
| 1049 |      > | 
|---|
| 1050 |      */ | 
|---|
| 1051 |      public function CategoryFeedURL($attr) | 
|---|
| 1052 |      { | 
|---|
| 1053 |           $type = !empty($attr['type']) ? $attr['type'] : 'atom'; | 
|---|
| 1054 |            | 
|---|
| 1055 |           if (!preg_match('#^(rss2|atom)$#',$type)) { | 
|---|
| 1056 |                $type = 'atom'; | 
|---|
| 1057 |           } | 
|---|
| 1058 |            | 
|---|
| 1059 |           $f = $this->getFilters($attr); | 
|---|
| 1060 |           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("feed","category/".'. | 
|---|
| 1061 |           '$_ctx->categories->cat_url."/'.$type.'")').'; ?>'; | 
|---|
| 1062 |      } | 
|---|
| 1063 |       | 
|---|
| 1064 |      /*dtd | 
|---|
| 1065 |      <!ELEMENT tpl:CategoryURL - O -- Category URL (complete iabsolute URL, including blog URL) --> | 
|---|
| 1066 |      */ | 
|---|
| 1067 |      public function CategoryURL($attr) | 
|---|
| 1068 |      { | 
|---|
| 1069 |           $f = $this->getFilters($attr); | 
|---|
| 1070 |           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("category",'. | 
|---|
| 1071 |                '$_ctx->categories->cat_url)').'; ?>'; | 
|---|
| 1072 |      } | 
|---|
| 1073 |       | 
|---|
| 1074 |      /*dtd | 
|---|
| 1075 |      <!ELEMENT tpl:CategoryShortURL - O -- Category short URL (relative URL, from /category/) --> | 
|---|
| 1076 |      */ | 
|---|
| 1077 |      public function CategoryShortURL($attr) | 
|---|
| 1078 |      { | 
|---|
| 1079 |           $f = $this->getFilters($attr); | 
|---|
| 1080 |           return '<?php echo '.sprintf($f,'$_ctx->categories->cat_url').'; ?>'; | 
|---|
| 1081 |      } | 
|---|
| 1082 |       | 
|---|
| 1083 |      /*dtd | 
|---|
| 1084 |      <!ELEMENT tpl:CategoryDescription - O -- Category description --> | 
|---|
| 1085 |      */ | 
|---|
| 1086 |      public function CategoryDescription($attr) | 
|---|
| 1087 |      { | 
|---|
| 1088 |           $f = $this->getFilters($attr); | 
|---|
| 1089 |           return '<?php echo '.sprintf($f,'$_ctx->categories->cat_desc').'; ?>'; | 
|---|
| 1090 |      } | 
|---|
| 1091 |       | 
|---|
| 1092 |      /*dtd | 
|---|
| 1093 |      <!ELEMENT tpl:CategoryTitle - O -- Category title --> | 
|---|
| 1094 |      */ | 
|---|
| 1095 |      public function CategoryTitle($attr) | 
|---|
| 1096 |      { | 
|---|
| 1097 |           $f = $this->getFilters($attr); | 
|---|
| 1098 |           return '<?php echo '.sprintf($f,'$_ctx->categories->cat_title').'; ?>'; | 
|---|
| 1099 |      } | 
|---|
| 1100 |  | 
|---|
| 1101 |      /*dtd | 
|---|
| 1102 |      <!ELEMENT tpl:CategoryEntriesCount - O -- Category number of entries --> | 
|---|
| 1103 |      */ | 
|---|
| 1104 |      public function CategoryEntriesCount($attr) | 
|---|
| 1105 |      { | 
|---|
| 1106 |           $f = $this->getFilters($attr); | 
|---|
| 1107 |           return '<?php echo '.sprintf($f,'$_ctx->categories->nb_post').'; ?>'; | 
|---|
| 1108 |      } | 
|---|
| 1109 |       | 
|---|
| 1110 |      /* Entries -------------------------------------------- */ | 
|---|
| 1111 |      /*dtd | 
|---|
| 1112 |      <!ELEMENT tpl:Entries - - -- Blog Entries loop --> | 
|---|
| 1113 |      <!ATTLIST tpl:Entries | 
|---|
| 1114 |      lastn     CDATA     #IMPLIED  -- limit number of results to specified value | 
|---|
| 1115 |      author    CDATA     #IMPLIED  -- get entries for a given user id | 
|---|
| 1116 |      category  CDATA     #IMPLIED  -- get entries for specific categories only (multiple comma-separated categories can be specified. Use "!" as prefix to exclude a category) | 
|---|
| 1117 |      no_category    CDATA     #IMPLIED  -- get entries without category | 
|---|
| 1118 |      no_context (1|0)    #IMPLIED  -- Override context information | 
|---|
| 1119 |      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) | 
|---|
| 1120 |      order     (desc|asc)     #IMPLIED  -- specify entries order (default : desc) | 
|---|
| 1121 |      no_content     (0|1)     #IMPLIED  -- do not retrieve entries content | 
|---|
| 1122 |      selected  (0|1)     #IMPLIED  -- retrieve posts marked as selected only (value: 1) or not selected only (value: 0) | 
|---|
| 1123 |      url       CDATA     #IMPLIED  -- retrieve post by its url | 
|---|
| 1124 |      type      CDATA     #IMPLIED  -- retrieve post with given post_type (there can be many ones separated by comma) | 
|---|
| 1125 |      age       CDATA     #IMPLIED  -- retrieve posts by maximum age (ex: -2 days, last month, last week) | 
|---|
| 1126 |      ignore_pagination   (0|1)     #IMPLIED  -- ignore page number provided in URL (useful when using multiple tpl:Entries on the same page) | 
|---|
| 1127 |      > | 
|---|
| 1128 |      */ | 
|---|
| 1129 |      public function Entries($attr,$content) | 
|---|
| 1130 |      { | 
|---|
| 1131 |           $lastn = -1; | 
|---|
| 1132 |           if (isset($attr['lastn'])) { | 
|---|
| 1133 |                $lastn = abs((integer) $attr['lastn'])+0; | 
|---|
| 1134 |           } | 
|---|
| 1135 |            | 
|---|
| 1136 |           $p = 'if (!isset($_page_number)) { $_page_number = 1; }'."\n"; | 
|---|
| 1137 |            | 
|---|
| 1138 |           if ($lastn != 0) { | 
|---|
| 1139 |                if ($lastn > 0) { | 
|---|
| 1140 |                     $p .= "\$params['limit'] = ".$lastn.";\n"; | 
|---|
| 1141 |                } else { | 
|---|
| 1142 |                     $p .= "\$params['limit'] = \$_ctx->nb_entry_per_page;\n"; | 
|---|
| 1143 |                } | 
|---|
| 1144 |                 | 
|---|
| 1145 |                if (!isset($attr['ignore_pagination']) || $attr['ignore_pagination'] == "0") { | 
|---|
| 1146 |                     $p .= "\$params['limit'] = array(((\$_page_number-1)*\$params['limit']),\$params['limit']);\n"; | 
|---|
| 1147 |                } else { | 
|---|
| 1148 |                     $p .= "\$params['limit'] = array(0, \$params['limit']);\n"; | 
|---|
| 1149 |                } | 
|---|
| 1150 |           } | 
|---|
| 1151 |            | 
|---|
| 1152 |           if (isset($attr['author'])) { | 
|---|
| 1153 |                $p .= "\$params['user_id'] = '".addslashes($attr['author'])."';\n"; | 
|---|
| 1154 |           } | 
|---|
| 1155 |            | 
|---|
| 1156 |           if (isset($attr['category'])) { | 
|---|
| 1157 |                $p .= "\$params['cat_url'] = '".addslashes($attr['category'])."';\n"; | 
|---|
| 1158 |                $p .= "context::categoryPostParam(\$params);\n"; | 
|---|
| 1159 |           } | 
|---|
| 1160 |            | 
|---|
| 1161 |           if (isset($attr['no_category']) && $attr['no_category']) { | 
|---|
| 1162 |                $p .= "@\$params['sql'] .= ' AND P.cat_id IS NULL ';\n"; | 
|---|
| 1163 |                $p .= "unset(\$params['cat_url']);\n"; | 
|---|
| 1164 |           } | 
|---|
| 1165 |            | 
|---|
| 1166 |           if (!empty($attr['type'])) { | 
|---|
| 1167 |                $p .= "\$params['post_type'] = preg_split('/\s*,\s*/','".addslashes($attr['type'])."',-1,PREG_SPLIT_NO_EMPTY);\n"; | 
|---|
| 1168 |           } | 
|---|
| 1169 |            | 
|---|
| 1170 |           if (!empty($attr['url'])) { | 
|---|
| 1171 |                $p .= "\$params['post_url'] = '".addslashes($attr['url'])."';\n"; | 
|---|
| 1172 |           } | 
|---|
| 1173 |            | 
|---|
| 1174 |           if (empty($attr['no_context'])) | 
|---|
| 1175 |           { | 
|---|
| 1176 |                if (!isset($attr['author'])) | 
|---|
| 1177 |                { | 
|---|
| 1178 |                     $p .= | 
|---|
| 1179 |                     'if ($_ctx->exists("users")) { '. | 
|---|
| 1180 |                          "\$params['user_id'] = \$_ctx->users->user_id; ". | 
|---|
| 1181 |                     "}\n"; | 
|---|
| 1182 |                } | 
|---|
| 1183 |                 | 
|---|
| 1184 |                if (!isset($attr['category']) && (!isset($attr['no_category']) || !$attr['no_category'])) | 
|---|
| 1185 |                { | 
|---|
| 1186 |                     $p .= | 
|---|
| 1187 |                     'if ($_ctx->exists("categories")) { '. | 
|---|
| 1188 |                          "\$params['cat_id'] = \$_ctx->categories->cat_id; ". | 
|---|
| 1189 |                     "}\n"; | 
|---|
| 1190 |                } | 
|---|
| 1191 |                 | 
|---|
| 1192 |                $p .= | 
|---|
| 1193 |                'if ($_ctx->exists("archives")) { '. | 
|---|
| 1194 |                     "\$params['post_year'] = \$_ctx->archives->year(); ". | 
|---|
| 1195 |                     "\$params['post_month'] = \$_ctx->archives->month(); "; | 
|---|
| 1196 |                if (!isset($attr['lastn'])) { | 
|---|
| 1197 |                     $p .= "unset(\$params['limit']); "; | 
|---|
| 1198 |                } | 
|---|
| 1199 |                $p .= | 
|---|
| 1200 |                "}\n"; | 
|---|
| 1201 |                 | 
|---|
| 1202 |                $p .= | 
|---|
| 1203 |                'if ($_ctx->exists("langs")) { '. | 
|---|
| 1204 |                     "\$params['post_lang'] = \$_ctx->langs->post_lang; ". | 
|---|
| 1205 |                "}\n"; | 
|---|
| 1206 |                 | 
|---|
| 1207 |                $p .= | 
|---|
| 1208 |                'if (isset($_search)) { '. | 
|---|
| 1209 |                     "\$params['search'] = \$_search; ". | 
|---|
| 1210 |                "}\n"; | 
|---|
| 1211 |           } | 
|---|
| 1212 |            | 
|---|
| 1213 |           $p .= "\$params['order'] = '".$this->getSortByStr($attr,'post')."';\n"; | 
|---|
| 1214 |            | 
|---|
| 1215 |           if (isset($attr['no_content']) && $attr['no_content']) { | 
|---|
| 1216 |                $p .= "\$params['no_content'] = true;\n"; | 
|---|
| 1217 |           } | 
|---|
| 1218 |            | 
|---|
| 1219 |           if (isset($attr['selected'])) { | 
|---|
| 1220 |                $p .= "\$params['post_selected'] = ".(integer) (boolean) $attr['selected'].";"; | 
|---|
| 1221 |           } | 
|---|
| 1222 |            | 
|---|
| 1223 |           if (isset($attr['age'])) { | 
|---|
| 1224 |                $age = $this->getAge($attr); | 
|---|
| 1225 |                $p .= !empty($age) ? "@\$params['sql'] .= ' AND P.post_dt > \'".$age."\'';\n" : ''; | 
|---|
| 1226 |           } | 
|---|
| 1227 |            | 
|---|
| 1228 |           $res = "<?php\n"; | 
|---|
| 1229 |           $res .= $p; | 
|---|
| 1230 |           $res .= $this->core->callBehavior("templatePrepareParams",  | 
|---|
| 1231 |                array("tag" => "Entries","method" => "blog::getPosts"),  | 
|---|
| 1232 |                $attr,$content); | 
|---|
| 1233 |           $res .= '$_ctx->post_params = $params;'."\n"; | 
|---|
| 1234 |           $res .= '$_ctx->posts = $core->blog->getPosts($params); unset($params);'."\n"; | 
|---|
| 1235 |           $res .= "?>\n"; | 
|---|
| 1236 |           $res .= | 
|---|
| 1237 |           '<?php while ($_ctx->posts->fetch()) : ?>'.$content.'<?php endwhile; '. | 
|---|
| 1238 |           '$_ctx->posts = null; $_ctx->post_params = null; ?>'; | 
|---|
| 1239 |            | 
|---|
| 1240 |           return $res; | 
|---|
| 1241 |      } | 
|---|
| 1242 |       | 
|---|
| 1243 |      /*dtd | 
|---|
| 1244 |      <!ELEMENT tpl:DateHeader - O -- Displays date, if post is the first post of the given day --> | 
|---|
| 1245 |      */ | 
|---|
| 1246 |      public function DateHeader($attr,$content) | 
|---|
| 1247 |      { | 
|---|
| 1248 |           return | 
|---|
| 1249 |           "<?php if (\$_ctx->posts->firstPostOfDay()) : ?>". | 
|---|
| 1250 |           $content. | 
|---|
| 1251 |           "<?php endif; ?>"; | 
|---|
| 1252 |      } | 
|---|
| 1253 |       | 
|---|
| 1254 |      /*dtd | 
|---|
| 1255 |      <!ELEMENT tpl:DateFooter - O -- Displays date,  if post is the last post of the given day --> | 
|---|
| 1256 |      */ | 
|---|
| 1257 |      public function DateFooter($attr,$content) | 
|---|
| 1258 |      { | 
|---|
| 1259 |           return | 
|---|
| 1260 |           "<?php if (\$_ctx->posts->lastPostOfDay()) : ?>". | 
|---|
| 1261 |           $content. | 
|---|
| 1262 |           "<?php endif; ?>"; | 
|---|
| 1263 |      } | 
|---|
| 1264 |       | 
|---|
| 1265 |      /*dtd | 
|---|
| 1266 |      <!ELEMENT tpl:EntryIf - - -- tests on current entry --> | 
|---|
| 1267 |      <!ATTLIST tpl:EntryIf | 
|---|
| 1268 |      type CDATA     #IMPLIED  -- post has a given type (default: "post") | 
|---|
| 1269 |      category  CDATA     #IMPLIED  -- post has a given category | 
|---|
| 1270 |      first     (0|1)     #IMPLIED  -- post is the first post from list (value : 1) or not (value : 0) | 
|---|
| 1271 |      odd  (0|1)     #IMPLIED  -- post is in an odd position (value : 1) or not (value : 0) | 
|---|
| 1272 |      even (0|1)     #IMPLIED  -- post is in an even position (value : 1) or not (value : 0) | 
|---|
| 1273 |      extended  (0|1)     #IMPLIED  -- post has an excerpt (value : 1) or not (value : 0) | 
|---|
| 1274 |      selected  (0|1)     #IMPLIED  -- post is selected (value : 1) or not (value : 0) | 
|---|
| 1275 |      has_category   (0|1)     #IMPLIED  -- post has a category (value : 1) or not (value : 0) | 
|---|
| 1276 |      has_attachment (0|1)     #IMPLIED  -- post has attachments (value : 1) or not (value : 0) (see Attachment plugin for code) | 
|---|
| 1277 |      comments_active     (0|1)     #IMPLIED  -- comments are active for this post (value : 1) or not (value : 0) | 
|---|
| 1278 |      pings_active   (0|1)     #IMPLIED  -- trackbacks are active for this post (value : 1) or not (value : 0) | 
|---|
| 1279 |      show_comments  (0|1)     #IMPLIED  -- there are comments for this post (value : 1) or not (value : 0) | 
|---|
| 1280 |      show_pings     (0|1)     #IMPLIED  -- there are trackbacks for this post (value : 1) or not (value : 0) | 
|---|
| 1281 |      republished    (0|1)     #IMPLIED  -- post has been updated since publication (value : 1) or not (value : 0) | 
|---|
| 1282 |      operator  (and|or)  #IMPLIED  -- combination of conditions, if more than 1 specifiec (default: and) | 
|---|
| 1283 |      url       CDATA     #IMPLIED  -- post has given url | 
|---|
| 1284 |      > | 
|---|
| 1285 |      */ | 
|---|
| 1286 |      public function EntryIf($attr,$content) | 
|---|
| 1287 |      { | 
|---|
| 1288 |           $if = new ArrayObject(); | 
|---|
| 1289 |           $extended = null; | 
|---|
| 1290 |           $hascategory = null; | 
|---|
| 1291 |            | 
|---|
| 1292 |           $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&'; | 
|---|
| 1293 |          | 
|---|
| 1294 |           if (isset($attr['type'])) { | 
|---|
| 1295 |                $type = trim($attr['type']); | 
|---|
| 1296 |                $type = !empty($type)?$type:'post'; | 
|---|
| 1297 |                $if[] = '$_ctx->posts->post_type == "'.addslashes($type).'"'; | 
|---|
| 1298 |           } | 
|---|
| 1299 |            | 
|---|
| 1300 |           if (isset($attr['url'])) { | 
|---|
| 1301 |                $url = trim($attr['url']); | 
|---|
| 1302 |                if (substr($url,0,1) == '!') { | 
|---|
| 1303 |                     $url = substr($url,1); | 
|---|
| 1304 |                     $if[] = '$_ctx->posts->post_url != "'.addslashes($url).'"'; | 
|---|
| 1305 |                } else { | 
|---|
| 1306 |                     $if[] = '$_ctx->posts->post_url == "'.addslashes($url).'"'; | 
|---|
| 1307 |                } | 
|---|
| 1308 |           } | 
|---|
| 1309 |            | 
|---|
| 1310 |           if (isset($attr['category'])) { | 
|---|
| 1311 |                $category = addslashes(trim($attr['category'])); | 
|---|
| 1312 |                if (substr($category,0,1) == '!') { | 
|---|
| 1313 |                     $category = substr($category,1); | 
|---|
| 1314 |                     $if[] = '($_ctx->posts->cat_url != "'.$category.'")'; | 
|---|
| 1315 |                } else { | 
|---|
| 1316 |                     $if[] = '($_ctx->posts->cat_url == "'.$category.'")'; | 
|---|
| 1317 |                } | 
|---|
| 1318 |           } | 
|---|
| 1319 |            | 
|---|
| 1320 |           if (isset($attr['first'])) { | 
|---|
| 1321 |                $sign = (boolean) $attr['first'] ? '=' : '!'; | 
|---|
| 1322 |                $if[] = '$_ctx->posts->index() '.$sign.'= 0'; | 
|---|
| 1323 |           } | 
|---|
| 1324 |            | 
|---|
| 1325 |           if (isset($attr['odd'])) { | 
|---|
| 1326 |                $sign = (boolean) $attr['odd'] ? '=' : '!'; | 
|---|
| 1327 |                $if[] = '($_ctx->posts->index()+1)%2 '.$sign.'= 1'; | 
|---|
| 1328 |           } | 
|---|
| 1329 |            | 
|---|
| 1330 |           if (isset($attr['extended'])) { | 
|---|
| 1331 |                $sign = (boolean) $attr['extended'] ? '' : '!'; | 
|---|
| 1332 |                $if[] = $sign.'$_ctx->posts->isExtended()'; | 
|---|
| 1333 |           } | 
|---|
| 1334 |            | 
|---|
| 1335 |           if (isset($attr['selected'])) { | 
|---|
| 1336 |                $sign = (boolean) $attr['selected'] ? '' : '!'; | 
|---|
| 1337 |                $if[] = $sign.'(boolean)$_ctx->posts->post_selected'; | 
|---|
| 1338 |           } | 
|---|
| 1339 |            | 
|---|
| 1340 |           if (isset($attr['has_category'])) { | 
|---|
| 1341 |                $sign = (boolean) $attr['has_category'] ? '' : '!'; | 
|---|
| 1342 |                $if[] = $sign.'$_ctx->posts->cat_id'; | 
|---|
| 1343 |           } | 
|---|
| 1344 |            | 
|---|
| 1345 |           if (isset($attr['comments_active'])) { | 
|---|
| 1346 |                $sign = (boolean) $attr['comments_active'] ? '' : '!'; | 
|---|
| 1347 |                $if[] = $sign.'$_ctx->posts->commentsActive()'; | 
|---|
| 1348 |           } | 
|---|
| 1349 |            | 
|---|
| 1350 |           if (isset($attr['pings_active'])) { | 
|---|
| 1351 |                $sign = (boolean) $attr['pings_active'] ? '' : '!'; | 
|---|
| 1352 |                $if[] = $sign.'$_ctx->posts->trackbacksActive()'; | 
|---|
| 1353 |           } | 
|---|
| 1354 |            | 
|---|
| 1355 |           if (isset($attr['has_comment'])) { | 
|---|
| 1356 |                $sign = (boolean) $attr['has_comment'] ? '' : '!'; | 
|---|
| 1357 |                $if[] = $sign.'$_ctx->posts->hasComments()'; | 
|---|
| 1358 |           } | 
|---|
| 1359 |            | 
|---|
| 1360 |           if (isset($attr['has_ping'])) { | 
|---|
| 1361 |                $sign = (boolean) $attr['has_ping'] ? '' : '!'; | 
|---|
| 1362 |                $if[] = $sign.'$_ctx->posts->hasTrackbacks()'; | 
|---|
| 1363 |           } | 
|---|
| 1364 |            | 
|---|
| 1365 |           if (isset($attr['show_comments'])) { | 
|---|
| 1366 |                if ((boolean) $attr['show_comments']) { | 
|---|
| 1367 |                     $if[] = '($_ctx->posts->hasComments() || $_ctx->posts->commentsActive())'; | 
|---|
| 1368 |                } else { | 
|---|
| 1369 |                     $if[] = '(!$_ctx->posts->hasComments() && !$_ctx->posts->commentsActive())'; | 
|---|
| 1370 |                } | 
|---|
| 1371 |           } | 
|---|
| 1372 |            | 
|---|
| 1373 |           if (isset($attr['show_pings'])) { | 
|---|
| 1374 |                if ((boolean) $attr['show_pings']) { | 
|---|
| 1375 |                     $if[] = '($_ctx->posts->hasTrackbacks() || $_ctx->posts->trackbacksActive())'; | 
|---|
| 1376 |                } else { | 
|---|
| 1377 |                     $if[] = '(!$_ctx->posts->hasTrackbacks() && !$_ctx->posts->trackbacksActive())'; | 
|---|
| 1378 |                } | 
|---|
| 1379 |           } | 
|---|
| 1380 |            | 
|---|
| 1381 |           if (isset($attr['republished'])) { | 
|---|
| 1382 |                $sign = (boolean) $attr['republished'] ? '' : '!'; | 
|---|
| 1383 |                $if[] = $sign.'(boolean)$_ctx->posts->isRepublished()'; | 
|---|
| 1384 |           } | 
|---|
| 1385 |            | 
|---|
| 1386 |           $this->core->callBehavior('tplIfConditions','EntryIf',$attr,$content,$if); | 
|---|
| 1387 |            | 
|---|
| 1388 |           if (count($if) != 0) { | 
|---|
| 1389 |                return '<?php if('.implode(' '.$operator.' ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; | 
|---|
| 1390 |           } else { | 
|---|
| 1391 |                return $content; | 
|---|
| 1392 |           } | 
|---|
| 1393 |      } | 
|---|
| 1394 |       | 
|---|
| 1395 |      /*dtd | 
|---|
| 1396 |      <!ELEMENT tpl:EntryIfFirst - O -- displays value if entry is the first one --> | 
|---|
| 1397 |      <!ATTLIST tpl:EntryIfFirst | 
|---|
| 1398 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: first) | 
|---|
| 1399 |      > | 
|---|
| 1400 |      */ | 
|---|
| 1401 |      public function EntryIfFirst($attr) | 
|---|
| 1402 |      { | 
|---|
| 1403 |           $ret = isset($attr['return']) ? $attr['return'] : 'first'; | 
|---|
| 1404 |           $ret = html::escapeHTML($ret); | 
|---|
| 1405 |            | 
|---|
| 1406 |           return | 
|---|
| 1407 |           '<?php if ($_ctx->posts->index() == 0) { '. | 
|---|
| 1408 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 1409 |      } | 
|---|
| 1410 |       | 
|---|
| 1411 |      /*dtd | 
|---|
| 1412 |      <!ELEMENT tpl:EntryIfOdd - O -- displays value if entry is in an odd position --> | 
|---|
| 1413 |      <!ATTLIST tpl:EntryIfOdd | 
|---|
| 1414 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: odd) | 
|---|
| 1415 |      > | 
|---|
| 1416 |      */ | 
|---|
| 1417 |      public function EntryIfOdd($attr) | 
|---|
| 1418 |      { | 
|---|
| 1419 |           $ret = isset($attr['return']) ? $attr['return'] : 'odd'; | 
|---|
| 1420 |           $ret = html::escapeHTML($ret); | 
|---|
| 1421 |            | 
|---|
| 1422 |           return | 
|---|
| 1423 |           '<?php if (($_ctx->posts->index()+1)%2 == 1) { '. | 
|---|
| 1424 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 1425 |      } | 
|---|
| 1426 |       | 
|---|
| 1427 |      /*dtd | 
|---|
| 1428 |      <!ELEMENT tpl:EntryIfSelected - O -- displays value if entry is selected --> | 
|---|
| 1429 |      <!ATTLIST tpl:EntryIfSelected | 
|---|
| 1430 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: selected) | 
|---|
| 1431 |      > | 
|---|
| 1432 |      */ | 
|---|
| 1433 |      public function EntryIfSelected($attr) | 
|---|
| 1434 |      { | 
|---|
| 1435 |           $ret = isset($attr['return']) ? $attr['return'] : 'selected'; | 
|---|
| 1436 |           $ret = html::escapeHTML($ret); | 
|---|
| 1437 |            | 
|---|
| 1438 |           return | 
|---|
| 1439 |           '<?php if ($_ctx->posts->post_selected) { '. | 
|---|
| 1440 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 1441 |      } | 
|---|
| 1442 |       | 
|---|
| 1443 |      /*dtd | 
|---|
| 1444 |      <!ELEMENT tpl:EntryContent - O -- Entry content --> | 
|---|
| 1445 |      <!ATTLIST tpl:EntryContent | 
|---|
| 1446 |      absolute_urls  CDATA     #IMPLIED -- transforms local URLs to absolute one | 
|---|
| 1447 |      full           (1|0)     #IMPLIED -- returns full content with excerpt | 
|---|
| 1448 |      > | 
|---|
| 1449 |      */ | 
|---|
| 1450 |      public function EntryContent($attr) | 
|---|
| 1451 |      { | 
|---|
| 1452 |           $urls = '0'; | 
|---|
| 1453 |           if (!empty($attr['absolute_urls'])) { | 
|---|
| 1454 |                $urls = '1'; | 
|---|
| 1455 |           } | 
|---|
| 1456 |            | 
|---|
| 1457 |           $f = $this->getFilters($attr); | 
|---|
| 1458 |            | 
|---|
| 1459 |           if (!empty($attr['full'])) { | 
|---|
| 1460 |                return '<?php echo '.sprintf($f, | 
|---|
| 1461 |                     '$_ctx->posts->getExcerpt('.$urls.')." ".$_ctx->posts->getContent('.$urls.')').'; ?>'; | 
|---|
| 1462 |           } else { | 
|---|
| 1463 |                return '<?php echo '.sprintf($f,'$_ctx->posts->getContent('.$urls.')').'; ?>'; | 
|---|
| 1464 |           } | 
|---|
| 1465 |      } | 
|---|
| 1466 |       | 
|---|
| 1467 |      /*dtd | 
|---|
| 1468 |      <!ELEMENT tpl:EntryExcerpt - O -- Entry excerpt --> | 
|---|
| 1469 |      <!ATTLIST tpl:EntryExcerpt | 
|---|
| 1470 |      absolute_urls  CDATA     #IMPLIED -- transforms local URLs to absolute one | 
|---|
| 1471 |      > | 
|---|
| 1472 |      */ | 
|---|
| 1473 |      public function EntryExcerpt($attr) | 
|---|
| 1474 |      { | 
|---|
| 1475 |           $urls = '0'; | 
|---|
| 1476 |           if (!empty($attr['absolute_urls'])) { | 
|---|
| 1477 |                $urls = '1'; | 
|---|
| 1478 |           } | 
|---|
| 1479 |            | 
|---|
| 1480 |           $f = $this->getFilters($attr); | 
|---|
| 1481 |           return '<?php echo '.sprintf($f,'$_ctx->posts->getExcerpt('.$urls.')').'; ?>'; | 
|---|
| 1482 |      } | 
|---|
| 1483 |       | 
|---|
| 1484 |       | 
|---|
| 1485 |      /*dtd | 
|---|
| 1486 |      <!ELEMENT tpl:EntryAuthorCommonName - O -- Entry author common name --> | 
|---|
| 1487 |      */ | 
|---|
| 1488 |      public function EntryAuthorCommonName($attr) | 
|---|
| 1489 |      { | 
|---|
| 1490 |           $f = $this->getFilters($attr); | 
|---|
| 1491 |           return '<?php echo '.sprintf($f,'$_ctx->posts->getAuthorCN()').'; ?>'; | 
|---|
| 1492 |      } | 
|---|
| 1493 |       | 
|---|
| 1494 |      /*dtd | 
|---|
| 1495 |      <!ELEMENT tpl:EntryAuthorDisplayName - O -- Entry author display name --> | 
|---|
| 1496 |      */ | 
|---|
| 1497 |      public function EntryAuthorDisplayName($attr) | 
|---|
| 1498 |      { | 
|---|
| 1499 |           $f = $this->getFilters($attr); | 
|---|
| 1500 |           return '<?php echo '.sprintf($f,'$_ctx->posts->user_displayname').'; ?>'; | 
|---|
| 1501 |      } | 
|---|
| 1502 |       | 
|---|
| 1503 |      /*dtd | 
|---|
| 1504 |      <!ELEMENT tpl:EntryAuthorID - O -- Entry author ID --> | 
|---|
| 1505 |      */ | 
|---|
| 1506 |      public function EntryAuthorID($attr) | 
|---|
| 1507 |      { | 
|---|
| 1508 |           $f = $this->getFilters($attr); | 
|---|
| 1509 |           return '<?php echo '.sprintf($f,'$_ctx->posts->user_id').'; ?>'; | 
|---|
| 1510 |      } | 
|---|
| 1511 |       | 
|---|
| 1512 |      /*dtd | 
|---|
| 1513 |      <!ELEMENT tpl:EntryAuthorEmail - O -- Entry author email --> | 
|---|
| 1514 |      <!ATTLIST tpl:EntryAuthorEmail | 
|---|
| 1515 |      spam_protected (0|1)     #IMPLIED  -- protect email from spam (default: 1) | 
|---|
| 1516 |      > | 
|---|
| 1517 |      */ | 
|---|
| 1518 |      public function EntryAuthorEmail($attr) | 
|---|
| 1519 |      { | 
|---|
| 1520 |           $p = 'true'; | 
|---|
| 1521 |           if (isset($attr['spam_protected']) && !$attr['spam_protected']) { | 
|---|
| 1522 |                $p = 'false'; | 
|---|
| 1523 |           } | 
|---|
| 1524 |            | 
|---|
| 1525 |           $f = $this->getFilters($attr); | 
|---|
| 1526 |           return '<?php echo '.sprintf($f,"\$_ctx->posts->getAuthorEmail(".$p.")").'; ?>'; | 
|---|
| 1527 |      } | 
|---|
| 1528 |       | 
|---|
| 1529 |      /*dtd | 
|---|
| 1530 |      <!ELEMENT tpl:EntryAuthorLink - O -- Entry author link --> | 
|---|
| 1531 |      */ | 
|---|
| 1532 |      public function EntryAuthorLink($attr) | 
|---|
| 1533 |      { | 
|---|
| 1534 |           $f = $this->getFilters($attr); | 
|---|
| 1535 |           return '<?php echo '.sprintf($f,'$_ctx->posts->getAuthorLink()').'; ?>'; | 
|---|
| 1536 |      } | 
|---|
| 1537 |       | 
|---|
| 1538 |      /*dtd | 
|---|
| 1539 |      <!ELEMENT tpl:EntryAuthorURL - O -- Entry author URL --> | 
|---|
| 1540 |      */ | 
|---|
| 1541 |      public function EntryAuthorURL($attr) | 
|---|
| 1542 |      { | 
|---|
| 1543 |           $f = $this->getFilters($attr); | 
|---|
| 1544 |           return '<?php echo '.sprintf($f,'$_ctx->posts->user_url').'; ?>'; | 
|---|
| 1545 |      } | 
|---|
| 1546 |       | 
|---|
| 1547 |      /*dtd | 
|---|
| 1548 |      <!ELEMENT tpl:EntryBasename - O -- Entry short URL (relative to /post) --> | 
|---|
| 1549 |      */ | 
|---|
| 1550 |      public function EntryBasename($attr) | 
|---|
| 1551 |      { | 
|---|
| 1552 |           $f = $this->getFilters($attr); | 
|---|
| 1553 |           return '<?php echo '.sprintf($f,'$_ctx->posts->post_url').'; ?>'; | 
|---|
| 1554 |      } | 
|---|
| 1555 |       | 
|---|
| 1556 |      /*dtd | 
|---|
| 1557 |      <!ELEMENT tpl:EntryCategory - O -- Entry category (full name) --> | 
|---|
| 1558 |      */ | 
|---|
| 1559 |      public function EntryCategory($attr) | 
|---|
| 1560 |      { | 
|---|
| 1561 |           $f = $this->getFilters($attr); | 
|---|
| 1562 |           return '<?php echo '.sprintf($f,'$_ctx->posts->cat_title').'; ?>'; | 
|---|
| 1563 |      } | 
|---|
| 1564 |       | 
|---|
| 1565 |      /*dtd | 
|---|
| 1566 |      <!ELEMENT tpl:EntryCategoriesBreadcrumb - - -- Current entry parents loop (without last one) --> | 
|---|
| 1567 |      */ | 
|---|
| 1568 |      public function EntryCategoriesBreadcrumb($attr,$content) | 
|---|
| 1569 |      { | 
|---|
| 1570 |           return | 
|---|
| 1571 |           "<?php\n". | 
|---|
| 1572 |           '$_ctx->categories = $core->blog->getCategoryParents($_ctx->posts->cat_id);'."\n". | 
|---|
| 1573 |           'while ($_ctx->categories->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->categories = null; ?>'; | 
|---|
| 1574 |      } | 
|---|
| 1575 |       | 
|---|
| 1576 |      /*dtd | 
|---|
| 1577 |      <!ELEMENT tpl:EntryCategoryID - O -- Entry category ID --> | 
|---|
| 1578 |      */ | 
|---|
| 1579 |      public function EntryCategoryID($attr) | 
|---|
| 1580 |      { | 
|---|
| 1581 |           $f = $this->getFilters($attr); | 
|---|
| 1582 |           return '<?php echo '.sprintf($f,'$_ctx->posts->cat_id').'; ?>'; | 
|---|
| 1583 |      } | 
|---|
| 1584 |       | 
|---|
| 1585 |      /*dtd | 
|---|
| 1586 |      <!ELEMENT tpl:EntryCategoryURL - O -- Entry category URL --> | 
|---|
| 1587 |      */ | 
|---|
| 1588 |      public function EntryCategoryURL($attr) | 
|---|
| 1589 |      { | 
|---|
| 1590 |           $f = $this->getFilters($attr); | 
|---|
| 1591 |           return '<?php echo '.sprintf($f,'$_ctx->posts->getCategoryURL()').'; ?>'; | 
|---|
| 1592 |      } | 
|---|
| 1593 |       | 
|---|
| 1594 |      /*dtd | 
|---|
| 1595 |      <!ELEMENT tpl:EntryCategoryShortURL - O -- Entry category short URL (relative URL, from /category/) --> | 
|---|
| 1596 |      */ | 
|---|
| 1597 |      public function EntryCategoryShortURL($attr) | 
|---|
| 1598 |      { | 
|---|
| 1599 |           $f = $this->getFilters($attr); | 
|---|
| 1600 |           return '<?php echo '.sprintf($f,'$_ctx->posts->cat_url').'; ?>'; | 
|---|
| 1601 |      } | 
|---|
| 1602 |       | 
|---|
| 1603 |       | 
|---|
| 1604 |      /*dtd | 
|---|
| 1605 |      <!ELEMENT tpl:EntryFeedID - O -- Entry feed ID --> | 
|---|
| 1606 |      */ | 
|---|
| 1607 |      public function EntryFeedID($attr) | 
|---|
| 1608 |      { | 
|---|
| 1609 |           $f = $this->getFilters($attr); | 
|---|
| 1610 |           return '<?php echo '.sprintf($f,'$_ctx->posts->getFeedID()').'; ?>'; | 
|---|
| 1611 |      } | 
|---|
| 1612 |       | 
|---|
| 1613 |      /*dtd | 
|---|
| 1614 |      <!ELEMENT tpl:EntryFirstImage - O -- Extracts entry first image if exists --> | 
|---|
| 1615 |      <!ATTLIST tpl:EntryAuthorEmail | 
|---|
| 1616 |      size           (sq|t|s|m|o)   #IMPLIED  -- Image size to extract | 
|---|
| 1617 |      class          CDATA          #IMPLIED  -- Class to add on image tag | 
|---|
| 1618 |      with_category  (1|0)          #IMPLIED  -- Search in entry category description if present (default 0) | 
|---|
| 1619 |      no_tag    (1|0)     #IMPLIED  -- Return image URL without HTML tag (default 0) | 
|---|
| 1620 |      > | 
|---|
| 1621 |      */ | 
|---|
| 1622 |      public function EntryFirstImage($attr) | 
|---|
| 1623 |      { | 
|---|
| 1624 |           $size = !empty($attr['size']) ? $attr['size'] : ''; | 
|---|
| 1625 |           $class = !empty($attr['class']) ? $attr['class'] : ''; | 
|---|
| 1626 |           $with_category = !empty($attr['with_category']) ? 'true' : 'false'; | 
|---|
| 1627 |           $no_tag = !empty($attr['no_tag']) ? 'true' : 'false'; | 
|---|
| 1628 |            | 
|---|
| 1629 |           return "<?php echo context::EntryFirstImageHelper('".addslashes($size)."',".$with_category.",'".addslashes($class).",'".$no_tag."'); ?>"; | 
|---|
| 1630 |      } | 
|---|
| 1631 |       | 
|---|
| 1632 |      /*dtd | 
|---|
| 1633 |      <!ELEMENT tpl:EntryID - O -- Entry ID --> | 
|---|
| 1634 |      */ | 
|---|
| 1635 |      public function EntryID($attr) | 
|---|
| 1636 |      { | 
|---|
| 1637 |           $f = $this->getFilters($attr); | 
|---|
| 1638 |           return '<?php echo '.sprintf($f,'$_ctx->posts->post_id').'; ?>'; | 
|---|
| 1639 |      } | 
|---|
| 1640 |       | 
|---|
| 1641 |      /*dtd | 
|---|
| 1642 |      <!ELEMENT tpl:EntryLang - O --  Entry language or blog lang if not defined --> | 
|---|
| 1643 |      */ | 
|---|
| 1644 |      public function EntryLang($attr) | 
|---|
| 1645 |      { | 
|---|
| 1646 |           $f = $this->getFilters($attr); | 
|---|
| 1647 |           return | 
|---|
| 1648 |           '<?php if ($_ctx->posts->post_lang) { '. | 
|---|
| 1649 |                'echo '.sprintf($f,'$_ctx->posts->post_lang').'; '. | 
|---|
| 1650 |           '} else {'. | 
|---|
| 1651 |                'echo '.sprintf($f,'$core->blog->settings->system->lang').'; '. | 
|---|
| 1652 |           '} ?>'; | 
|---|
| 1653 |      } | 
|---|
| 1654 |       | 
|---|
| 1655 |      /*dtd | 
|---|
| 1656 |      <!ELEMENT tpl:EntryNext - - -- Next entry block --> | 
|---|
| 1657 |      <!ATTLIST tpl:EntryNext | 
|---|
| 1658 |      restrict_to_category     (0|1)     #IMPLIED  -- find next post in the same category (default: 0) | 
|---|
| 1659 |      restrict_to_lang         (0|1)     #IMPLIED  -- find next post in the same language (default: 0) | 
|---|
| 1660 |      > | 
|---|
| 1661 |      */ | 
|---|
| 1662 |      public function EntryNext($attr,$content) | 
|---|
| 1663 |      { | 
|---|
| 1664 |           $restrict_to_category = !empty($attr['restrict_to_category']) ? '1' : '0'; | 
|---|
| 1665 |           $restrict_to_lang = !empty($attr['restrict_to_lang']) ? '1' : '0'; | 
|---|
| 1666 |            | 
|---|
| 1667 |           return | 
|---|
| 1668 |           '<?php $next_post = $core->blog->getNextPost($_ctx->posts,1,'.$restrict_to_category.','.$restrict_to_lang.'); ?>'."\n". | 
|---|
| 1669 |           '<?php if ($next_post !== null) : ?>'. | 
|---|
| 1670 |                 | 
|---|
| 1671 |                '<?php $_ctx->posts = $next_post; unset($next_post);'."\n". | 
|---|
| 1672 |                'while ($_ctx->posts->fetch()) : ?>'. | 
|---|
| 1673 |                $content. | 
|---|
| 1674 |                '<?php endwhile; $_ctx->posts = null; ?>'. | 
|---|
| 1675 |           "<?php endif; ?>\n"; | 
|---|
| 1676 |      } | 
|---|
| 1677 |       | 
|---|
| 1678 |      /*dtd | 
|---|
| 1679 |      <!ELEMENT tpl:EntryPrevious - - -- Previous entry block --> | 
|---|
| 1680 |      <!ATTLIST tpl:EntryPrevious | 
|---|
| 1681 |      restrict_to_category     (0|1)     #IMPLIED  -- find previous post in the same category (default: 0) | 
|---|
| 1682 |      restrict_to_lang         (0|1)     #IMPLIED  -- find next post in the same language (default: 0) | 
|---|
| 1683 |      > | 
|---|
| 1684 |      */ | 
|---|
| 1685 |      public function EntryPrevious($attr,$content) | 
|---|
| 1686 |      { | 
|---|
| 1687 |           $restrict_to_category = !empty($attr['restrict_to_category']) ? '1' : '0'; | 
|---|
| 1688 |           $restrict_to_lang = !empty($attr['restrict_to_lang']) ? '1' : '0'; | 
|---|
| 1689 |            | 
|---|
| 1690 |           return | 
|---|
| 1691 |           '<?php $prev_post = $core->blog->getNextPost($_ctx->posts,-1,'.$restrict_to_category.','.$restrict_to_lang.'); ?>'."\n". | 
|---|
| 1692 |           '<?php if ($prev_post !== null) : ?>'. | 
|---|
| 1693 |                 | 
|---|
| 1694 |                '<?php $_ctx->posts = $prev_post; unset($prev_post);'."\n". | 
|---|
| 1695 |                'while ($_ctx->posts->fetch()) : ?>'. | 
|---|
| 1696 |                $content. | 
|---|
| 1697 |                '<?php endwhile; $_ctx->posts = null; ?>'. | 
|---|
| 1698 |           "<?php endif; ?>\n"; | 
|---|
| 1699 |      } | 
|---|
| 1700 |       | 
|---|
| 1701 |      /*dtd | 
|---|
| 1702 |      <!ELEMENT tpl:EntryTitle - O -- Entry title --> | 
|---|
| 1703 |      */ | 
|---|
| 1704 |      public function EntryTitle($attr) | 
|---|
| 1705 |      { | 
|---|
| 1706 |           $f = $this->getFilters($attr); | 
|---|
| 1707 |           return '<?php echo '.sprintf($f,'$_ctx->posts->post_title').'; ?>'; | 
|---|
| 1708 |      } | 
|---|
| 1709 |       | 
|---|
| 1710 |      /*dtd | 
|---|
| 1711 |      <!ELEMENT tpl:EntryURL - O -- Entry URL --> | 
|---|
| 1712 |      */ | 
|---|
| 1713 |      public function EntryURL($attr) | 
|---|
| 1714 |      { | 
|---|
| 1715 |           $f = $this->getFilters($attr); | 
|---|
| 1716 |           return '<?php echo '.sprintf($f,'$_ctx->posts->getURL()').'; ?>'; | 
|---|
| 1717 |      } | 
|---|
| 1718 |       | 
|---|
| 1719 |      /*dtd | 
|---|
| 1720 |      <!ELEMENT tpl:EntryDate - O -- Entry date --> | 
|---|
| 1721 |      <!ATTLIST tpl:EntryDate | 
|---|
| 1722 |      format    CDATA     #IMPLIED  -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified) | 
|---|
| 1723 |      iso8601   CDATA     #IMPLIED  -- if set, tells that date format is ISO 8601 | 
|---|
| 1724 |      rfc822    CDATA     #IMPLIED  -- if set, tells that date format is RFC 822 | 
|---|
| 1725 |      upddt     CDATA     #IMPLIED  -- if set, uses the post update time | 
|---|
| 1726 |      creadt    CDATA     #IMPLIED  -- if set, uses the post creation time | 
|---|
| 1727 |      > | 
|---|
| 1728 |      */ | 
|---|
| 1729 |      public function EntryDate($attr) | 
|---|
| 1730 |      { | 
|---|
| 1731 |           $format = ''; | 
|---|
| 1732 |           if (!empty($attr['format'])) { | 
|---|
| 1733 |                $format = addslashes($attr['format']); | 
|---|
| 1734 |           } | 
|---|
| 1735 |            | 
|---|
| 1736 |           $iso8601 = !empty($attr['iso8601']); | 
|---|
| 1737 |           $rfc822 = !empty($attr['rfc822']); | 
|---|
| 1738 |           $type = (!empty($attr['creadt']) ? 'creadt' : ''); | 
|---|
| 1739 |           $type = (!empty($attr['upddt']) ? 'upddt' : $type); | 
|---|
| 1740 |            | 
|---|
| 1741 |           $f = $this->getFilters($attr); | 
|---|
| 1742 |            | 
|---|
| 1743 |           if ($rfc822) { | 
|---|
| 1744 |                return '<?php echo '.sprintf($f,"\$_ctx->posts->getRFC822Date('".$type."')").'; ?>'; | 
|---|
| 1745 |           } elseif ($iso8601) { | 
|---|
| 1746 |                return '<?php echo '.sprintf($f,"\$_ctx->posts->getISO8601Date('".$type."')").'; ?>'; | 
|---|
| 1747 |           } else { | 
|---|
| 1748 |                return '<?php echo '.sprintf($f,"\$_ctx->posts->getDate('".$format."','".$type."')").'; ?>'; | 
|---|
| 1749 |           } | 
|---|
| 1750 |      } | 
|---|
| 1751 |       | 
|---|
| 1752 |      /*dtd | 
|---|
| 1753 |      <!ELEMENT tpl:EntryTime - O -- Entry date --> | 
|---|
| 1754 |      <!ATTLIST tpl:EntryTime | 
|---|
| 1755 |      format    CDATA     #IMPLIED  -- time format  | 
|---|
| 1756 |      upddt     CDATA     #IMPLIED  -- if set, uses the post update time | 
|---|
| 1757 |      creadt    CDATA     #IMPLIED  -- if set, uses the post creation time | 
|---|
| 1758 |      > | 
|---|
| 1759 |      */ | 
|---|
| 1760 |      public function EntryTime($attr) | 
|---|
| 1761 |      { | 
|---|
| 1762 |           $format = ''; | 
|---|
| 1763 |           if (!empty($attr['format'])) { | 
|---|
| 1764 |                $format = addslashes($attr['format']); | 
|---|
| 1765 |           } | 
|---|
| 1766 |            | 
|---|
| 1767 |           $type = (!empty($attr['creadt']) ? 'creadt' : ''); | 
|---|
| 1768 |           $type = (!empty($attr['upddt']) ? 'upddt' : $type); | 
|---|
| 1769 |          | 
|---|
| 1770 |           $f = $this->getFilters($attr); | 
|---|
| 1771 |           return '<?php echo '.sprintf($f,"\$_ctx->posts->getTime('".$format."','".$type."')").'; ?>'; | 
|---|
| 1772 |      } | 
|---|
| 1773 |       | 
|---|
| 1774 |      /*dtd | 
|---|
| 1775 |      <!ELEMENT tpl:EntriesHeader - - -- First entries result container --> | 
|---|
| 1776 |      */ | 
|---|
| 1777 |      public function EntriesHeader($attr,$content) | 
|---|
| 1778 |      { | 
|---|
| 1779 |           return | 
|---|
| 1780 |           "<?php if (\$_ctx->posts->isStart()) : ?>". | 
|---|
| 1781 |           $content. | 
|---|
| 1782 |           "<?php endif; ?>"; | 
|---|
| 1783 |      } | 
|---|
| 1784 |       | 
|---|
| 1785 |      /*dtd | 
|---|
| 1786 |      <!ELEMENT tpl:EntriesFooter - - -- Last entries result container --> | 
|---|
| 1787 |      */ | 
|---|
| 1788 |      public function EntriesFooter($attr,$content) | 
|---|
| 1789 |      { | 
|---|
| 1790 |           return | 
|---|
| 1791 |           "<?php if (\$_ctx->posts->isEnd()) : ?>". | 
|---|
| 1792 |           $content. | 
|---|
| 1793 |           "<?php endif; ?>"; | 
|---|
| 1794 |      } | 
|---|
| 1795 |       | 
|---|
| 1796 |      /*dtd | 
|---|
| 1797 |      <!ELEMENT tpl:EntryCommentCount - O -- Number of comments for entry --> | 
|---|
| 1798 |      <!ATTLIST tpl:EntryCommentCount | 
|---|
| 1799 |      none      CDATA     #IMPLIED  -- text to display for "no comment" (default: no comment) | 
|---|
| 1800 |      one       CDATA     #IMPLIED  -- text to display for "one comment" (default: one comment) | 
|---|
| 1801 |      more      CDATA     #IMPLIED  -- text to display for "more comments" (default: %s comments, %s is replaced by the number of comment) | 
|---|
| 1802 |      count_all CDATA     #IMPLIED  -- count comments and trackbacks | 
|---|
| 1803 |      > | 
|---|
| 1804 |      */ | 
|---|
| 1805 |      public function EntryCommentCount($attr) | 
|---|
| 1806 |      { | 
|---|
| 1807 |           $none = 'no comment'; | 
|---|
| 1808 |           $one = 'one comment'; | 
|---|
| 1809 |           $more = '%d comments'; | 
|---|
| 1810 |            | 
|---|
| 1811 |           if (isset($attr['none'])) { | 
|---|
| 1812 |                $none = addslashes($attr['none']); | 
|---|
| 1813 |           } | 
|---|
| 1814 |           if (isset($attr['one'])) { | 
|---|
| 1815 |                $one = addslashes($attr['one']); | 
|---|
| 1816 |           } | 
|---|
| 1817 |           if (isset($attr['more'])) { | 
|---|
| 1818 |                $more = addslashes($attr['more']); | 
|---|
| 1819 |           } | 
|---|
| 1820 |            | 
|---|
| 1821 |           if (empty($attr['count_all'])) { | 
|---|
| 1822 |                $operation = '$_ctx->posts->nb_comment'; | 
|---|
| 1823 |           } else { | 
|---|
| 1824 |                $operation = '($_ctx->posts->nb_comment + $_ctx->posts->nb_trackback)'; | 
|---|
| 1825 |           } | 
|---|
| 1826 |            | 
|---|
| 1827 |           return | 
|---|
| 1828 |           "<?php if (".$operation." == 0) {\n". | 
|---|
| 1829 |           "  printf(__('".$none."'),".$operation.");\n". | 
|---|
| 1830 |           "} elseif (".$operation." == 1) {\n". | 
|---|
| 1831 |           "  printf(__('".$one."'),".$operation.");\n". | 
|---|
| 1832 |           "} else {\n". | 
|---|
| 1833 |           "  printf(__('".$more."'),".$operation.");\n". | 
|---|
| 1834 |           "} ?>"; | 
|---|
| 1835 |      } | 
|---|
| 1836 |       | 
|---|
| 1837 |      /*dtd | 
|---|
| 1838 |      <!ELEMENT tpl:EntryPingCount - O -- Number of trackbacks for entry --> | 
|---|
| 1839 |      <!ATTLIST tpl:EntryPingCount | 
|---|
| 1840 |      none CDATA     #IMPLIED  -- text to display for "no ping" (default: no ping) | 
|---|
| 1841 |      one  CDATA     #IMPLIED  -- text to display for "one ping" (default: one ping) | 
|---|
| 1842 |      more CDATA     #IMPLIED  -- text to display for "more pings" (default: %s trackbacks, %s is replaced by the number of pings) | 
|---|
| 1843 |      > | 
|---|
| 1844 |      */ | 
|---|
| 1845 |      public function EntryPingCount($attr) | 
|---|
| 1846 |      { | 
|---|
| 1847 |           $none = 'no trackback'; | 
|---|
| 1848 |           $one = 'one trackback'; | 
|---|
| 1849 |           $more = '%d trackbacks'; | 
|---|
| 1850 |            | 
|---|
| 1851 |           if (isset($attr['none'])) { | 
|---|
| 1852 |                $none = addslashes($attr['none']); | 
|---|
| 1853 |           } | 
|---|
| 1854 |           if (isset($attr['one'])) { | 
|---|
| 1855 |                $one = addslashes($attr['one']); | 
|---|
| 1856 |           } | 
|---|
| 1857 |           if (isset($attr['more'])) { | 
|---|
| 1858 |                $more = addslashes($attr['more']); | 
|---|
| 1859 |           } | 
|---|
| 1860 |            | 
|---|
| 1861 |           return | 
|---|
| 1862 |           "<?php if (\$_ctx->posts->nb_trackback == 0) {\n". | 
|---|
| 1863 |           "  printf(__('".$none."'),(integer) \$_ctx->posts->nb_trackback);\n". | 
|---|
| 1864 |           "} elseif (\$_ctx->posts->nb_trackback == 1) {\n". | 
|---|
| 1865 |           "  printf(__('".$one."'),(integer) \$_ctx->posts->nb_trackback);\n". | 
|---|
| 1866 |           "} else {\n". | 
|---|
| 1867 |           "  printf(__('".$more."'),(integer) \$_ctx->posts->nb_trackback);\n". | 
|---|
| 1868 |           "} ?>"; | 
|---|
| 1869 |      } | 
|---|
| 1870 |       | 
|---|
| 1871 |      /*dtd | 
|---|
| 1872 |      <!ELEMENT tpl:EntryPingData - O -- Display trackback RDF information --> | 
|---|
| 1873 |      */ | 
|---|
| 1874 |      public function EntryPingData($attr) | 
|---|
| 1875 |      { | 
|---|
| 1876 |           return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackData(); } ?>\n"; | 
|---|
| 1877 |      } | 
|---|
| 1878 |       | 
|---|
| 1879 |      /*dtd | 
|---|
| 1880 |      <!ELEMENT tpl:EntryPingLink - O -- Entry trackback link --> | 
|---|
| 1881 |      */ | 
|---|
| 1882 |      public function EntryPingLink($attr) | 
|---|
| 1883 |      { | 
|---|
| 1884 |           return "<?php if (\$_ctx->posts->trackbacksActive()) { echo \$_ctx->posts->getTrackbackLink(); } ?>\n"; | 
|---|
| 1885 |      } | 
|---|
| 1886 |       | 
|---|
| 1887 |      /* Languages -------------------------------------- */ | 
|---|
| 1888 |      /*dtd | 
|---|
| 1889 |      <!ELEMENT tpl:Languages - - -- Languages loop --> | 
|---|
| 1890 |      <!ATTLIST tpl:Languages | 
|---|
| 1891 |      lang CDATA     #IMPLIED  -- restrict loop on given lang | 
|---|
| 1892 |      order     (desc|asc)     #IMPLIED  -- languages ordering (default: desc) | 
|---|
| 1893 |      > | 
|---|
| 1894 |      */ | 
|---|
| 1895 |      public function Languages($attr,$content) | 
|---|
| 1896 |      { | 
|---|
| 1897 |           $p = "if (!isset(\$params)) \$params = array();\n"; | 
|---|
| 1898 |            | 
|---|
| 1899 |           if (isset($attr['lang'])) { | 
|---|
| 1900 |                $p = "\$params['lang'] = '".addslashes($attr['lang'])."';\n"; | 
|---|
| 1901 |           } | 
|---|
| 1902 |            | 
|---|
| 1903 |           $order = 'desc'; | 
|---|
| 1904 |           if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) { | 
|---|
| 1905 |                $p .= "\$params['order'] = '".$attr['order']."';\n "; | 
|---|
| 1906 |           } | 
|---|
| 1907 |            | 
|---|
| 1908 |           $res = "<?php\n"; | 
|---|
| 1909 |           $res .= $p; | 
|---|
| 1910 |           $res .= $this->core->callBehavior("templatePrepareParams",  | 
|---|
| 1911 |                array("tag" => "Languages","method" => "blog::getLangs"),  | 
|---|
| 1912 |                $attr,$content); | 
|---|
| 1913 |           $res .= '$_ctx->langs = $core->blog->getLangs($params); unset($params);'."\n"; | 
|---|
| 1914 |           $res .= "?>\n"; | 
|---|
| 1915 |            | 
|---|
| 1916 |           $res .= | 
|---|
| 1917 |           '<?php if ($_ctx->langs->count() > 1) : '. | 
|---|
| 1918 |           'while ($_ctx->langs->fetch()) : ?>'.$content. | 
|---|
| 1919 |           '<?php endwhile; $_ctx->langs = null; endif; ?>'; | 
|---|
| 1920 |            | 
|---|
| 1921 |           return $res; | 
|---|
| 1922 |      } | 
|---|
| 1923 |       | 
|---|
| 1924 |      /*dtd | 
|---|
| 1925 |      <!ELEMENT tpl:LanguagesHeader - - -- First languages result container --> | 
|---|
| 1926 |      */ | 
|---|
| 1927 |      public function LanguagesHeader($attr,$content) | 
|---|
| 1928 |      { | 
|---|
| 1929 |           return | 
|---|
| 1930 |           "<?php if (\$_ctx->langs->isStart()) : ?>". | 
|---|
| 1931 |           $content. | 
|---|
| 1932 |           "<?php endif; ?>"; | 
|---|
| 1933 |      } | 
|---|
| 1934 |       | 
|---|
| 1935 |      /*dtd | 
|---|
| 1936 |      <!ELEMENT tpl:LanguagesFooter - - -- Last languages result container --> | 
|---|
| 1937 |      */ | 
|---|
| 1938 |      public function LanguagesFooter($attr,$content) | 
|---|
| 1939 |      { | 
|---|
| 1940 |           return | 
|---|
| 1941 |           "<?php if (\$_ctx->langs->isEnd()) : ?>". | 
|---|
| 1942 |           $content. | 
|---|
| 1943 |           "<?php endif; ?>"; | 
|---|
| 1944 |      } | 
|---|
| 1945 |       | 
|---|
| 1946 |      /*dtd | 
|---|
| 1947 |      <!ELEMENT tpl:LanguageCode - O -- Language code --> | 
|---|
| 1948 |      */ | 
|---|
| 1949 |      public function LanguageCode($attr) | 
|---|
| 1950 |      { | 
|---|
| 1951 |           $f = $this->getFilters($attr); | 
|---|
| 1952 |           return '<?php echo '.sprintf($f,'$_ctx->langs->post_lang').'; ?>'; | 
|---|
| 1953 |      } | 
|---|
| 1954 |       | 
|---|
| 1955 |      /*dtd | 
|---|
| 1956 |      <!ELEMENT tpl:LanguageIfCurrent - - -- tests if post language is current language --> | 
|---|
| 1957 |      */ | 
|---|
| 1958 |      public function LanguageIfCurrent($attr,$content) | 
|---|
| 1959 |      { | 
|---|
| 1960 |           return | 
|---|
| 1961 |           "<?php if (\$_ctx->cur_lang == \$_ctx->langs->post_lang) : ?>". | 
|---|
| 1962 |           $content. | 
|---|
| 1963 |           "<?php endif; ?>"; | 
|---|
| 1964 |      } | 
|---|
| 1965 |       | 
|---|
| 1966 |      /*dtd | 
|---|
| 1967 |      <!ELEMENT tpl:LanguageURL - O -- Language URL --> | 
|---|
| 1968 |      */ | 
|---|
| 1969 |      public function LanguageURL($attr) | 
|---|
| 1970 |      { | 
|---|
| 1971 |           $f = $this->getFilters($attr); | 
|---|
| 1972 |           return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getURLFor("lang",'. | 
|---|
| 1973 |                '$_ctx->langs->post_lang)').'; ?>'; | 
|---|
| 1974 |      } | 
|---|
| 1975 |       | 
|---|
| 1976 |      /* Pagination ------------------------------------- */ | 
|---|
| 1977 |      /*dtd | 
|---|
| 1978 |      <!ELEMENT tpl:Pagination - - -- Pagination container --> | 
|---|
| 1979 |      <!ATTLIST tpl:Pagination | 
|---|
| 1980 |      no_context     (0|1)     #IMPLIED  -- override test on posts count vs number of posts per page | 
|---|
| 1981 |      > | 
|---|
| 1982 |      */ | 
|---|
| 1983 |      public function Pagination($attr,$content) | 
|---|
| 1984 |      { | 
|---|
| 1985 |           $p = "<?php\n"; | 
|---|
| 1986 |           $p .= '$params = $_ctx->post_params;'."\n"; | 
|---|
| 1987 |           $p .= $this->core->callBehavior("templatePrepareParams",  | 
|---|
| 1988 |                array("tag" => "Pagination","method" => "blog::getPosts"),  | 
|---|
| 1989 |                $attr,$content); | 
|---|
| 1990 |           $p .= '$_ctx->pagination = $core->blog->getPosts($params,true); unset($params);'."\n"; | 
|---|
| 1991 |           $p .= "?>\n"; | 
|---|
| 1992 |            | 
|---|
| 1993 |           if (isset($attr['no_context']) && $attr['no_context']) { | 
|---|
| 1994 |                return $p.$content; | 
|---|
| 1995 |           } | 
|---|
| 1996 |          | 
|---|
| 1997 |           return | 
|---|
| 1998 |                $p. | 
|---|
| 1999 |                '<?php if ($_ctx->pagination->f(0) > $_ctx->posts->count()) : ?>'. | 
|---|
| 2000 |                $content. | 
|---|
| 2001 |                '<?php endif; ?>'; | 
|---|
| 2002 |      } | 
|---|
| 2003 |       | 
|---|
| 2004 |      /*dtd | 
|---|
| 2005 |      <!ELEMENT tpl:PaginationCounter - O -- Number of pages --> | 
|---|
| 2006 |      */ | 
|---|
| 2007 |      public function PaginationCounter($attr) | 
|---|
| 2008 |      { | 
|---|
| 2009 |           $f = $this->getFilters($attr); | 
|---|
| 2010 |           return '<?php echo '.sprintf($f,"context::PaginationNbPages()").'; ?>'; | 
|---|
| 2011 |      } | 
|---|
| 2012 |       | 
|---|
| 2013 |      /*dtd | 
|---|
| 2014 |      <!ELEMENT tpl:PaginationCurrent - O -- current page --> | 
|---|
| 2015 |      */ | 
|---|
| 2016 |      public function PaginationCurrent($attr) | 
|---|
| 2017 |      { | 
|---|
| 2018 |           $offset = 0; | 
|---|
| 2019 |           if (isset($attr['offset'])) { | 
|---|
| 2020 |                $offset = (integer) $attr['offset']; | 
|---|
| 2021 |           } | 
|---|
| 2022 |            | 
|---|
| 2023 |           $f = $this->getFilters($attr); | 
|---|
| 2024 |           return '<?php echo '.sprintf($f,"context::PaginationPosition(".$offset.")").'; ?>'; | 
|---|
| 2025 |      } | 
|---|
| 2026 |       | 
|---|
| 2027 |      /*dtd | 
|---|
| 2028 |      <!ELEMENT tpl:PaginationIf - - -- pages tests --> | 
|---|
| 2029 |      <!ATTLIST tpl:PaginationIf | 
|---|
| 2030 |      start     (0|1)     #IMPLIED  -- test if we are at first page (value : 1) or not (value : 0) | 
|---|
| 2031 |      end  (0|1)     #IMPLIED  -- test if we are at last page (value : 1) or not (value : 0) | 
|---|
| 2032 |      > | 
|---|
| 2033 |      */ | 
|---|
| 2034 |      public function PaginationIf($attr,$content) | 
|---|
| 2035 |      { | 
|---|
| 2036 |           $if = array(); | 
|---|
| 2037 |            | 
|---|
| 2038 |           if (isset($attr['start'])) { | 
|---|
| 2039 |                $sign = (boolean) $attr['start'] ? '' : '!'; | 
|---|
| 2040 |                $if[] = $sign.'context::PaginationStart()'; | 
|---|
| 2041 |           } | 
|---|
| 2042 |            | 
|---|
| 2043 |           if (isset($attr['end'])) { | 
|---|
| 2044 |                $sign = (boolean) $attr['end'] ? '' : '!'; | 
|---|
| 2045 |                $if[] = $sign.'context::PaginationEnd()'; | 
|---|
| 2046 |           } | 
|---|
| 2047 |            | 
|---|
| 2048 |           $this->core->callBehavior('tplIfConditions','PaginationIf',$attr,$content,$if); | 
|---|
| 2049 |            | 
|---|
| 2050 |           if (count($if) != 0) { | 
|---|
| 2051 |                return '<?php if('.implode(' && ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; | 
|---|
| 2052 |           } else { | 
|---|
| 2053 |                return $content; | 
|---|
| 2054 |           } | 
|---|
| 2055 |      } | 
|---|
| 2056 |       | 
|---|
| 2057 |      /*dtd | 
|---|
| 2058 |      <!ELEMENT tpl:PaginationURL - O -- link to previoux/next page --> | 
|---|
| 2059 |      <!ATTLIST tpl:PaginationURL | 
|---|
| 2060 |      offset    CDATA     #IMPLIED  -- page offset (negative for previous pages), default: 0 | 
|---|
| 2061 |      > | 
|---|
| 2062 |      */ | 
|---|
| 2063 |      public function PaginationURL($attr) | 
|---|
| 2064 |      { | 
|---|
| 2065 |           $offset = 0; | 
|---|
| 2066 |           if (isset($attr['offset'])) { | 
|---|
| 2067 |                $offset = (integer) $attr['offset']; | 
|---|
| 2068 |           } | 
|---|
| 2069 |            | 
|---|
| 2070 |           $f = $this->getFilters($attr); | 
|---|
| 2071 |           return '<?php echo '.sprintf($f,"context::PaginationURL(".$offset.")").'; ?>'; | 
|---|
| 2072 |      } | 
|---|
| 2073 |       | 
|---|
| 2074 |      /* Comments --------------------------------------- */ | 
|---|
| 2075 |      /*dtd | 
|---|
| 2076 |      <!ELEMENT tpl:Comments - - -- Comments container --> | 
|---|
| 2077 |      <!ATTLIST tpl:Comments | 
|---|
| 2078 |      with_pings     (0|1)     #IMPLIED  -- include trackbacks in request | 
|---|
| 2079 |      lastn     CDATA     #IMPLIED  -- restrict the number of entries  | 
|---|
| 2080 |      no_context (1|0)         #IMPLIED  -- Override context information | 
|---|
| 2081 |      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) | 
|---|
| 2082 |      order     (desc|asc)     #IMPLIED  -- result ordering (default: asc) | 
|---|
| 2083 |      age       CDATA     #IMPLIED  -- retrieve comments by maximum age (ex: -2 days, last month, last week) | 
|---|
| 2084 |      > | 
|---|
| 2085 |      */ | 
|---|
| 2086 |      public function Comments($attr,$content) | 
|---|
| 2087 |      { | 
|---|
| 2088 |           $p = ""; | 
|---|
| 2089 |           if (empty($attr['with_pings'])) { | 
|---|
| 2090 |                $p .= "\$params['comment_trackback'] = false;\n"; | 
|---|
| 2091 |           } | 
|---|
| 2092 |            | 
|---|
| 2093 |           $lastn = 0; | 
|---|
| 2094 |           if (isset($attr['lastn'])) { | 
|---|
| 2095 |                $lastn = abs((integer) $attr['lastn'])+0; | 
|---|
| 2096 |           } | 
|---|
| 2097 |            | 
|---|
| 2098 |           if ($lastn > 0) { | 
|---|
| 2099 |                $p .= "\$params['limit'] = ".$lastn.";\n"; | 
|---|
| 2100 |           } else { | 
|---|
| 2101 |                $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n"; | 
|---|
| 2102 |           } | 
|---|
| 2103 |            | 
|---|
| 2104 |           if (empty($attr['no_context'])) | 
|---|
| 2105 |           { | 
|---|
| 2106 |                $p .= | 
|---|
| 2107 |                "if (\$_ctx->posts !== null) { ". | 
|---|
| 2108 |                     "\$params['post_id'] = \$_ctx->posts->post_id; ". | 
|---|
| 2109 |                     "\$core->blog->withoutPassword(false);\n". | 
|---|
| 2110 |                "}\n"; | 
|---|
| 2111 |                $p .= | 
|---|
| 2112 |                'if ($_ctx->exists("categories")) { '. | 
|---|
| 2113 |                     "\$params['cat_id'] = \$_ctx->categories->cat_id; ". | 
|---|
| 2114 |                "}\n"; | 
|---|
| 2115 |                 | 
|---|
| 2116 |                $p .= | 
|---|
| 2117 |                'if ($_ctx->exists("langs")) { '. | 
|---|
| 2118 |                     "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ". | 
|---|
| 2119 |                "}\n"; | 
|---|
| 2120 |           } | 
|---|
| 2121 |            | 
|---|
| 2122 |           if (!isset($attr['order'])) { | 
|---|
| 2123 |                $attr['order'] = 'asc'; | 
|---|
| 2124 |           } | 
|---|
| 2125 |            | 
|---|
| 2126 |           $p .= "\$params['order'] = '".$this->getSortByStr($attr,'comment')."';\n"; | 
|---|
| 2127 |            | 
|---|
| 2128 |           if (isset($attr['no_content']) && $attr['no_content']) { | 
|---|
| 2129 |                $p .= "\$params['no_content'] = true;\n"; | 
|---|
| 2130 |           } | 
|---|
| 2131 |            | 
|---|
| 2132 |           if (isset($attr['age'])) { | 
|---|
| 2133 |                $age = $this->getAge($attr); | 
|---|
| 2134 |                $p .= !empty($age) ? "@\$params['sql'] .= ' AND P.post_dt > \'".$age."\'';\n" : ''; | 
|---|
| 2135 |           } | 
|---|
| 2136 |            | 
|---|
| 2137 |           $res = "<?php\n"; | 
|---|
| 2138 |           $res .= $this->core->callBehavior("templatePrepareParams",  | 
|---|
| 2139 |                array("tag" => "Comments","method" => "blog::getComments"),  | 
|---|
| 2140 |                $attr,$content); | 
|---|
| 2141 |           $res .= $p; | 
|---|
| 2142 |           $res .= '$_ctx->comments = $core->blog->getComments($params); unset($params);'."\n"; | 
|---|
| 2143 |           $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n"; | 
|---|
| 2144 |            | 
|---|
| 2145 |           if (!empty($attr['with_pings'])) { | 
|---|
| 2146 |                $res .= '$_ctx->pings = $_ctx->comments;'."\n"; | 
|---|
| 2147 |           } | 
|---|
| 2148 |            | 
|---|
| 2149 |           $res .= "?>\n"; | 
|---|
| 2150 |            | 
|---|
| 2151 |           $res .= | 
|---|
| 2152 |           '<?php while ($_ctx->comments->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->comments = null; ?>'; | 
|---|
| 2153 |            | 
|---|
| 2154 |           return $res; | 
|---|
| 2155 |      } | 
|---|
| 2156 |       | 
|---|
| 2157 |      /*dtd | 
|---|
| 2158 |      <!ELEMENT tpl:CommentAuthor - O -- Comment author --> | 
|---|
| 2159 |      */ | 
|---|
| 2160 |      public function CommentAuthor($attr) | 
|---|
| 2161 |      { | 
|---|
| 2162 |           $f = $this->getFilters($attr); | 
|---|
| 2163 |           return '<?php echo '.sprintf($f,"\$_ctx->comments->comment_author").'; ?>'; | 
|---|
| 2164 |      } | 
|---|
| 2165 |       | 
|---|
| 2166 |      /*dtd | 
|---|
| 2167 |      <!ELEMENT tpl:CommentAuthorDomain - O -- Comment author website domain --> | 
|---|
| 2168 |      */ | 
|---|
| 2169 |      public function CommentAuthorDomain($attr) | 
|---|
| 2170 |      { | 
|---|
| 2171 |           return '<?php echo preg_replace("#^http(?:s?)://(.+?)/.*$#msu",\'$1\',$_ctx->comments->comment_site); ?>'; | 
|---|
| 2172 |      } | 
|---|
| 2173 |       | 
|---|
| 2174 |      /*dtd | 
|---|
| 2175 |      <!ELEMENT tpl:CommentAuthorLink - O -- Comment author link --> | 
|---|
| 2176 |      */ | 
|---|
| 2177 |      public function CommentAuthorLink($attr) | 
|---|
| 2178 |      { | 
|---|
| 2179 |           $f = $this->getFilters($attr); | 
|---|
| 2180 |           return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorLink()').'; ?>'; | 
|---|
| 2181 |      } | 
|---|
| 2182 |       | 
|---|
| 2183 |      /*dtd | 
|---|
| 2184 |      <!ELEMENT tpl:CommentAuthorMailMD5 - O -- Comment author email MD5 sum --> | 
|---|
| 2185 |      */ | 
|---|
| 2186 |      public function CommentAuthorMailMD5($attr) | 
|---|
| 2187 |      { | 
|---|
| 2188 |           return '<?php echo md5($_ctx->comments->comment_email) ; ?>'; | 
|---|
| 2189 |      } | 
|---|
| 2190 |       | 
|---|
| 2191 |      /*dtd | 
|---|
| 2192 |      <!ELEMENT tpl:CommentAuthorURL - O -- Comment author URL --> | 
|---|
| 2193 |      */ | 
|---|
| 2194 |      public function CommentAuthorURL($attr) | 
|---|
| 2195 |      { | 
|---|
| 2196 |           $f = $this->getFilters($attr); | 
|---|
| 2197 |           return '<?php echo '.sprintf($f,'$_ctx->comments->getAuthorURL()').'; ?>'; | 
|---|
| 2198 |      } | 
|---|
| 2199 |       | 
|---|
| 2200 |      /*dtd | 
|---|
| 2201 |      <!ELEMENT tpl:CommentContent - O --  Comment content --> | 
|---|
| 2202 |      <!ATTLIST tpl:CommentContent | 
|---|
| 2203 |      absolute_urls  (0|1)     #IMPLIED  -- convert URLS to absolute urls | 
|---|
| 2204 |      > | 
|---|
| 2205 |      */ | 
|---|
| 2206 |      public function CommentContent($attr) | 
|---|
| 2207 |      { | 
|---|
| 2208 |           $urls = '0'; | 
|---|
| 2209 |           if (!empty($attr['absolute_urls'])) { | 
|---|
| 2210 |                $urls = '1'; | 
|---|
| 2211 |           } | 
|---|
| 2212 |            | 
|---|
| 2213 |           $f = $this->getFilters($attr); | 
|---|
| 2214 |           return '<?php echo '.sprintf($f,'$_ctx->comments->getContent('.$urls.')').'; ?>'; | 
|---|
| 2215 |      } | 
|---|
| 2216 |       | 
|---|
| 2217 |      /*dtd | 
|---|
| 2218 |      <!ELEMENT tpl:CommentDate - O -- Comment date --> | 
|---|
| 2219 |      <!ATTLIST tpl:CommentDate | 
|---|
| 2220 |      format    CDATA     #IMPLIED  -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified) | 
|---|
| 2221 |      iso8601   CDATA     #IMPLIED  -- if set, tells that date format is ISO 8601 | 
|---|
| 2222 |      rfc822    CDATA     #IMPLIED  -- if set, tells that date format is RFC 822 | 
|---|
| 2223 |      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time | 
|---|
| 2224 |      > | 
|---|
| 2225 |      */ | 
|---|
| 2226 |      public function CommentDate($attr) | 
|---|
| 2227 |      { | 
|---|
| 2228 |           $format = ''; | 
|---|
| 2229 |           if (!empty($attr['format'])) { | 
|---|
| 2230 |                $format = addslashes($attr['format']); | 
|---|
| 2231 |           } | 
|---|
| 2232 |            | 
|---|
| 2233 |           $iso8601 = !empty($attr['iso8601']); | 
|---|
| 2234 |           $rfc822 = !empty($attr['rfc822']); | 
|---|
| 2235 |           $type = (!empty($attr['upddt']) ? 'upddt' : ''); | 
|---|
| 2236 |            | 
|---|
| 2237 |           $f = $this->getFilters($attr); | 
|---|
| 2238 |            | 
|---|
| 2239 |           if ($rfc822) { | 
|---|
| 2240 |                return '<?php echo '.sprintf($f,"\$_ctx->comments->getRFC822Date('".$type."')").'; ?>'; | 
|---|
| 2241 |           } elseif ($iso8601) { | 
|---|
| 2242 |                return '<?php echo '.sprintf($f,"\$_ctx->comments->getISO8601Date('".$type."')").'; ?>'; | 
|---|
| 2243 |           } else { | 
|---|
| 2244 |                return '<?php echo '.sprintf($f,"\$_ctx->comments->getDate('".$format."','".$type."')").'; ?>'; | 
|---|
| 2245 |           } | 
|---|
| 2246 |      } | 
|---|
| 2247 |       | 
|---|
| 2248 |      /*dtd | 
|---|
| 2249 |      <!ELEMENT tpl:CommentTime - O -- Comment date --> | 
|---|
| 2250 |      <!ATTLIST tpl:CommentTime | 
|---|
| 2251 |      format    CDATA     #IMPLIED  -- time format  | 
|---|
| 2252 |      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time | 
|---|
| 2253 |      > | 
|---|
| 2254 |      */ | 
|---|
| 2255 |      public function CommentTime($attr) | 
|---|
| 2256 |      { | 
|---|
| 2257 |           $format = ''; | 
|---|
| 2258 |           if (!empty($attr['format'])) { | 
|---|
| 2259 |                $format = addslashes($attr['format']); | 
|---|
| 2260 |           } | 
|---|
| 2261 |           $type = (!empty($attr['upddt']) ? 'upddt' : ''); | 
|---|
| 2262 |          | 
|---|
| 2263 |           $f = $this->getFilters($attr); | 
|---|
| 2264 |           return '<?php echo '.sprintf($f,"\$_ctx->comments->getTime('".$format."','".$type."')").'; ?>'; | 
|---|
| 2265 |      } | 
|---|
| 2266 |       | 
|---|
| 2267 |      /*dtd | 
|---|
| 2268 |      <!ELEMENT tpl:CommentEmail - O -- Comment author email --> | 
|---|
| 2269 |      <!ATTLIST tpl:CommentEmail | 
|---|
| 2270 |      spam_protected (0|1)     #IMPLIED  -- protect email from spam (default: 1) | 
|---|
| 2271 |      > | 
|---|
| 2272 |      */ | 
|---|
| 2273 |      public function CommentEmail($attr) | 
|---|
| 2274 |      { | 
|---|
| 2275 |           $p = 'true'; | 
|---|
| 2276 |           if (isset($attr['spam_protected']) && !$attr['spam_protected']) { | 
|---|
| 2277 |                $p = 'false'; | 
|---|
| 2278 |           } | 
|---|
| 2279 |            | 
|---|
| 2280 |           $f = $this->getFilters($attr); | 
|---|
| 2281 |           return '<?php echo '.sprintf($f,"\$_ctx->comments->getEmail(".$p.")").'; ?>'; | 
|---|
| 2282 |      } | 
|---|
| 2283 |       | 
|---|
| 2284 |      /*dtd | 
|---|
| 2285 |      <!ELEMENT tpl:CommentEntryTitle - O -- Title of the comment entry --> | 
|---|
| 2286 |      */ | 
|---|
| 2287 |      public function CommentEntryTitle($attr) | 
|---|
| 2288 |      { | 
|---|
| 2289 |           $f = $this->getFilters($attr); | 
|---|
| 2290 |           return '<?php echo '.sprintf($f,'$_ctx->comments->post_title').'; ?>'; | 
|---|
| 2291 |      } | 
|---|
| 2292 |       | 
|---|
| 2293 |      /*dtd | 
|---|
| 2294 |      <!ELEMENT tpl:CommentFeedID - O -- Comment feed ID --> | 
|---|
| 2295 |      */ | 
|---|
| 2296 |      public function CommentFeedID($attr) | 
|---|
| 2297 |      { | 
|---|
| 2298 |           $f = $this->getFilters($attr); | 
|---|
| 2299 |           return '<?php echo '.sprintf($f,'$_ctx->comments->getFeedID()').'; ?>'; | 
|---|
| 2300 |      } | 
|---|
| 2301 |       | 
|---|
| 2302 |      /*dtd | 
|---|
| 2303 |      <!ELEMENT tpl:CommentID - O -- Comment ID --> | 
|---|
| 2304 |      */ | 
|---|
| 2305 |      public function CommentID($attr) | 
|---|
| 2306 |      { | 
|---|
| 2307 |           return '<?php echo $_ctx->comments->comment_id; ?>'; | 
|---|
| 2308 |      } | 
|---|
| 2309 |      | 
|---|
| 2310 |      /*dtd | 
|---|
| 2311 |      <!ELEMENT tpl:CommentIf - - -- test container for comments --> | 
|---|
| 2312 |      <!ATTLIST tpl:CommentIf | 
|---|
| 2313 |      is_ping   (0|1)     #IMPLIED  -- test if comment is a trackback (value : 1) or not (value : 0) | 
|---|
| 2314 |      > | 
|---|
| 2315 |      */ | 
|---|
| 2316 |      public function CommentIf($attr,$content) | 
|---|
| 2317 |      { | 
|---|
| 2318 |           $if = array(); | 
|---|
| 2319 |           $is_ping = null; | 
|---|
| 2320 |            | 
|---|
| 2321 |           if (isset($attr['is_ping'])) { | 
|---|
| 2322 |                $sign = (boolean) $attr['is_ping'] ? '' : '!'; | 
|---|
| 2323 |                $if[] = $sign.'$_ctx->comments->comment_trackback'; | 
|---|
| 2324 |           } | 
|---|
| 2325 |            | 
|---|
| 2326 |           $this->core->callBehavior('tplIfConditions','CommentIf',$attr,$content,$if); | 
|---|
| 2327 |            | 
|---|
| 2328 |           if (count($if) != 0) { | 
|---|
| 2329 |                return '<?php if('.implode(' && ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; | 
|---|
| 2330 |           } else { | 
|---|
| 2331 |                return $content; | 
|---|
| 2332 |           } | 
|---|
| 2333 |      } | 
|---|
| 2334 |       | 
|---|
| 2335 |      /*dtd | 
|---|
| 2336 |      <!ELEMENT tpl:CommentIfFirst - O -- displays value if comment is the first one --> | 
|---|
| 2337 |      <!ATTLIST tpl:CommentIfFirst | 
|---|
| 2338 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: first) | 
|---|
| 2339 |      > | 
|---|
| 2340 |      */ | 
|---|
| 2341 |      public function CommentIfFirst($attr) | 
|---|
| 2342 |      { | 
|---|
| 2343 |           $ret = isset($attr['return']) ? $attr['return'] : 'first'; | 
|---|
| 2344 |           $ret = html::escapeHTML($ret); | 
|---|
| 2345 |            | 
|---|
| 2346 |           return | 
|---|
| 2347 |           '<?php if ($_ctx->comments->index() == 0) { '. | 
|---|
| 2348 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 2349 |      } | 
|---|
| 2350 |       | 
|---|
| 2351 |      /*dtd | 
|---|
| 2352 |      <!ELEMENT tpl:CommentIfMe - O -- displays value if comment is the from the entry author --> | 
|---|
| 2353 |      <!ATTLIST tpl:CommentIfMe | 
|---|
| 2354 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: me) | 
|---|
| 2355 |      > | 
|---|
| 2356 |      */ | 
|---|
| 2357 |      public function CommentIfMe($attr) | 
|---|
| 2358 |      { | 
|---|
| 2359 |           $ret = isset($attr['return']) ? $attr['return'] : 'me'; | 
|---|
| 2360 |           $ret = html::escapeHTML($ret); | 
|---|
| 2361 |            | 
|---|
| 2362 |           return | 
|---|
| 2363 |           '<?php if ($_ctx->comments->isMe()) { '. | 
|---|
| 2364 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 2365 |      } | 
|---|
| 2366 |       | 
|---|
| 2367 |      /*dtd | 
|---|
| 2368 |      <!ELEMENT tpl:CommentIfOdd - O -- displays value if comment is  at an odd position --> | 
|---|
| 2369 |      <!ATTLIST tpl:CommentIfOdd | 
|---|
| 2370 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: odd) | 
|---|
| 2371 |      > | 
|---|
| 2372 |      */ | 
|---|
| 2373 |      public function CommentIfOdd($attr) | 
|---|
| 2374 |      { | 
|---|
| 2375 |           $ret = isset($attr['return']) ? $attr['return'] : 'odd'; | 
|---|
| 2376 |           $ret = html::escapeHTML($ret); | 
|---|
| 2377 |            | 
|---|
| 2378 |           return | 
|---|
| 2379 |           '<?php if (($_ctx->comments->index()+1)%2) { '. | 
|---|
| 2380 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 2381 |      } | 
|---|
| 2382 |       | 
|---|
| 2383 |      /*dtd | 
|---|
| 2384 |      <!ELEMENT tpl:CommentIP - O -- Comment author IP --> | 
|---|
| 2385 |      */ | 
|---|
| 2386 |      public function CommentIP($attr) | 
|---|
| 2387 |      { | 
|---|
| 2388 |           return '<?php echo $_ctx->comments->comment_ip; ?>'; | 
|---|
| 2389 |      } | 
|---|
| 2390 |       | 
|---|
| 2391 |      /*dtd | 
|---|
| 2392 |      <!ELEMENT tpl:CommentOrderNumber - O -- Comment order in page --> | 
|---|
| 2393 |      */ | 
|---|
| 2394 |      public function CommentOrderNumber($attr) | 
|---|
| 2395 |      { | 
|---|
| 2396 |           return '<?php echo $_ctx->comments->index()+1; ?>'; | 
|---|
| 2397 |      } | 
|---|
| 2398 |       | 
|---|
| 2399 |      /*dtd | 
|---|
| 2400 |      <!ELEMENT tpl:CommentsFooter - - -- Last comments result container --> | 
|---|
| 2401 |      */ | 
|---|
| 2402 |      public function CommentsFooter($attr,$content) | 
|---|
| 2403 |      { | 
|---|
| 2404 |           return | 
|---|
| 2405 |           "<?php if (\$_ctx->comments->isEnd()) : ?>". | 
|---|
| 2406 |           $content. | 
|---|
| 2407 |           "<?php endif; ?>"; | 
|---|
| 2408 |      } | 
|---|
| 2409 |       | 
|---|
| 2410 |      /*dtd | 
|---|
| 2411 |      <!ELEMENT tpl:CommentsHeader - - -- First comments result container --> | 
|---|
| 2412 |      */ | 
|---|
| 2413 |      public function CommentsHeader($attr,$content) | 
|---|
| 2414 |      { | 
|---|
| 2415 |           return | 
|---|
| 2416 |           "<?php if (\$_ctx->comments->isStart()) : ?>". | 
|---|
| 2417 |           $content. | 
|---|
| 2418 |           "<?php endif; ?>"; | 
|---|
| 2419 |      } | 
|---|
| 2420 |       | 
|---|
| 2421 |      /*dtd | 
|---|
| 2422 |      <!ELEMENT tpl:CommentPostURL - O -- Comment Entry URL --> | 
|---|
| 2423 |      */ | 
|---|
| 2424 |      public function CommentPostURL($attr) | 
|---|
| 2425 |      { | 
|---|
| 2426 |           $f = $this->getFilters($attr); | 
|---|
| 2427 |           return '<?php echo '.sprintf($f,'$_ctx->comments->getPostURL()').'; ?>'; | 
|---|
| 2428 |      } | 
|---|
| 2429 |       | 
|---|
| 2430 |      /*dtd | 
|---|
| 2431 |      <!ELEMENT tpl:IfCommentAuthorEmail - - -- Container displayed if comment author email is set --> | 
|---|
| 2432 |      */ | 
|---|
| 2433 |      public function IfCommentAuthorEmail($attr,$content) | 
|---|
| 2434 |      { | 
|---|
| 2435 |           return | 
|---|
| 2436 |           "<?php if (\$_ctx->comments->comment_email) : ?>". | 
|---|
| 2437 |           $content. | 
|---|
| 2438 |           "<?php endif; ?>"; | 
|---|
| 2439 |      } | 
|---|
| 2440 |       | 
|---|
| 2441 |      /*dtd | 
|---|
| 2442 |      <!ELEMENT tpl:CommentHelp - 0 -- Comment syntax mini help --> | 
|---|
| 2443 |      */ | 
|---|
| 2444 |      public function CommentHelp($attr,$content) | 
|---|
| 2445 |      { | 
|---|
| 2446 |           return | 
|---|
| 2447 |           "<?php if (\$core->blog->settings->system->wiki_comments) {\n". | 
|---|
| 2448 |           "  echo __('Comments can be formatted using a simple wiki syntax.');\n". | 
|---|
| 2449 |           "} else {\n". | 
|---|
| 2450 |           "  echo __('HTML code is displayed as text and web addresses are automatically converted.');\n". | 
|---|
| 2451 |           "} ?>"; | 
|---|
| 2452 |      } | 
|---|
| 2453 |       | 
|---|
| 2454 |      /* Comment preview -------------------------------- */ | 
|---|
| 2455 |      /*dtd | 
|---|
| 2456 |      <!ELEMENT tpl:IfCommentPreview - - -- Container displayed if comment is being previewed --> | 
|---|
| 2457 |      */ | 
|---|
| 2458 |      public function IfCommentPreview($attr,$content) | 
|---|
| 2459 |      { | 
|---|
| 2460 |           return | 
|---|
| 2461 |           '<?php if ($_ctx->comment_preview !== null && $_ctx->comment_preview["preview"]) : ?>'. | 
|---|
| 2462 |           $content. | 
|---|
| 2463 |           '<?php endif; ?>'; | 
|---|
| 2464 |      } | 
|---|
| 2465 |       | 
|---|
| 2466 |      /*dtd | 
|---|
| 2467 |      <!ELEMENT tpl:CommentPreviewName - O -- Author name for the previewed comment --> | 
|---|
| 2468 |      */ | 
|---|
| 2469 |      public function CommentPreviewName($attr) | 
|---|
| 2470 |      { | 
|---|
| 2471 |           $f = $this->getFilters($attr); | 
|---|
| 2472 |           return '<?php echo '.sprintf($f,'$_ctx->comment_preview["name"]').'; ?>'; | 
|---|
| 2473 |      } | 
|---|
| 2474 |       | 
|---|
| 2475 |      /*dtd | 
|---|
| 2476 |      <!ELEMENT tpl:CommentPreviewEmail - O -- Author email for the previewed comment --> | 
|---|
| 2477 |      */ | 
|---|
| 2478 |      public function CommentPreviewEmail($attr) | 
|---|
| 2479 |      { | 
|---|
| 2480 |           $f = $this->getFilters($attr); | 
|---|
| 2481 |           return '<?php echo '.sprintf($f,'$_ctx->comment_preview["mail"]').'; ?>'; | 
|---|
| 2482 |      } | 
|---|
| 2483 |       | 
|---|
| 2484 |      /*dtd | 
|---|
| 2485 |      <!ELEMENT tpl:CommentPreviewSite - O -- Author site for the previewed comment --> | 
|---|
| 2486 |      */ | 
|---|
| 2487 |      public function CommentPreviewSite($attr) | 
|---|
| 2488 |      { | 
|---|
| 2489 |           $f = $this->getFilters($attr); | 
|---|
| 2490 |           return '<?php echo '.sprintf($f,'$_ctx->comment_preview["site"]').'; ?>'; | 
|---|
| 2491 |      } | 
|---|
| 2492 |       | 
|---|
| 2493 |      /*dtd | 
|---|
| 2494 |      <!ELEMENT tpl:CommentPreviewContent - O -- Content of the previewed comment --> | 
|---|
| 2495 |      <!ATTLIST tpl:CommentPreviewContent | 
|---|
| 2496 |      raw  (0|1)     #IMPLIED  -- display comment in raw content | 
|---|
| 2497 |      > | 
|---|
| 2498 |      */ | 
|---|
| 2499 |      public function CommentPreviewContent($attr) | 
|---|
| 2500 |      { | 
|---|
| 2501 |           $f = $this->getFilters($attr); | 
|---|
| 2502 |            | 
|---|
| 2503 |           if (!empty($attr['raw'])) { | 
|---|
| 2504 |                $co = '$_ctx->comment_preview["rawcontent"]'; | 
|---|
| 2505 |           } else { | 
|---|
| 2506 |                $co = '$_ctx->comment_preview["content"]'; | 
|---|
| 2507 |           } | 
|---|
| 2508 |            | 
|---|
| 2509 |           return '<?php echo '.sprintf($f,$co).'; ?>'; | 
|---|
| 2510 |      } | 
|---|
| 2511 |       | 
|---|
| 2512 |      /*dtd | 
|---|
| 2513 |      <!ELEMENT tpl:CommentPreviewCheckRemember - O -- checkbox attribute for "remember me" (same value as before preview) --> | 
|---|
| 2514 |      */ | 
|---|
| 2515 |      public function CommentPreviewCheckRemember($attr) | 
|---|
| 2516 |      { | 
|---|
| 2517 |           return | 
|---|
| 2518 |           "<?php if (\$_ctx->comment_preview['remember']) { echo ' checked=\"checked\"'; } ?>"; | 
|---|
| 2519 |      } | 
|---|
| 2520 |       | 
|---|
| 2521 |      /* Trackbacks ------------------------------------- */ | 
|---|
| 2522 |      /*dtd | 
|---|
| 2523 |      <!ELEMENT tpl:PingBlogName - O -- Trackback blog name --> | 
|---|
| 2524 |      */ | 
|---|
| 2525 |      public function PingBlogName($attr) | 
|---|
| 2526 |      { | 
|---|
| 2527 |           $f = $this->getFilters($attr); | 
|---|
| 2528 |           return '<?php echo '.sprintf($f,'$_ctx->pings->comment_author').'; ?>'; | 
|---|
| 2529 |      } | 
|---|
| 2530 |       | 
|---|
| 2531 |      /*dtd | 
|---|
| 2532 |      <!ELEMENT tpl:PingContent - O -- Trackback content --> | 
|---|
| 2533 |      */ | 
|---|
| 2534 |      public function PingContent($attr) | 
|---|
| 2535 |      { | 
|---|
| 2536 |           $f = $this->getFilters($attr); | 
|---|
| 2537 |           return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackContent()').'; ?>'; | 
|---|
| 2538 |      } | 
|---|
| 2539 |       | 
|---|
| 2540 |      /*dtd | 
|---|
| 2541 |      <!ELEMENT tpl:PingDate - O -- Trackback date --> | 
|---|
| 2542 |      <!ATTLIST tpl:PingDate | 
|---|
| 2543 |      format    CDATA     #IMPLIED  -- date format (encoded in dc:str by default if iso8601 or rfc822 not specified) | 
|---|
| 2544 |      iso8601   CDATA     #IMPLIED  -- if set, tells that date format is ISO 8601 | 
|---|
| 2545 |      rfc822    CDATA     #IMPLIED  -- if set, tells that date format is RFC 822 | 
|---|
| 2546 |      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time | 
|---|
| 2547 |      > | 
|---|
| 2548 |      */ | 
|---|
| 2549 |      public function PingDate($attr,$type='') | 
|---|
| 2550 |      { | 
|---|
| 2551 |           $format = ''; | 
|---|
| 2552 |           if (!empty($attr['format'])) { | 
|---|
| 2553 |                $format = addslashes($attr['format']); | 
|---|
| 2554 |           } | 
|---|
| 2555 |            | 
|---|
| 2556 |           $iso8601 = !empty($attr['iso8601']); | 
|---|
| 2557 |           $rfc822 = !empty($attr['rfc822']); | 
|---|
| 2558 |           $type = (!empty($attr['upddt']) ? 'upddt' : ''); | 
|---|
| 2559 |            | 
|---|
| 2560 |           $f = $this->getFilters($attr); | 
|---|
| 2561 |            | 
|---|
| 2562 |           if ($rfc822) { | 
|---|
| 2563 |                return '<?php echo '.sprintf($f,"\$_ctx->pings->getRFC822Date('".$type."')").'; ?>'; | 
|---|
| 2564 |           } elseif ($iso8601) { | 
|---|
| 2565 |                return '<?php echo '.sprintf($f,"\$_ctx->pings->getISO8601Date('".$type."')").'; ?>'; | 
|---|
| 2566 |           } else { | 
|---|
| 2567 |                return '<?php echo '.sprintf($f,"\$_ctx->pings->getDate('".$format."','".$type."')").'; ?>'; | 
|---|
| 2568 |           } | 
|---|
| 2569 |      } | 
|---|
| 2570 |       | 
|---|
| 2571 |      /*dtd | 
|---|
| 2572 |      <!ELEMENT tpl:PingTime - O -- Trackback date --> | 
|---|
| 2573 |      <!ATTLIST tpl:PingTime | 
|---|
| 2574 |      format    CDATA     #IMPLIED  -- time format  | 
|---|
| 2575 |      upddt     CDATA     #IMPLIED  -- if set, uses the comment update time | 
|---|
| 2576 |      > | 
|---|
| 2577 |      */ | 
|---|
| 2578 |      public function PingTime($attr) | 
|---|
| 2579 |      { | 
|---|
| 2580 |           $format = ''; | 
|---|
| 2581 |           if (!empty($attr['format'])) { | 
|---|
| 2582 |                $format = addslashes($attr['format']); | 
|---|
| 2583 |           } | 
|---|
| 2584 |           $type = (!empty($attr['upddt']) ? 'upddt' : ''); | 
|---|
| 2585 |            | 
|---|
| 2586 |           $f = $this->getFilters($attr); | 
|---|
| 2587 |           return '<?php echo '.sprintf($f,"\$_ctx->pings->getTime('".$format."','".$type."')").'; ?>'; | 
|---|
| 2588 |      } | 
|---|
| 2589 |       | 
|---|
| 2590 |      /*dtd | 
|---|
| 2591 |      <!ELEMENT tpl:PingEntryTitle - O -- Trackback entry title --> | 
|---|
| 2592 |      */ | 
|---|
| 2593 |      public function PingEntryTitle($attr) | 
|---|
| 2594 |      { | 
|---|
| 2595 |           $f = $this->getFilters($attr); | 
|---|
| 2596 |           return '<?php echo '.sprintf($f,'$_ctx->pings->post_title').'; ?>'; | 
|---|
| 2597 |      } | 
|---|
| 2598 |       | 
|---|
| 2599 |      /*dtd | 
|---|
| 2600 |      <!ELEMENT tpl:PingFeedID - O -- Trackback feed ID --> | 
|---|
| 2601 |      */ | 
|---|
| 2602 |      public function PingFeedID($attr) | 
|---|
| 2603 |      { | 
|---|
| 2604 |           $f = $this->getFilters($attr); | 
|---|
| 2605 |           return '<?php echo '.sprintf($f,'$_ctx->pings->getFeedID()').'; ?>'; | 
|---|
| 2606 |      } | 
|---|
| 2607 |       | 
|---|
| 2608 |      /*dtd | 
|---|
| 2609 |      <!ELEMENT tpl:PingID - O -- Trackback ID --> | 
|---|
| 2610 |      */ | 
|---|
| 2611 |      public function PingID($attr) | 
|---|
| 2612 |      { | 
|---|
| 2613 |           return '<?php echo $_ctx->pings->comment_id; ?>'; | 
|---|
| 2614 |      } | 
|---|
| 2615 |       | 
|---|
| 2616 |      /*dtd | 
|---|
| 2617 |      <!ELEMENT tpl:PingIfFirst - O -- displays value if trackback is the first one --> | 
|---|
| 2618 |      <!ATTLIST tpl:PingIfFirst | 
|---|
| 2619 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: first) | 
|---|
| 2620 |      > | 
|---|
| 2621 |      */ | 
|---|
| 2622 |      public function PingIfFirst($attr) | 
|---|
| 2623 |      { | 
|---|
| 2624 |           $ret = isset($attr['return']) ? $attr['return'] : 'first'; | 
|---|
| 2625 |           $ret = html::escapeHTML($ret); | 
|---|
| 2626 |            | 
|---|
| 2627 |           return | 
|---|
| 2628 |           '<?php if ($_ctx->pings->index() == 0) { '. | 
|---|
| 2629 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 2630 |      } | 
|---|
| 2631 |       | 
|---|
| 2632 |      /*dtd | 
|---|
| 2633 |      <!ELEMENT tpl:PingIfOdd - O -- displays value if trackback is  at an odd position --> | 
|---|
| 2634 |      <!ATTLIST tpl:PingIfOdd | 
|---|
| 2635 |      return    CDATA     #IMPLIED  -- value to display in case of success (default: odd) | 
|---|
| 2636 |      > | 
|---|
| 2637 |      */ | 
|---|
| 2638 |      public function PingIfOdd($attr) | 
|---|
| 2639 |      { | 
|---|
| 2640 |           $ret = isset($attr['return']) ? $attr['return'] : 'odd'; | 
|---|
| 2641 |           $ret = html::escapeHTML($ret); | 
|---|
| 2642 |            | 
|---|
| 2643 |           return | 
|---|
| 2644 |           '<?php if (($_ctx->pings->index()+1)%2) { '. | 
|---|
| 2645 |           "echo '".addslashes($ret)."'; } ?>"; | 
|---|
| 2646 |      } | 
|---|
| 2647 |       | 
|---|
| 2648 |      /*dtd | 
|---|
| 2649 |      <!ELEMENT tpl:PingIP - O -- Trackback author IP --> | 
|---|
| 2650 |      */ | 
|---|
| 2651 |      public function PingIP($attr) | 
|---|
| 2652 |      { | 
|---|
| 2653 |           return '<?php echo $_ctx->pings->comment_ip; ?>'; | 
|---|
| 2654 |      } | 
|---|
| 2655 |       | 
|---|
| 2656 |      /*dtd | 
|---|
| 2657 |      <!ELEMENT tpl:PingNoFollow - O -- displays 'rel="nofollow"' if set in blog --> | 
|---|
| 2658 |      */ | 
|---|
| 2659 |      public function PingNoFollow($attr) | 
|---|
| 2660 |      { | 
|---|
| 2661 |           return | 
|---|
| 2662 |           '<?php if($core->blog->settings->system->comments_nofollow) { '. | 
|---|
| 2663 |           'echo \' rel="nofollow"\';'. | 
|---|
| 2664 |           '} ?>'; | 
|---|
| 2665 |      } | 
|---|
| 2666 |       | 
|---|
| 2667 |      /*dtd | 
|---|
| 2668 |      <!ELEMENT tpl:PingOrderNumber - O -- Trackback order in page --> | 
|---|
| 2669 |      */ | 
|---|
| 2670 |      public function PingOrderNumber($attr) | 
|---|
| 2671 |      { | 
|---|
| 2672 |           return '<?php echo $_ctx->pings->index()+1; ?>'; | 
|---|
| 2673 |      } | 
|---|
| 2674 |       | 
|---|
| 2675 |      /*dtd | 
|---|
| 2676 |      <!ELEMENT tpl:PingPostURL - O -- Trackback Entry URL --> | 
|---|
| 2677 |      */ | 
|---|
| 2678 |      public function PingPostURL($attr) | 
|---|
| 2679 |      { | 
|---|
| 2680 |           $f = $this->getFilters($attr); | 
|---|
| 2681 |           return '<?php echo '.sprintf($f,'$_ctx->pings->getPostURL()').'; ?>'; | 
|---|
| 2682 |      } | 
|---|
| 2683 |       | 
|---|
| 2684 |      /*dtd | 
|---|
| 2685 |      <!ELEMENT tpl:Pings - - -- Trackbacks container --> | 
|---|
| 2686 |      <!ATTLIST tpl:Pings | 
|---|
| 2687 |      with_pings     (0|1)     #IMPLIED  -- include trackbacks in request | 
|---|
| 2688 |      lastn     CDATA          #IMPLIED  -- restrict the number of entries  | 
|---|
| 2689 |      no_context (1|0)         #IMPLIED  -- Override context information | 
|---|
| 2690 |      order     (desc|asc)     #IMPLIED  -- result ordering (default: asc) | 
|---|
| 2691 |      > | 
|---|
| 2692 |      */ | 
|---|
| 2693 |      public function Pings($attr,$content) | 
|---|
| 2694 |      { | 
|---|
| 2695 |           $p = | 
|---|
| 2696 |           "if (\$_ctx->posts !== null) { ". | 
|---|
| 2697 |                "\$params['post_id'] = \$_ctx->posts->post_id; ". | 
|---|
| 2698 |                "\$core->blog->withoutPassword(false);\n". | 
|---|
| 2699 |           "}\n"; | 
|---|
| 2700 |            | 
|---|
| 2701 |           $p .= "\$params['comment_trackback'] = true;\n"; | 
|---|
| 2702 |            | 
|---|
| 2703 |           $lastn = 0; | 
|---|
| 2704 |           if (isset($attr['lastn'])) { | 
|---|
| 2705 |                $lastn = abs((integer) $attr['lastn'])+0; | 
|---|
| 2706 |           } | 
|---|
| 2707 |            | 
|---|
| 2708 |           if ($lastn > 0) { | 
|---|
| 2709 |                $p .= "\$params['limit'] = ".$lastn.";\n"; | 
|---|
| 2710 |           } else { | 
|---|
| 2711 |                $p .= "if (\$_ctx->nb_comment_per_page !== null) { \$params['limit'] = \$_ctx->nb_comment_per_page; }\n"; | 
|---|
| 2712 |           } | 
|---|
| 2713 |            | 
|---|
| 2714 |           if (empty($attr['no_context'])) | 
|---|
| 2715 |           { | 
|---|
| 2716 |                $p .= | 
|---|
| 2717 |                'if ($_ctx->exists("categories")) { '. | 
|---|
| 2718 |                     "\$params['cat_id'] = \$_ctx->categories->cat_id; ". | 
|---|
| 2719 |                "}\n"; | 
|---|
| 2720 |                 | 
|---|
| 2721 |                $p .= | 
|---|
| 2722 |                'if ($_ctx->exists("langs")) { '. | 
|---|
| 2723 |                     "\$params['sql'] = \"AND P.post_lang = '\".\$core->blog->con->escape(\$_ctx->langs->post_lang).\"' \"; ". | 
|---|
| 2724 |                "}\n"; | 
|---|
| 2725 |           } | 
|---|
| 2726 |            | 
|---|
| 2727 |           $order = 'asc'; | 
|---|
| 2728 |           if (isset($attr['order']) && preg_match('/^(desc|asc)$/i',$attr['order'])) { | 
|---|
| 2729 |                $order = $attr['order']; | 
|---|
| 2730 |           } | 
|---|
| 2731 |            | 
|---|
| 2732 |           $p .= "\$params['order'] = 'comment_dt ".$order."';\n"; | 
|---|
| 2733 |            | 
|---|
| 2734 |           if (isset($attr['no_content']) && $attr['no_content']) { | 
|---|
| 2735 |                $p .= "\$params['no_content'] = true;\n"; | 
|---|
| 2736 |           } | 
|---|
| 2737 |            | 
|---|
| 2738 |           $res = "<?php\n"; | 
|---|
| 2739 |           $res .= $p; | 
|---|
| 2740 |           $res .= $this->core->callBehavior("templatePrepareParams",  | 
|---|
| 2741 |                array("tag" => "Pings","method" => "blog::getComments"),  | 
|---|
| 2742 |                $attr,$content); | 
|---|
| 2743 |           $res .= '$_ctx->pings = $core->blog->getComments($params); unset($params);'."\n"; | 
|---|
| 2744 |           $res .= "if (\$_ctx->posts !== null) { \$core->blog->withoutPassword(true);}\n"; | 
|---|
| 2745 |           $res .= "?>\n"; | 
|---|
| 2746 |            | 
|---|
| 2747 |           $res .= | 
|---|
| 2748 |           '<?php while ($_ctx->pings->fetch()) : ?>'.$content.'<?php endwhile; $_ctx->pings = null; ?>'; | 
|---|
| 2749 |            | 
|---|
| 2750 |           return $res; | 
|---|
| 2751 |      } | 
|---|
| 2752 |       | 
|---|
| 2753 |      /*dtd | 
|---|
| 2754 |      <!ELEMENT tpl:PingsFooter - - -- Last trackbacks result container --> | 
|---|
| 2755 |      */ | 
|---|
| 2756 |      public function PingsFooter($attr,$content) | 
|---|
| 2757 |      { | 
|---|
| 2758 |           return | 
|---|
| 2759 |           "<?php if (\$_ctx->pings->isEnd()) : ?>". | 
|---|
| 2760 |           $content. | 
|---|
| 2761 |           "<?php endif; ?>"; | 
|---|
| 2762 |      } | 
|---|
| 2763 |       | 
|---|
| 2764 |      /*dtd | 
|---|
| 2765 |      <!ELEMENT tpl:PingsHeader - - -- First trackbacks result container --> | 
|---|
| 2766 |      */ | 
|---|
| 2767 |      public function PingsHeader($attr,$content) | 
|---|
| 2768 |      { | 
|---|
| 2769 |           return | 
|---|
| 2770 |           "<?php if (\$_ctx->pings->isStart()) : ?>". | 
|---|
| 2771 |           $content. | 
|---|
| 2772 |           "<?php endif; ?>"; | 
|---|
| 2773 |      } | 
|---|
| 2774 |       | 
|---|
| 2775 |      /*dtd | 
|---|
| 2776 |      <!ELEMENT tpl:PingTitle - O -- Trackback title --> | 
|---|
| 2777 |      */ | 
|---|
| 2778 |      public function PingTitle($attr) | 
|---|
| 2779 |      { | 
|---|
| 2780 |           $f = $this->getFilters($attr); | 
|---|
| 2781 |           return '<?php echo '.sprintf($f,'$_ctx->pings->getTrackbackTitle()').'; ?>'; | 
|---|
| 2782 |      } | 
|---|
| 2783 |       | 
|---|
| 2784 |      /*dtd | 
|---|
| 2785 |      <!ELEMENT tpl:PingAuthorURL - O -- Trackback author URL --> | 
|---|
| 2786 |      */ | 
|---|
| 2787 |      public function PingAuthorURL($attr) | 
|---|
| 2788 |      { | 
|---|
| 2789 |           $f = $this->getFilters($attr); | 
|---|
| 2790 |           return '<?php echo '.sprintf($f,'$_ctx->pings->getAuthorURL()').'; ?>'; | 
|---|
| 2791 |      } | 
|---|
| 2792 |       | 
|---|
| 2793 |      # System | 
|---|
| 2794 |      /*dtd | 
|---|
| 2795 |      <!ELEMENT tpl:SysBehavior - O -- Call a given behavior --> | 
|---|
| 2796 |      <!ATTLIST tpl:SysBehavior | 
|---|
| 2797 |      behavior  CDATA     #IMPLIED  -- behavior to call | 
|---|
| 2798 |      > | 
|---|
| 2799 |      */ | 
|---|
| 2800 |      public function SysBehavior($attr,$raw) | 
|---|
| 2801 |      { | 
|---|
| 2802 |           if (!isset($attr['behavior'])) { | 
|---|
| 2803 |                return; | 
|---|
| 2804 |           } | 
|---|
| 2805 |            | 
|---|
| 2806 |           $b = addslashes($attr['behavior']); | 
|---|
| 2807 |           return | 
|---|
| 2808 |           '<?php if ($core->hasBehavior(\''.$b.'\')) { '. | 
|---|
| 2809 |                '$core->callBehavior(\''.$b.'\',$core,$_ctx);'. | 
|---|
| 2810 |           '} ?>'; | 
|---|
| 2811 |      } | 
|---|
| 2812 |       | 
|---|
| 2813 |      /*dtd | 
|---|
| 2814 |      <!ELEMENT tpl:SysIf - - -- System settings tester container --> | 
|---|
| 2815 |      <!ATTLIST tpl:SysIf | 
|---|
| 2816 |      categories          (0|1)     #IMPLIED  -- test if categories are set in current context (value : 1) or not (value : 0) | 
|---|
| 2817 |      posts               (0|1)     #IMPLIED  -- test if posts are set in current context (value : 1) or not (value : 0) | 
|---|
| 2818 |      blog_lang           CDATA     #IMPLIED  -- tests if blog language is the one given in parameter | 
|---|
| 2819 |      current_tpl         CDATA     #IMPLIED  -- tests if current template is the one given in paramater | 
|---|
| 2820 |      current_mode        CDATA     #IMPLIED  -- tests if current URL mode is the one given in parameter | 
|---|
| 2821 |      has_tpl             CDATA     #IMPLIED  -- tests if a named template exists | 
|---|
| 2822 |      has_tag             CDATA     #IMPLIED  -- tests if a named template block or value exists | 
|---|
| 2823 |      blog_id             CDATA     #IMPLIED  -- tests if current blog ID is the one given in parameter | 
|---|
| 2824 |      comments_active     (0|1)     #IMPLIED  -- test if comments are enabled blog-wide  | 
|---|
| 2825 |      pings_active        (0|1)     #IMPLIED  -- test if trackbacks are enabled blog-wide  | 
|---|
| 2826 |      wiki_comments       (0|1)     #IMPLIED  -- test if wiki syntax is enabled for comments | 
|---|
| 2827 |      operator            (and|or)  #IMPLIED  -- combination of conditions, if more than 1 specifiec (default: and) | 
|---|
| 2828 |      > | 
|---|
| 2829 |      */ | 
|---|
| 2830 |      public function SysIf($attr,$content) | 
|---|
| 2831 |      { | 
|---|
| 2832 |           $if = new ArrayObject(); | 
|---|
| 2833 |           $is_ping = null; | 
|---|
| 2834 |            | 
|---|
| 2835 |           $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&'; | 
|---|
| 2836 |            | 
|---|
| 2837 |           if (isset($attr['categories'])) { | 
|---|
| 2838 |                $sign = (boolean) $attr['categories'] ? '!' : '='; | 
|---|
| 2839 |                $if[] = '$_ctx->categories '.$sign.'== null'; | 
|---|
| 2840 |           } | 
|---|
| 2841 |            | 
|---|
| 2842 |           if (isset($attr['posts'])) { | 
|---|
| 2843 |                $sign = (boolean) $attr['posts'] ? '!' : '='; | 
|---|
| 2844 |                $if[] = '$_ctx->posts '.$sign.'== null'; | 
|---|
| 2845 |           } | 
|---|
| 2846 |            | 
|---|
| 2847 |           if (isset($attr['blog_lang'])) { | 
|---|
| 2848 |                $if[] = "\$core->blog->settings->system->lang == '".addslashes($attr['blog_lang'])."'"; | 
|---|
| 2849 |           } | 
|---|
| 2850 |            | 
|---|
| 2851 |           if (isset($attr['current_tpl'])) { | 
|---|
| 2852 |                $sign = '='; | 
|---|
| 2853 |                if (substr($attr['current_tpl'],0,1) == '!') { | 
|---|
| 2854 |                     $sign = '!'; | 
|---|
| 2855 |                     $attr['current_tpl'] = substr($attr['current_tpl'],1); | 
|---|
| 2856 |                } | 
|---|
| 2857 |                $if[] = "\$_ctx->current_tpl ".$sign."= '".addslashes($attr['current_tpl'])."'"; | 
|---|
| 2858 |           } | 
|---|
| 2859 |            | 
|---|
| 2860 |           if (isset($attr['current_mode'])) { | 
|---|
| 2861 |                $sign = '='; | 
|---|
| 2862 |                if (substr($attr['current_mode'],0,1) == '!') { | 
|---|
| 2863 |                     $sign = '!'; | 
|---|
| 2864 |                     $attr['current_mode'] = substr($attr['current_mode'],1); | 
|---|
| 2865 |                } | 
|---|
| 2866 |                $if[] = "\$core->url->type ".$sign."= '".addslashes($attr['current_mode'])."'"; | 
|---|
| 2867 |           } | 
|---|
| 2868 |            | 
|---|
| 2869 |           if (isset($attr['has_tpl'])) { | 
|---|
| 2870 |                $sign = ''; | 
|---|
| 2871 |                if (substr($attr['has_tpl'],0,1) == '!') { | 
|---|
| 2872 |                     $sign = '!'; | 
|---|
| 2873 |                     $attr['has_tpl'] = substr($attr['has_tpl'],1); | 
|---|
| 2874 |                } | 
|---|
| 2875 |                $if[] = $sign."\$core->tpl->getFilePath('".addslashes($attr['has_tpl'])."') !== false"; | 
|---|
| 2876 |           } | 
|---|
| 2877 |            | 
|---|
| 2878 |           if (isset($attr['has_tag'])) { | 
|---|
| 2879 |                $sign = 'true'; | 
|---|
| 2880 |                if (substr($attr['has_tag'],0,1) == '!') { | 
|---|
| 2881 |                     $sign = 'false'; | 
|---|
| 2882 |                     $attr['has_tag'] = substr($attr['has_tag'],1); | 
|---|
| 2883 |                } | 
|---|
| 2884 |                $if[] =  "\$core->tpl->tagExists('".addslashes($attr['has_tag'])."') === ".$sign; | 
|---|
| 2885 |           } | 
|---|
| 2886 |            | 
|---|
| 2887 |           if (isset($attr['blog_id'])) { | 
|---|
| 2888 |                $sign = ''; | 
|---|
| 2889 |                if (substr($attr['blog_id'],0,1) == '!') { | 
|---|
| 2890 |                     $sign = '!'; | 
|---|
| 2891 |                     $attr['blog_id'] = substr($attr['blog_id'],1); | 
|---|
| 2892 |                } | 
|---|
| 2893 |                $if[] = $sign."(\$core->blog->id == '".addslashes($attr['blog_id'])."')"; | 
|---|
| 2894 |           } | 
|---|
| 2895 |            | 
|---|
| 2896 |           if (isset($attr['comments_active'])) { | 
|---|
| 2897 |                $sign = (boolean) $attr['comments_active'] ? '' : '!'; | 
|---|
| 2898 |                $if[] = $sign.'$core->blog->settings->system->allow_comments'; | 
|---|
| 2899 |           } | 
|---|
| 2900 |            | 
|---|
| 2901 |           if (isset($attr['pings_active'])) { | 
|---|
| 2902 |                $sign = (boolean) $attr['pings_active'] ? '' : '!'; | 
|---|
| 2903 |                $if[] = $sign.'$core->blog->settings->system->allow_trackbacks'; | 
|---|
| 2904 |           } | 
|---|
| 2905 |          | 
|---|
| 2906 |           if (isset($attr['wiki_comments'])) { | 
|---|
| 2907 |                $sign = (boolean) $attr['wiki_comments'] ? '' : '!'; | 
|---|
| 2908 |                $if[] = $sign.'$core->blog->settings->system->wiki_comments'; | 
|---|
| 2909 |           } | 
|---|
| 2910 |            | 
|---|
| 2911 |           if (isset($attr['search_count']) && | 
|---|
| 2912 |                preg_match('/^((=|!|>|<)=|(>|<))\s*[0-9]+$/',trim($attr['search_count']))) { | 
|---|
| 2913 |                $if[] = '(isset($_search_count) && $_search_count '.html::decodeEntities($attr['search_count']).')'; | 
|---|
| 2914 |           } | 
|---|
| 2915 |            | 
|---|
| 2916 |           $this->core->callBehavior('tplIfConditions','SysIf',$attr,$content,$if); | 
|---|
| 2917 |            | 
|---|
| 2918 |           if (count($if) != 0) { | 
|---|
| 2919 |                return '<?php if('.implode(' '.$operator.' ', (array) $if).') : ?>'.$content.'<?php endif; ?>'; | 
|---|
| 2920 |           } else { | 
|---|
| 2921 |                return $content; | 
|---|
| 2922 |           } | 
|---|
| 2923 |      } | 
|---|
| 2924 |       | 
|---|
| 2925 |      /*dtd | 
|---|
| 2926 |      <!ELEMENT tpl:SysIfCommentPublished - - -- Container displayed if comment has been published --> | 
|---|
| 2927 |      */ | 
|---|
| 2928 |      public function SysIfCommentPublished($attr,$content) | 
|---|
| 2929 |      { | 
|---|
| 2930 |           return | 
|---|
| 2931 |           '<?php if (!empty($_GET[\'pub\'])) : ?>'. | 
|---|
| 2932 |           $content. | 
|---|
| 2933 |           '<?php endif; ?>'; | 
|---|
| 2934 |      } | 
|---|
| 2935 |       | 
|---|
| 2936 |      /*dtd | 
|---|
| 2937 |      <!ELEMENT tpl:SysIfCommentPending - - -- Container displayed if comment is pending after submission --> | 
|---|
| 2938 |      */ | 
|---|
| 2939 |      public function SysIfCommentPending($attr,$content) | 
|---|
| 2940 |      { | 
|---|
| 2941 |           return | 
|---|
| 2942 |           '<?php if (isset($_GET[\'pub\']) && $_GET[\'pub\'] == 0) : ?>'. | 
|---|
| 2943 |           $content. | 
|---|
| 2944 |           '<?php endif; ?>'; | 
|---|
| 2945 |      } | 
|---|
| 2946 |       | 
|---|
| 2947 |      /*dtd | 
|---|
| 2948 |      <!ELEMENT tpl:SysFeedSubtitle - O -- Feed subtitle --> | 
|---|
| 2949 |      */ | 
|---|
| 2950 |      public function SysFeedSubtitle($attr) | 
|---|
| 2951 |      { | 
|---|
| 2952 |           $f = $this->getFilters($attr); | 
|---|
| 2953 |           return '<?php if ($_ctx->feed_subtitle !== null) { echo '.sprintf($f,'$_ctx->feed_subtitle').';} ?>'; | 
|---|
| 2954 |      } | 
|---|
| 2955 |       | 
|---|
| 2956 |      /*dtd | 
|---|
| 2957 |      <!ELEMENT tpl:SysIfFormError - O -- Container displayed if an error has been detected after form submission --> | 
|---|
| 2958 |      */ | 
|---|
| 2959 |      public function SysIfFormError($attr,$content) | 
|---|
| 2960 |      { | 
|---|
| 2961 |           return | 
|---|
| 2962 |           '<?php if ($_ctx->form_error !== null) : ?>'. | 
|---|
| 2963 |           $content. | 
|---|
| 2964 |           '<?php endif; ?>'; | 
|---|
| 2965 |      } | 
|---|
| 2966 |       | 
|---|
| 2967 |      /*dtd | 
|---|
| 2968 |      <!ELEMENT tpl:SysIfFormError - O -- Form error --> | 
|---|
| 2969 |      */ | 
|---|
| 2970 |      public function SysFormError($attr) | 
|---|
| 2971 |      { | 
|---|
| 2972 |           return | 
|---|
| 2973 |           '<?php if ($_ctx->form_error !== null) { echo $_ctx->form_error; } ?>'; | 
|---|
| 2974 |      } | 
|---|
| 2975 |       | 
|---|
| 2976 |      public function SysPoweredBy($attr) | 
|---|
| 2977 |      { | 
|---|
| 2978 |           return | 
|---|
| 2979 |           '<?php printf(__("Powered by %s"),"<a href=\"http://dotclear.org/\">Dotclear</a>"); ?>'; | 
|---|
| 2980 |      } | 
|---|
| 2981 |       | 
|---|
| 2982 |      public function SysSearchString($attr) | 
|---|
| 2983 |      { | 
|---|
| 2984 |           $s = isset($attr['string']) ? $attr['string'] : '%1$s'; | 
|---|
| 2985 |            | 
|---|
| 2986 |           $f = $this->getFilters($attr); | 
|---|
| 2987 |           return '<?php if (isset($_search)) { echo sprintf(__(\''.$s.'\'),'.sprintf($f,'$_search').',$_search_count);} ?>'; | 
|---|
| 2988 |      } | 
|---|
| 2989 |       | 
|---|
| 2990 |      public function SysSelfURI($attr) | 
|---|
| 2991 |      { | 
|---|
| 2992 |           $f = $this->getFilters($attr); | 
|---|
| 2993 |           return '<?php echo '.sprintf($f,'http::getSelfURI()').'; ?>'; | 
|---|
| 2994 |      } | 
|---|
| 2995 | } | 
|---|
| 2996 |  | 
|---|
| 2997 | # Template nodes, for parsing purposes | 
|---|
| 2998 |  | 
|---|
| 2999 | # Generic list node, this one may only be instanciated  | 
|---|
| 3000 | # once for root element | 
|---|
| 3001 | class tplNode  | 
|---|
| 3002 | { | 
|---|
| 3003 |      # Basic tree structure : links to parent, children forrest | 
|---|
| 3004 |      protected $parentNode; | 
|---|
| 3005 |      protected $children; | 
|---|
| 3006 |       | 
|---|
| 3007 |      public function __construct() { | 
|---|
| 3008 |           $this->children = array(); | 
|---|
| 3009 |           $this->parentNode = null; | 
|---|
| 3010 |      } | 
|---|
| 3011 |       | 
|---|
| 3012 |      // Returns compiled block | 
|---|
| 3013 |      public function compile($tpl) { | 
|---|
| 3014 |           $res=''; | 
|---|
| 3015 |           foreach ($this->children as $child) { | 
|---|
| 3016 |                $res .= $child->compile($tpl); | 
|---|
| 3017 |           } | 
|---|
| 3018 |           return $res; | 
|---|
| 3019 |      } | 
|---|
| 3020 |       | 
|---|
| 3021 |      # Add a children to current node | 
|---|
| 3022 |      public function addChild ($child) { | 
|---|
| 3023 |           $this->children[] = $child; | 
|---|
| 3024 |           $child->setParent($this); | 
|---|
| 3025 |      } | 
|---|
| 3026 |       | 
|---|
| 3027 |      # Defines parent for current node | 
|---|
| 3028 |      protected function setParent($parent) { | 
|---|
| 3029 |           $this->parentNode = $parent; | 
|---|
| 3030 |      } | 
|---|
| 3031 |       | 
|---|
| 3032 |      # Retrieves current node parent. | 
|---|
| 3033 |      # If parent is root node, null is returned | 
|---|
| 3034 |      public function getParent() { | 
|---|
| 3035 |           return $this->parentNode; | 
|---|
| 3036 |      } | 
|---|
| 3037 |       | 
|---|
| 3038 |      # Current node tag | 
|---|
| 3039 |      public function getTag() { | 
|---|
| 3040 |           return "ROOT"; | 
|---|
| 3041 |      } | 
|---|
| 3042 | } | 
|---|
| 3043 |  | 
|---|
| 3044 | // Text node, for any non-tpl content | 
|---|
| 3045 | class tplNodeText extends tplNode  | 
|---|
| 3046 | { | 
|---|
| 3047 |      // Simple text node, only holds its content | 
|---|
| 3048 |      protected $content; | 
|---|
| 3049 |       | 
|---|
| 3050 |      public function __construct($text) { | 
|---|
| 3051 |           parent::__construct(); | 
|---|
| 3052 |           $this->content=$text; | 
|---|
| 3053 |      } | 
|---|
| 3054 |       | 
|---|
| 3055 |      public function compile($tpl) { | 
|---|
| 3056 |           return $this->content; | 
|---|
| 3057 |      } | 
|---|
| 3058 |       | 
|---|
| 3059 |      public function getTag() { | 
|---|
| 3060 |           return "TEXT"; | 
|---|
| 3061 |      } | 
|---|
| 3062 | } | 
|---|
| 3063 |  | 
|---|
| 3064 | // Block node, for all <tpl:Tag>...</tpl:Tag> | 
|---|
| 3065 | class tplNodeBlock extends tplNode  | 
|---|
| 3066 | { | 
|---|
| 3067 |      protected $attr; | 
|---|
| 3068 |      protected $tag; | 
|---|
| 3069 |      protected $closed; | 
|---|
| 3070 |      | 
|---|
| 3071 |      public function __construct($tag,$attr) { | 
|---|
| 3072 |           parent::__construct(); | 
|---|
| 3073 |           $this->content=''; | 
|---|
| 3074 |           $this->tag = $tag; | 
|---|
| 3075 |           $this->attr = $attr; | 
|---|
| 3076 |           $this->closed=false; | 
|---|
| 3077 |      } | 
|---|
| 3078 |      public function setClosing() { | 
|---|
| 3079 |           $this->closed = true; | 
|---|
| 3080 |      } | 
|---|
| 3081 |      public function isClosed() { | 
|---|
| 3082 |           return $this->closed; | 
|---|
| 3083 |      } | 
|---|
| 3084 |      public function compile($tpl) { | 
|---|
| 3085 |           if ($this->closed) { | 
|---|
| 3086 |                $content = parent::compile($tpl); | 
|---|
| 3087 |                return $tpl->compileBlockNode($this->tag,$this->attr,$content); | 
|---|
| 3088 |           } else { | 
|---|
| 3089 |                // if tag has not been closed, silently ignore its content... | 
|---|
| 3090 |                return ''; | 
|---|
| 3091 |           } | 
|---|
| 3092 |      } | 
|---|
| 3093 |      public function getTag() { | 
|---|
| 3094 |           return $this->tag; | 
|---|
| 3095 |      } | 
|---|
| 3096 | } | 
|---|
| 3097 |  | 
|---|
| 3098 | // Value node, for all {{tpl:Tag}} | 
|---|
| 3099 | class tplNodeValue extends tplNode  | 
|---|
| 3100 | { | 
|---|
| 3101 |      protected $attr; | 
|---|
| 3102 |      protected $str_attr; | 
|---|
| 3103 |      protected $tag; | 
|---|
| 3104 |       | 
|---|
| 3105 |      public function __construct($tag,$attr,$str_attr) { | 
|---|
| 3106 |           parent::__construct(); | 
|---|
| 3107 |           $this->content=''; | 
|---|
| 3108 |           $this->tag = $tag; | 
|---|
| 3109 |           $this->attr = $attr; | 
|---|
| 3110 |           $this->str_attr = $str_attr; | 
|---|
| 3111 |      } | 
|---|
| 3112 |       | 
|---|
| 3113 |      public function compile($tpl) { | 
|---|
| 3114 |           return $tpl->compileValueNode($this->tag,$this->attr,$this->str_attr); | 
|---|
| 3115 |      } | 
|---|
| 3116 |       | 
|---|
| 3117 |      public function getTag() { | 
|---|
| 3118 |           return $this->tag; | 
|---|
| 3119 |      } | 
|---|
| 3120 | } | 
|---|
| 3121 |  | 
|---|
| 3122 | ?> | 
|---|