Changeset 27042


Ignore:
Timestamp:
Jan 29, 2014, 9:31:33 PM (11 years ago)
Author:
mistic100
Message:

update for Piwigo 2.6 + use underscore for admin

Location:
extensions/linked_pages
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/linked_pages/include/functions.inc.php

    r17925 r27042  
    2525  global $page, $user, $template, $conf;
    2626 
    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']))
    2828  {
    2929    $where_clauses = array('category_id = '.$page['category']['id']);
     
    5050  WHERE user_id = '.$user['id'].'
    5151;';
    52         $user_groups = array_from_query($query, 'group_id');
     52        $user_groups = query2array($query, null, 'group_id');
    5353      }
    5454    }
     
    7878    while ($row = pwg_db_fetch_assoc($result))
    7979    {
    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']))
    8181      {
    8282        $authorized = false;
     
    9191        if (!$authorized) continue;
    9292      }
    93        
    9493     
    9594      $row['U_PAGE'] = make_index_url(array('section'=>'page')).'/'.(isset($row['permalink']) ? $row['permalink'] : $row['page_id']);
     
    9998   
    10099    $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'));
    102102   
    103103  }
    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']))
    105105  {
    106106    $where_clauses = array('page_id = '.$page['additional_page']['id']);
     
    150150  }
    151151}
    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  
    99*/
    1010
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    1212
    1313if (mobile_theme())
     
    2121// | Define plugin constants                                               |
    2222// +-----------------------------------------------------------------------+
    23 defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__)));
     23define('LINKEDPAGES_ID',      basename(dirname(__FILE__)));
    2424define('LINKEDPAGES_PATH' ,   PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/');
    2525define('LINKEDPAGES_TABLE',   $prefixeTable . 'linked_pages');
     
    4444  }
    4545 
     46  include_once(LINKEDPAGES_PATH . 'maintain.inc.php');
     47  $maintain = new linked_pages_maintain(LINKEDPAGES_ID);
     48  $maintain->autoUpdate(LINKEDPAGES_VERSION, 'install');
     49 
    4650  // add event handlers
    4751  if (defined('IN_ADMIN'))
     
    5559
    5660  include_once(LINKEDPAGES_PATH . 'include/functions.inc.php');
    57  
    58   if (
    59     LINKEDPAGES_VERSION == 'auto' or
    60     $pwg_loaded_plugins[LINKEDPAGES_ID]['version'] == 'auto' or
    61     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   }
    8361}
    84 
    85 ?>
  • extensions/linked_pages/maintain.inc.php

    r17927 r27042  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 defined('LINKEDPAGES_ID') or define('LINKEDPAGES_ID', basename(dirname(__FILE__)));
    5 include_once(PHPWG_PLUGINS_PATH . LINKEDPAGES_ID . '/include/install.inc.php');
     4class linked_pages_maintain extends PluginMaintain
     5{
     6  private $installed = false;
    67
     8  function install($plugin_version, &$errors=array())
     9  {
     10    global $prefixeTable;
    711
    8 function plugin_install()
    9 {
    10   linked_pages_install();
    11   define('linked_pages_installed', true);
    12 }
     12    pwg_query('
     13CREATE 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;');
    1320
     21    $this->installed = true;
     22  }
    1423
    15 function plugin_activate()
    16 {
    17   if (!defined('linked_pages_installed'))
     24  function activate($plugin_version, &$errors=array())
    1825  {
    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`;');
    2041  }
    2142}
    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.8
     1{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    });
    99  });
    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');
    2113    $(this).parents("li.menuLi").remove();
    2214    $("select[name='add_page'] option[value='"+ id +"']").removeAttr("disabled");
    2315  });
    24 }
    2516
    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  }
    3723
    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());
    5425
    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");
    6029
    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      }));
    6337
    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}
    6559#menuOrdering a:hover { border:none; }
    66 {/literal}{/html_style}
     60.menuPos { display:none; }
     61.menuLi { cursor:move; }
     62{/html_style}
    6763
    6864
    6965<div class="titrePage">
    70   <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> &#8250; {'Edit album'|@translate} {$TABSHEET_TITLE}</h2>
     66  <h2><span style="letter-spacing:0">{$CATEGORIES_NAV}</span> &#8250; {'Edit album'|translate} {$TABSHEET_TITLE}</h2>
    7167</div>
    7268
     
    7470{if count($pages)}
    7571  <p style="margin-bottom:15px;">
    76     {'ap_add_page'|@translate}
     72    {'ap_add_page'|translate}
    7773    <select name="add_page">
    7874      <option value="-1" selected="selected">------------</option>
     
    8581  </p>
    8682
    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>
    11084 
    11185  <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}">
    11488  </p>
    11589{/if}
    11690
    11791<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>
    11993</p>
    12094
    12195</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"}
    22
    33<ul id="linked_pages">
  • extensions/linked_pages/template/style.css

    r17882 r27042  
    66  #linked_pages li {
    77    display:inline-block;
    8     padding:0;
     8    padding:0 0 15px 0;
    99  }
    1010  #linked_pages li a {
Note: See TracChangeset for help on using the changeset viewer.