Changeset 26298
- Timestamp:
- Dec 28, 2013, 6:08:42 PM (10 years ago)
- Location:
- extensions/header_manager
- Files:
-
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/header_manager/admin.php
r19181 r26298 1 1 <?php 2 if (!defined('HEADER_MANAGER_PATH'))die('Hacking attempt!');2 defined('HEADER_MANAGER_PATH') or die('Hacking attempt!'); 3 3 4 4 global $template, $page; … … 31 31 32 32 $template->assign_var_from_handle('ADMIN_CONTENT', 'header_manager'); 33 34 ?> -
extensions/header_manager/admin/add.php
r24010 r26298 1 1 <?php 2 if (!defined('HEADER_MANAGER_PATH'))die('Hacking attempt!');2 defined('HEADER_MANAGER_PATH') or die('Hacking attempt!'); 3 3 4 4 // cancel crop … … 15 15 16 16 $banner = get_banner($_POST['picture_file']); 17 17 18 $img = new banner_image($banner['PATH']); 18 $crop = hm_get_crop_display(array('width'=>$img->get_width(), 'height'=>$img->get_height()));19 20 19 $img->banner_resize( 21 20 $banner['PATH'], 22 $_POST['x'], 23 $_POST['y'], 24 $_POST['x2'], 25 $_POST['y2'], 26 $crop['display_width'], 27 $crop['display_height'] 21 $_POST 28 22 ); 29 23 $img->destroy(); 30 24 31 $img = new banner_image($banner['PATH']);25 $img = new pwg_image($banner['PATH']); 32 26 $img->pwg_resize( 33 27 $banner['THUMB'], … … 67 61 if (!pwg_db_num_rows($result)) 68 62 { 69 array_push($page['errors'], l10n('Unknown picture id'));63 $page['errors'][] = l10n('Unknown picture id'); 70 64 } 71 65 else … … 86 80 if ($file['error'] > 0) 87 81 { 88 array_push($page['errors'], l10n('Unknown upload error'));82 $page['errors'][] = l10n('Unknown upload error'); 89 83 } 90 else if ( !in_array($file['type'], array('image/jpeg','image/png','image/gif')))84 else if (!in_array($file['type'], array('image/jpeg','image/png','image/gif'))) 91 85 { 92 array_push($page['errors'], l10n('Incorrect file type,').' '.sprintf(l10n('Allowed file types: %s.'), 'jpg, png, gif'));86 $page['errors'][] = l10n('Incorrect file type,').' '.l10n('Allowed file types: %s.', 'jpg, png, gif'); 93 87 } 94 88 … … 117 111 $conf['header_manager']['height'] = intval($_POST['height']); 118 112 conf_update_param('header_manager', serialize($conf['header_manager'])); 119 113 120 114 $picture['banner_src'] = HEADER_MANAGER_DIR . $picture['filename']; 121 115 … … 149 143 } 150 144 151 $template->assign('F_ACTION', HEADER_MANAGER_ADMIN . '-add' .(!empty($_GET['redirect']) ? '&redirect='.urlencode($_GET['redirect']) : '')); 145 $template->assign('F_ACTION', HEADER_MANAGER_ADMIN . '-add' . 146 (!empty($_GET['redirect']) ? '&redirect='.urlencode($_GET['redirect']) : '')); 152 147 153 $template->set_filename('header_manager', dirname(__FILE__).'/template/add.tpl'); 154 155 ?> 148 $template->set_filename('header_manager', realpath(HEADER_MANAGER_PATH . 'admin/template/add.tpl')); -
extensions/header_manager/admin/album.php
r24010 r26298 1 1 <?php 2 // +-----------------------------------------------------------------------+ 3 // | Piwigo - a PHP based photo gallery | 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | 8 // +-----------------------------------------------------------------------+ 9 // | This program is free software; you can redistribute it and/or modify | 10 // | it under the terms of the GNU General Public License as published by | 11 // | the Free Software Foundation | 12 // | | 13 // | This program is distributed in the hope that it will be useful, but | 14 // | WITHOUT ANY WARRANTY; without even the implied warranty of | 15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 // | General Public License for more details. | 17 // | | 18 // | You should have received a copy of the GNU General Public License | 19 // | along with this program; if not, write to the Free Software | 20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 21 // | USA. | 22 // +-----------------------------------------------------------------------+ 23 24 if(!defined("PHPWG_ROOT_PATH")) die ("Hacking attempt!"); 2 defined('HEADER_MANAGER_PATH') or die ("Hacking attempt!"); 25 3 26 4 // +-----------------------------------------------------------------------+ … … 47 25 } 48 26 27 $cat_id = $_GET['cat_id']; 28 29 49 30 // +-----------------------------------------------------------------------+ 50 31 // | Tabs | … … 60 41 61 42 62 $cat_id = $_GET['cat_id'];63 64 65 43 // +-----------------------------------------------------------------------+ 66 44 // | Save Form | … … 68 46 if (isset($_POST['save_banner'])) 69 47 { 70 if ( 48 if (!isset($_POST['image']) or $_POST['image'] == 'default') 71 49 { 72 50 $query = ' … … 136 114 )); 137 115 138 $template->set_filename('header_manager', dirname(__FILE__).'/template/album.tpl'); 139 140 ?> 116 $template->set_filename('header_manager', realpath(HEADER_MANAGER_PATH . 'admin/template/album.tpl')); -
extensions/header_manager/admin/config.php
r20169 r26298 1 1 <?php 2 if (!defined('HEADER_MANAGER_PATH'))die('Hacking attempt!');2 defined('HEADER_MANAGER_PATH') or die('Hacking attempt!'); 3 3 4 4 // change banner to last uploaded 5 if ( pwg_get_session_var('added_banner')!==null and $conf['header_manager']['image']!='random')5 if (pwg_get_session_var('added_banner')!==null and $conf['header_manager']['image']!='random') 6 6 { 7 7 $conf['header_manager']['image'] = pwg_get_session_var('added_banner'); … … 29 29 conf_update_param('header_manager', serialize($conf['header_manager'])); 30 30 31 array_push($page['infos'], l10n('Information data registered in database'));31 $page['infos'][] = l10n('Information data registered in database'); 32 32 } 33 33 … … 37 37 { 38 38 $banner = get_banner($_GET['delete_banner']); 39 if ( $banner !== false or @unlink($banner['PATH']))39 if ($banner !== false or @unlink($banner['PATH'])) 40 40 { 41 41 @unlink($banner['THUMB']); … … 53 53 pwg_query($query); 54 54 55 array_push($page['infos'], l10n('Banner deleted'));55 $page['infos'][] = l10n('Banner deleted'); 56 56 } 57 57 else 58 58 { 59 array_push($page['warnings'], l10n('File/directory read error').' : ' . HEADER_MANAGER_DIR . $_GET['delete_banner']);59 $page['warnings'][] = l10n('File/directory read error').' : ' . HEADER_MANAGER_DIR . $_GET['delete_banner']; 60 60 } 61 61 } … … 63 63 if (isset($_GET['delete_cat_banner'])) 64 64 { 65 65 $query = ' 66 66 DELETE FROM '.HEADER_MANAGER_TABLE.' 67 67 WHERE category_id = "'.$_GET['delete_cat_banner'].'" 68 68 ;'; 69 69 pwg_query($query); 70 70 } 71 71 … … 85 85 ORDER BY global_rank ASC 86 86 ;'; 87 $categories = hash_from_query($query, 'id');87 $categories = query2array($query, 'id'); 88 88 89 89 foreach ($categories as $category) … … 91 91 $tpl_cat = 92 92 array( 93 'NAME' 94 'ID' 95 'IMAGE' 96 'DEEP' 97 'U_DELETE' 93 'NAME' => get_cat_display_name_from_id($category['id'], HEADER_MANAGER_ADMIN.'-album&cat_id='), 94 'ID' => $category['id'], 95 'IMAGE' => get_filename_wo_extension($category['image']), 96 'DEEP' => $category['deep'], 97 'U_DELETE' => HEADER_MANAGER_ADMIN.'-config&delete_cat_banner='.$category['id'], 98 98 ); 99 99 … … 103 103 104 104 // config template 105 if ( empty($conf['header_manager']['image']) or get_banner($conf['header_manager']['image']) === false)105 if (empty($conf['header_manager']['image']) or get_banner($conf['header_manager']['image']) === false) 106 106 { 107 107 $conf['header_manager']['image'] = 'random'; … … 116 116 )); 117 117 118 $template->set_filename('header_manager', dirname(__FILE__).'/template/config.tpl'); 119 120 ?> 118 $template->set_filename('header_manager', realpath(HEADER_MANAGER_PATH . 'admin/template/config.tpl')); -
extensions/header_manager/admin/template/add.tpl
r24010 r26298 1 {combine_css path=$HEADER_MANAGER_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$HEADER_MANAGER_PATH|cat:'admin/template/style.css'} 2 2 3 3 <div class="titrePage"> … … 10 10 11 11 {footer_script require="jquery"} 12 var jcrop_api; 12 (function(){ 13 var jcrop_api; 13 14 14 jQuery("#jcrop").Jcrop({ldelim} 15 boxWidth: {$crop.display_width}, 16 boxHeight: {$crop.display_height}, 15 jQuery("#jcrop").Jcrop({ 16 boxWidth: {$crop.box_width}, 17 boxHeight: {$crop.box_height}, 18 trueSize: [{$picture.width}, {$picture.height}], 19 aspectRatio: {$crop.real_width}/{$crop.real_height}, 17 20 setSelect: [{$crop.l}, {$crop.t}, {$crop.r}, {$crop.b}], 18 onChange: jOnChange, 19 onRelease: jOnRelease 20 }, 21 function(){ldelim} 21 onChange: function(sel) { 22 jQuery("input[name='x']").val(Math.round(sel.x)); 23 jQuery("input[name='y']").val(Math.round(sel.y)); 24 jQuery("input[name='x2']").val(Math.round(sel.x2)); 25 jQuery("input[name='y2']").val(Math.round(sel.y2)); 26 27 var final_width = Math.min(Math.round(sel.x2-sel.x), {$crop.desired_width}), 28 final_height = Math.round((sel.y2-sel.y)*final_width/(sel.x2-sel.x)); 29 30 jQuery("#width").html(final_width); 31 jQuery("#height").html(final_height); 32 }, 33 onRelease: function() { 34 jcrop_api.setSelect([{$crop.l}, {$crop.t}, {$crop.r}, {$crop.b}]); 35 } 36 }, 37 function() { 22 38 jcrop_api = this; 23 39 }); 24 40 25 function jOnChange(sel) {ldelim} 26 jQuery("input[name='x']").val(sel.x); 27 jQuery("input[name='y']").val(sel.y); 28 jQuery("input[name='x2']").val(sel.x2); 29 jQuery("input[name='y2']").val(sel.y2); 30 31 jQuery("#width").html(sel.x2-sel.x); 32 jQuery("#height").html(sel.y2-sel.y); 33 } 34 35 function jOnRelease() {ldelim} 36 jcrop_api.setSelect([{$crop.l}, {$crop.t}, {$crop.r}, {$crop.b}]); 37 } 41 jQuery('input[name="keep_ratio"]').on('change', function() { 42 jcrop_api.setOptions({ 43 aspectRatio: jQuery(this).prop('checked') ? {$crop.real_width}/{$crop.real_height} : 0 44 }); 45 if (!jQuery(this).prop('checked')) { 46 jcrop_api.release(); 47 } 48 }); 49 }()); 38 50 {/footer_script} 39 51 40 52 <form method="post" action="{$F_ACTION}"> 41 53 <fieldset> 42 <legend>{'Crop banner image'| @translate}</legend>43 {'Choose the part of the image you want to use as your header.'| @translate}<br>54 <legend>{'Crop banner image'|translate}</legend> 55 {'Choose the part of the image you want to use as your header.'|translate}<br> 44 56 45 <img id="jcrop" src="{$picture.banner_src}" width="{$crop.display_width}" height="{$crop.display_height}">57 <img id="jcrop" src="{$picture.banner_src}"> 46 58 47 59 <ul> 48 <li><b>{'Width'|@translate}:</b> <span id="width"></span>px</li> 49 <li><b>{'Height'|@translate}:</b> <span id="height"></span>px</li> 60 <li><b>{'Width'|translate}:</b> <span id="width"></span>px</li> 61 <li><b>{'Height'|translate}:</b> <span id="height"></span>px</li> 62 <li><label><input type="checkbox" name="keep_ratio" checked> {'Respect %s aspect ratio'|translate:($crop.desired_width|cat:'/'|cat:$crop.desired_height)}</label></li> 50 63 </ul> 51 64 … … 56 69 <input type="hidden" name="picture_file" value="{$picture.filename}"> 57 70 58 <input type="submit" name="submit_crop" value="{'Submit'| @translate}">59 <input type="submit" name="cancel_crop" value="{'Cancel'| @translate}">71 <input type="submit" name="submit_crop" value="{'Submit'|translate}"> 72 <input type="submit" name="cancel_crop" value="{'Cancel'|translate}"> 60 73 </fieldset> 61 74 </form> 62 75 63 76 {else} 64 {footer_script require="jquery"} {literal}77 {footer_script require="jquery"} 65 78 jQuery(".showInfo").tipTip({ 66 79 delay: 0, … … 75 88 $("input[name='upload_gallery_image']").click(); 76 89 return false; 77 } else { 90 } 91 else { 78 92 return true; 79 93 } 80 94 }); 81 {/ literal}{/footer_script}95 {/footer_script} 82 96 83 97 <form method="post" action="{$F_ACTION}" ENCTYPE="multipart/form-data"> 84 98 <fieldset> 85 <legend>{'Default banner size'| @translate}</legend>99 <legend>{'Default banner size'|translate}</legend> 86 100 87 101 <label> 88 {'Width'| @translate}:102 {'Width'|translate}: 89 103 <input type="text" name="width" size="4" value="{$BANNER_WIDTH}"> px 90 104 </label> … … 92 106 <br> 93 107 <label> 94 {'Height'| @translate}:108 {'Height'|translate}: 95 109 <input type="text" name="height" size="4" value="{$BANNER_HEIGHT}"> px 96 110 </label> 97 111 <br> 98 112 <br> 99 <i>{'For MontBlancXL and BlancMontXL, advised size is 900×190.'| @translate}</i>113 <i>{'For MontBlancXL and BlancMontXL, advised size is 900×190.'|translate}</i> 100 114 </fieldset> 101 115 102 116 <fieldset> 103 <legend>{'Select an image'| @translate}</legend>104 {'You can upload a custom header image or select one from your gallery. On the next screen you will be able to crop the image.'| @translate}117 <legend>{'Select an image'|translate}</legend> 118 {'You can upload a custom header image or select one from your gallery. On the next screen you will be able to crop the image.'|translate} 105 119 <br><br> 106 120 107 <b>{'Choose an image from your computer'| @translate}</b>121 <b>{'Choose an image from your computer'|translate}</b> 108 122 <blockquote> 109 {'Maximum file size: %sB.'| @translate|@sprintf:$upload_max_filesize_shorthand} {'Allowed file types: %s.'|@translate|@sprintf:'jpg, png, gif'}<br>123 {'Maximum file size: %sB.'|translate:$upload_max_filesize_shorthand} {'Allowed file types: %s.'|translate:'jpg, png, gif'}<br> 110 124 <input type="file" name="new_image"> 111 125 <input type="hidden" name="MAX_FILE_SIZE" value="{$upload_max_filesize}"> 112 <input type="submit" name="upload_new_image" value="{'Upload'| @translate}" class="submit">126 <input type="submit" name="upload_new_image" value="{'Upload'|translate}" class="submit"> 113 127 </blockquote> 114 128 115 <b>{'or choose a picture from the gallery'| @translate}</b>129 <b>{'or choose a picture from the gallery'|translate}</b> 116 130 <blockquote> 117 {'Picture id.'| @translate} <a class="icon-info-circled-1 showInfo" title="{'The numeric identifier can be found on the picture edition page, near the thumbnail.'|@translate}"></a>131 {'Picture id.'|translate} <a class="icon-info-circled-1 showInfo" title="{'The numeric identifier can be found on the picture edition page, near the thumbnail.'|translate}"></a> 118 132 <input type="text" name="picture_id" size="5"> 119 <input type="submit" name="upload_gallery_image" value="{'Use'| @translate}" class="submit">133 <input type="submit" name="upload_gallery_image" value="{'Use'|translate}" class="submit"> 120 134 </blockquote> 121 135 </fieldset> -
extensions/header_manager/admin/template/album.tpl
r24010 r26298 1 {combine_css path=$HEADER_MANAGER_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$HEADER_MANAGER_PATH|cat:'admin/template/style.css'} 2 2 3 3 <div class="titrePage"> 4 <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> › {'Edit album'| @translate} [{'Banner'|@translate}]</h2>4 <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> › {'Edit album'|translate} [{'Banner'|translate}]</h2> 5 5 </div> 6 6 … … 9 9 <div class="banner-radio" style="display:block;"> 10 10 <input type="radio" name="image" value="default" id="banner-default"{if $BANNER_IMAGE=='default'}checked="checked"{/if}> 11 <label for="banner-default"><b>{'Default banner'| @translate}</b></label>11 <label for="banner-default"><b>{'Default banner'|translate}</b></label> 12 12 </div> 13 13 {foreach from=$banners item=image} … … 23 23 {/foreach} 24 24 {else} 25 <p style="text-align:left;">{'No banner added yet'| @translate}</p>25 <p style="text-align:left;">{'No banner added yet'|translate}</p> 26 26 {/if} 27 27 28 28 <p style="text-align:left;"> 29 <a href="{$ADD_IMAGE_URL}&redirect={$F_ACTION|urlencode}">{'Add a banner'| @translate}</a>29 <a href="{$ADD_IMAGE_URL}&redirect={$F_ACTION|urlencode}">{'Add a banner'|translate}</a> 30 30 </p> 31 31 32 32 {if $banners} 33 33 <p class="actionButtons"> 34 <label><input type="checkbox" name="deep" value="1" {if $BANNER_DEEP}checked="checked"{/if}> {'Apply to sub-albums'| @translate}</label>34 <label><input type="checkbox" name="deep" value="1" {if $BANNER_DEEP}checked="checked"{/if}> {'Apply to sub-albums'|translate}</label> 35 35 <br><br> 36 <input type="submit" name="save_banner" value="{'Submit'| @translate}" class="submit">36 <input type="submit" name="save_banner" value="{'Submit'|translate}" class="submit"> 37 37 </p> 38 38 {/if} -
extensions/header_manager/admin/template/config.tpl
r20169 r26298 1 {combine_css path=$HEADER_MANAGER_PATH| @cat:"admin/template/style.css"}1 {combine_css path=$HEADER_MANAGER_PATH|cat:'admin/template/style.css'} 2 2 3 {footer_script require="jquery"} {literal}3 {footer_script require="jquery"} 4 4 jQuery("input[name='display']").change(function() { 5 5 jQuery(".display-help:not(#"+ jQuery(this).val() +")").slideUp(); … … 13 13 defaultPosition: 'top' 14 14 }); 15 {/ literal}{/footer_script}15 {/footer_script} 16 16 17 17 <div class="titrePage"> … … 21 21 <form method="post" action="{$CONFIG_URL}" class="properties"> 22 22 <fieldset> 23 <legend>{'Display'| @translate}</legend>23 <legend>{'Display'|translate}</legend> 24 24 25 <label><input type="radio" name="display" value="image_only" {if $BANNER_DISPLAY=='image_only'}checked="checked"{/if}> {'Image only'| @translate}</label><br>25 <label><input type="radio" name="display" value="image_only" {if $BANNER_DISPLAY=='image_only'}checked="checked"{/if}> {'Image only'|translate}</label><br> 26 26 27 <label><input type="radio" name="display" value="with_title" {if $BANNER_DISPLAY=='with_title'}checked="checked"{/if}> {'Gallery title above image'| @translate}</label><br>27 <label><input type="radio" name="display" value="with_title" {if $BANNER_DISPLAY=='with_title'}checked="checked"{/if}> {'Gallery title above image'|translate}</label><br> 28 28 <div class="display-help" id="with_title" {if $BANNER_DISPLAY!='with_title'}style="display:none;"{/if}> 29 <i>{'You can customize the display by adding CSS rules to'| @translate}</i>29 <i>{'You can customize the display by adding CSS rules to'|translate}</i> 30 30 <span style="font-family:monospace;font-size:14px;color:#000;background:#eee;padding:0 2px;">#<span style="color:#09f;font-weight:bold;">theHeader</span> <span style="color:#00f;">div</span>.<span style="color:#f00;">banner</span></span> 31 31 </div> 32 32 33 <label><input type="radio" name="display" value="with_text" {if $BANNER_DISPLAY=='with_text'}checked="checked"{/if}> {'With text'| @translate}</label><br>33 <label><input type="radio" name="display" value="with_text" {if $BANNER_DISPLAY=='with_text'}checked="checked"{/if}> {'With text'|translate}</label><br> 34 34 <div class="display-help" id="with_text" {if $BANNER_DISPLAY!='with_text'}style="display:none;"{/if}> 35 35 <textarea rows="5" cols="50" class="description" name="conf_page_banner">{$CONF_PAGE_BANNER}</textarea><br> 36 <i>{'Put <b>%header_manager%</b> where you want to display the image.'| @translate}</i>36 <i>{'Put <b>%header_manager%</b> where you want to display the image.'|translate}</i> 37 37 </div> 38 38 39 <label><input style="margin-top:20px;" type="checkbox" name="banner_on_picture" value="true" {if $BANNER_ON_PICTURE}checked="checked"{/if}> <b>{'Display banner on photo page'| @translate}</b></label>39 <label><input style="margin-top:20px;" type="checkbox" name="banner_on_picture" value="true" {if $BANNER_ON_PICTURE}checked="checked"{/if}> <b>{'Display banner on photo page'|translate}</b></label> 40 40 </fieldset> 41 41 42 42 <fieldset id="batchManagerGlobal"> 43 <legend>{'Banner'| @translate}</legend>43 <legend>{'Banner'|translate}</legend> 44 44 45 45 {if $banners} 46 46 <div class="banner-radio" style="display:block;"> 47 47 <input type="radio" name="image" value="random" id="banner-random" {if $BANNER_IMAGE=='random'}checked="checked"{/if}> 48 <label for="banner-random"><b>{'Random'| @translate}</b></label>48 <label for="banner-random"><b>{'Random'|translate}</b></label> 49 49 </div> 50 50 {foreach from=$banners item=image key=name} … … 54 54 </span> 55 55 <span class="banner-wrapper"> 56 <a href="{$CONFIG_URL}&delete_banner={$image.NAME}" title="{'Delete'| @translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');" class="delete-banner">×</a>56 <a href="{$CONFIG_URL}&delete_banner={$image.NAME}" title="{'Delete'|translate}" onclick="return confirm('{'Are you sure?'|translate|@escape:javascript}');" class="delete-banner">×</a> 57 57 <span class="banner-size">{$image.SIZE[0]} × {$image.SIZE[1]} px</span> 58 58 <label for="banner-{$image.NAME}" title="{$name}"><img src="{$image.THUMB}" alt="{$image.NAME}"></label> … … 61 61 {/foreach} 62 62 {else} 63 {'No banner added yet'| @translate}63 {'No banner added yet'|translate} 64 64 {/if} 65 65 66 66 <br><br> 67 <a href="{$ADD_IMAGE_URL}">{'Add a banner'| @translate}</a>67 <a href="{$ADD_IMAGE_URL}">{'Add a banner'|translate}</a> 68 68 </fieldset> 69 69 70 <p class="formButtons"><input type="submit" name="save_config" value="{'Submit'| @translate}" class="submit"></p>70 <p class="formButtons"><input type="submit" name="save_config" value="{'Submit'|translate}" class="submit"></p> 71 71 72 72 <fieldset> 73 <legend>{'Album specific banners'| @translate}</legend>74 <i>{'In order to add a specific banner, go to the admin page of the desired album.'| @translate}</i>73 <legend>{'Album specific banners'|translate}</legend> 74 <i>{'In order to add a specific banner, go to the admin page of the desired album.'|translate}</i> 75 75 76 76 {if $categories} … … 80 80 {$cat.NAME} 81 81 <a class="showImage" title="<img src='{$banners[$cat.IMAGE].THUMB}'>"><img src="{$HEADER_MANAGER_PATH}admin/template/image_{$cat.DEEP}.png"></a> 82 <a href="{$cat.U_DELETE}" title="{'Restore default banner'| @translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>82 <a href="{$cat.U_DELETE}" title="{'Restore default banner'|translate}" onclick="return confirm('{'Are you sure?'|translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a> 83 83 </li> 84 84 {/foreach} … … 86 86 87 87 <p> 88 <img src="{$HEADER_MANAGER_PATH}admin/template/image_0.png"> : {'Non recursive'| @translate} •89 <img src="{$HEADER_MANAGER_PATH}admin/template/image_1.png"> : {'Recursive'| @translate}88 <img src="{$HEADER_MANAGER_PATH}admin/template/image_0.png"> : {'Non recursive'|translate} • 89 <img src="{$HEADER_MANAGER_PATH}admin/template/image_1.png"> : {'Recursive'|translate} 90 90 </p> 91 91 {/if} -
extensions/header_manager/include/banner.class.php
r15854 r26298 1 1 <?php 2 if (!defined('HEADER_MANAGER_PATH'))die('Hacking attempt!');2 defined('HEADER_MANAGER_PATH') or die('Hacking attempt!'); 3 3 4 4 include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php'); … … 9 9 class banner_image extends pwg_image 10 10 { 11 function banner_resize($destination_filepath, $ x, $y, $x2, $y2, $width, $height)11 function banner_resize($destination_filepath, $selection) 12 12 { 13 13 global $conf; … … 18 18 $source_height = $this->image->get_height(); 19 19 20 $resize_dimensions = array( 21 'width' => $width, 22 'height'=> $height, 23 'crop' => array( 24 'width' => $x2-$x, 25 'height' => $y2-$y, 26 'x' => $x, 27 'y' => $y, 28 ), 20 $crop = array( 21 'width' => $selection['x2']-$selection['x'], 22 'height' => $selection['y2']-$selection['y'], 23 'x' => $selection['x'], 24 'y' => $selection['y'], 29 25 ); 30 26 31 // maybe resizing/crop ing is useless ?32 if ( $resize_dimensions['crop']['width'] == $source_width and $resize_dimensions['crop']['height'] == $source_height)27 // maybe resizing/cropping is useless ? 28 if ($conf['header_manager']['width'] == $source_width and $conf['header_manager']['height'] == $source_height) 33 29 { 34 30 // the image doesn't need any resize! We just copy it to the destination 35 31 copy($this->source_filepath, $destination_filepath); 36 return $this->get_resize_result($destination_filepath, $ resize_dimensions['width'], $resize_dimensions['height'], $starttime);32 return $this->get_resize_result($destination_filepath, $source_width, $source_height, $starttime); 37 33 } 38 34 … … 40 36 $this->image->strip(); 41 37 38 // crop 39 $this->image->crop($crop['width'], $crop['height'], $crop['x'], $crop['y']); 40 42 41 // resize to what is displayed on crop screen 43 if ($ source_width> $conf['header_manager']['width'])42 if ($crop['width'] > $conf['header_manager']['width']) 44 43 { 45 $this->image->resize($ resize_dimensions['width'], $source_height*$resize_dimensions['width']/$source_width);44 $this->image->resize($conf['header_manager']['width'], $crop['height']*$conf['header_manager']['width']/$crop['width']); 46 45 } 47 48 // crop49 $this->image->crop($resize_dimensions['crop']['width'], $resize_dimensions['crop']['height'], $resize_dimensions['crop']['x'], $resize_dimensions['crop']['y']);50 46 51 47 // save … … 53 49 54 50 // everything should be OK if we are here! 55 return $this->get_resize_result($destination_filepath, $ resize_dimensions['crop']['width'], $resize_dimensions['crop']['height'], $starttime);51 return $this->get_resize_result($destination_filepath, $crop['width'], $crop['height'], $starttime); 56 52 } 57 53 … … 69 65 } 70 66 } 71 72 ?> -
extensions/header_manager/include/functions.inc.php
r22857 r26298 8 8 function list_banners($delete_orphans=false) 9 9 { 10 if (!file_exists(HEADER_MANAGER_DIR)) return array(); 10 if (!file_exists(HEADER_MANAGER_DIR)) 11 { 12 return array(); 13 } 14 11 15 $dir = scandir(HEADER_MANAGER_DIR); 12 16 $banners = array(); … … 14 18 foreach ($dir as $file) 15 19 { 16 if ( in_array($file, array('.','..','index.php','.svn'))) continue;17 if ( !in_array(strtolower(get_extension($file)), array('jpg','jpeg','png','gif'))) continue;18 if ( strpos($file, '-thumbnail')!==false) continue;20 if (in_array($file, array('.','..','index.php','.svn'))) continue; 21 if (!in_array(strtolower(get_extension($file)), array('jpg','jpeg','png','gif'))) continue; 22 if (strpos($file, '-thumbnail')!==false) continue; 19 23 20 24 $banner = get_banner($file); 21 25 22 if ( $delete_orphans and !file_exists($banner['THUMB']))26 if ($delete_orphans and !file_exists($banner['THUMB'])) 23 27 { 24 28 @unlink($banner['PATH']); … … 43 47 return array( 44 48 'NAME' => $file, 45 'PATH' => get_root_url() .HEADER_MANAGER_DIR . $file,46 'THUMB' => get_root_url() .HEADER_MANAGER_DIR . get_filename_wo_extension($file) . '-thumbnail.'. get_extension($file),49 'PATH' => get_root_url() . HEADER_MANAGER_DIR . $file, 50 'THUMB' => get_root_url() . HEADER_MANAGER_DIR . get_filename_wo_extension($file) . '-thumbnail.' . get_extension($file), 47 51 'SIZE' => getimagesize(HEADER_MANAGER_DIR . $file), 48 52 ); … … 85 89 $crop['coi']['y'] = ($picture['coi']['b']+$picture['coi']['t'])/2; 86 90 87 // define default crop frame 88 if ($picture['width'] > $conf['header_manager']['width']) 91 $crop['desired_width'] = $conf['header_manager']['width']; 92 $crop['desired_height'] = $conf['header_manager']['height']; 93 94 if ($picture['width'] > $crop['desired_width']) 89 95 { 90 $crop['display_width'] = $conf['header_manager']['width']; 91 $crop['display_height'] = round($picture['height']*$crop['display_width']/$picture['width']); 92 93 $crop['coi']['x'] = round($crop['coi']['x']*$crop['display_width']/$picture['width']); 94 $crop['coi']['y'] = round($crop['coi']['y']*$crop['display_height']/$picture['height']); 95 96 $crop['l'] = 0; 97 $crop['r'] = $conf['header_manager']['width']; 98 $crop['t'] = max(0, $crop['coi']['y']-$conf['header_manager']['height']/2); 99 $crop['b'] = min($crop['display_height'], $crop['t']+$conf['header_manager']['height']); 96 $crop['box_width'] = $crop['desired_width']; 97 $crop['box_height'] = round($picture['height']*$crop['box_width']/$picture['width']); 100 98 } 101 99 else 102 100 { 103 $crop['display_width'] = $picture['width']; 104 $crop['display_height'] = $picture['height']; 105 106 $adapted_crop_height = round($conf['header_manager']['height']*$picture['width']/$conf['header_manager']['width']); 107 108 $crop['l'] = 0; 109 $crop['r'] = $picture['width']; 110 $crop['t'] = max(0, $crop['coi']['y']-$adapted_crop_height/2); 111 $crop['b'] = min($crop['display_height'], $crop['t']+$adapted_crop_height); 101 $crop['box_width'] = $picture['width']; 102 $crop['box_height'] = $picture['height']; 112 103 } 104 105 $crop['real_width'] = $picture['width']; 106 $crop['real_height'] = round($crop['desired_height']*$crop['real_width']/$crop['desired_width']); 107 108 $crop['l'] = 0; 109 $crop['r'] = $crop['real_width']; 110 $crop['t'] = max(0, $crop['coi']['y']-$crop['real_height']/2); 111 $crop['b'] = min($picture['height'], $crop['t']+$crop['real_height']); 113 112 114 113 return $crop; 115 114 } 116 117 /**118 * clean table when categroies are delete119 */120 function header_manager_delete_categories($ids)121 {122 $query = '123 DELETE FROM '.HEADER_MANAGER_TABLE.'124 WHERE category_id IN('.implode(',', $ids).')125 ;';126 pwg_query($query);127 }128 129 ?> -
extensions/header_manager/include/header_manager.inc.php
r20169 r26298 1 1 <?php 2 if (!defined('HEADER_MANAGER_PATH'))die('Hacking attempt!');2 defined('HEADER_MANAGER_PATH') or die('Hacking attempt!'); 3 3 4 4 /** … … 9 9 global $conf, $user, $template, $page; 10 10 11 if ( script_basename() == 'picture' and !$conf['header_manager']['banner_on_picture'])11 if (script_basename() == 'picture' and !$conf['header_manager']['banner_on_picture']) 12 12 { 13 return null; 13 return ''; 14 } 15 16 // no support for Kardon (not enough space) 17 if ($user['theme'] == 'kardon') 18 { 19 return $page_banner; 14 20 } 15 21 … … 48 54 if (!isset($banner)) 49 55 { 50 if ( 56 if (empty($conf['header_manager']['image']) or $conf['header_manager']['image'] == 'random') 51 57 { 52 58 $banners = array_values(list_banners()); 53 if (!count($banners)) return $page_banner; 59 if (!count($banners)) 60 { 61 return $page_banner; 62 } 54 63 $banner = $banners[ mt_rand(0, count($banners)-1) ]; 55 64 } … … 57 66 { 58 67 $banner = get_banner($conf['header_manager']['image']); 59 if ($banner === false) return $page_banner; 68 if ($banner === false) 69 { 70 return $page_banner; 71 } 60 72 } 61 73 } 62 74 63 75 // for MontBlancXL and BlancMontXL the banner is displayed as background of the header 64 if ( in_array($user['theme'], array('blancmontxl','montblancxl')))76 if (in_array($user['theme'], array('blancmontxl','montblancxl'))) 65 77 { 66 $template->append('head_elements', 67 '<style type="text/css"> 68 #theHeader { background: transparent url('.$banner['PATH'].') center bottom no-repeat; } 69 </style>' 78 $template->block_html_style(null, 79 '#theHeader { background: transparent url('.$banner['PATH'].') center bottom no-repeat; }' 70 80 ); 71 81 72 82 if ($conf['header_manager']['display'] == 'image_only') 73 83 { 74 $page_banner = null;84 $page_banner = ''; 75 85 } 76 86 else 77 87 { 78 $page_banner = str_replace('%header_manager%', null, $page_banner);88 $page_banner = str_replace('%header_manager%', '', $page_banner); 79 89 } 80 90 } 81 // no support for Kardon (not enough space) 82 else if ($user['theme'] != 'kardon') 91 else 83 92 { 84 $template->append('head_elements', 85 '<style type="text/css"> 86 #theHeader div.banner { background:transparent url(\''.$banner['PATH'].'\') center center no-repeat;height:'.$banner['SIZE'][1].'px;line-height:'.($banner['SIZE'][1]-12).'px;font-size:2.5em;color:#fff;text-shadow:0 0 5px #000;text-align:center; } 87 </style>' 93 $template->block_html_style(null, 94 '#theHeader div.banner { background:transparent url(\''.$banner['PATH'].'\') center center no-repeat; height:'. ($banner['SIZE'][1]) .'px; line-height:'. ($banner['SIZE'][1]-12) .'px; font-size:2.5em; color:#fff; text-shadow:0 0 5px #000; text-align:center; }' 88 95 ); 89 96 90 $banner_img = '<div class="banner">'. ($conf['header_manager']['display']=='with_title' ? $conf['gallery_title'] : ' ').'</div>';97 $banner_img = '<div class="banner">'. ($conf['header_manager']['display']=='with_title' ? $conf['gallery_title'] : ' ') .'</div>'; 91 98 92 99 if ($conf['header_manager']['display'] == 'with_text') … … 96 103 else 97 104 { 98 $page_banner = '<a href="'. get_gallery_home_url().'">'.$banner_img.'</a>';105 $page_banner = '<a href="'. get_gallery_home_url() .'">'. $banner_img .'</a>'; 99 106 } 100 107 } … … 109 116 return array_search($a['category_id'], $ids) < array_search($b['category_id'], $ids); 110 117 } 111 112 ?> -
extensions/header_manager/main.inc.php
r24010 r26298 9 9 */ 10 10 11 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');11 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 12 12 13 13 global $prefixeTable; … … 37 37 38 38 /** 39 * update plugin & unserialize conf39 * initialization 40 40 */ 41 41 function header_manager_init() … … 43 43 global $conf, $pwg_loaded_plugins, $page; 44 44 45 if ( 46 HEADER_MANAGER_VERSION == 'auto' or 47 $pwg_loaded_plugins['header_manager']['version'] == 'auto' or 48 version_compare($pwg_loaded_plugins['header_manager']['version'], HEADER_MANAGER_VERSION, '<') 49 ) 50 { 51 include_once(HEADER_MANAGER_PATH . 'include/install.inc.php'); 52 header_manager_install(); 53 54 if ( $pwg_loaded_plugins['header_manager']['version'] != 'auto' and HEADER_MANAGER_VERSION != 'auto' ) 55 { 56 $query = ' 57 UPDATE '. PLUGINS_TABLE .' 58 SET version = "'. HEADER_MANAGER_VERSION .'" 59 WHERE id = "header_manager"'; 60 pwg_query($query); 61 62 $pwg_loaded_plugins['header_manager']['version'] = HEADER_MANAGER_VERSION; 63 64 if (defined('IN_ADMIN')) 65 { 66 $_SESSION['page_infos'][] = 'Header Manager updated to version '. HEADER_MANAGER_VERSION; 67 } 68 } 69 } 45 include_once(HEADER_MANAGER_PATH . 'maintain.inc.php'); 46 $maintain = new header_manager_maintain('header_manager'); 47 $maintain->autoUpdate(HEADER_MANAGER_VERSION, 'install'); 70 48 71 49 $conf['header_manager'] = unserialize($conf['header_manager']); … … 77 55 function header_manager_admin_menu($menu) 78 56 { 79 array_push($menu,array(57 $menu[] = array( 80 58 'NAME' => 'Header Manager', 81 59 'URL' => HEADER_MANAGER_ADMIN, 82 ));60 ); 83 61 return $menu; 84 62 } … … 102 80 } 103 81 104 ?> 82 /** 83 * clean table when categories are deleted 84 */ 85 function header_manager_delete_categories($ids) 86 { 87 $query = ' 88 DELETE FROM '.HEADER_MANAGER_TABLE.' 89 WHERE category_id IN('.implode(',', $ids).') 90 ;'; 91 pwg_query($query); 92 } -
extensions/header_manager/maintain.inc.php
r17655 r26298 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 3 3 4 include_once(PHPWG_PLUGINS_PATH . 'header_manager/include/install.inc.php'); 4 class header_manager_maintain extends PluginMaintain 5 { 6 private $installed = false; 5 7 6 function plugin_install() 7 { 8 header_manager_install(); 9 10 define('header_manager_installed', true); 11 } 8 private $default_conf = array( 9 'width' => 1000, 10 'height' => 150, 11 'image' => 'random', 12 'display' => 'image_only', 13 'banner_on_picture' => true, 14 ); 12 15 13 function plugin_activate() 14 { 15 if (!defined('header_manager_installed')) 16 function install($plugin_version, &$errors=array()) 16 17 { 17 header_manager_install(); 18 global $conf, $prefixeTable; 19 20 // configuration 21 if (empty($conf['header_manager'])) 22 { 23 $conf['header_manager'] = serialize($this->default_conf); 24 conf_update_param('header_manager', $conf['header_manager']); 25 } 26 else 27 { 28 $new_conf = is_string($conf['header_manager']) ? unserialize($conf['header_manager']) : $conf['header_manager']; 29 if (!isset($new_conf['banner_on_picture'])) 30 { 31 $new_conf['banner_on_picture'] = true; 32 $conf['header_manager'] = serialize($new_conf); 33 conf_update_param('header_manager', $conf['header_manager']); 34 } 35 } 36 37 // banners directory 38 if (!file_exists(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners')) 39 { 40 mkdir(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'banners', 0755); 41 } 42 43 // banners table 44 $query = ' 45 CREATE TABLE IF NOT EXISTS `' .$prefixeTable . 'category_banner` ( 46 `category_id` smallint(5) unsigned NOT NULL, 47 `image` varchar(255) NOT NULL, 48 `deep` tinyint(1) DEFAULT 1, 49 PRIMARY KEY (`category_id`) 50 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 51 ;'; 52 pwg_query($query); 53 54 $this->installed = true; 55 } 56 57 function activate($plugin_version, &$errors=array()) 58 { 59 if (!$this->installed) 60 { 61 $this->install($plugin_version, $errors); 62 } 63 } 64 65 function deactivate() 66 { 67 } 68 69 function uninstall() 70 { 71 global $prefixeTable; 72 73 conf_delete_param('header_manager'); 74 75 pwg_query('DROP TABLE `' .$prefixeTable . 'category_banner`;'); 18 76 } 19 77 } 20 21 function plugin_uninstall()22 {23 global $prefixeTable;24 25 pwg_query('DROP TABLE `' .$prefixeTable . 'category_banner`;');26 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "header_manager" LIMIT 1;');27 }28 29 ?>
Note: See TracChangeset
for help on using the changeset viewer.