Dotclear

Changeset 2169


Ignore:
Timestamp:
04/08/10 00:55:01 (13 years ago)
Author:
Osku
Message:

Plugin filesAlias - O.2: ~ enjoy :) ~

  • Add auto-generated URL
  • Add disposable URL option (one click then 404)
  • Revisited admin
  • Many fixes
Location:
plugins/filesAlias
Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • plugins/filesAlias/_admin.php

    r1850 r2169  
    44# This file is part of filesAlias, a plugin for Dotclear 2. 
    55#  
    6 # Copyright (c) 2009 Osku and contributors 
     6# Copyright (c) 2009-2010 Osku and contributors 
    77# 
    88# Licensed under the GPL version 2.0 license. 
  • plugins/filesAlias/_define.php

    r1850 r2169  
    44# This file is part of filesAlias, a plugin for Dotclear 2. 
    55#  
    6 # Copyright (c) 2009 Osku and contributors 
     6# Copyright (c) 2009-2010 Osku and contributors 
    77# 
    88# Licensed under the GPL version 2.0 license. 
     
    1717     /* Description*/         "Create aliases of your blog's files", 
    1818     /* Author */             "Osku", 
    19      /* Version */            '0.1', 
     19     /* Version */            '0.2', 
    2020     /* Permissions */        'contentadmin' 
    2121); 
  • plugins/filesAlias/_install.php

    r1850 r2169  
    44# This file is part of filesAlias, a plugin for Dotclear 2. 
    55#  
    6 # Copyright (c) 2009 Osku and contributors 
     6# Copyright (c) 2009-2010 Osku and contributors 
    77# 
    88# Licensed under the GPL version 2.0 license. 
     
    2828     ->filesalias_destination('varchar',255,false) 
    2929     ->filesalias_position('smallint',0,false,1) 
     30     ->filesalias_disposable('smallint',0,false,0) 
    3031      
    3132     ->primary('pk_filesalias','blog_id','filesalias_url') 
     
    4142$changes = $si->synchronize($s); 
    4243 
     44$core->blog->settings->setNamespace('filesalias'); 
     45$s =& $core->blog->settings; 
     46$s->put('filesalias_prefix','pub','string','Medias alias URL prefix',true,true); 
     47 
    4348$core->setVersion('filesAlias',$version); 
    4449return true; 
  • plugins/filesAlias/_prepend.php

    r1850 r2169  
    44# This file is part of filesAlias, a plugin for Dotclear 2. 
    55#  
    6 # Copyright (c) 2009 Osku and contributors 
     6# Copyright (c) 2009-2010 Osku and contributors 
    77# 
    88# Licensed under the GPL version 2.0 license. 
  • plugins/filesAlias/_public.php

    r1850 r2169  
    44# This file is part of filesAlias, a plugin for Dotclear 2. 
    55#  
    6 # Copyright (c) 2009 Osku and contributors 
     6# Copyright (c) 2009-2010 Osku and contributors 
    77# 
    88# Licensed under the GPL version 2.0 license. 
     
    1919     { 
    2020          $o = new FilesAliases($GLOBALS['core']); 
    21           $aliases = $o->getAliases(); 
    22  
    23           foreach ($aliases as $v) 
    24           { 
    25                if ($v['filesalias_url'] == $args) 
    26                { 
    27                     http::head(302, 'Found'); 
    28                     header('Location: '.$v['filesalias_destination']); 
    29                     return; 
    30                } 
     21          $dest = $o->getAlias($args); 
     22           
     23          if ($dest->isEmpty()) { 
     24               self::p404(); 
    3125          } 
    32            
    33           self::p404(); 
     26          $link = $dest->filesalias_destination; 
     27          if ($dest->filesalias_disposable) { 
     28               $o->deleteAlias($args); 
     29          } 
     30          http::head(302, 'Found'); 
     31          header('Location: '.$link); 
    3432     } 
    3533} 
  • plugins/filesAlias/inc/class.files.alias.php

    r1850 r2169  
    44# This file is part of filesAlias, a plugin for Dotclear 2. 
    55#  
    6 # Copyright (c) 2009 Osku and contributors 
     6# Copyright (c) 2009-2010 Osku and contributors 
    77# 
    88# Licensed under the GPL version 2.0 license. 
     
    1717     protected $aliases; 
    1818      
    19      public function __construct(&$core) 
     19     public function __construct($core) 
    2020     { 
    2121          $this->core =& $core; 
     
    2929           
    3030          $this->aliases = array(); 
    31           $sql =    'SELECT filesalias_url, filesalias_destination, filesalias_position '. 
     31          $sql =    'SELECT filesalias_url, filesalias_destination, filesalias_position, filesalias_disposable '. 
    3232                    'FROM '.$this->core->prefix.'filesalias '. 
    3333                    "WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ". 
     
    3535          $this->aliases = $this->core->con->select($sql)->rows(); 
    3636          return $this->aliases; 
     37     } 
     38      
     39     public function getAlias($url) 
     40     { 
     41          $strReq = 'SELECT filesalias_url, filesalias_destination, filesalias_position, filesalias_disposable '. 
     42                    'FROM '.$this->core->prefix.'filesalias '. 
     43                    "WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ". 
     44                    "AND filesalias_url = '".$url."' ". 
     45                    'ORDER BY filesalias_position ASC '; 
     46 
     47          $rs = $this->core->con->select($strReq); 
     48          return $rs; 
    3749     } 
    3850      
     
    4759                    if (!empty($v['filesalias_url']) && !empty($v['filesalias_destination'])) 
    4860                    { 
    49                          $this->createAlias($v['filesalias_url'],$v['filesalias_destination'],$k+1); 
     61                         $this->createAlias($v['filesalias_url'],$v['filesalias_destination'],$k+1,$v['filesalias_disposable']); 
    5062                    } 
    5163               } 
     
    6072     } 
    6173      
    62      public function createAlias($url,$destination,$position) 
     74     public function createAlias($url,$destination,$position,$disposable=0) 
    6375     { 
    6476          if (!$url) { 
     
    7587          $cur->filesalias_destination = (string) $destination; 
    7688          $cur->filesalias_position = abs((integer) $position); 
     89          $cur->filesalias_disposable = abs((integer) $disposable); 
    7790          $cur->insert(); 
    7891     } 
     
    8598          ); 
    8699     } 
     100 
     101     public function deleteAlias($url) 
     102     { 
     103          $this->core->con->execute( 
     104               'DELETE FROM '.$this->core->prefix.'filesalias '. 
     105               "WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ". 
     106               "AND filesalias_url = '".$url."' " 
     107          ); 
     108     } 
    87109} 
    88110?> 
  • plugins/filesAlias/index.php

    r1850 r2169  
    44# This file is part of filesAlias, a plugin for Dotclear 2. 
    55#  
    6 # Copyright (c) 2009 Osku and contributors 
     6# Copyright (c) 2009-2010 Osku and contributors 
    77# 
    88# Licensed under the GPL version 2.0 license. 
     
    1111# 
    1212# -- END LICENSE BLOCK ------------------------------------ 
    13  
    14 // Setting default parameters if missing configuration 
    15 if (is_null($core->blog->settings->filesalias_prefix)) { 
    16      try { 
    17                $core->blog->settings->setNameSpace('filesalias'); 
    18  
    19                $core->blog->settings->put('filesalias_prefix','pub','string','Medias alias URL prefix'); 
    20                $core->blog->triggerBlog(); 
    21                http::redirect(http::getSelfURI()); 
    22           } 
    23      catch (Exception $e) { 
    24           $core->error->add($e->getMessage()); 
    25      } 
    26 } 
    2713 
    2814$o = new FilesAliases($core); 
     
    4329if (isset($_POST['filesalias_url'])) 
    4430{ 
     31     $filesalias_url = empty($_POST['filesalias_url']) ? md5(uniqid(rand(), true)) : $_POST['filesalias_url']; 
     32      
    4533     try { 
    46           $o->createAlias($_POST['filesalias_url'],$_POST['filesalias_destination'],count($aliases)+1); 
     34          $o->createAlias($filesalias_url,$_POST['filesalias_destination'],count($aliases)+1,$_POST['filesalias_disposable']); 
    4735          http::redirect($p_url.'&created=1'); 
    4836     } catch (Exception $e) { 
     
    7462<body> 
    7563<?php 
     64echo 
     65'<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; '.__('Aliases for files').'</h2>'; 
     66?> 
     67<?php 
    7668if (!empty($_GET['up'])) { 
    7769     echo '<p class="message">'.__('Aliases successfully updated.').'</p>'; 
     
    8577     echo '<p class="message">'.__('Configuration successfully updated.').'</p>'; 
    8678} 
    87 ?> 
    88 <?php 
    89 echo 
    90 '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; '.__('Aliases for files').'</h2>'; 
    9179 
    9280if (empty($aliases)) 
     
    10088     '<fieldset>'. 
    10189     '<legend>'.__('Aliases list').'</legend>'. 
    102      '<table><tr>'. 
     90     '<table class="maximal"><tr>'. 
    10391     '<th>'.__('alias').'</th>'. 
    10492     '<th>'.__('destination').'</th>'. 
     93     '<th>'.'<img alt="'.__('disposable').'" title="'.__('disposable?').'" src="index.php?pf=filesAlias/img/trash.png" />'.'</th>'.     
    10594     //'<td>'.__('Alias position').'</td>'. 
    10695     '</tr>'; 
     
    10897     foreach ($aliases as $k => $v) 
    10998     { 
     99          if($v['filesalias_disposable']) { 
     100               $line = 'offline'; 
     101               $status = '<img alt="'.__('disposable').'" title="'.__('disposable').'" src="index.php?pf=filesAlias/img/bomb.png" />'; 
     102          } 
     103          else 
     104          { 
     105               $line = ''; 
     106               $status = '<img alt="'.__('not disposable').'" title="'.__('not disposable').'" src="index.php?pf=filesAlias/img/default.png" />'; 
     107          } 
     108           
     109          $link = '<a href="'.$core->blog->url.$core->url->getBase('filesalias').'/'.html::escapeHTML($v['filesalias_url']).'">'. 
     110                    '<img alt="'.__('Direct link').'" title="'.__('Direct link').'" src="index.php?pf=filesAlias/img/link.png" /></a>'; 
     111      
    110112          echo 
    111           '<tr>'. 
    112           '<td class="nowrap minimal">'.$core->blog->url.'<strong>'.$core->url->getBase('filesalias').'</strong>'.'/'.form::field(array('a['.$k.'][filesalias_url]'),20,255,html::escapeHTML($v['filesalias_url'])).'&nbsp;<a href="'.$core->blog->url.$core->url->getBase('filesalias').'/'.html::escapeHTML($v['filesalias_url']).'">'.__('Link').'</a></td>'. 
    113           '<td>'.form::field(array('a['.$k.'][filesalias_destination]'),70,255,html::escapeHTML($v['filesalias_destination'])).'</td>'. 
    114           //'<td>'.form::field(array('a['.$k.'][filesalias_position]'),3,5,html::escapeHTML($v['filesalias_position'])).'</td>'. 
     113          '<tr class='.$line.'>'. 
     114          '<td class="status nowrap">'.$status.form::field(array('a['.$k.'][filesalias_url]'),48,255,html::escapeHTML($v['filesalias_url']),'','','','style="margin-left:10px;"').'&nbsp;&bull;&nbsp;'.$link.'&nbsp;</td>'. 
     115          '<td class=" ">'.form::field(array('a['.$k.'][filesalias_destination]'),70,255,html::escapeHTML($v['filesalias_destination']),'maximal').'</td>'. 
     116          '<td class="status nowrap">'.form::checkbox(array('a['.$k.'][filesalias_disposable]'),1,$v['filesalias_disposable']).'</td>'. 
    115117          '</tr>'; 
    116118     } 
     
    128130'<fieldset>'. 
    129131'<legend>'.__('New alias').'</legend>'. 
    130 '<p class="field"><label>'.__('Media URL:').' '.form::field('filesalias_url',50,255).'</label></p>'. 
    131 '<p class="field"><label>'.__('Media destination:').' '.form::field('filesalias_destination',50,255).'</label></p>'. 
     132'<p class="field"><label class="required">'.__('Destination:').' '.form::field('filesalias_destination',50,255).'</label></p>'. 
     133'<p class="field"><label>'.__('Choose URL:').' '.form::field('filesalias_url',50,255).'</label></p><br />'. 
     134'<p class="form-note">'.__('Leave empty for an auto-generated URL.').'</p>'. 
     135'<p class="field"><label>'.__('Disposable:').' '.form::checkbox('filesalias_disposable',1).'</label></p>'. 
    132136'<p>'.$core->formNonce().'<input type="submit" value="'.__('Save').'" /></p>'. 
    133137'</fieldset>'. 
     
    138142'<fieldset>'. 
    139143'<legend>'.__('Prefix of Aliases URLs').'</legend>'. 
     144'<p>'.__('Base URL scheme:').'&nbsp;&mdash;&nbsp;'.$core->blog->url.'<span style="color : #069">'.$core->url->getBase('filesalias').'</span></p>'. 
    140145'<p><label class="required">' 
    141146.__('Media prefix URL:').' '.form::field('filesalias_prefix',20,255,$core->blog->settings->filesalias_prefix).'</label></p>'. 
  • plugins/filesAlias/locales/fr/main.po

    r1850 r2169  
    11# Language: français 
    2 # Module: filesAlias - 0.0 
    3 # Date: 2009-11-02 12:49:51 
     2# Module: filesAlias - 0.2 
     3# Date: 2010-04-07 22:14:28 
    44# Translated with translater 1.3 
    55 
     
    77msgstr "" 
    88"Content-Type: text/plain; charset=UTF-8\n" 
    9 "Project-Id-Version: filesAlias 0.0\n" 
     9"Project-Id-Version: filesAlias 0.2\n" 
    1010"POT-Creation-Date: \n" 
    11 "PO-Revision-Date: 2009-11-02T12:49:51+00:00\n" 
     11"PO-Revision-Date: 2010-04-07T22:14:28+00:00\n" 
    1212"Last-Translator: Osku\n" 
    1313"Language-Team: \n" 
     
    1616 
    1717#: _admin.php:15 
    18 #: index.php:71 
    19 #: index.php:90 
     18#: index.php:59 
     19#: index.php:65 
    2020msgid "Aliases for files" 
    2121msgstr "Alias pour fichiers" 
    2222 
    23 #: inc/class.files.alias.php:65 
     23#: inc/class.files.alias.php:77 
    2424msgid "File URL is empty." 
    25 msgstr "L'URL du fichier est vide" 
     25msgstr "L'URL du fichier est vide." 
    2626 
    27 #: inc/class.files.alias.php:69 
     27#: inc/class.files.alias.php:81 
    2828msgid "File destination is empty." 
    2929msgstr "La destination du fichier est vide." 
    3030 
    31 #: index.php:58 
     31#: index.php:46 
    3232msgid "No prefix for your files aliases." 
    3333msgstr "Aucun préfixe pour vos alias de fichiers." 
    3434 
    35 #: index.php:77 
     35#: index.php:69 
    3636msgid "Aliases successfully updated." 
    3737msgstr "Les alias ont été mis à jour avec succès." 
    3838 
    39 #: index.php:81 
     39#: index.php:73 
    4040msgid "Alias for this media created." 
    4141msgstr "L'alias pour votre fichier a été créé." 
    4242 
    43 #: index.php:85 
     43#: index.php:77 
    4444msgid "Configuration successfully updated." 
    4545msgstr "Configuration mise à jour avec succès." 
    4646 
    47 #: index.php:94 
     47#: index.php:82 
    4848msgid "No alias" 
    4949msgstr "Aucun alias" 
    5050 
    51 #: index.php:101 
     51#: index.php:89 
    5252msgid "Aliases list" 
    5353msgstr "Liste des alias" 
    5454 
    55 #: index.php:103 
     55#: index.php:91 
    5656msgid "alias" 
    5757msgstr "alias" 
    5858 
    59 #: index.php:104 
     59#: index.php:92 
    6060msgid "destination" 
    6161msgstr "destination" 
    6262 
    63 #: index.php:105 
     63#: index.php:93 
     64#: index.php:101 
     65#: index.php:101 
     66msgid "disposable" 
     67msgstr "jetable" 
     68 
     69#: index.php:93 
     70msgid "disposable?" 
     71msgstr "jetable ?" 
     72 
     73#: index.php:94 
    6474msgid "Alias position" 
    6575msgstr "Position de l'alias" 
    6676 
    67 #: index.php:112 
     77#: index.php:106 
     78#: index.php:106 
     79msgid "not disposable" 
     80msgstr "non jetable" 
     81 
     82#: index.php:110 
     83#: index.php:110 
     84msgid "Direct link" 
     85msgstr "Lien direct" 
     86 
     87#: index.php:121 
     88msgid "To remove a link, empty its alias or destination." 
     89msgstr "Pour supprimer un lien, vider son alias ou sa destination." 
     90 
     91#: index.php:123 
     92msgid "Update" 
     93msgstr "Mettre à jour" 
     94 
     95#: index.php:131 
     96msgid "New alias" 
     97msgstr "Nouvel alias" 
     98 
     99#: index.php:132 
     100msgid "Destination:" 
     101msgstr "Destination :" 
     102 
     103#: index.php:133 
     104msgid "Choose URL:" 
     105msgstr "Choisir l'URL :" 
     106 
     107#: index.php:134 
     108msgid "Leave empty for an auto-generated URL." 
     109msgstr "Laisser vide pour une URL générée automatiquement." 
     110 
     111#: index.php:135 
     112msgid "Disposable:" 
     113msgstr "Jetable :" 
     114 
     115#: index.php:136 
     116#: index.php:147 
     117msgid "Save" 
     118msgstr "Enregistrer" 
     119 
     120#: index.php:143 
     121msgid "Prefix of Aliases URLs" 
     122msgstr "Préfixe de l'URL des alias" 
     123 
     124#: index.php:144 
     125msgid "Base URL scheme:" 
     126msgstr "Schéma de base des URL :" 
     127 
     128#: index.php:146 
     129msgid "Media prefix URL:" 
     130msgstr "Préfixe de l'URL :" 
     131 
    68132msgid "Link" 
    69133msgstr "Lien" 
    70134 
    71 #: index.php:119 
    72 msgid "To remove a link, empty its alias or destination." 
    73 msgstr "Pour supprimer un lien, vider son alias ou sa destination." 
    74  
    75 #: index.php:121 
    76 msgid "Update" 
    77 msgstr "Mettre à jour" 
    78  
    79 #: index.php:129 
    80 msgid "New alias" 
    81 msgstr "Nouvel alias" 
    82  
    83 #: index.php:130 
    84 msgid "Media URL:" 
    85 msgstr "URL du média :" 
    86  
    87 #: index.php:131 
    88 msgid "Media destination:" 
    89 msgstr "Destination du média :" 
    90  
    91 #: index.php:132 
    92 #: index.php:142 
    93 msgid "Save" 
    94 msgstr "Enregistrer" 
    95  
    96 #: index.php:139 
    97 msgid "Prefix of Aliases URLs" 
    98 msgstr "Préfixe de l'URL des alias" 
    99  
    100 #: index.php:141 
    101 msgid "Media prefix URL:" 
    102 msgstr "Préfixe de l'URL :" 
    103  
Note: See TracChangeset for help on using the changeset viewer.

Sites map