Changeset 852:969647a6c35e
- Timestamp:
- 07/31/12 15:15:32 (13 years ago)
- Branch:
- sexy
- Files:
-
- 5 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/blog_pref.php
r848 r852 88 88 } 89 89 90 # Image title combo91 $img_title_combo = array(92 __('Title') => 'Title ;; separator(, )',93 __('Title, Date') => 'Title ;; Date(%b %Y) ;; separator(, )',94 __('Title, Country, Date') => 'Title ;; Country ;; Date(%b %Y) ;; separator(, )',95 __('Title, City, Country, Date') => 'Title ;; City ;; Country ;; Date(%b %Y) ;; separator(, )',96 );97 if (!in_array($blog_settings->system->media_img_title_pattern,$img_title_combo)) {98 $img_title_combo[html::escapeHTML($blog_settings->system->media_img_title_pattern)] = html::escapeHTML($blog_settings->system->media_img_title_pattern);99 }100 90 101 91 # Robots policy options … … 119 109 $cur->blog_name = $_POST['blog_name']; 120 110 $cur->blog_desc = $_POST['blog_desc']; 121 122 $media_img_t_size = abs((integer) $_POST['media_img_t_size']);123 if ($media_img_t_size < 0) { $media_img_t_size = 100; }124 125 $media_img_s_size = abs((integer) $_POST['media_img_s_size']);126 if ($media_img_s_size < 0) { $media_img_s_size = 240; }127 128 $media_img_m_size = abs((integer) $_POST['media_img_m_size']);129 if ($media_img_m_size < 0) { $media_img_m_size = 448; }130 111 131 112 $nb_post_per_page = abs((integer) $_POST['nb_post_per_page']); … … 183 164 $blog_settings->system->put('nb_post_per_page',$nb_post_per_page); 184 165 $blog_settings->system->put('use_smilies',!empty($_POST['use_smilies'])); 185 $blog_settings->system->put('media_img_t_size',$media_img_t_size);186 $blog_settings->system->put('media_img_s_size',$media_img_s_size);187 $blog_settings->system->put('media_img_m_size',$media_img_m_size);188 $blog_settings->system->put('media_img_title_pattern',$_POST['media_img_title_pattern']);189 166 $blog_settings->system->put('nb_post_per_feed',$nb_post_per_feed); 190 167 $blog_settings->system->put('short_feed_items',!empty($_POST['short_feed_items'])); … … 352 329 '</fieldset>'; 353 330 354 echo355 '<fieldset><legend>'.__('Media and images').'</legend>'.356 '<div class="two-cols">'.357 '<div class="col">'.358 '<h4>'.__('Generated image sizes (in pixels)').'</h4>'.359 '<p class="field"><label for="media_img_t_size">'.__('Thumbnails:').' '.360 form::field('media_img_t_size',3,3,$blog_settings->system->media_img_t_size).'</label></p>'.361 362 '<p class="field"><label for="media_img_s_size">'.__('Small:').' '.363 form::field('media_img_s_size',3,3,$blog_settings->system->media_img_s_size).'</label></p>'.364 365 '<p class="field"><label for="media_img_m_size">'.__('Medium:').' '.366 form::field('media_img_m_size',3,3,$blog_settings->system->media_img_m_size).'</label></p>'.367 '</div>'.368 369 '<div class="col">'.370 '<h4><label for="media_img_title_pattern">'.__('Inserted image title').'</label></h4>'.371 '<p>'.__('This defines image tag title when you insert it in a post from the media manager. It is retrieved from the picture\'s metadata.').'</p>'.372 '<p>'.form::combo('media_img_title_pattern',$img_title_combo,html::escapeHTML($blog_settings->system->media_img_title_pattern)).'</p>'.373 '</div>'.374 '</div>'.375 '</fieldset>';376 331 377 332 echo -
admin/post.php
r851 r852 124 124 } 125 125 126 try {127 $core->media = new dcMedia($core);128 } catch (Exception $e) {}129 126 } 130 127 } -
admin/preferences.php
r821 r852 456 456 __('Enable WYSIWYG mode').'</label></p>'. 457 457 458 '<p><label for="user_ui_enhanceduploader" class="classic">'.459 form::checkbox('user_ui_enhanceduploader',1,$user_ui_enhanceduploader).' '.460 __('Activate enhanced uploader in media manager').'</label></p>'.461 462 458 '<p><label for="user_ui_nofavmenu" class="classic">'. 463 459 form::checkbox('user_ui_nofavmenu',1,$user_ui_nofavmenu).' '. -
admin/services.php
r848 r852 20 20 $core->rest->addFunction('quickPost',array('dcRestMethods','quickPost')); 21 21 $core->rest->addFunction('validatePostMarkup',array('dcRestMethods','validatePostMarkup')); 22 $core->rest->addFunction('getZipMediaContent',array('dcRestMethods','getZipMediaContent'));23 22 $core->rest->addFunction('getMeta',array('dcRestMethods','getMeta')); 24 23 $core->rest->addFunction('delMeta',array('dcRestMethods','delMeta')); … … 163 162 } 164 163 165 public static function getZipMediaContent($core,$get,$post)166 {167 if (empty($get['id'])) {168 throw new Exception('No media ID');169 }170 171 $id = (integer) $get['id'];172 173 if (!$core->auth->check('media,media_admin',$core->blog)) {174 throw new Exception('Permission denied');175 }176 177 $core->media = new dcMedia($core);178 $file = $core->media->getFile($id);179 180 if ($file === null || $file->type != 'application/zip' || !$file->editable) {181 throw new Exception('Not a valid file');182 }183 184 $rsp = new xmlTag('result');185 $content = $core->media->getZipContent($file);186 187 foreach ($content as $k => $v) {188 $rsp->file($k);189 }190 191 return $rsp;192 }193 194 164 public static function getMeta($core,$get) 195 165 { -
inc/admin/lib.dc.page.php
r851 r852 414 414 self::jsVar('dotclear.msg.confirm_delete_user', 415 415 __('Are you sure you want to delete selected users (%s)?')). 416 self::jsVar('dotclear.msg.confirm_delete_media',417 __('Are you sure you want to remove media "%s"?')).418 416 self::jsVar('dotclear.msg.confirm_extract_current', 419 417 __('Are you sure you want to extract archive in current directory?')). … … 623 621 "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". 624 622 625 "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ".626 623 "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; "; 627 624 628 if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) {629 $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n";630 }631 625 632 626 $res .= -
inc/admin/lib.pager.php
r851 r852 100 100 } 101 101 102 $attach = '';103 $nb_media = $this->rs->countMedia();104 if ($nb_media > 0) {105 $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');106 $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');107 }108 102 109 103 $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. … … 117 111 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. 118 112 '<td class="nowrap">'.$this->rs->user_id.'</td>'. 119 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.113 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.'</td>'. 120 114 '</tr>'; 121 115 … … 196 190 } 197 191 198 $attach = '';199 $nb_media = $this->rs->countMedia();200 if ($nb_media > 0) {201 $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');202 $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png');203 }204 192 205 193 $res = '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. … … 212 200 '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'. 213 201 '<td class="nowrap">'.$this->rs->user_id.'</td>'. 214 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'.202 '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.'</td>'. 215 203 '</tr>'; 216 204 -
inc/admin/prepend.php
r851 r852 146 146 { 147 147 $_SESSION['sess_blog_id'] = $_REQUEST['switchblog']; 148 if (isset($_SESSION['media_manager_dir'])) { 149 unset($_SESSION['media_manager_dir']); 150 } 151 if (isset($_SESSION['media_manager_page'])) { 152 unset($_SESSION['media_manager_page']); 153 } 154 148 155 149 # Removing switchblog from URL 156 150 $redir = $_SERVER['REQUEST_URI']; … … 238 232 'images/menu/search.png','images/menu/search-b.png', 239 233 'usage,contentadmin',null,null)); 240 $_fav['media'] = new ArrayObject(array('media','Media manager','media.php',241 'images/menu/media.png','images/menu/media-b.png',242 'media,media_admin',null,null));243 234 $_fav['blog_pref'] = new ArrayObject(array('blog_pref','Blog settings','blog_pref.php', 244 235 'images/menu/blog-pref.png','images/menu/blog-pref-b.png', … … 296 287 preg_match('/blog_pref.php(\?.*)?$/',$_SERVER['REQUEST_URI']), 297 288 $core->auth->check('admin',$core->blog->id)); 298 $_menu['Blog']->prependItem(__('Media manager'),'media.php','images/menu/media.png',299 preg_match('/media(_item)?.php(\?.*)?$/',$_SERVER['REQUEST_URI']),300 $core->auth->check('media,media_admin',$core->blog->id));301 289 $_menu['Blog']->prependItem(__('Search'),'search.php','images/menu/search.png', 302 290 preg_match('/search.php(\?.*)?$/',$_SERVER['REQUEST_URI']), -
inc/core/class.dc.auth.php
r851 r852 75 75 'publish' => __('publish entries and comments'), 76 76 'delete' => __('delete entries and comments'), 77 'contentadmin' => __('manage all entries and comments'), 78 'media' => __('manage their own media items'), 79 'media_admin' => __('manage all media items') 77 'contentadmin' => __('manage all entries and comments') 80 78 ); 81 79 } -
inc/core/class.dc.blog.php
r851 r852 361 361 $rs = $this->con->select($strReq); 362 362 $rs->core = $this->core; 363 $rs->_nb_media = array();364 363 $rs->extend('rsExtPost'); 365 364 -
inc/core/class.dc.core.php
r848 r852 35 35 public $wiki2xhtml; ///< <b>wiki2xhtml</b> wiki2xhtml object 36 36 public $plugins; ///< <b>dcModules</b> dcModules object 37 public $media; ///< <b>dcMedia</b> dcMedia object38 public $postmedia; ///< <b>dcPostMedia</b> dcPostMedia object39 37 public $rest; ///< <b>dcRestServer</b> dcRestServer object 40 38 public $log; ///< <b>dcLog</b> dcLog object … … 1202 1200 array('lang','string','en', 1203 1201 'Default blog language'), 1204 array('media_exclusion','string','/\.php$/i',1205 'File name exclusion pattern in media manager. (PCRE value)'),1206 array('media_img_m_size','integer',448,1207 'Image medium size in media manager'),1208 array('media_img_s_size','integer',240,1209 'Image small size in media manager'),1210 array('media_img_t_size','integer',100,1211 'Image thumbnail size in media manager'),1212 array('media_img_title_pattern','string','Title ;; Date(%b %Y) ;; separator(, )',1213 'Pattern to set image title when you insert it in a post'),1214 1202 array('nb_post_per_page','integer',20, 1215 1203 'Number of entries on home page and category pages'), -
inc/core/class.dc.rs.extensions.php
r851 r852 335 335 } 336 336 337 /**338 Returns post media count using a subquery.339 340 @param rs Invisible parameter341 @return <b>integer</b>342 */343 public static function countMedia($rs)344 {345 if (isset($rs->_nb_media[$rs->index()]))346 {347 return $rs->_nb_media[$rs->index()];348 }349 else350 {351 $strReq =352 'SELECT count(media_id) '.353 'FROM '.$rs->core->prefix.'post_media '.354 'WHERE post_id = '.(integer) $rs->post_id.' ';355 356 $res = (integer) $rs->core->con->select($strReq)->f(0);357 $rs->_nb_media[$rs->index()] = $res;358 return $res;359 }360 }361 337 } 362 338 -
inc/core/class.dc.xmlrpc.php
r851 r852 75 75 'List of most recent posts in the system'); 76 76 77 $this->addCallback('metaWeblog.newMediaObject',array($this,'mw_newMediaObject'),78 array('struct','string','string','string','struct'),79 'Upload a file on the web server');80 81 77 # MovableType methods 82 78 $this->addCallback('mt.getRecentPostTitles',array($this,'mt_getRecentPostTitles'), … … 573 569 574 570 return true; 575 }576 577 private function newMediaObject($blog_id,$user,$pwd,$file)578 {579 if (empty($file['name'])) {580 throw new Exception('No file name');581 }582 583 if (empty($file['bits'])) {584 throw new Exception('No file content');585 }586 587 $file_name = $file['name'];588 $file_bits = $file['bits'];589 590 $this->setUser($user,$pwd);591 $this->setBlog();592 593 $media = new dcMedia($this->core);594 595 $dir_name = path::clean(dirname($file_name));596 $file_name = basename($file_name);597 598 $dir_name = preg_replace('!^/!','',$dir_name);599 if ($dir_name != '')600 {601 $dir = explode('/',$dir_name);602 $cwd = './';603 foreach ($dir as $v)604 {605 $v = files::tidyFileName($v);606 $cwd .= $v.'/';607 $media->makeDir($v);608 $media->chdir($cwd);609 }610 }611 612 $media_id = $media->uploadBits($file_name,$file_bits);613 614 $f = $media->getFile($media_id);615 return array(616 'file' => $file_name,617 'url' => $f->file_url,618 'type' => files::getMimeType($file_name)619 );620 571 } 621 572 … … 940 891 } 941 892 942 public function mw_newMediaObject($blogid,$username,$password,$file)943 {944 return $this->newMediaObject($blogid,$username,$password,$file);945 }946 947 893 /* MovableType methods 948 894 --------------------------------------------------- */ … … 1024 970 { 1025 971 return $this->getTags($username,$password); 1026 }1027 1028 public function wp_uploadFile($blogid,$username,$password,$file)1029 {1030 return $this->newMediaObject($blogid,$username,$password,$file);1031 972 } 1032 973 -
inc/dbschema/db-schema.php
r851 r852 112 112 ; 113 113 114 $_s->media115 ->media_id ('bigint', 0, false)116 ->user_id ('varchar', 32, false)117 ->media_path ('varchar', 255, false)118 ->media_title ('varchar', 255, false)119 ->media_file ('varchar', 255, false)120 ->media_dir ('varchar', 255, false, "'.'")121 ->media_meta ('text', 0, true, null)122 ->media_dt ('timestamp', 0, false, 'now()')123 ->media_creadt ('timestamp', 0, false, 'now()')124 ->media_upddt ('timestamp', 0, false, 'now()')125 ->media_private ('smallint', 0, false, 0)126 127 ->primary('pk_media','media_id')128 ;129 130 $_s->post_media131 ->media_id ('bigint', 0, false)132 ->post_id ('bigint', 0, false)133 ->link_type ('varchar', 32, false, "'attachment'")134 135 ->primary('pk_post_media','media_id','post_id','link_type')136 ;137 114 138 115 $_s->log … … 181 158 $_s->post->index ('idx_post_user_id', 'btree', 'user_id'); 182 159 $_s->post->index ('idx_post_blog_id', 'btree', 'blog_id'); 183 $_s->media->index ('idx_media_user_id', 'btree', 'user_id');184 $_s->post_media->index ('idx_post_media_post_id', 'btree', 'post_id');185 $_s->post_media->index ('idx_post_media_media_id', 'btree', 'media_id');186 160 $_s->log->index ('idx_log_user_id', 'btree', 'user_id'); 187 161 $_s->meta->index ('idx_meta_post_id', 'btree','post_id'); … … 206 180 $_s->post->reference('fk_post_user','user_id','user','user_id','cascade','cascade'); 207 181 $_s->post->reference('fk_post_blog','blog_id','blog','blog_id','cascade','cascade'); 208 $_s->media->reference('fk_media_user','user_id','user','user_id','cascade','cascade');209 $_s->post_media->reference('fk_media','media_id','media','media_id','cascade','cascade');210 $_s->post_media->reference('fk_media_post','post_id','post','post_id','cascade','cascade');211 182 $_s->log->reference('fk_log_blog','blog_id','blog','blog_id','cascade','set null'); 212 183 $_s->meta->reference('fk_meta_post','post_id','post','post_id','cascade','cascade'); … … 218 189 { 219 190 $_s->setting->index ('idx_setting_blog_id_null', 'btree', '(blog_id IS NULL)'); 220 $_s->media->index ('idx_media_media_path', 'btree', 'media_path', 'media_dir');221 191 $_s->pref->index ('idx_pref_user_id_null', 'btree', '(user_id IS NULL)'); 222 192 } -
inc/prepend.php
r851 r852 31 31 $__autoload['dcError'] = dirname(__FILE__).'/core/class.dc.error.php'; 32 32 $__autoload['dcMeta'] = dirname(__FILE__).'/core/class.dc.meta.php'; 33 $__autoload['dcMedia'] = dirname(__FILE__).'/core/class.dc.media.php';34 $__autoload['dcPostMedia'] = dirname(__FILE__).'/core/class.dc.postmedia.php';35 33 $__autoload['dcModules'] = dirname(__FILE__).'/core/class.dc.modules.php'; 36 34 $__autoload['dcThemes'] = dirname(__FILE__).'/core/class.dc.themes.php'; -
inc/public/lib.tpl.context.php
r851 r852 318 318 } 319 319 320 # First post image helpers321 public static function EntryFirstImageHelper($size,$class="")322 {323 global $core, $_ctx;324 325 $media = new dcMedia($core);326 $sizes = implode('|',array_keys($media->thumb_sizes)).'|o';327 if (!preg_match('/^'.$sizes.'$/',$size)) {328 $size = 's';329 }330 $p_url = $core->blog->settings->system->public_url;331 $p_site = preg_replace('#^(.+?//.+?)/(.*)$#','$1',$core->blog->url);332 $p_root = $core->blog->public_path;333 334 $pattern = '(?:'.preg_quote($p_site,'/').')?'.preg_quote($p_url,'/');335 $pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|jpeg|gif|png))"[^>]+/msu',$pattern);336 337 $src = '';338 $alt = '';339 340 # We first look in post content341 if ($_ctx->posts)342 {343 $subject = $_ctx->posts->post_excerpt_xhtml.$_ctx->posts->post_content_xhtml;344 if (preg_match_all($pattern,$subject,$m) > 0)345 {346 foreach ($m[1] as $i => $img) {347 if (($src = self::ContentFirstImageLookup($p_root,$img,$size)) !== false) {348 $src = $p_url.(dirname($img) != '/' ? dirname($img) : '').'/'.$src;349 if (preg_match('/alt="([^"]+)"/',$m[0][$i],$malt)) {350 $alt = $malt[1];351 }352 break;353 }354 }355 }356 }357 358 if ($src) {359 return '<img alt="'.$alt.'" src="'.$src.'" class="'.$class.'" />';360 }361 }362 363 private static function ContentFirstImageLookup($root,$img,$size)364 {365 global $core;366 367 # Get base name and extension368 $info = path::info($img);369 $base = $info['base'];370 371 $media = new dcMedia($core);372 $sizes = implode('|',array_keys($media->thumb_sizes));373 if (preg_match('/^\.(.+)_('.$sizes.')$/',$base,$m)) {374 $base = $m[1];375 }376 377 $res = false;378 if ($size != 'o' && file_exists($root.'/'.$info['dirname'].'/.'.$base.'_'.$size.'.jpg'))379 {380 $res = '.'.$base.'_'.$size.'.jpg';381 }382 else383 {384 $f = $root.'/'.$info['dirname'].'/'.$base;385 if (file_exists($f.'.'.$info['extension'])) {386 $res = $base.'.'.$info['extension'];387 } elseif (file_exists($f.'.jpg')) {388 $res = $base.'.jpg';389 } elseif (file_exists($f.'.jpeg')) {390 $res = $base.'.jpeg';391 } elseif (file_exists($f.'.png')) {392 $res = $base.'.png';393 } elseif (file_exists($f.'.gif')) {394 $res = $base.'.gif';395 }396 }397 398 if ($res) {399 return $res;400 }401 return false;402 }403 320 } 404 321 ?> -
inc/public/prepend.php
r420 r852 49 49 ,70); 50 50 } 51 52 # Loading media53 try {54 $core->media = new dcMedia($core);55 } catch (Exception $e) {}56 51 57 52 # Creating template context -
locales/en/resources.php
r851 r852 24 24 $__resources['help'] = array( 25 25 'core_blog_pref' => dirname(__FILE__).'/help/blog_pref.html', 26 'core_media' => dirname(__FILE__).'/help/media.html',27 26 'core_post' => dirname(__FILE__).'/help/post.html', 28 27 'core_posts' => dirname(__FILE__).'/help/posts.html', -
plugins/attachments/_public.php
r464 r852 13 13 14 14 # Attachments 15 $core->tpl->addBlock('Attachments',array('attachmentTpl','Attachments'));15 /*$core->tpl->addBlock('Attachments',array('attachmentTpl','Attachments')); 16 16 $core->tpl->addBlock('AttachmentsHeader',array('attachmentTpl','AttachmentsHeader')); 17 17 $core->tpl->addBlock('AttachmentsFooter',array('attachmentTpl','AttachmentsFooter')); … … 29 29 30 30 $core->addBehavior('tplIfConditions',array('attachmentBehavior','tplIfConditions')); 31 31 */ 32 32 class attachmentTpl { 33 33
Note: See TracChangeset
for help on using the changeset viewer.