Changeset 2474
- Timestamp:
- 07/10/10 19:11:01 (13 years ago)
- Location:
- plugins/filesAlias
- Files:
-
- 3 added
- 4 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/filesAlias/_admin.php
r2169 r2474 13 13 if (!defined('DC_CONTEXT_ADMIN')) { return; } 14 14 15 $_menu['Plugins']->addItem(__(' Aliases for files'),'plugin.php?p=filesAlias','index.php?pf=filesAlias/icon.png',15 $_menu['Plugins']->addItem(__('Medias sharing'),'plugin.php?p=filesAlias','index.php?pf=filesAlias/icon.png', 16 16 preg_match('/plugin.php\?p=filesAlias(&.*)?$/',$_SERVER['REQUEST_URI']), 17 17 $core->auth->check('admin',$core->blog->id)); -
plugins/filesAlias/_define.php
r2179 r2474 15 15 $this->registerModule( 16 16 /* Name */ 'filesAlias', 17 /* Description*/ " Create aliases of your blog's files",18 /* Author */ "Osku ",19 /* Version */ '0. 3.3',17 /* Description*/ "Manage aliases of your blog's medias", 18 /* Author */ "Osku and contributors", 19 /* Version */ '0.4.2', 20 20 /* Permissions */ 'contentadmin' 21 21 ); -
plugins/filesAlias/_install.php
r2169 r2474 27 27 ->filesalias_url('varchar',255,false) 28 28 ->filesalias_destination('varchar',255,false) 29 ->filesalias_p osition('smallint',0,false,1)29 ->filesalias_password('varchar',32,true,null) 30 30 ->filesalias_disposable('smallint',0,false,0) 31 31 … … 33 33 34 34 ->index('idx_filesalias_blog_id','btree','blog_id') 35 ->index('idx_filesalias_blog_id_filesalias_position','btree','blog_id','filesalias_position')36 35 37 36 ->reference('fk_filesalias_blog','blog_id','blog','blog_id','cascade','cascade') … … 42 41 $changes = $si->synchronize($s); 43 42 44 $core->blog->settings->setNamespace('filesalias'); 45 $s =& $core->blog->settings; 43 $s =& $core->blog->settings->filesalias; 46 44 $s->put('filesalias_prefix','pub','string','Medias alias URL prefix',true,true); 47 45 -
plugins/filesAlias/_prepend.php
r2179 r2474 13 13 if (!defined('DC_RC_PATH')) { return; } 14 14 15 $__autoload[' FilesAliases'] = dirname(__FILE__).'/inc/class.files.alias.php';15 $__autoload['filesAliases'] = dirname(__FILE__).'/inc/class.files.alias.php'; 16 16 $__autoload['aliasMedia'] = dirname(__FILE__).'/inc/class.files.alias.php'; 17 17 18 $core-> url->register('filesalias',$core->blog->settings->filesalias_prefix,'^'19 .$GLOBALS['core']->blog->settings->filesalias_prefix.'/(.+)$',array('urlFilesAlias','alias'));18 $core->blog->settings->addNamespace('filesalias'); 19 $core->filealias = new filesAliases($core); 20 20 21 $core->url->register('filesalias', 22 $core->blog->settings->filesalias->filesalias_prefix, 23 '^'.$core->blog->settings->filesalias->filesalias_prefix.'/(.+)$', 24 array('urlFilesAlias','alias') 25 ); 21 26 ?> -
plugins/filesAlias/_public.php
r2179 r2474 14 14 if (!defined('DC_RC_PATH')) { return; } 15 15 16 $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__).'/default-templates'); 17 $core->tpl->addValue('fileAliasURL',array('templateAlias','fileAliasURL')); 18 19 class templateAlias 20 { 21 public static function fileAliasURL($attr) 22 { 23 global $core, $_ctx; 24 25 $f = $GLOBALS['core']->tpl->getFilters($attr); 26 return '<?php echo '.sprintf($f,'$core->blog->url.$core->url->getBase("filesalias")."/".$_ctx->filealias->filesalias_url').'; ?>'; 27 } 28 } 29 16 30 class urlFilesAlias extends dcUrlHandlers 17 31 { 18 32 public static function alias($args) 19 33 { 20 global $core; 21 $f = new FilesAliases($core); 22 $dest = $f->getAlias($args); 23 $owned = false; 24 25 if ($dest->isEmpty()) { 34 $_ctx =& $GLOBALS['_ctx']; 35 $core =& $GLOBALS['core']; 36 $delete = false; 37 38 $_ctx->filealias = $core->filealias->getAlias($args); 39 40 if ($_ctx->filealias->isEmpty()) { 26 41 self::p404(); 27 42 } 28 43 29 $target = $dest->filesalias_destination; 44 if ($_ctx->filealias->filesalias_disposable) { 45 $delete = true; 46 } 30 47 31 if ($dest->filesalias_disposable) { 32 $f->deleteAlias($args); 33 } 34 35 $a= new aliasMedia($core); 48 if ($_ctx->filealias->filesalias_password) { 36 49 37 if (!preg_match('/^'.preg_quote($a->root_url,'/').'/',$target)) { 38 39 $media = $a->getMediaId($target); 40 41 if (empty($media)) 50 # Check for match 51 if (!empty($_POST['filepassword']) && $_POST['filepassword'] == $_ctx->filealias->filesalias_password) 42 52 { 43 self:: p404();53 self::servefile($_ctx->filealias->filesalias_destination,$delete); 44 54 } 45 46 $file = $core->media->getFile($media); 47 48 if (empty($file->file)) 49 { 50 self::p404(); 51 return; 52 } 53 54 header('Content-type: '.$file->type); 55 header('Content-Length: '.$file->size); 56 header('Content-Disposition: attachment; filename="'.$file->basename.'"'); 57 readfile($file->file); 58 return; 55 else 56 { 57 self::serveDocument('file-password-form.html','text/html',false); 58 return; 59 } 59 60 } 60 61 else 61 62 { 62 http::head(302, 'Found'); 63 header('Location: '.$target); 64 exit; 63 self::servefile($_ctx->filealias->filesalias_destination,$delete); 65 64 } 65 } 66 67 public static function servefile($target,$delete=false) 68 { 69 $core =& $GLOBALS['core']; 70 71 $a= new aliasMedia($core); 72 $media = $a->getMediaId($target); 73 74 if (empty($media)) 75 { 76 self::p404(); 77 } 78 79 $file = $core->media->getFile($media); 80 81 if (empty($file->file)) 82 { 83 self::p404(); 84 } 85 86 header('Content-type: '.$file->type); 87 header('Content-Length: '.$file->size); 88 header('Content-Disposition: attachment; filename="'.$file->basename.'"'); 89 readfile($file->file); 90 if ($delete) { 91 $core->filealias->deleteAlias($target); 92 } 93 return; 66 94 } 67 95 } -
plugins/filesAlias/inc/class.files.alias.php
r2179 r2474 12 12 # -- END LICENSE BLOCK ------------------------------------ 13 13 14 class FilesAliases14 class filesAliases 15 15 { 16 16 protected $core; … … 29 29 30 30 $this->aliases = array(); 31 $sql = 'SELECT filesalias_url, filesalias_destination, filesalias_p osition, filesalias_disposable '.31 $sql = 'SELECT filesalias_url, filesalias_destination, filesalias_password, filesalias_disposable '. 32 32 'FROM '.$this->core->prefix.'filesalias '. 33 33 "WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ". 34 'ORDER BY filesalias_ positionASC ';34 'ORDER BY filesalias_url ASC '; 35 35 $this->aliases = $this->core->con->select($sql)->rows(); 36 36 return $this->aliases; … … 39 39 public function getAlias($url) 40 40 { 41 $strReq = 'SELECT filesalias_url, filesalias_destination, filesalias_p osition, filesalias_disposable '.41 $strReq = 'SELECT filesalias_url, filesalias_destination, filesalias_password, filesalias_disposable '. 42 42 'FROM '.$this->core->prefix.'filesalias '. 43 43 "WHERE blog_id = '".$this->core->con->escape($this->core->blog->id)."' ". 44 44 "AND filesalias_url = '".$this->core->con->escape($url)."' ". 45 'ORDER BY filesalias_ positionASC ';45 'ORDER BY filesalias_url ASC '; 46 46 47 47 $rs = $this->core->con->select($strReq); … … 59 59 if (!empty($v['filesalias_url']) && !empty($v['filesalias_destination'])) 60 60 { 61 $this->createAlias($v['filesalias_url'],$v['filesalias_destination'],$ k+1,$v['filesalias_disposable']);61 $this->createAlias($v['filesalias_url'],$v['filesalias_destination'],$v['filesalias_disposable'],$v['filesalias_password']); 62 62 } 63 63 } … … 72 72 } 73 73 74 public function createAlias($url,$destination,$ position,$disposable=0)74 public function createAlias($url,$destination,$disposable=0,$password=null) 75 75 { 76 76 if (!$url) { … … 86 86 $cur->filesalias_url = (string) $url; 87 87 $cur->filesalias_destination = (string) $destination; 88 $cur->filesalias_p osition = abs((integer) $position);88 $cur->filesalias_password = $password; 89 89 $cur->filesalias_disposable = abs((integer) $disposable); 90 90 $cur->insert(); … … 109 109 } 110 110 111 class 111 class aliasMedia extends dcMedia 112 112 { 113 113 public function __construct($core) -
plugins/filesAlias/index.php
r2179 r2474 12 12 # -- END LICENSE BLOCK ------------------------------------ 13 13 14 $o = new FilesAliases($core);14 $o = $core->filealias; 15 15 $aliases = $o->getAliases(); 16 16 $media = new dcMedia($core); 17 $a= new aliasMedia($core); 17 18 18 19 # Update aliases … … 34 35 $target = $_POST['filesalias_destination']; 35 36 $totrash = $_POST['filesalias_disposable']; 37 $password = empty($_POST['filesalias_password'])? null : $_POST['filesalias_password']; 36 38 37 39 if (preg_match('/^'.preg_quote($media->root_url,'/').'/',$target)) { 38 40 $target = preg_replace('/^'.preg_quote($media->root_url,'/').'/','',$target); 41 $media = $a->getMediaId($target); 42 43 if (!empty($media)) 44 { 45 try { 46 $o->createAlias($url,$target,$totrash,$password); 47 http::redirect($p_url.'&created=1'); 48 } catch (Exception $e) { 49 $core->error->add($e->getMessage()); 50 } 51 } 52 else 53 { 54 $core->error->add(__('Target is not in medias manager.')); 55 } 39 56 } 40 41 try { 42 $o->createAlias($url,$target,count($aliases)+1,$totrash); 43 http::redirect($p_url.'&created=1'); 44 } catch (Exception $e) { 45 $core->error->add($e->getMessage()); 57 else 58 { 59 $core->error->add(__('Target is not in medias manager.')); 46 60 } 47 61 } … … 51 65 { 52 66 try { 53 if (empty($_POST['filesalias_prefix'])) { 54 throw new Exception(__('No prefix for your files aliases.')); 55 } 56 $core->blog->settings->setNameSpace('filesalias'); 57 $core->blog->settings->put('filesalias_prefix',$_POST['filesalias_prefix'],'string','Medias alias URL prefix'); 67 $prefix = (empty($_POST['filesalias_prefix'])) ? 'pub' : $_POST['filesalias_prefix']; 68 69 $core->blog->settings->filesalias->put('filesalias_prefix',$prefix,'string','Medias alias URL prefix'); 58 70 $core->blog->triggerBlog(); 59 71 http::redirect($p_url.'&modified=1'); … … 65 77 <html> 66 78 <head> 67 <title><?php echo __(' Aliases for files'); ?></title>79 <title><?php echo __('Medias sharing'); ?></title> 68 80 </head> 69 81 … … 71 83 <?php 72 84 echo 73 '<h2>'.html::escapeHTML($core->blog->name).' › '.__(' Aliases for files').'</h2>';85 '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Medias sharing').'</h2>'; 74 86 ?> 75 87 <?php … … 99 111 '<th>'.__('alias').'</th>'. 100 112 '<th>'.__('destination').'</th>'. 113 '<th>'.__('password').'</th>'. 101 114 '<th>'.'<img alt="'.__('disposable').'" title="'.__('disposable?').'" src="index.php?pf=filesAlias/img/trash.png" />'.'</th>'. 102 //'<td>'.__('Alias position').'</td>'.103 115 '</tr>'; 104 116 105 117 foreach ($aliases as $k => $v) 106 118 { 107 if($v['filesalias_disposable']) {108 $line = 'offline';109 $status = '<img alt="'.__('disposable').'" title="'.__('disposable').'" src="index.php?pf=filesAlias/img/bomb.png" />';110 }111 else112 {113 $line = '';114 $status = '<img alt="'.__('not disposable').'" title="'.__('not disposable').'" src="index.php?pf=filesAlias/img/default.png" />';115 }116 117 119 $url = $core->blog->url.$core->url->getBase('filesalias').'/'.html::escapeHTML($v['filesalias_url']); 118 120 $link = '<a href="'.$url.'">'. 119 '<img alt="'.__('Direct link').'" title="'. $url.'" src="index.php?pf=filesAlias/img/link.png" /></a>';121 '<img alt="'.__('Direct link').'" title="'.__('Direct link').'" src="index.php?pf=filesAlias/img/bt_link.png" /></a>'; 120 122 121 if (!preg_match('#^http(s)?://#',$v['filesalias_destination'])) {122 $public = 'style="background:#FFF6BF;color:#514721;"';123 }124 else125 {126 $public = '';127 }128 129 123 echo 130 '<tr class="'.$line.'" >'. 131 '<td class="status nowrap">'.$link.' '.$status.form::field(array('a['.$k.'][filesalias_url]'),48,255,html::escapeHTML($v['filesalias_url']),'','','','style="margin-left:10px;"').'</td>'. 132 '<td class=" ">'.form::field(array('a['.$k.'][filesalias_destination]'),70,255,html::escapeHTML($v['filesalias_destination']),'maximal','','',$public).'</td>'. 133 '<td class="status nowrap">'.form::checkbox(array('a['.$k.'][filesalias_disposable]'),1,$v['filesalias_disposable']).'</td>'. 124 '<tr>'. 125 '<td>'.form::field(array('a['.$k.'][filesalias_url]'),40,255,html::escapeHTML($v['filesalias_url'])).'</td>'. 126 '<td class="maximal">'.form::field(array('a['.$k.'][filesalias_destination]'),50,255,html::escapeHTML($v['filesalias_destination'])).'</td>'. 127 '<td>'.form::field(array('a['.$k.'][filesalias_password]'),20,255,html::escapeHTML($v['filesalias_password'])).'</td>'. 128 '<td class="status nowrap">'.form::checkbox(array('a['.$k.'][filesalias_disposable]'),1,$v['filesalias_disposable']).$link.'</td>'. 134 129 '</tr>'; 135 130 } … … 148 143 '<legend>'.__('New alias').'</legend>'. 149 144 '<p class="field"><label class="required">'.__('Destination:').' '.form::field('filesalias_destination',50,255).'</label></p>'. 150 '<p class="field"><label>'.__('Choose URL:').' '.form::field('filesalias_url',50,255).'</label></p> <br />'.151 '<p class="f orm-note">'.__('Leave empty for an auto-generated URL.').'</p>'.145 '<p class="field"><label>'.__('Choose URL:').' '.form::field('filesalias_url',50,255).'</label></p>'. 146 '<p class="field"><label>'.__('Password:').' '.form::field('filesalias_password',50,255).'</label></p>'. 152 147 '<p class="field"><label>'.__('Disposable:').' '.form::checkbox('filesalias_disposable',1).'</label></p>'. 148 153 149 '<p>'.$core->formNonce().'<input type="submit" value="'.__('Save').'" /></p>'. 154 150 '</fieldset>'. … … 161 157 '<p>'.__('Base URL scheme:').' — '.$core->blog->url.'<span style="color : #069">'.$core->url->getBase('filesalias').'</span></p>'. 162 158 '<p><label class="required">' 163 .__('Media prefix URL:').' '.form::field('filesalias_prefix',20,255,$core->blog->settings->filesalias _prefix).'</label></p>'.159 .__('Media prefix URL:').' '.form::field('filesalias_prefix',20,255,$core->blog->settings->filesalias->filesalias_prefix).'</label></p>'. 164 160 '<p>'.$core->formNonce().'<input type="submit" value="'.__('Save').'" /></p>'. 165 161 '</fieldset>'. -
plugins/filesAlias/locales/fr/main.po
r2169 r2474 1 # Language: français2 # Module: filesAlias - 0. 23 # Date: 2010-0 4-07 22:14:284 # Translated with translater 1. 31 # Language: Français 2 # Module: filesAlias - 0.4 3 # Date: 2010-07-09 15:39:30 4 # Translated with translater 1.4.1 5 5 6 6 msgid "" 7 7 msgstr "" 8 8 "Content-Type: text/plain; charset=UTF-8\n" 9 "Project-Id-Version: filesAlias 0. 2\n"9 "Project-Id-Version: filesAlias 0.4\n" 10 10 "POT-Creation-Date: \n" 11 "PO-Revision-Date: 2010-0 4-07T22:14:28+00:00\n"12 "Last-Translator: Osku\n"11 "PO-Revision-Date: 2010-07-09T15:39:30+00:00\n" 12 "Last-Translator: osku\n" 13 13 "Language-Team: \n" 14 14 "MIME-Version: 1.0\n" … … 16 16 17 17 #: _admin.php:15 18 #: index.php: 5919 #: index.php: 6520 msgid " Aliases for files"21 msgstr " Alias pour fichiers"18 #: index.php:69 19 #: index.php:75 20 msgid "Medias sharing" 21 msgstr "Partage de médias" 22 22 23 23 #: inc/class.files.alias.php:77 … … 29 29 msgstr "La destination du fichier est vide." 30 30 31 #: index.php:4 632 msgid " No prefix for your files aliases."33 msgstr " Aucun préfixe pour vos alias de fichiers."31 #: index.php:49 32 msgid "Target is not in medias manager." 33 msgstr "La cible n'est pas dans le gestionnaire de médias." 34 34 35 #: index.php: 6935 #: index.php:79 36 36 msgid "Aliases successfully updated." 37 37 msgstr "Les alias ont été mis à jour avec succès." 38 38 39 #: index.php: 7339 #: index.php:83 40 40 msgid "Alias for this media created." 41 41 msgstr "L'alias pour votre fichier a été créé." 42 42 43 #: index.php: 7743 #: index.php:87 44 44 msgid "Configuration successfully updated." 45 45 msgstr "Configuration mise à jour avec succès." 46 46 47 #: index.php: 8247 #: index.php:92 48 48 msgid "No alias" 49 49 msgstr "Aucun alias" 50 50 51 #: index.php: 8951 #: index.php:99 52 52 msgid "Aliases list" 53 53 msgstr "Liste des alias" 54 54 55 #: index.php: 9155 #: index.php:101 56 56 msgid "alias" 57 57 msgstr "alias" 58 58 59 #: index.php: 9259 #: index.php:102 60 60 msgid "destination" 61 61 msgstr "destination" 62 62 63 #: index.php:93 64 #: index.php:101 65 #: index.php:101 63 #: index.php:103 64 msgid "password" 65 msgstr "mot de passe" 66 67 #: index.php:104 66 68 msgid "disposable" 67 69 msgstr "jetable" 68 70 69 #: index.php: 9371 #: index.php:104 70 72 msgid "disposable?" 71 73 msgstr "jetable ?" 72 74 73 #: index.php:94 74 msgid "Alias position" 75 msgstr "Position de l'alias" 76 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 75 #: index.php:111 76 #: index.php:111 84 77 msgid "Direct link" 85 78 msgstr "Lien direct" 86 79 87 #: index.php:12 180 #: index.php:123 88 81 msgid "To remove a link, empty its alias or destination." 89 82 msgstr "Pour supprimer un lien, vider son alias ou sa destination." 90 83 91 #: index.php:12 384 #: index.php:125 92 85 msgid "Update" 93 86 msgstr "Mettre à jour" 94 87 95 #: index.php:13 188 #: index.php:133 96 89 msgid "New alias" 97 90 msgstr "Nouvel alias" 98 91 99 #: index.php:13 292 #: index.php:134 100 93 msgid "Destination:" 101 94 msgstr "Destination :" 102 95 103 #: index.php:13 396 #: index.php:135 104 97 msgid "Choose URL:" 105 98 msgstr "Choisir l'URL :" 106 99 107 #: index.php:13 4108 msgid " Leave empty for an auto-generated URL."109 msgstr " Laisser vide pour une URL générée automatiquement."100 #: index.php:136 101 msgid "Password:" 102 msgstr "Mot de passe :" 110 103 111 #: index.php:13 5104 #: index.php:137 112 105 msgid "Disposable:" 113 106 msgstr "Jetable :" 114 107 115 #: index.php:13 6116 #: index.php:1 47108 #: index.php:139 109 #: index.php:150 117 110 msgid "Save" 118 111 msgstr "Enregistrer" 119 112 120 #: index.php:14 3113 #: index.php:146 121 114 msgid "Prefix of Aliases URLs" 122 115 msgstr "Préfixe de l'URL des alias" 123 116 124 #: index.php:14 4117 #: index.php:147 125 118 msgid "Base URL scheme:" 126 119 msgstr "Schéma de base des URL :" 127 120 128 #: index.php:14 6121 #: index.php:149 129 122 msgid "Media prefix URL:" 130 123 msgstr "Préfixe de l'URL :"
Note: See TracChangeset
for help on using the changeset viewer.