Dotclear

Changeset 2466


Ignore:
Timestamp:
07/09/10 20:37:44 (13 years ago)
Author:
hadrien
Message:

Possibilité de choisir l'api de shortening de son choix

Location:
plugins/twitterPost
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • plugins/twitterPost/_admin.php

    r2451 r2466  
    11<?php 
     2# ***** BEGIN LICENSE BLOCK ***** 
     3# This file is part of TwitterPost. 
     4# Copyright (c) 2009 Hadrien Lanneau. 
     5# All rights reserved. 
     6# 
     7# Pixearch is free software; you can redistribute it and/or modify 
     8# it under the terms of the GNU General Public License as published by 
     9# the Free Software Foundation; either version 2 of the License, or 
     10# (at your option) any later version. 
     11# 
     12# Pixearch is distributed in the hope that it will be useful, 
     13# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     15# GNU General Public License for more details. 
     16# 
     17# You should have received a copy of the GNU General Public License 
     18# along with Pixearch; if not, write to the Free Software 
     19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# 
     21# http://alt-i.fr/pages/TwitterPost 
     22# 
     23# ***** END LICENSE BLOCK ***** 
     24 
    225include_once(dirname(__FILE__) . '/inc/TwitterPost.class.php'); 
    326$core->addBehavior( 
  • plugins/twitterPost/_define.php

    r2451 r2466  
    11<?php 
     2# ***** BEGIN LICENSE BLOCK ***** 
     3# This file is part of TwitterPost. 
     4# Copyright (c) 2009 Hadrien Lanneau. 
     5# All rights reserved. 
     6# 
     7# Pixearch is free software; you can redistribute it and/or modify 
     8# it under the terms of the GNU General Public License as published by 
     9# the Free Software Foundation; either version 2 of the License, or 
     10# (at your option) any later version. 
     11# 
     12# Pixearch is distributed in the hope that it will be useful, 
     13# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     15# GNU General Public License for more details. 
     16# 
     17# You should have received a copy of the GNU General Public License 
     18# along with Pixearch; if not, write to the Free Software 
     19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# 
     21# http://alt-i.fr/pages/TwitterPost 
     22# 
     23# ***** END LICENSE BLOCK ***** 
    224if (!defined('DC_RC_PATH')) { return; } 
    325 
  • plugins/twitterPost/_install.php

    r2451 r2466  
    11<?php 
     2# ***** BEGIN LICENSE BLOCK ***** 
     3# This file is part of TwitterPost. 
     4# Copyright (c) 2009 Hadrien Lanneau. 
     5# All rights reserved. 
     6# 
     7# Pixearch is free software; you can redistribute it and/or modify 
     8# it under the terms of the GNU General Public License as published by 
     9# the Free Software Foundation; either version 2 of the License, or 
     10# (at your option) any later version. 
     11# 
     12# Pixearch is distributed in the hope that it will be useful, 
     13# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     15# GNU General Public License for more details. 
     16# 
     17# You should have received a copy of the GNU General Public License 
     18# along with Pixearch; if not, write to the Free Software 
     19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     20# 
     21# http://alt-i.fr/pages/TwitterPost 
     22# 
     23# ***** END LICENSE BLOCK ***** 
    224if (!defined('DC_CONTEXT_ADMIN')) { return; } 
    325$core->blog->settings->setNamespace('twitterpost'); 
  • plugins/twitterPost/inc/TwitterPost.class.php

    r2451 r2466  
    1919# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    2020# 
    21 # http://www.alti.info/pages/TwitterPost 
     21# http://alt-i.fr/pages/TwitterPost 
    2222# 
    2323# ***** END LICENSE BLOCK ***** 
     
    6868 
    6969          $status = $core->blog->settings->twitterpost_status; 
    70  
     70           
    7171          if (!empty($_POST['twitterpost_twit']) and 
    7272               $_POST['twitterpost_twit'] and 
     
    179179          $uri = '') 
    180180     { 
    181           $c = new netHttp( 
    182                'alti.pro' 
     181          global $core; 
     182          $shortener = $core->blog->settings->twitterpost->twitterpost_shortener; 
     183           
     184          if (is_null($shortener)) 
     185          { 
     186               // Default 
     187               $shortener = 'http://alti.pro/api.php?longurl=%url%'; 
     188          } 
     189           
     190          $uri = str_replace( 
     191               '%url%', 
     192               $uri, 
     193               $shortener 
    183194          ); 
    184           $c->get( 
    185                '/api.php', 
    186                array( 
    187                     'longurl' => $uri 
    188                ) 
    189           ); 
    190           if ($c->getStatus() == '200') 
     195           
     196          $uri = netHttp::quickGet($uri); 
     197           
     198          if ($uri === false) 
    191199          { 
    192                $uri = $c->getContent(); 
     200               throw new Exception('Shortener url is invalid.'); 
    193201          } 
     202           
    194203          return $uri; 
    195204     } 
  • plugins/twitterPost/index.php

    r2451 r2466  
    2222# 
    2323# ***** END LICENSE BLOCK ***** 
     24 
    2425$core->blog->settings->setNamespace('twitterpost'); 
    25  
    2626// Twitter 
    27 if (!empty($_POST['twitterpost_username'])) 
     27if (isset($_POST['twitterpost_username'])) 
    2828{ 
    2929     $username  = $_POST['twitterpost_username']; 
     
    6666 
    6767// Identica 
    68 if (!empty($_POST['twitterpost_username_identica'])) 
     68if (isset($_POST['twitterpost_username_identica'])) 
    6969{ 
    7070     $username_identica  = $_POST['twitterpost_username_identica']; 
     
    9696} 
    9797 
    98 // Tr.im 
    99 if (!empty($_POST['twitterpost_username_trim'])) 
    100 { 
    101      $username_trim  = $_POST['twitterpost_username_trim']; 
    102      $password_trim = $_POST['twitterpost_password_trim']; 
    103  
    104      $core->blog->settings->put( 
    105           'twitterpost_username_trim', 
    106           $username_trim, 
    107           'string', 
    108           __('Tr.im login'), 
    109           true, 
    110           false 
    111      ); 
    112      $core->blog->settings->put( 
    113           'twitterpost_password_trim', 
    114           $password_trim, 
    115           'string', 
    116           __('Tr.im password'), 
    117           true, 
    118           false 
    119      ); 
    120  
    121      $msg = __('Configuration successfully updated'); 
    122 } 
    123 else 
    124 { 
    125      $username_trim = $core->blog->settings->twitterpost_username_trim; 
    126      $password_trim = $core->blog->settings->twitterpost_password_trim; 
     98// Shortener 
     99if (isset($_POST['twitterpost_shortener'])) 
     100{ 
     101     $shortener  = $_POST['twitterpost_shortener']; 
     102 
     103     $core->blog->settings->put( 
     104          'twitterpost_shortener', 
     105          $shortener, 
     106          'string', 
     107          __('Shortener api url'), 
     108          true, 
     109          false 
     110     ); 
     111 
     112     $msg = __('Configuration successfully updated'); 
     113} 
     114else 
     115{ 
     116     $shortener = $core->blog->settings->twitterpost->twitterpost_shortener; 
    127117} 
    128118 
     
    145135else 
    146136{ 
    147      $status = $core->blog->settings->twitterpost_status; 
     137     $status = $core->blog->settings->twitterpost->twitterpost_status; 
    148138} 
    149139 
     
    232222               </fieldset> 
    233223 
     224               <fieldset> 
     225                    <legend><?php echo __('Shortener'); ?></legend> 
     226                    <p class="label"> 
     227                         <label class="classic"> 
     228                              <?php echo __('API :'); ?> 
     229                              <?php echo form::field( 
     230                                   'twitterpost_shortener', 
     231                                   50, 
     232                                   null, 
     233                                   $shortener 
     234                              ); ?>&nbsp; 
     235                         </label> 
     236                    </p> 
     237                    <p> 
     238                         <?php echo __('You can set your own shortener'); ?><br /> 
     239                         <?php echo __('Exemple'); ?> "<em>http://alti.pro/api.php?longurl=%url%</em>" 
     240                    </p> 
     241               </fieldset> 
     242 
    234243               <input type="hidden" name="p" value="twitterPost" /> 
    235244               <?php echo $core->formNonce(); ?> 
  • plugins/twitterPost/locales/en/admin.po

    r2134 r2466  
    4848msgid "Twitter Post: Post must be published" 
    4949msgstr "Twitter Post : Post must be published." 
     50 
     51msgid "You can set your own shortener" 
     52msgstr "You can set your own shortener. Default is is.gd." 
     53 
     54msgid "Example" 
     55msgstr "Example" 
  • plugins/twitterPost/locales/fr/main.po

    r2134 r2466  
    4848msgid "Twitter Post: Post must be published" 
    4949msgstr "Twitter Post : votre article doit être publié." 
     50 
     51msgid "You can set your own shortener" 
     52msgstr "Vous pouvez utiliser votre propre shortener. Par défaut, is.gd sera utilisé" 
     53 
     54msgid "Example" 
     55msgstr "Exemple" 
Note: See TracChangeset for help on using the changeset viewer.

Sites map