Changeset 2169
- Timestamp:
- 04/08/10 00:55:01 (13 years ago)
- Location:
- plugins/filesAlias
- Files:
-
- 6 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/filesAlias/_admin.php
r1850 r2169 4 4 # This file is part of filesAlias, a plugin for Dotclear 2. 5 5 # 6 # Copyright (c) 2009 Osku and contributors6 # Copyright (c) 2009-2010 Osku and contributors 7 7 # 8 8 # Licensed under the GPL version 2.0 license. -
plugins/filesAlias/_define.php
r1850 r2169 4 4 # This file is part of filesAlias, a plugin for Dotclear 2. 5 5 # 6 # Copyright (c) 2009 Osku and contributors6 # Copyright (c) 2009-2010 Osku and contributors 7 7 # 8 8 # Licensed under the GPL version 2.0 license. … … 17 17 /* Description*/ "Create aliases of your blog's files", 18 18 /* Author */ "Osku", 19 /* Version */ '0. 1',19 /* Version */ '0.2', 20 20 /* Permissions */ 'contentadmin' 21 21 ); -
plugins/filesAlias/_install.php
r1850 r2169 4 4 # This file is part of filesAlias, a plugin for Dotclear 2. 5 5 # 6 # Copyright (c) 2009 Osku and contributors6 # Copyright (c) 2009-2010 Osku and contributors 7 7 # 8 8 # Licensed under the GPL version 2.0 license. … … 28 28 ->filesalias_destination('varchar',255,false) 29 29 ->filesalias_position('smallint',0,false,1) 30 ->filesalias_disposable('smallint',0,false,0) 30 31 31 32 ->primary('pk_filesalias','blog_id','filesalias_url') … … 41 42 $changes = $si->synchronize($s); 42 43 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 43 48 $core->setVersion('filesAlias',$version); 44 49 return true; -
plugins/filesAlias/_prepend.php
r1850 r2169 4 4 # This file is part of filesAlias, a plugin for Dotclear 2. 5 5 # 6 # Copyright (c) 2009 Osku and contributors6 # Copyright (c) 2009-2010 Osku and contributors 7 7 # 8 8 # Licensed under the GPL version 2.0 license. -
plugins/filesAlias/_public.php
r1850 r2169 4 4 # This file is part of filesAlias, a plugin for Dotclear 2. 5 5 # 6 # Copyright (c) 2009 Osku and contributors6 # Copyright (c) 2009-2010 Osku and contributors 7 7 # 8 8 # Licensed under the GPL version 2.0 license. … … 19 19 { 20 20 $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(); 31 25 } 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); 34 32 } 35 33 } -
plugins/filesAlias/inc/class.files.alias.php
r1850 r2169 4 4 # This file is part of filesAlias, a plugin for Dotclear 2. 5 5 # 6 # Copyright (c) 2009 Osku and contributors6 # Copyright (c) 2009-2010 Osku and contributors 7 7 # 8 8 # Licensed under the GPL version 2.0 license. … … 17 17 protected $aliases; 18 18 19 public function __construct( &$core)19 public function __construct($core) 20 20 { 21 21 $this->core =& $core; … … 29 29 30 30 $this->aliases = array(); 31 $sql = 'SELECT filesalias_url, filesalias_destination, filesalias_position '.31 $sql = 'SELECT filesalias_url, filesalias_destination, filesalias_position, filesalias_disposable '. 32 32 'FROM '.$this->core->prefix.'filesalias '. 33 33 "WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ". … … 35 35 $this->aliases = $this->core->con->select($sql)->rows(); 36 36 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; 37 49 } 38 50 … … 47 59 if (!empty($v['filesalias_url']) && !empty($v['filesalias_destination'])) 48 60 { 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']); 50 62 } 51 63 } … … 60 72 } 61 73 62 public function createAlias($url,$destination,$position )74 public function createAlias($url,$destination,$position,$disposable=0) 63 75 { 64 76 if (!$url) { … … 75 87 $cur->filesalias_destination = (string) $destination; 76 88 $cur->filesalias_position = abs((integer) $position); 89 $cur->filesalias_disposable = abs((integer) $disposable); 77 90 $cur->insert(); 78 91 } … … 85 98 ); 86 99 } 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 } 87 109 } 88 110 ?> -
plugins/filesAlias/index.php
r1850 r2169 4 4 # This file is part of filesAlias, a plugin for Dotclear 2. 5 5 # 6 # Copyright (c) 2009 Osku and contributors6 # Copyright (c) 2009-2010 Osku and contributors 7 7 # 8 8 # Licensed under the GPL version 2.0 license. … … 11 11 # 12 12 # -- END LICENSE BLOCK ------------------------------------ 13 14 // Setting default parameters if missing configuration15 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 }27 13 28 14 $o = new FilesAliases($core); … … 43 29 if (isset($_POST['filesalias_url'])) 44 30 { 31 $filesalias_url = empty($_POST['filesalias_url']) ? md5(uniqid(rand(), true)) : $_POST['filesalias_url']; 32 45 33 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']); 47 35 http::redirect($p_url.'&created=1'); 48 36 } catch (Exception $e) { … … 74 62 <body> 75 63 <?php 64 echo 65 '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Aliases for files').'</h2>'; 66 ?> 67 <?php 76 68 if (!empty($_GET['up'])) { 77 69 echo '<p class="message">'.__('Aliases successfully updated.').'</p>'; … … 85 77 echo '<p class="message">'.__('Configuration successfully updated.').'</p>'; 86 78 } 87 ?>88 <?php89 echo90 '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Aliases for files').'</h2>';91 79 92 80 if (empty($aliases)) … … 100 88 '<fieldset>'. 101 89 '<legend>'.__('Aliases list').'</legend>'. 102 '<table ><tr>'.90 '<table class="maximal"><tr>'. 103 91 '<th>'.__('alias').'</th>'. 104 92 '<th>'.__('destination').'</th>'. 93 '<th>'.'<img alt="'.__('disposable').'" title="'.__('disposable?').'" src="index.php?pf=filesAlias/img/trash.png" />'.'</th>'. 105 94 //'<td>'.__('Alias position').'</td>'. 106 95 '</tr>'; … … 108 97 foreach ($aliases as $k => $v) 109 98 { 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 110 112 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'])).' <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;"').' • '.$link.' </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>'. 115 117 '</tr>'; 116 118 } … … 128 130 '<fieldset>'. 129 131 '<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>'. 132 136 '<p>'.$core->formNonce().'<input type="submit" value="'.__('Save').'" /></p>'. 133 137 '</fieldset>'. … … 138 142 '<fieldset>'. 139 143 '<legend>'.__('Prefix of Aliases URLs').'</legend>'. 144 '<p>'.__('Base URL scheme:').' — '.$core->blog->url.'<span style="color : #069">'.$core->url->getBase('filesalias').'</span></p>'. 140 145 '<p><label class="required">' 141 146 .__('Media prefix URL:').' '.form::field('filesalias_prefix',20,255,$core->blog->settings->filesalias_prefix).'</label></p>'. -
plugins/filesAlias/locales/fr/main.po
r1850 r2169 1 1 # Language: français 2 # Module: filesAlias - 0. 03 # Date: 20 09-11-02 12:49:512 # Module: filesAlias - 0.2 3 # Date: 2010-04-07 22:14:28 4 4 # Translated with translater 1.3 5 5 … … 7 7 msgstr "" 8 8 "Content-Type: text/plain; charset=UTF-8\n" 9 "Project-Id-Version: filesAlias 0. 0\n"9 "Project-Id-Version: filesAlias 0.2\n" 10 10 "POT-Creation-Date: \n" 11 "PO-Revision-Date: 20 09-11-02T12:49:51+00:00\n"11 "PO-Revision-Date: 2010-04-07T22:14:28+00:00\n" 12 12 "Last-Translator: Osku\n" 13 13 "Language-Team: \n" … … 16 16 17 17 #: _admin.php:15 18 #: index.php: 7119 #: index.php: 9018 #: index.php:59 19 #: index.php:65 20 20 msgid "Aliases for files" 21 21 msgstr "Alias pour fichiers" 22 22 23 #: inc/class.files.alias.php: 6523 #: inc/class.files.alias.php:77 24 24 msgid "File URL is empty." 25 msgstr "L'URL du fichier est vide "25 msgstr "L'URL du fichier est vide." 26 26 27 #: inc/class.files.alias.php: 6927 #: inc/class.files.alias.php:81 28 28 msgid "File destination is empty." 29 29 msgstr "La destination du fichier est vide." 30 30 31 #: index.php: 5831 #: index.php:46 32 32 msgid "No prefix for your files aliases." 33 33 msgstr "Aucun préfixe pour vos alias de fichiers." 34 34 35 #: index.php: 7735 #: index.php:69 36 36 msgid "Aliases successfully updated." 37 37 msgstr "Les alias ont été mis à jour avec succès." 38 38 39 #: index.php: 8139 #: index.php:73 40 40 msgid "Alias for this media created." 41 41 msgstr "L'alias pour votre fichier a été créé." 42 42 43 #: index.php: 8543 #: index.php:77 44 44 msgid "Configuration successfully updated." 45 45 msgstr "Configuration mise à jour avec succès." 46 46 47 #: index.php: 9447 #: index.php:82 48 48 msgid "No alias" 49 49 msgstr "Aucun alias" 50 50 51 #: index.php: 10151 #: index.php:89 52 52 msgid "Aliases list" 53 53 msgstr "Liste des alias" 54 54 55 #: index.php: 10355 #: index.php:91 56 56 msgid "alias" 57 57 msgstr "alias" 58 58 59 #: index.php: 10459 #: index.php:92 60 60 msgid "destination" 61 61 msgstr "destination" 62 62 63 #: index.php:105 63 #: index.php:93 64 #: index.php:101 65 #: index.php:101 66 msgid "disposable" 67 msgstr "jetable" 68 69 #: index.php:93 70 msgid "disposable?" 71 msgstr "jetable ?" 72 73 #: index.php:94 64 74 msgid "Alias position" 65 75 msgstr "Position de l'alias" 66 76 67 #: index.php:112 77 #: index.php:106 78 #: index.php:106 79 msgid "not disposable" 80 msgstr "non jetable" 81 82 #: index.php:110 83 #: index.php:110 84 msgid "Direct link" 85 msgstr "Lien direct" 86 87 #: index.php:121 88 msgid "To remove a link, empty its alias or destination." 89 msgstr "Pour supprimer un lien, vider son alias ou sa destination." 90 91 #: index.php:123 92 msgid "Update" 93 msgstr "Mettre à jour" 94 95 #: index.php:131 96 msgid "New alias" 97 msgstr "Nouvel alias" 98 99 #: index.php:132 100 msgid "Destination:" 101 msgstr "Destination :" 102 103 #: index.php:133 104 msgid "Choose URL:" 105 msgstr "Choisir l'URL :" 106 107 #: index.php:134 108 msgid "Leave empty for an auto-generated URL." 109 msgstr "Laisser vide pour une URL générée automatiquement." 110 111 #: index.php:135 112 msgid "Disposable:" 113 msgstr "Jetable :" 114 115 #: index.php:136 116 #: index.php:147 117 msgid "Save" 118 msgstr "Enregistrer" 119 120 #: index.php:143 121 msgid "Prefix of Aliases URLs" 122 msgstr "Préfixe de l'URL des alias" 123 124 #: index.php:144 125 msgid "Base URL scheme:" 126 msgstr "Schéma de base des URL :" 127 128 #: index.php:146 129 msgid "Media prefix URL:" 130 msgstr "Préfixe de l'URL :" 131 68 132 msgid "Link" 69 133 msgstr "Lien" 70 134 71 #: index.php:11972 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:12176 msgid "Update"77 msgstr "Mettre à jour"78 79 #: index.php:12980 msgid "New alias"81 msgstr "Nouvel alias"82 83 #: index.php:13084 msgid "Media URL:"85 msgstr "URL du média :"86 87 #: index.php:13188 msgid "Media destination:"89 msgstr "Destination du média :"90 91 #: index.php:13292 #: index.php:14293 msgid "Save"94 msgstr "Enregistrer"95 96 #: index.php:13997 msgid "Prefix of Aliases URLs"98 msgstr "Préfixe de l'URL des alias"99 100 #: index.php:141101 msgid "Media prefix URL:"102 msgstr "Préfixe de l'URL :"103
Note: See TracChangeset
for help on using the changeset viewer.