Dotclear

Changeset 1521


Ignore:
Timestamp:
09/27/09 22:31:16 (14 years ago)
Author:
Jeremie
Message:

Micro-Blogging 0.3

  • make behaviors PHP 5.3 ready
  • Clear blog cache every 10 min (necessary for widget. This need improvement)
  • Add new post message customization in admin
Location:
plugins/microBlog
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/microBlog/_define.php

    r1391 r1521  
    1717        /* Description*/  "Display and update your streamlifes all over the Web", 
    1818        /* Author */      "Jeremie Patonnier", 
    19         /* Version */     '0.2.2', 
     19        /* Version */     '0.3', 
    2020        /* Permissions */ 'usage,contentadmin' 
    2121); 
    2222 
    2323# CHANGELOG 
     24# TODO Check login validity when adding a service 
     25# TODO Add help page 
     26# TODO Fix autosend note for planified post 
    2427 
    25 # v. 0.2.2 
     28# v. 0.3 
     29# make behaviors PHP 5.3 ready 
     30# Clear blog cache every 10 min (necessary for widget... need improvement) 
     31# Add new post message customization in admin 
     32 
     33 
     34# v. 0.2.2 rev 1391 
    2635# fixe install 
    2736 
  • plugins/microBlog/_prepend.php

    r1359 r1521  
    3939//// Action sur le blog ///////////////////////////////////////////// 
    4040 
     41$core->addBehavior('publicPrepend', array(microBlogBehaviors::ini($core),'publicPrepend')); 
     42 
    4143$core->addBehavior('adminAfterPostCreate', array(microBlogBehaviors::ini($core),'afterPostCreate')); 
    4244$core->addBehavior('adminBeforePostUpdade',array(microBlogBehaviors::ini($core),'beforePostUpdate')); 
  • plugins/microBlog/inc/class.micro.blog.behaviors.php

    r1359 r1521  
    8080     } 
    8181      
     82     /** 
     83      * Method that must be bind with the publicPrepend behavior 
     84      *  
     85      * @param dcBlog $blog 
     86      */ 
     87     public function publicPrepend(dcCore $core) 
     88     { 
     89           
     90          $oldDate = $core->blog->upddt; 
     91          $newDate = time(); 
     92           
     93          if($newDate - $oldDate > 600){ 
     94               $core->blog->triggerBlog(); 
     95          } 
     96     } 
    8297      
    8398     /** 
     
    87102      * @param $post_id 
    88103      */ 
    89      public function afterPostCreate(&$Post,$post_id) 
     104     public function afterPostCreate(cursor $Post,$post_id) 
    90105     { 
    91106          if ($Post->post_status == 1) { 
    92                $this->pushNote($Post->post_url); 
     107               $this->pushNote($Post); 
    93108          } 
    94109     } 
     
    101116      * @param $post_id 
    102117      */ 
    103      public static function beforePostUpdate(&$Post,$post_id) 
     118     public function beforePostUpdate(cursor $Post,$post_id) 
    104119     { 
    105120          $this->status[$post_id] = $Post->post_status; 
     
    113128      * @param $post_id 
    114129      */ 
    115      public function afterPostUpdate(&$Post,$post_id) 
     130     public function afterPostUpdate(cursor $Post,$post_id) 
    116131     { 
    117132          $new = $Post->post_status; 
     
    119134           
    120135          if ($new == 1 && $new != $old){ 
    121                $this->pushNote($Post->post_url); 
     136               $this->pushNote($Post); 
    122137          } 
    123138           
     
    131146      * @param $post_url string 
    132147      */ 
    133      private function pushNote($post_url) 
     148     private function pushNote(cursor $Post) 
    134149     { 
    135           $txt = __('New Blog Post: ') 
    136                 . $this->dc_core->blog->url 
    137                 . $this->dc_core->url->getBase('publicpage') 
    138                 . $post_url; 
     150          $txt = $this->micro_blog->getDefaultNote(); 
     151          $url = $this->dc_core->blog->url 
     152               . $this->dc_core->url->getBase('publicpage') 
     153               . $Post->post_url; 
     154           
     155          $txt = str_replace('%url%',$url,$txt); 
     156          $txt = str_replace('%title%',$Post->post_title,$txt); 
    139157 
    140158          $services = $this->micro_blog->getServicesList(); 
  • plugins/microBlog/inc/class.micro.blog.php

    r1361 r1521  
    5656     static private $sType = array(); 
    5757      
     58     /** 
     59      * Default note use to send automatic note 
     60      *  
     61      * It's possible to use the following constants: 
     62      * %url% : URL of the blog post 
     63      * %title% : title of the blog post 
     64      * %blog% : name of the blog 
     65      *  
     66      * @var string 
     67      */ 
     68     static private $dNote = 'New blog post: %url%'; 
     69      
    5870      
    5971     //// METHODES PUBLICS /////////////////////////////////// 
     
    245257           
    246258          return self::$sAccess[$serviceId]; 
     259     } 
     260      
     261     public function setDefaultNote($note) 
     262     { 
     263          self::$dNote = (string)$note; 
     264     } 
     265      
     266     public function getDefaultNote() 
     267     { 
     268          return self::$dNote;      
    247269     } 
    248270      
  • plugins/microBlog/index.php

    r1374 r1521  
    194194          else { 
    195195               $_SESSION['mb_post_msg'][] = __('Services successfully updated'); 
     196          } 
     197     } 
     198      
     199     # ---------------------------------------------------- 
     200     # Paramétrage de la note par deffaut 
     201     if (isset($_POST['MB_defnote'])  
     202      && is_string($_POST['MB_defnote'])) 
     203     { 
     204          $old = $MicroBlog->getDefaultNote(); 
     205           
     206          if($old != $_POST['MB_defnote']) 
     207          { 
     208               $MicroBlog->setDefaultNote($_POST['MB_defnote']); 
     209           
     210               $_SESSION['mb_post_msg'][] = __('Default note updated'); 
    196211          } 
    197212     } 
     
    386401               </fieldset> 
    387402                
     403               <fieldset> 
     404                    <legend><?php echo __('Default note'); ?></legend> 
     405                    <p class="area"> 
     406                         <?php echo form::textarea('MB_defnote', 15, 3, $MicroBlog->getDefaultNote()); ?> 
     407                    </p>  
     408               </fieldset> 
     409                
    388410               <p> 
    389411                    <?php echo $core->formNonce(); ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map