Dotclear

Changeset 407:eb5bd0f66932


Ignore:
Timestamp:
06/23/11 13:00:59 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
default
Message:
  • Re-enabled blank post_type required by media.php in class dcBlog
  • Attachments are now handled by a plugins/attachments/_admin.php
  • Added core dcPostMedia multi-purpose class, and 'link_type' in post_media table
  • Added new behavior : tplIfConditions, to enable to add new attributes to tpl:XXXIf tags
  • Moved tpl:SysIf has_tag attribute to Tags plugin
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • admin/media.php

    r270 r407  
    6060$post_id = !empty($_GET['post_id']) ? (integer) $_GET['post_id'] : null; 
    6161if ($post_id) { 
    62      $post = $core->blog->getPosts(array('post_id'=>$post_id,'post_type'=>'')); 
     62     $post = $core->blog->getPosts(array('post_id'=>$post_id)); 
    6363     if ($post->isEmpty()) { 
    6464          $post_id = null; 
     
    6868     unset($post); 
    6969} 
    70  
    7170$d = isset($_REQUEST['d']) ? $_REQUEST['d'] : null; 
    7271$dir = null; 
  • admin/post.php

    r322 r407  
    3232$post_open_comment = $core->blog->settings->system->allow_comments; 
    3333$post_open_tb = $core->blog->settings->system->allow_trackbacks; 
    34  
    35 $post_media = array(); 
    3634 
    3735$page_title = __('New entry'); 
     
    146144          try { 
    147145               $core->media = new dcMedia($core); 
    148                $post_media = $core->media->getPostMedia($post_id); 
    149146          } catch (Exception $e) {} 
    150147     } 
     
    408405     '</div>'; 
    409406      
    410      if ($post_id) 
    411      { 
    412           echo 
    413           '<h3 class="clear">'.__('Attachments').'</h3>'; 
    414           foreach ($post_media as $f) 
    415           { 
    416                $ftitle = $f->media_title; 
    417                if (strlen($ftitle) > 18) { 
    418                     $ftitle = substr($ftitle,0,16).'...'; 
    419                } 
    420                echo 
    421                '<div class="media-item">'. 
    422                '<a class="media-icon" href="media_item.php?id='.$f->media_id.'">'. 
    423                '<img src="'.$f->media_icon.'" alt="" title="'.$f->basename.'" /></a>'. 
    424                '<ul>'. 
    425                '<li><a class="media-link" href="media_item.php?id='.$f->media_id.'"'. 
    426                'title="'.$f->basename.'">'.$ftitle.'</a></li>'. 
    427                '<li>'.$f->media_dtstr.'</li>'. 
    428                '<li>'.files::size($f->size).' - '. 
    429                '<a href="'.$f->file_url.'">'.__('open').'</a>'.'</li>'. 
    430                 
    431                '<li class="media-action"><a class="attachment-remove" id="attachment-'.$f->media_id.'" '. 
    432                'href="post_media.php?post_id='.$post_id.'&amp;media_id='.$f->media_id.'&amp;remove=1">'. 
    433                '<img src="images/check-off.png" alt="'.__('remove').'" /></a>'. 
    434                '</li>'. 
    435                 
    436                '</ul>'. 
    437                '</div>'; 
    438           } 
    439           unset($f); 
    440            
    441           if (empty($post_media)) { 
    442                echo '<p>'.__('No attachment.').'</p>'; 
    443           } 
    444           echo '<p><a class="button" href="media.php?post_id='.$post_id.'">'.__('Add files to this entry').'</a></p>'; 
    445      } 
    446       
    447407     # --BEHAVIOR-- adminPostFormSidebar 
    448408     $core->callBehavior('adminPostFormSidebar',isset($post) ? $post : null); 
     
    491451     } 
    492452      
    493      if ($post_id && !empty($post_media)) 
    494      { 
    495           echo 
    496           '<form action="post_media.php" id="attachment-remove-hide" method="post">'. 
    497           '<div>'.form::hidden(array('post_id'),$post_id). 
    498           form::hidden(array('media_id'),''). 
    499           form::hidden(array('remove'),1). 
    500           $core->formNonce().'</div></form>'; 
    501      } 
    502453} 
    503454 
  • inc/core/class.dc.blog.php

    r340 r407  
    727727          if (isset($params['post_type'])) 
    728728          { 
    729                $strReq .= 'AND post_type '.$this->con->in($params['post_type']); 
     729               if (is_array($params['post_type']) || $params['post_type'] != '') { 
     730                    $strReq .= 'AND post_type '.$this->con->in($params['post_type']); 
     731               } 
    730732          } 
    731733          else 
  • inc/core/class.dc.core.php

    r331 r407  
    2727{ 
    2828     public $con;        ///< <b>connection</b>        Database connection object 
    29      public $prefix;     ///< <b>string</b>            Database tables prefix 
     29     public $prefix;          ///< <b>string</b>            Database tables prefix 
    3030     public $blog;       ///< <b>dcBlog</b>            dcBlog object 
    3131     public $error;      ///< <b>dcError</b>           dcError object 
     
    3636     public $plugins;    ///< <b>dcModules</b>         dcModules object 
    3737     public $media;      ///< <b>dcMedia</b>           dcMedia object 
    38      public $rest;       ///< <b>dcRestServer</b>      dcRestServer object 
     38     public $postmedia;  ///< <b>dcPostMedia</b>       dcPostMedia object 
     39     public $rest;       ///< <b>dcRestServer</b> dcRestServer object 
    3940     public $log;        ///< <b>dcLog</b>             dcLog object 
    4041      
  • inc/core/class.dc.media.php

    r270 r407  
    2323     protected $con;          ///< <b>connection</b> Database connection 
    2424     protected $table;        ///< <b>string</b> Media table name 
    25      protected $table_ref;    ///< <b>string</b> Post-media relation table name 
    2625     protected $type;         ///< <b>string</b> Media type filter 
     26     protected $postmedia; 
    2727     protected $file_sort = 'name-asc'; 
    2828      
     
    5757          $this->core =& $core; 
    5858          $this->con =& $core->con; 
     59          $this->postmedia = new dcPostMedia($core); 
    5960           
    6061          if ($this->core->blog == null) { 
     
    6364           
    6465          $this->table = $this->core->prefix.'media'; 
    65           $this->table_ref = $this->core->prefix.'post_media'; 
    6666          $root = $this->core->blog->public_path; 
    6767           
     
    494494     public function getPostMedia($post_id,$media_id=null) 
    495495     { 
    496           $post_id = (integer) $post_id; 
    497            
    498           $strReq = 
    499           'SELECT media_file, M.media_id, media_path, media_title, media_meta, media_dt, '. 
    500           'media_creadt, media_upddt, media_private, user_id '. 
    501           'FROM '.$this->table.' M '. 
    502           'INNER JOIN '.$this->table_ref.' PM ON (M.media_id = PM.media_id) '. 
    503           "WHERE media_path = '".$this->path."' ". 
    504           'AND post_id = '.$post_id.' '; 
    505            
     496          $params = array( 
     497               'post_id' => $post_id, 
     498               'media_path' => $this->path 
     499          ); 
    506500          if ($media_id) { 
    507                $strReq .= 'AND M.media_id = '.(integer) $media_id.' '; 
    508           } 
    509            
    510           $rs = $this->con->select($strReq); 
     501               $params['media_id'] = (integer) $media_id; 
     502          } 
     503          $rs = $this->postmedia->getPostMedia($params); 
    511504           
    512505          $res = array(); 
     
    523516      
    524517     /** 
    525      Attaches a media to a post. 
    526       
    527      @param    post_id   <b>integer</b>      Post ID 
    528      @param    media_id  <b>integer</b>      Optionnal media ID 
     518     @deprecated since version 2.4 
     519     @see dcPostMedia::addPostMedia 
    529520     */ 
    530521     public function addPostMedia($post_id,$media_id) 
    531522     { 
    532           $post_id = (integer) $post_id; 
    533           $media_id = (integer) $media_id; 
    534            
    535           $f = $this->getPostMedia($post_id,$media_id); 
    536            
    537           if (!empty($f)) { 
    538                return; 
    539           } 
    540            
    541           $cur = $this->con->openCursor($this->table_ref); 
    542           $cur->post_id = $post_id; 
    543           $cur->media_id = $media_id; 
    544            
    545           $cur->insert(); 
    546           $this->core->blog->triggerBlog(); 
    547      } 
    548       
    549      /** 
    550      Detaches a media from a post. 
    551       
    552      @param    post_id   <b>integer</b>      Post ID 
    553      @param    media_id  <b>integer</b>      Optionnal media ID 
     523          $this->postmedia->addPostMedia($post_id,$media_id); 
     524     } 
     525      
     526     /** 
     527     @deprecated since version 2.4 
     528     @see dcPostMedia::removePostMedia 
    554529     */ 
    555530     public function removePostMedia($post_id,$media_id) 
    556531     { 
    557           $post_id = (integer) $post_id; 
    558           $media_id = (integer) $media_id; 
    559            
    560           $strReq = 'DELETE FROM '.$this->table_ref.' '. 
    561                     'WHERE post_id = '.$post_id.' '. 
    562                     'AND media_id = '.$media_id.' '; 
    563            
    564           $this->con->execute($strReq); 
    565           $this->core->blog->triggerBlog(); 
     532          $this->postmedia->removePostMedia($post_id,$media_id,"attachment"); 
    566533     } 
    567534      
  • inc/dbschema/db-schema.php

    r270 r407  
    152152     ->media_id     ('bigint',     0,   false) 
    153153     ->post_id      ('bigint',     0,   false) 
    154       
    155      ->primary('pk_post_media','media_id','post_id') 
     154     ->link_type         ('varchar',    32,  false,    "'attachment'") 
     155      
     156     ->primary('pk_post_media','media_id','post_id','link_type') 
    156157     ; 
    157158 
     
    235236$_s->media->index        ('idx_media_user_id',              'btree',  'user_id'); 
    236237$_s->post_media->index   ('idx_post_media_post_id',         'btree',  'post_id'); 
     238$_s->post_media->index   ('idx_post_media_media_id',        'btree',  'media_id'); 
    237239$_s->log->index          ('idx_log_user_id',                'btree',  'user_id'); 
    238240$_s->comment->index      ('idx_comment_post_id',            'btree',  'post_id'); 
  • inc/prepend.php

    r372 r407  
    4343$__autoload['dcMeta']                   = dirname(__FILE__).'/core/class.dc.meta.php'; 
    4444$__autoload['dcMedia']                  = dirname(__FILE__).'/core/class.dc.media.php'; 
     45$__autoload['dcPostMedia']                   = dirname(__FILE__).'/core/class.dc.postmedia.php'; 
    4546$__autoload['dcModules']                = dirname(__FILE__).'/core/class.dc.modules.php'; 
    4647$__autoload['dcThemes']                 = dirname(__FILE__).'/core/class.dc.themes.php'; 
  • inc/public/class.dc.template.php

    r406 r407  
    5454          $this->addValue('ArchiveEntriesCount',array($this,'ArchiveEntriesCount')); 
    5555          $this->addValue('ArchiveURL',array($this,'ArchiveURL')); 
    56            
    57           # Attachments 
    58           $this->addBlock('Attachments',array($this,'Attachments')); 
    59           $this->addBlock('AttachmentsHeader',array($this,'AttachmentsHeader')); 
    60           $this->addBlock('AttachmentsFooter',array($this,'AttachmentsFooter')); 
    61           $this->addValue('AttachmentMimeType',array($this,'AttachmentMimeType')); 
    62           $this->addValue('AttachmentType',array($this,'AttachmentType')); 
    63           $this->addValue('AttachmentFileName',array($this,'AttachmentFileName')); 
    64           $this->addValue('AttachmentSize',array($this,'AttachmentSize')); 
    65           $this->addValue('AttachmentTitle',array($this,'AttachmentTitle')); 
    66           $this->addValue('AttachmentThumbnailURL',array($this,'AttachmentThumbnailURL')); 
    67           $this->addValue('AttachmentURL',array($this,'AttachmentURL')); 
    68           $this->addBlock('AttachmentIf',array($this,'AttachmentIf')); 
    69           $this->addValue('MediaURL',array($this,'MediaURL')); 
    7056           
    7157          # Blog 
     
    141127          $this->addBlock('EntriesHeader',array($this,'EntriesHeader')); 
    142128          $this->addValue('EntryExcerpt',array($this,'EntryExcerpt')); 
    143           $this->addValue('EntryAttachmentCount',array($this,'EntryAttachmentCount')); 
    144129          $this->addValue('EntryAuthorCommonName',array($this,'EntryAuthorCommonName')); 
    145130          $this->addValue('EntryAuthorDisplayName',array($this,'EntryAuthorDisplayName')); 
     
    749734     } 
    750735      
    751      /* Attachments ---------------------------------------- */ 
    752      /*dtd 
    753      <!ELEMENT tpl:Attachments - - -- Post Attachments loop --> 
    754      */ 
    755      public function Attachments($attr,$content) 
    756      { 
    757           $res = 
    758           "<?php\n". 
    759           'if ($_ctx->posts !== null && $core->media) {'."\n". 
    760                '$_ctx->attachments = new ArrayObject($core->media->getPostMedia($_ctx->posts->post_id));'."\n". 
    761           "?>\n". 
    762            
    763           '<?php foreach ($_ctx->attachments as $attach_i => $attach_f) : '. 
    764           '$GLOBALS[\'attach_i\'] = $attach_i; $GLOBALS[\'attach_f\'] = $attach_f;'. 
    765           '$_ctx->file_url = $attach_f->file_url; ?>'. 
    766           $content. 
    767           '<?php endforeach; $_ctx->attachments = null; unset($attach_i,$attach_f,$_ctx->file_url); ?>'. 
    768            
    769           "<?php } ?>\n"; 
    770            
    771           return $res; 
    772      } 
    773       
    774      /*dtd 
    775      <!ELEMENT tpl:AttachmentsHeader - - -- First attachments result container --> 
    776      */ 
    777      public function AttachmentsHeader($attr,$content) 
    778      { 
    779           return 
    780           "<?php if (\$attach_i == 0) : ?>". 
    781           $content. 
    782           "<?php endif; ?>"; 
    783      } 
    784       
    785      /*dtd 
    786      <!ELEMENT tpl:AttachmentsFooter - - -- Last attachments result container --> 
    787      */ 
    788      public function AttachmentsFooter($attr,$content) 
    789      { 
    790           return 
    791           "<?php if (\$attach_i+1 == count(\$_ctx->attachments)) : ?>". 
    792           $content. 
    793           "<?php endif; ?>"; 
    794      } 
    795       
    796      /*dtd 
    797      <!ELEMENT tpl:AttachmentsIf - - -- Test on attachment fields --> 
    798      <!ATTLIST tpl:AttachmentIf 
    799      is_image  (0|1)     #IMPLIED  -- test if attachment is an image (value : 1) or not (value : 0) 
    800      has_thumb (0|1)     #IMPLIED  -- test if attachment has a square thumnail (value : 1) or not (value : 0) 
    801      is_mp3    (0|1)     #IMPLIED  -- test if attachment is a mp3 file (value : 1) or not (value : 0) 
    802      is_flv    (0|1)     #IMPLIED  -- test if attachment is a flv file (value : 1) or not (value : 0) 
    803      > 
    804      */ 
    805      public function AttachmentIf($attr,$content) 
    806      { 
    807           $if = array(); 
    808            
    809           $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&'; 
    810            
    811           if (isset($attr['is_image'])) { 
    812                $sign = (boolean) $attr['is_image'] ? '' : '!'; 
    813                $if[] = $sign.'$attach_f->media_image'; 
    814           } 
    815            
    816           if (isset($attr['has_thumb'])) { 
    817                $sign = (boolean) $attr['has_thumb'] ? '' : '!'; 
    818                $if[] = $sign.'isset($attach_f->media_thumb[\'sq\'])'; 
    819           } 
    820            
    821           if (isset($attr['is_mp3'])) { 
    822                $sign = (boolean) $attr['is_mp3'] ? '==' : '!='; 
    823                $if[] = '$attach_f->type '.$sign.' "audio/mpeg3"'; 
    824           } 
    825            
    826           if (isset($attr['is_flv'])) { 
    827                $sign = (boolean) $attr['is_flv'] ? '' : '!'; 
    828                $if[] = $sign. 
    829                     '($attach_f->type == "video/x-flv" || '. 
    830                     '$attach_f->type == "video/mp4" || '. 
    831                     '$attach_f->type == "video/x-m4v")'; 
    832           } 
    833            
    834           if (!empty($if)) { 
    835                return '<?php if('.implode(' '.$operator.' ',$if).') : ?>'.$content.'<?php endif; ?>'; 
    836           } else { 
    837                return $content; 
    838           } 
    839      } 
    840       
    841      /*dtd 
    842      <!ELEMENT tpl:AttachmentMimeType - O -- Attachment MIME Type --> 
    843      */ 
    844      public function AttachmentMimeType($attr) 
    845      { 
    846           $f = $this->getFilters($attr); 
    847           return '<?php echo '.sprintf($f,'$attach_f->type').'; ?>'; 
    848      } 
    849       
    850      /*dtd 
    851      <!ELEMENT tpl:AttachmentType - O -- Attachment type --> 
    852      */ 
    853      public function AttachmentType($attr) 
    854      { 
    855           $f = $this->getFilters($attr); 
    856           return '<?php echo '.sprintf($f,'$attach_f->media_type').'; ?>'; 
    857      } 
    858       
    859      /*dtd 
    860      <!ELEMENT tpl:AttachmentFileName - O -- Attachment file name --> 
    861      */ 
    862      public function AttachmentFileName($attr) 
    863      { 
    864           $f = $this->getFilters($attr); 
    865           return '<?php echo '.sprintf($f,'$attach_f->basename').'; ?>'; 
    866      } 
    867       
    868      /*dtd 
    869      <!ELEMENT tpl:AttachmentSize - O -- Attachment size --> 
    870      <!ATTLIST tpl:AttachmentSize 
    871      full CDATA     #IMPLIED  -- if set, size is rounded to a human-readable value (in KB, MB, GB, TB) 
    872      > 
    873      */ 
    874      public function AttachmentSize($attr) 
    875      { 
    876           $f = $this->getFilters($attr); 
    877           if (!empty($attr['full'])) { 
    878                return '<?php echo '.sprintf($f,'$attach_f->size').'; ?>'; 
    879           } 
    880           return '<?php echo '.sprintf($f,'files::size($attach_f->size)').'; ?>'; 
    881      } 
    882       
    883      /*dtd 
    884      <!ELEMENT tpl:AttachmentTitle - O -- Attachment title --> 
    885      */ 
    886      public function AttachmentTitle($attr) 
    887      { 
    888           $f = $this->getFilters($attr); 
    889           return '<?php echo '.sprintf($f,'$attach_f->media_title').'; ?>'; 
    890      } 
    891       
    892      /*dtd 
    893      <!ELEMENT tpl:AttachmentThumbnailURL - O -- Attachment square thumbnail URL --> 
    894      */ 
    895      public function AttachmentThumbnailURL($attr) 
    896      { 
    897           $f = $this->getFilters($attr); 
    898           return 
    899           '<?php '. 
    900           'if (isset($attach_f->media_thumb[\'sq\'])) {'. 
    901                'echo '.sprintf($f,'$attach_f->media_thumb[\'sq\']').';'. 
    902           '}'. 
    903           '?>'; 
    904      } 
    905       
    906      /*dtd 
    907      <!ELEMENT tpl:AttachmentURL - O -- Attachment URL --> 
    908      */ 
    909      public function AttachmentURL($attr) 
    910      { 
    911           $f = $this->getFilters($attr); 
    912           return '<?php echo '.sprintf($f,'$attach_f->file_url').'; ?>'; 
    913      } 
    914       
    915      public function MediaURL($attr) 
    916      { 
    917           $f = $this->getFilters($attr); 
    918           return '<?php echo '.sprintf($f,'$_ctx->file_url').'; ?>'; 
    919      } 
    920736      
    921737     /* Blog ----------------------------------------------- */ 
     
    1160976     public function CategoryIf($attr,$content) 
    1161977     { 
    1162           $if = array(); 
     978          $if = new ArrayObject(); 
    1163979          $operator = isset($attr['operator']) ? $this->getOperator($attr['operator']) : '&&'; 
    1164980           
     
    1182998               $if[] = '$_ctx->categories->cat_desc '.$sign.' ""';  
    1183999          }  
     1000           
     1001          $this->core->callBehavior('tplIfConditions','CategoryIf',$attr,$content,$if); 
    11841002           
    11851003          if (!empty($if)) { 
     
    14311249     selected  (0|1)     #IMPLIED  -- post is selected (value : 1) or not (value : 0) 
    14321250     has_category   (0|1)     #IMPLIED  -- post has a category (value : 1) or not (value : 0) 
    1433      has_attachment (0|1)     #IMPLIED  -- post has attachments (value : 1) or not (value : 0) 
     1251     has_attachment (0|1)     #IMPLIED  -- post has attachments (value : 1) or not (value : 0) (see Attachment plugin for code) 
    14341252     comments_active     (0|1)     #IMPLIED  -- comments are active for this post (value : 1) or not (value : 0) 
    14351253     pings_active   (0|1)     #IMPLIED  -- trackbacks are active for this post (value : 1) or not (value : 0) 
     
    14421260     public function EntryIf($attr,$content) 
    14431261     { 
    1444           $if = array(); 
     1262          $if = new ArrayObject(); 
    14451263          $extended = null; 
    14461264          $hascategory = null; 
     
    14991317          } 
    15001318           
    1501           if (isset($attr['has_attachment'])) { 
    1502                $sign = (boolean) $attr['has_attachment'] ? '' : '!'; 
    1503                $if[] = $sign.'$_ctx->posts->countMedia()'; 
    1504           } 
    1505            
    15061319          if (isset($attr['comments_active'])) { 
    15071320               $sign = (boolean) $attr['comments_active'] ? '' : '!'; 
     
    15401353          } 
    15411354           
     1355          $this->core->callBehavior('tplIfConditions','EntryIf',$attr,$content,$if); 
     1356           
    15421357          if (!empty($if)) { 
    1543                return '<?php if('.implode(' '.$operator.' ',$if).') : ?>'.$content.'<?php endif; ?>'; 
     1358               return '<?php if('.implode(' '.$operator.' ',(array)$if).') : ?>'.$content.'<?php endif; ?>'; 
    15441359          } else { 
    15451360               return $content; 
     
    16361451     } 
    16371452      
    1638      /*dtd 
    1639      <!ELEMENT tpl:EntryAttachmentCount - O -- Number of attachments for entry --> 
    1640      <!ATTLIST tpl:EntryAttachmentCount 
    1641      none CDATA     #IMPLIED  -- text to display for "no attachment" (default: no attachment) 
    1642      one  CDATA     #IMPLIED  -- text to display for "one attachment" (default: one attachment) 
    1643      more CDATA     #IMPLIED  -- text to display for "more attachment" (default: %s attachment, %s is replaced by the number of attachments) 
    1644      > 
    1645      */ 
    1646      public function EntryAttachmentCount($attr) 
    1647      { 
    1648           $none = 'no attachment'; 
    1649           $one = 'one attachment'; 
    1650           $more = '%d attachments'; 
    1651            
    1652           if (isset($attr['none'])) { 
    1653                $none = addslashes($attr['none']); 
    1654           } 
    1655           if (isset($attr['one'])) { 
    1656                $one = addslashes($attr['one']); 
    1657           } 
    1658           if (isset($attr['more'])) { 
    1659                $more = addslashes($attr['more']); 
    1660           } 
    1661            
    1662           return 
    1663           "<?php if (\$_ctx->posts->countMedia() == 0) {\n". 
    1664           "  printf(__('".$none."'),(integer) \$_ctx->posts->countMedia());\n". 
    1665           "} elseif (\$_ctx->posts->countMedia() == 1) {\n". 
    1666           "  printf(__('".$one."'),(integer) \$_ctx->posts->countMedia());\n". 
    1667           "} else {\n". 
    1668           "  printf(__('".$more."'),(integer) \$_ctx->posts->countMedia());\n". 
    1669           "} ?>"; 
    1670      } 
    16711453      
    16721454     /*dtd 
     
    22232005               $if[] = $sign.'context::PaginationEnd()'; 
    22242006          } 
     2007           
     2008          $this->core->callBehavior('tplIfConditions','PaginationIf',$attr,$content,$if); 
    22252009           
    22262010          if (!empty($if)) { 
     
    24972281          } 
    24982282           
     2283          $this->core->callBehavior('tplIfConditions','CommentIf',$attr,$content,$if); 
     2284           
    24992285          if (!empty($if)) { 
    25002286               return '<?php if('.implode(' && ',$if).') : ?>'.$content.'<?php endif; ?>'; 
     
    29882774     current_mode        CDATA     #IMPLIED  -- tests if current URL mode is the one given in parameter 
    29892775     has_tpl             CDATA     #IMPLIED  -- tests if a named template exists 
    2990      has_tag             CDATA     #IMPLIED  -- tests if a named template tag exists 
     2776     has_tag             CDATA     #IMPLIED  -- tests if a named template tag exists (see Tag plugin for code) 
    29912777     blog_id             CDATA     #IMPLIED  -- tests if current blog ID is the one given in parameter 
    29922778     comments_active     (0|1)     #IMPLIED  -- test if comments are enabled blog-wide  
     
    29982784     public function SysIf($attr,$content) 
    29992785     { 
    3000           $if = array(); 
     2786          $if = new ArrayObject(); 
    30012787          $is_ping = null; 
    30022788           
     
    30442830          } 
    30452831           
    3046           if (isset($attr['has_tag'])) { 
    3047                $sign = ''; 
    3048                if (substr($attr['has_tag'],0,1) == '!') { 
    3049                     $sign = '!'; 
    3050                     $attr['has_tag'] = substr($attr['has_tag'],1); 
    3051                } 
    3052                $if[] =  $sign."(\$core->tpl->tagExists('".addslashes($attr['has_tag'])."') )"; 
    3053           } 
    3054            
    30552832          if (isset($attr['blog_id'])) { 
    30562833               $sign = ''; 
     
    30812858               $if[] = '(isset($_search_count) && $_search_count '.html::decodeEntities($attr['search_count']).')'; 
    30822859          } 
     2860           
     2861          $this->core->callBehavior('tplIfConditions','SysIf',$attr,$content,$if); 
    30832862           
    30842863          if (!empty($if)) { 
  • plugins/tags/_public.php

    r270 r407  
    4444 
    4545$core->addBehavior('templateBeforeBlock',array('behaviorsTags','templateBeforeBlock')); 
     46$core->addBehavior('tplSysIfConditions',array('behaviorsTags','tplSysIfConditions')); 
    4647 
    4748class behaviorsTags 
     
    6869                    "\$params['sql'] .= \"AND META.meta_id = '\".\$core->con->escape(\$_ctx->meta->meta_id).\"' \";\n". 
    6970               "} ?>\n"; 
     71          } 
     72     } 
     73      
     74     public static function tplIfConditions($tag, $attr,$content,$if) 
     75     { 
     76          if ($tag == 'Sys' && isset($attr['has_tag'])) { 
     77               $sign = ''; 
     78               if (substr($attr['has_tag'],0,1) == '!') { 
     79                    $sign = '!'; 
     80                    $attr['has_tag'] = substr($attr['has_tag'],1); 
     81               } 
     82               $if[] =  $sign."(\$core->tpl->tagExists('".addslashes($attr['has_tag'])."') )"; 
    7083          } 
    7184     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map