Dotclear

Changeset 407 for plugins/dcom


Ignore:
Timestamp:
04/13/08 10:46:42 (15 years ago)
Author:
sacha
Message:

Dcom :

  • A part of code rewrited
  • Permissions fixed
  • CHANGELOG added
Location:
plugins/dcom
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcom/_admin.php

    r271 r407  
    1 <?php 
     1<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ 
    22/***************************************************************\ 
    33 *  This is 'Dcom', a plugin for Dotclear 2                    * 
    44 *                                                             * 
    5  *  Copyright (c) 2007                                         * 
     5 *  Copyright (c) 2007-2008                                    * 
    66 *  Oleksandr Syenchuk, Jean-François Michaud and contributors.* 
    77 *                                                             * 
     
    3030               __('Title:'),$p['title']); 
    3131          $w->lastcomments->setting('c_limit', 
    32                __('Comments limit (leave empty to disable limit):'),$p['c_limit']); 
     32               __('Comments limit:'),$p['c_limit']); 
    3333          $w->lastcomments->setting('t_limit', 
    3434               __('Title lenght limit:'),$p['t_limit']); 
  • plugins/dcom/_define.php

    r271 r407  
    33 *  This is 'Dcom', a plugin for Dotclear 2                    * 
    44 *                                                             * 
    5  *  Copyright (c) 2007                                         * 
     5 *  Copyright (c) 2007-2008                                    * 
    66 *  Oleksandr Syenchuk, Jean-François Michaud and contributors.* 
    77 *                                                             * 
     
    1616 
    1717$this->registerModule( 
    18      /* Name */          "Dcom", 
    19      /* Description*/    "Last comments with more options", 
    20      /* Author */        "Oleksandr Syenchuk", 
    21      /* Version */       '0.7.3', 
    22      /* Permissions */   'usage,contentadmin', 
    23      /* Priority */      50 
     18     /* Name */          'Dcom', 
     19     /* Description*/    'Last comments with more options', 
     20     /* Author */        'Oleksandr Syenchuk', 
     21     /* Version */       '0.8', 
     22     /* Permissions */   'admin' 
    2423); 
    2524?> 
  • plugins/dcom/_prepend.php

    r271 r407  
    1 <?php 
     1<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ 
    22/***************************************************************\ 
    33 *  This is 'Dcom', a plugin for Dotclear 2                    * 
    44 *                                                             * 
    5  *  Copyright (c) 2007                                         * 
     5 *  Copyright (c) 2007-2008                                    * 
    66 *  Oleksandr Syenchuk, Jean-François Michaud and contributors.* 
    77 *                                                             * 
     
    2222           
    2323          if (!is_array($p)) { 
    24                $p = array(); 
     24               $r = array(); 
     25          } else { 
     26               $r = $p; 
    2527          } 
    2628           
    27           if (!isset($p['homeonly'])) { 
    28                $p['homeonly'] = false; 
    29           } 
    30           else { 
    31                $p['homeonly'] = (bool) $p['homeonly']; 
    32           } 
    33            
    34           if (!isset($p['c_limit'])) { 
    35                $p['c_limit'] = 10; 
    36           } 
    37           else { 
    38                $p['c_limit'] = abs((integer) $p['c_limit']); 
    39           } 
    40            
    41           if (!isset($p['t_limit'])) { 
    42                $p['t_limit'] = 20; 
    43           } 
    44           else { 
    45                $p['t_limit'] = abs((integer) $p['t_limit']); 
    46           } 
    47            
    48           if (!isset($p['co_limit'])) { 
    49                $p['co_limit'] = 80; 
    50           } 
    51           else { 
    52                $p['co_limit'] = abs((integer) $p['co_limit']); 
    53           } 
    54            
    55           if (!isset($p['title'])) { 
    56                $p['title'] = __('Last comments'); 
    57           } 
    58            
    59           if (empty($p['stringformat'])) { 
    60                $p['stringformat'] = 
    61                     '<a href="%5$s" title="%4$s">%2$s - %3$s<br/>%1$s</a>'; 
    62           } 
    63            
    64           if (empty($p['dateformat'])) { 
    65                $p['dateformat'] = 
    66                     $core->blog->settings->date_format.','. 
    67                     $core->blog->settings->time_format; 
    68           } 
     29          $p = array(); 
     30          $p['homeonly'] = empty($r['homeonly']) 
     31               ? false 
     32               : true; 
     33          $p['c_limit'] = isset($r['c_limit']) 
     34               ? abs((integer) $r['c_limit']) 
     35               : 10; 
     36          $p['t_limit'] = isset($r['t_limit']) 
     37               ? abs((integer) $r['t_limit']) 
     38               : 20; 
     39          $p['co_limit'] = !empty($r['co_limit']) 
     40               ? abs((integer) $r['co_limit']) 
     41               : 80; 
     42          $p['title'] = isset($r['title']) 
     43               ? (string) $r['title'] 
     44               : __('Last comments'); 
     45          $p['stringformat'] = !empty($r['stringformat']) 
     46               ? (string) $r['stringformat'] 
     47               : '<a href="%5$s" title="%4$s">%2$s - %3$s<br/>%1$s</a>'; 
     48          $p['dateformat'] = !empty($r['dateformat']) 
     49               ? (string) $r['dateformat'] 
     50               : $core->blog->settings->date_format.','. 
     51                 $core->blog->settings->time_format; 
    6952     } 
    7053} 
  • plugins/dcom/_public.php

    r333 r407  
    1 <?php 
     1<?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ 
    22/***************************************************************\ 
    33 *  This is 'Dcom', a plugin for Dotclear 2                    * 
    44 *                                                             * 
    5  *  Copyright (c) 2007                                         * 
     5 *  Copyright (c) 2007-2008                                    * 
    66 *  Oleksandr Syenchuk, Jean-François Michaud and contributors.* 
    77 *                                                             * 
     
    4949          commonDcom::adjustDefaults($attr); 
    5050           
    51           $res = '<?php echo publicDcom::show(unserialize(\''. 
     51          return '<?php echo publicDcom::show(unserialize(\''. 
    5252                addcslashes(serialize($attr),'\'\\').'\')); ?>'; 
    53           return $res; 
    5453     } 
    5554      
     
    8786               } 
    8887               if ($s_title) { 
    89                     $title = html::escapeHTML(self::cutString($rs->post_title,$p['t_limit'])); 
     88                    $title = self::truncate($rs->post_title,$p['t_limit'],false); 
    9089               } 
    9190               if ($s_author) { 
     
    9392               } 
    9493               if ($s_comment) { 
    95                     $comment = html::escapeHTML(self::cutString(html::decodeEntities(html::clean($rs->comment_content)),$p['co_limit'])); 
     94                    $comment = self::truncate($rs->comment_content,$p['co_limit']); 
    9695               } 
    9796 
     
    104103     } 
    105104      
    106      public static function cutString($str,$maxlength=false) 
     105     public static function truncate($str,$maxlength,$html=true) 
    107106     { 
    108           if (mb_strlen($str) > $maxlength && $maxlength) 
    109                return self::myCutString($str,$maxlength).'...'; 
    110           return $str; 
    111      } 
    112       
    113      // Fonction cutString() de Dotclear écrite par Olivier Meunier 
    114      // Corrigée pour supporter le UTF-8 
    115      // https://clearbricks.org/svn/trunk/common/lib.text.php [72] 
    116      public static function myCutString($str,$l) 
    117      { 
    118           $s = preg_split('/([\s]+)/u',$str,-1,PREG_SPLIT_DELIM_CAPTURE); 
    119            
    120           $res = ''; 
    121           $L = 0; 
    122            
    123           if (mb_strlen($s[0]) >= $l) { 
    124                return mb_substr($s[0],0,$l); 
     107          # On rend la chaîne lisible 
     108          if ($html) { 
     109               $str = html::decodeEntities(html::clean($str)); 
    125110          } 
    126111           
    127           foreach ($s as $v) 
    128           { 
    129                $L = $L+strlen($v); 
    130                 
    131                if ($L > $l) { 
    132                     break; 
    133                } else { 
    134                     $res .= $v; 
    135                } 
     112          # On coupe la chaîne si elle est trop longue 
     113          if (mb_strlen($str) > $maxlength) { 
     114               $str = text::cutString($str,$maxlength).'…'; 
    136115          } 
    137116           
    138           return trim($res); 
     117          # On encode la chaîne pour pouvoir l'insérer dans un document HTML 
     118          return html::escapeHTML($str); 
    139119     } 
    140120} 
  • plugins/dcom/locales/fr/main.po

    r271 r407  
    11# French translation of Dcom 
    2 # Copyright (c) 2007. 
    3 # Oleksandr Syenchuk <sacha@xn--phnix-csa.net>, 2007. 
     2# Copyright (c) 2007-2008. 
     3# Oleksandr Syenchuk <sacha@xn--phnix-csa.net>, 2008. 
    44 
    55msgid "" 
    66msgstr "Content-Type: text/plain; charset=UTF-8\n" 
    77 
    8 msgid "Comments limit (leave empty to disable limit):" 
    9 msgstr "Nombre de commentaires maximum (laissez vide pour désactiver la limite) :" 
     8msgid "Comments limit:" 
     9msgstr "Nombre de commentaires maximum :" 
    1010 
    1111msgid "Title lenght limit:" 
Note: See TracChangeset for help on using the changeset viewer.

Sites map