Changeset 29046 for trunk/plugins


Ignore:
Timestamp:
Jul 15, 2014, 8:03:00 PM (10 years ago)
Author:
flop25
Message:

Take A Tour:
-only 2 files per tour.tpl
-allow external tours
-absolute url when ending the tour
-better code, commented
wiki updated (2.7 technical changes)

Location:
trunk/plugins/TakeATour
Files:
3 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/TakeATour/main.inc.php

    r29007 r29046  
    1414
    1515/** Tour sended via $_POST or $_GET**/
    16 if ( isset($_REQUEST['submited_tour']) and defined('IN_ADMIN') and IN_ADMIN )
     16if ( isset($_REQUEST['submited_tour_path']) and defined('IN_ADMIN') and IN_ADMIN )
    1717{
    1818  check_pwg_token();
    19   pwg_set_session_var('tour_to_launch', $_REQUEST['submited_tour']);
     19  pwg_set_session_var('tour_to_launch', $_REQUEST['submited_tour_path']);
    2020  global $TAT_restart;
    2121  $TAT_restart=true;
     
    2828/** Setup the tour **/
    2929/*
    30  * REMOVE FOR RELEASE
    31 $version_=str_replace('.','_',PHPWG_VERSION);
    32 if (pwg_get_session_var('tour_to_launch')!=$version_ and isset($_GET['page']) and $_GET['page']=="plugin-TakeATour")
     30 * CHANGE FOR RELEASE
     31$version_=str_replace('.','_',PHPWG_VERSION);*/
     32$version_="2_7_0";
     33/***/
     34if (pwg_get_session_var('tour_to_launch')!='tours/'.$version_ and isset($_GET['page']) and $_GET['page']=="plugin-TakeATour")
    3335{
    3436  pwg_unset_session_var('tour_to_launch');
    3537}
    36 else*/if ( pwg_get_session_var('tour_to_launch') )
     38elseif ( pwg_get_session_var('tour_to_launch') )
    3739{
    3840  add_event_handler('init', 'TAT_tour_setup');
    39   include('tours/'.pwg_get_session_var('tour_to_launch').'/config.inc.php');
    4041}
    4142
     
    4546  $tour_to_launch=pwg_get_session_var('tour_to_launch');
    4647  load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/', array('force_fallback'=>'en_UK'));
     48
    4749  $template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
    48   $template->assign(
    49   array(
    50     'ADMIN_THEME'    => $conf['admin_theme'],
    51     )
    52   );
     50  $template->assign('ADMIN_THEME', $conf['admin_theme']);
    5351  $template->parse('TAT_js_css');
     52
    5453  if (isset($TAT_restart) and $TAT_restart)
    5554  {
     
    5958  $tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
    6059  $template->assign('TAT_path', $tat_path);
    61   @include('tours/'.$tour_to_launch.'/config_preparse.inc.php');
    62   $template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tours/'.$tour_to_launch.'/tour.tpl');
     60  $template->assign('ABS_U_ADMIN', get_absolute_root_url());// absolute one due to public pages and $conf['question_mark_in_urls'] = false+$conf['php_extension_in_urls'] = false;
     61  include($tour_to_launch.'/config.inc.php');
     62  $template->set_filename('TAT_tour_tpl', $TOUR_PATH);
    6363  $template->parse('TAT_tour_tpl');
    6464}
     
    102102{
    103103  $search = '<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
    104   $replacement = '<div class="bigButton"><a href="'.get_root_url().'admin.php?submited_tour=first_contact&pwg_token='.get_pwg_token().'">{\'I want to discover my gallery and add photos\'|@translate}</a></div>
     104  $replacement = '<div class="bigButton"><a href="'.get_root_url().'admin.php?submited_tour_path=tours/first_contact&pwg_token='.get_pwg_token().'">{\'I want to discover my gallery and add photos\'|@translate}</a></div>
    105105<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
    106106  return(str_replace($search, $replacement, $content));
     
    115115  if (file_exists('tours/'.$version_.'/config.inc.php'))
    116116  {
    117     $page['infos'][] = '<a href="'.get_root_url().'admin.php?submited_tour='.$version_.'&pwg_token='.get_pwg_token().'">'.l10n('Discover what is new in the version %s of Piwigo', PHPWG_VERSION).'</a>';
     117    $page['infos'][] = '<a href="'.get_root_url().'admin.php?submited_tour_path=tours/'.$version_.'&pwg_token='.get_pwg_token().'">'.l10n('Discover what is new in the version %s of Piwigo', PHPWG_VERSION).'</a>';
    118118  }
    119119}
  • trunk/plugins/TakeATour/tours/2_7_0/config.inc.php

    r28393 r29046  
    11<?php
     2/**********************************
     3 * REQUIRED PATH TO THE TPL FILE */
    24
     5$TOUR_PATH = PHPWG_PLUGINS_PATH.'TakeATour/tours/2_7_0/tour.tpl';
     6
     7/*********************************/
     8
     9
     10/**********************
     11 *    Preparse part   *
     12 **********************/
     13  $template->assign('TAT_index', make_index_url(array('section' => 'categories')));
     14  $template->assign('TAT_search', get_root_url().'search.php');
     15
     16  //picture id
     17  if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
     18  {
     19    $_GET['image_id'] = $matches[1];
     20  }
     21  check_input_parameter('image_id', $_GET, false, PATTERN_ID);
     22  if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
     23  {
     24    $template->assign('TAT_image_id', $_GET['image_id']);
     25    pwg_set_session_var('TAT_image_id', $_GET['image_id']);
     26  }
     27  elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
     28  {
     29    $template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
     30  }
     31  else
     32  {
     33    $query = '
     34    SELECT id
     35      FROM '.IMAGES_TABLE.'
     36      ORDER BY RAND()
     37      LIMIT 1 
     38    ;';
     39    $row = pwg_db_fetch_assoc(pwg_query($query));
     40    $template->assign('TAT_image_id', $row['id']);
     41  }
    342?>
  • trunk/plugins/TakeATour/tours/2_7_0/tour.tpl

    r28951 r29046  
    44  name: "2_7_0",
    55  orphan: true,
    6   onEnd: function (tour) {window.location = "admin.php?page=plugin-TakeATour&tour_ended=2_7_0"},
     6  onEnd: function (tour) {window.location = "{/literal}{$ABS_U_ADMIN}{literal}admin.php?page=plugin-TakeATour&tour_ended=2_7_0"},
    77  template: "<div class='popover'>          <div class='arrow'></div>          <h3 class='popover-title'></h3>          <div class='popover-content'></div>          <div class='popover-navigation'>            <div class='btn-group'>              <button class='btn btn-sm btn-default' data-role='prev'>&laquo; {/literal}{'Prev'|@translate|@escape:'javascript'}{literal}</button>              <button class='btn btn-sm btn-default' data-role='next'>{/literal}{'Next '|@translate|@escape:'javascript'}{literal} &raquo;</button>            </div>            <button class='btn btn-sm btn-default' data-role='end'>{/literal}{'End tour'|@translate|@escape:'javascript'}{literal}</button>          </div>        </div>",
    88});
  • trunk/plugins/TakeATour/tours/first_contact/config.inc.php

    r28169 r29046  
    11<?php
     2/**********************************
     3 * REQUIRED PATH TO THE TPL FILE */
     4
     5$TOUR_PATH = PHPWG_PLUGINS_PATH.'TakeATour/tours/first_contact/tour.tpl';
     6
     7/*********************************/
     8
    29if ( defined('IN_ADMIN') and IN_ADMIN )
    310{
     
    6976}
    7077
     78/**********************
     79 *    Preparse part   *
     80 **********************/
     81  //picture id
     82  if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
     83  {
     84    $_GET['image_id'] = $matches[1];
     85  }
     86  check_input_parameter('image_id', $_GET, false, PATTERN_ID);
     87  if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
     88  {
     89    $template->assign('TAT_image_id', $_GET['image_id']);
     90    pwg_set_session_var('TAT_image_id', $_GET['image_id']);
     91  }
     92  elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
     93  {
     94    $template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
     95  }
     96  else
     97  {
     98    $query = '
     99    SELECT id
     100      FROM '.IMAGES_TABLE.'
     101      ORDER BY RAND()
     102      LIMIT 1 
     103    ;';
     104    $row = pwg_db_fetch_assoc(pwg_query($query));
     105    $template->assign('TAT_image_id', $row['id']);
     106  }
     107  //album id
     108  if (isset($_GET['page']) and preg_match('/^album-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
     109  {
     110    $_GET['cat_id'] = $matches[1];
     111  }
     112  check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
     113  if (isset($_GET['cat_id']) and pwg_get_session_var('TAT_cat_id')==null)
     114  {
     115    $template->assign('TAT_cat_id', $_GET['cat_id']);
     116    pwg_set_session_var('TAT_cat_id', $_GET['cat_id']);
     117  }
     118  elseif (is_numeric(pwg_get_session_var('TAT_cat_id')))
     119  {
     120    $template->assign('TAT_cat_id', pwg_get_session_var('TAT_cat_id'));
     121  }
     122  else
     123  {
     124    $query = '
     125    SELECT id
     126      FROM '.CATEGORIES_TABLE.'
     127      ORDER BY RAND()
     128      LIMIT 1 
     129    ;';
     130    $row = pwg_db_fetch_assoc(pwg_query($query));
     131    $template->assign('TAT_cat_id', $row['id']);
     132  }
     133  global $conf;
     134  if ( isset($conf['enable_synchronization']) )
     135  {
     136    $template->assign('TAT_FTP', $conf['enable_synchronization']);
     137  }
     138
    71139?>
  • trunk/plugins/TakeATour/tours/first_contact/tour.tpl

    r28775 r29046  
    44  name: "first_contact",
    55  orphan: true,
    6   onEnd: function (tour) {window.location = "admin.php?page=plugin-TakeATour&tour_ended=first_contact"},
     6  onEnd: function (tour) {window.location = "{/literal}{$ABS_U_ADMIN}{literal}admin.php?page=plugin-TakeATour&tour_ended=first_contact"},
    77  template: "<div class='popover'>          <div class='arrow'></div>          <h3 class='popover-title'></h3>          <div class='popover-content'></div>          <div class='popover-navigation'>            <div class='btn-group'>              <button class='btn btn-sm btn-default' data-role='prev'>&laquo; {/literal}{'Prev'|@translate|@escape:'javascript'}{literal}</button>              <button class='btn btn-sm btn-default' data-role='next'>{/literal}{'Next '|@translate|@escape:'javascript'}{literal} &raquo;</button>            </div>            <button class='btn btn-sm btn-default' data-role='end'>{/literal}{'End tour'|@translate|@escape:'javascript'}{literal}</button>          </div>        </div>",
    88});
  • trunk/plugins/TakeATour/tours/privacy/config.inc.php

    r28951 r29046  
    11<?php
    2 if ( defined('IN_ADMIN') and IN_ADMIN )
    3 {
    4 /* first contact */
    5 add_event_handler('loc_end_element_set_global', 'TAT_FC_14');
    6 add_event_handler('loc_end_picture_modify', 'TAT_FC_16');
    7 add_event_handler('loc_end_picture_modify', 'TAT_FC_17');
    8 add_event_handler('loc_end_cat_modify', 'TAT_FC_23');
    9 add_event_handler('loc_end_themes_installed', 'TAT_FC_35');
    10 }
     2/**********************************
     3 * REQUIRED PATH TO THE TPL FILE */
    114
    12 function TAT_FC_14()
    13 {
    14   global $template;
    15   $template->set_prefilter('batch_manager_global', 'TAT_FC_14_prefilter');
    16 }
    17 function TAT_FC_14_prefilter ($content, &$smarty)
    18 {
    19   $search = '<span class="wrap2';
    20   $replacement = '{counter print=false assign=TAT_FC_14}<span {if $TAT_FC_14==1}id="TAT_FC_14"{/if} class="wrap2';
    21   $content = str_replace($search, $replacement, $content);
    22   $search = 'target="_blank">{\'Edit\'';
    23   $replacement = '>{\'Edit\'';
    24   return str_replace($search, $replacement, $content);
    25 }
    26 function TAT_FC_16()
    27 {
    28   global $template;
    29   $template->set_prefilter('picture_modify', 'TAT_FC_16_prefilter');
    30 }
    31 function TAT_FC_16_prefilter ($content, &$smarty)
    32 {
    33   $search = '<strong>{\'Linked albums\'|@translate}</strong>';
    34   $replacement = '<span id="TAT_FC_16"><strong>{\'Linked albums\'|@translate}</strong></span>';
    35   return str_replace($search, $replacement, $content);
    36 }
    37 function TAT_FC_17()
    38 {
    39   global $template;
    40   $template->set_prefilter('picture_modify', 'TAT_FC_17_prefilter');
    41 }
    42 function TAT_FC_17_prefilter ($content, &$smarty)
    43 {
    44   $search = '<strong>{\'Representation of albums\'|@translate}</strong>';
    45   $replacement = '<span id="TAT_FC_17"><strong>{\'Representation of albums\'|@translate}</strong></span>';
    46   return str_replace($search, $replacement, $content);
    47 }
    48 function TAT_FC_23()
    49 {
    50   global $template;
    51   $template->set_prefilter('album_properties', 'TAT_FC_23_prefilter');
    52 }
    53 function TAT_FC_23_prefilter ($content, &$smarty)
    54 {
    55   $search = '<strong>{\'Lock\'|@translate}</strong>';
    56   $replacement = '<span id="TAT_FC_23"><strong>{\'Lock\'|@translate}</strong></span>';
    57   return str_replace($search, $replacement, $content);
    58 }
    59 function TAT_FC_35()
    60 {
    61   global $template;
    62   $template->set_prefilter('themes', 'TAT_FC_35_prefilter');
    63 }
    64 function TAT_FC_35_prefilter ($content, &$smarty)
    65 {
    66   $search = '<a href="{$set_default_baseurl}{$theme.ID}" class="tiptip"';
    67   $replacement = '{counter print=false assign=TAT_FC_35}<a href="{$set_default_baseurl}{$theme.ID}" class="tiptip" {if $TAT_FC_35==1}id="TAT_FC_35"{/if}';
    68   return str_replace($search, $replacement, $content);
    69 }
     5$TOUR_PATH = PHPWG_PLUGINS_PATH.'TakeATour/tours/privacy/tour.tpl';
    706
     7/*********************************/
     8
     9
     10
     11/**********************
     12 *    Preparse part   *
     13 **********************/
     14  //picture id
     15  if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
     16  {
     17    $_GET['image_id'] = $matches[1];
     18  }
     19  check_input_parameter('image_id', $_GET, false, PATTERN_ID);
     20  if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
     21  {
     22    $template->assign('TAT_image_id', $_GET['image_id']);
     23    pwg_set_session_var('TAT_image_id', $_GET['image_id']);
     24  }
     25  elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
     26  {
     27    $template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
     28  }
     29  else
     30  {
     31    $query = '
     32    SELECT id
     33      FROM '.IMAGES_TABLE.'
     34      ORDER BY RAND()
     35      LIMIT 1 
     36    ;';
     37    $row = pwg_db_fetch_assoc(pwg_query($query));
     38    $template->assign('TAT_image_id', $row['id']);
     39  }
     40  //album id
     41  if (isset($_GET['page']) and preg_match('/^album-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
     42  {
     43    $_GET['cat_id'] = $matches[1];
     44  }
     45  check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
     46  if (isset($_GET['cat_id']) and pwg_get_session_var('TAT_cat_id')==null)
     47  {
     48    $template->assign('TAT_cat_id', $_GET['cat_id']);
     49    pwg_set_session_var('TAT_cat_id', $_GET['cat_id']);
     50  }
     51  elseif (is_numeric(pwg_get_session_var('TAT_cat_id')))
     52  {
     53    $template->assign('TAT_cat_id', pwg_get_session_var('TAT_cat_id'));
     54  }
     55  else
     56  {
     57    $query = '
     58    SELECT id
     59      FROM '.CATEGORIES_TABLE.'
     60      ORDER BY RAND()
     61      LIMIT 1 
     62    ;';
     63    $row = pwg_db_fetch_assoc(pwg_query($query));
     64    $template->assign('TAT_cat_id', $row['id']);
     65  }
     66  global $conf;
     67  if ( isset($conf['enable_synchronization']) )
     68  {
     69    $template->assign('TAT_FTP', $conf['enable_synchronization']);
     70  }
    7171?>
  • trunk/plugins/TakeATour/tours/privacy/tour.tpl

    r29007 r29046  
    44  name: "privacy",
    55  orphan: true,
    6   onEnd: function (tour) {window.location = "admin.php?tour_ended=privacy";},
     6  onEnd: function (tour) {window.location = "{/literal}{$ABS_U_ADMIN}{literal}admin.php?tour_ended=privacy";},
    77  template: "<div class='popover tour'>
    88  <div class='arrow'></div>
  • trunk/plugins/TakeATour/tpl/admin.tpl

    r28393 r29046  
    99    <div class="TAT_description">{'first_contact_descrp'|@translate}</div>
    1010    <form action="{$F_ACTION}" method="post">
    11       <input type="hidden" name="submited_tour" value="first_contact">
     11      <input type="hidden" name="submited_tour_path" value=".../../admin/themes/first_contact">
    1212      <input type="hidden" name="pwg_token" value="{$pwg_token}">
    1313      <input type="submit" name="button2" id="button2" value="{'Start the Tour'|@translate}">
     
    2020    <div class="TAT_description">{'2_7_0_descrp'|@translate}</div>
    2121    <form action="{$F_ACTION}" method="post">
    22       <input type="hidden" name="submited_tour" value="2_7_0">
     22      <input type="hidden" name="submited_tour_path" value="tours/2_7_0">
    2323      <input type="hidden" name="pwg_token" value="{$pwg_token}">
    2424      <input type="submit" name="button2" id="button2" value="{'Start the Tour'|@translate}">
Note: See TracChangeset for help on using the changeset viewer.