Changeset 27042
- Timestamp:
- Jan 29, 2014, 9:31:33 PM (11 years ago)
- Location:
- extensions/linked_pages
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/linked_pages/include/functions.inc.php
r17925 r27042 25 25 global $page, $user, $template, $conf; 26 26 27 if ( isset($page['section']) and $page['section']=='categories' and isset($page['category']))27 if (isset($page['section']) and $page['section']=='categories' and isset($page['category'])) 28 28 { 29 29 $where_clauses = array('category_id = '.$page['category']['id']); … … 50 50 WHERE user_id = '.$user['id'].' 51 51 ;'; 52 $user_groups = array_from_query($query, 'group_id');52 $user_groups = query2array($query, null, 'group_id'); 53 53 } 54 54 } … … 78 78 while ($row = pwg_db_fetch_assoc($result)) 79 79 { 80 if ( !is_admin() and $conf['AP']['group_perm'] and !empty($row['groups']))80 if (!is_admin() and $conf['AP']['group_perm'] and !empty($row['groups'])) 81 81 { 82 82 $authorized = false; … … 91 91 if (!$authorized) continue; 92 92 } 93 94 93 95 94 $row['U_PAGE'] = make_index_url(array('section'=>'page')).'/'.(isset($row['permalink']) ? $row['permalink'] : $row['page_id']); … … 99 98 100 99 $template->assign('LINKEDPAGES_PATH', LINKEDPAGES_PATH); 101 $template->set_prefilter('index', 'linked_pages_prefilter_index'); 100 $template->set_filename('linked_pages_content', realpath(LINKEDPAGES_PATH . 'template/index_menu.tpl')); 101 $template->assign('PLUGIN_INDEX_CONTENT_BEGIN', $template->parse('linked_pages_content',true).$template->get_template_vars('PLUGIN_INDEX_CONTENT_BEGIN')); 102 102 103 103 } 104 else if ( isset($page['section']) and $page['section']=='additional_page' and isset($page['additional_page']))104 else if (isset($page['section']) and $page['section']=='additional_page' and isset($page['additional_page'])) 105 105 { 106 106 $where_clauses = array('page_id = '.$page['additional_page']['id']); … … 150 150 } 151 151 } 152 153 function linked_pages_prefilter_index($content)154 {155 $search = '#(</div>{\* <!-- titrePage --> \*}|<div id="subcontent">|<div class="subcontent">)#';156 $replace = "$1\n".file_get_contents(LINKEDPAGES_PATH . 'template/index_menu.tpl');157 return preg_replace($search, $replace, $content);158 }159 160 161 ?> -
extensions/linked_pages/main.inc.php
r23218 r27042 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 if (mobile_theme()) … … 21 21 // | Define plugin constants | 22 22 // +-----------------------------------------------------------------------+ 23 define d('LINKEDPAGES_ID') or define('LINKEDPAGES_ID',basename(dirname(__FILE__)));23 define('LINKEDPAGES_ID', basename(dirname(__FILE__))); 24 24 define('LINKEDPAGES_PATH' , PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/'); 25 25 define('LINKEDPAGES_TABLE', $prefixeTable . 'linked_pages'); … … 44 44 } 45 45 46 include_once(LINKEDPAGES_PATH . 'maintain.inc.php'); 47 $maintain = new linked_pages_maintain(LINKEDPAGES_ID); 48 $maintain->autoUpdate(LINKEDPAGES_VERSION, 'install'); 49 46 50 // add event handlers 47 51 if (defined('IN_ADMIN')) … … 55 59 56 60 include_once(LINKEDPAGES_PATH . 'include/functions.inc.php'); 57 58 if (59 LINKEDPAGES_VERSION == 'auto' or60 $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] == 'auto' or61 version_compare($pwg_loaded_plugins[LINKEDPAGES_ID]['version'], LINKEDPAGES_VERSION, '<')62 )63 {64 include_once(LINKEDPAGES_PATH . 'include/install.inc.php');65 linked_pages_install();66 67 if ( $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] != 'auto' and LINKEDPAGES_VERSION != 'auto')68 {69 $query = '70 UPDATE '. PLUGINS_TABLE .'71 SET version = "'. LINKEDPAGES_VERSION .'"72 WHERE id = "'. LINKEDPAGES_ID .'"';73 pwg_query($query);74 75 $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] = LINKEDPAGES_VERSION;76 77 if (defined('IN_ADMIN'))78 {79 $_SESSION['page_infos'][] = 'Linked Pages updated to version '. LINKEDPAGES_VERSION;80 }81 }82 }83 61 } 84 85 ?> -
extensions/linked_pages/maintain.inc.php
r17927 r27042 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 3 3 4 defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__))); 5 include_once(PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/include/install.inc.php'); 4 class linked_pages_maintain extends PluginMaintain 5 { 6 private $installed = false; 6 7 8 function install($plugin_version, &$errors=array()) 9 { 10 global $prefixeTable; 7 11 8 function plugin_install() 9 { 10 linked_pages_install(); 11 define('linked_pages_installed', true); 12 } 12 pwg_query(' 13 CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'linked_pages` ( 14 `page_id` smallint(5) unsigned NOT NULL, 15 `category_id` smallint(5) unsigned NOT NULL, 16 `pos` smallint(5) unsigned NOT NULL, 17 UNIQUE KEY `UNIQUE`(`page_id`,`category_id`) 18 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 19 ;'); 13 20 21 $this->installed = true; 22 } 14 23 15 function plugin_activate() 16 { 17 if (!defined('linked_pages_installed')) 24 function activate($plugin_version, &$errors=array()) 18 25 { 19 linked_pages_install(); 26 if (!$this->installed) 27 { 28 $this->install($plugin_version, $errors); 29 } 30 } 31 32 function deactivate() 33 { 34 } 35 36 function uninstall() 37 { 38 global $prefixeTable; 39 40 pwg_query('DROP TABLE `'.$prefixeTable.'linked_pages`;'); 20 41 } 21 42 } 22 23 24 function plugin_uninstall()25 {26 global $prefixeTable;27 28 pwg_query('DROP TABLE `'.$prefixeTable.'linked_pages`;');29 }30 31 ?> -
extensions/linked_pages/template/admin_album.tpl
r23218 r27042 1 { footer_script require='jquery.ui.sortable'}{literal}2 function init_handlers() { 3 jQuery(".menuPos").hide(); 4 jQuery(".drag_button").show(); 5 jQuery(".menuLi").css("cursor","move");6 jQuery(".menuUl").sortable({7 axis: "y",8 opacity: 0.81 {combine_script id='jquery.underscore' load='footer' path='themes/default/js/plugins/underscore.js'} 2 3 {footer_script require='jquery.ui.sortable'} 4 (function($){ 5 $("#menuOrdering").submit(function() { 6 $('.menuUl li').each(function(i) { 7 $('.menuPos[name="position[' + $(this).data('id') + ']"]').val(i); 8 }); 9 9 }); 10 11 jQuery("#menuOrdering").submit(function() { 12 ar = jQuery('.menuUl').sortable('toArray'); 13 for(i=0; i<ar.length; i++) { 14 men = ar[i].split('menu_'); 15 document.getElementsByName('position[' + men[1] + ']')[0].value = i; 16 } 17 }); 18 19 $("a.deletePage").click(function() { 20 id = $(this).parents("li.menuLi").attr("id").split("menu_")[1]; 10 11 $('.menuUl').on('click', 'a.deletePage', function() { 12 var id = $(this).parents("li.menuLi").data('id'); 21 13 $(this).parents("li.menuLi").remove(); 22 14 $("select[name='add_page'] option[value='"+ id +"']").removeAttr("disabled"); 23 15 }); 24 }25 16 26 $("select[name='add_page']").change(function() { 27 if ($(this).val() != -1) { 28 $option = $(this).children("option:selected"); 29 30 {/literal} 31 var html = 32 '<li class="menuLi" id="menu_'+ $(this).val() +'">'+ 33 '<p>'+ 34 '<span style="margin:2px 5px;">'+ 35 '<a href="#" class="deletePage"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_delete.png" alt="{'delete'|@translate}" title="{'delete'|@translate}"></a>'+ 36 '</span>'+ 17 function init_sortable() { 18 $(".menuUl").sortable({ 19 axis: "y", 20 opacity: 0.8 21 }); 22 } 37 23 38 ' <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}">'+ 39 ' <b><a href="'+ $option.data('href') +'">'+ $option.html() +'</a></b>'; 40 if ($option.data('standalone')) html+= ' - {'ap_standalone_page'|@translate}'; 41 if ($option.data('language')) html+= ' <i>('+ $option.data('language')+')</i>'; 42 html+= 43 '</p>'+ 44 '<p class="menuPos">'+ 45 '<label>'+ 46 '{'Position'|@translate} :'+ 47 ' <input type="text" size="4" name="position['+ $(this).val() +']" maxlength="4" value="0">'+ 48 '</label>'+ 49 '</p>'+ 50 '</li>'; 51 {literal} 52 53 $("ul.menuUl").append(html); 24 var template = _.template($('#lp_template').html()); 54 25 55 $option.attr("disabled", "disabled"); 56 $(this).val(-1); 57 init_handlers(); 58 } 59 }); 26 $("select[name='add_page']").change(function() { 27 if ($(this).val() != -1) { 28 var $option = $(this).children("option:selected"); 60 29 61 init_handlers(); 62 {/literal}{/footer_script} 30 $("ul.menuUl").append(template({ 31 id: $(this).val(), 32 name: $option.html(), 33 href: $option.data('href'), 34 standalone: $option.data('standalone'), 35 language: $option.data('language') 36 })); 63 37 64 {html_style}{literal} 38 $option.attr("disabled", "disabled"); 39 $(this).val(-1); 40 init_sortable(); 41 } 42 }); 43 44 init_sortable(); 45 46 {foreach from=$cat_pages item=page} 47 $("ul.menuUl").append(template({ 48 id: {$page.page_id}, 49 name: '{$page.title}', 50 href: '{$page.U_PAGE}', 51 standalone: {$page.standalone}, 52 language: '{$page.language}' 53 })); 54 {/foreach} 55 }(jQuery)); 56 {/footer_script} 57 58 {html_style} 65 59 #menuOrdering a:hover { border:none; } 66 {/literal}{/html_style} 60 .menuPos { display:none; } 61 .menuLi { cursor:move; } 62 {/html_style} 67 63 68 64 69 65 <div class="titrePage"> 70 <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> › {'Edit album'| @translate} {$TABSHEET_TITLE}</h2>66 <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> › {'Edit album'|translate} {$TABSHEET_TITLE}</h2> 71 67 </div> 72 68 … … 74 70 {if count($pages)} 75 71 <p style="margin-bottom:15px;"> 76 {'ap_add_page'| @translate}72 {'ap_add_page'|translate} 77 73 <select name="add_page"> 78 74 <option value="-1" selected="selected">------------</option> … … 85 81 </p> 86 82 87 <ul class="menuUl"> 88 {foreach from=$cat_pages item=page} 89 <li class="menuLi" id="menu_{$page.page_id}"> 90 <p> 91 <span style="margin:2px 5px;"> 92 <a href="#" class="deletePage"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_delete.png" alt="{'delete'|@translate}" title="{'delete'|@translate}"></a> 93 </span> 94 95 <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" style="display:none;" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}"> 96 <b><a href="{$page.U_PAGE}">{$page.title}</a></b> 97 {if $page.standalone == 'true'} - {'ap_standalone_page'|@translate}{/if} 98 {if !empty($page.language)}<i>({$page.language})</i>{/if} 99 </p> 100 101 <p class="menuPos"> 102 <label> 103 {'Position'|@translate} : 104 <input type="text" size="4" name="position[{$page.page_id}]" maxlength="4" value="{$page.pos}"> 105 </label> 106 </p> 107 </li> 108 {/foreach} 109 </ul> 83 <ul class="menuUl"></ul> 110 84 111 85 <p class="menuSubmit"> 112 <input type="submit" name="save_pages" value="{'Submit'| @translate}">113 <input type="submit" name="reset" value="{'Reset'| @translate}">86 <input type="submit" name="save_pages" value="{'Submit'|translate}"> 87 <input type="submit" name="reset" value="{'Reset'|translate}"> 114 88 </p> 115 89 {/if} 116 90 117 91 <p style="text-align:left;"> 118 <a href="{$AP_ADMIN}">{'ap_add_page'| @translate}</a>92 <a href="{$AP_ADMIN}">{'ap_add_page'|translate}</a> 119 93 </p> 120 94 121 95 </form> 96 97 <script type="text/template" id="lp_template"> 98 <li class="menuLi" data-id=<%= id %>> 99 <p> 100 <span style="margin:2px 5px;"> 101 <a href="#" class="deletePage"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/category_delete.png" alt="{'delete'|translate}" title="{'delete'|translate}"></a> 102 </span> 103 104 <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="button drag_button" alt="{'Drag to re-order'|translate}" title="{'Drag to re-order'|translate}"> 105 <b><a href="<%= href %>"><%= name %></a></b> 106 <% if (standalone) { %> 107 - {'ap_standalone_page'|translate} 108 <% } %> 109 <% if (language) { %> 110 <i>(<%= language %>)</i> 111 <% } %> 112 </p> 113 114 <input class="menuPos" type="text" size="4" name="position[<%= id %>]" maxlength="4" value="0"> 115 </li> 116 </script> -
extensions/linked_pages/template/index_menu.tpl
r17882 r27042 1 {combine_css path=$LINKEDPAGES_PATH| @cat:"template/style.css"}1 {combine_css path=$LINKEDPAGES_PATH|cat:"template/style.css"} 2 2 3 3 <ul id="linked_pages"> -
extensions/linked_pages/template/style.css
r17882 r27042 6 6 #linked_pages li { 7 7 display:inline-block; 8 padding:0 ;8 padding:0 0 15px 0; 9 9 } 10 10 #linked_pages li a {
Note: See TracChangeset
for help on using the changeset viewer.