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)

git-svn-id: http://piwigo.org/svn/trunk@29046 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
flop25
2014-07-15 18:03:00 +00:00
parent 0efcdefe41
commit 69c4a00dae
11 changed files with 195 additions and 237 deletions
+16 -16
View File
@@ -13,10 +13,10 @@ if (!defined('PHPWG_ROOT_PATH'))
}
/** Tour sended via $_POST or $_GET**/
if ( isset($_REQUEST['submited_tour']) and defined('IN_ADMIN') and IN_ADMIN )
if ( isset($_REQUEST['submited_tour_path']) and defined('IN_ADMIN') and IN_ADMIN )
{
check_pwg_token();
pwg_set_session_var('tour_to_launch', $_REQUEST['submited_tour']);
pwg_set_session_var('tour_to_launch', $_REQUEST['submited_tour_path']);
global $TAT_restart;
$TAT_restart=true;
}
@@ -27,16 +27,17 @@ elseif ( isset($_GET['tour_ended']) and defined('IN_ADMIN') and IN_ADMIN )
/** Setup the tour **/
/*
* REMOVE FOR RELEASE
$version_=str_replace('.','_',PHPWG_VERSION);
if (pwg_get_session_var('tour_to_launch')!=$version_ and isset($_GET['page']) and $_GET['page']=="plugin-TakeATour")
* CHANGE FOR RELEASE
$version_=str_replace('.','_',PHPWG_VERSION);*/
$version_="2_7_0";
/***/
if (pwg_get_session_var('tour_to_launch')!='tours/'.$version_ and isset($_GET['page']) and $_GET['page']=="plugin-TakeATour")
{
pwg_unset_session_var('tour_to_launch');
}
else*/if ( pwg_get_session_var('tour_to_launch') )
elseif ( pwg_get_session_var('tour_to_launch') )
{
add_event_handler('init', 'TAT_tour_setup');
include('tours/'.pwg_get_session_var('tour_to_launch').'/config.inc.php');
}
function TAT_tour_setup()
@@ -44,13 +45,11 @@ function TAT_tour_setup()
global $template, $TAT_restart, $conf;
$tour_to_launch=pwg_get_session_var('tour_to_launch');
load_language('plugin.lang', PHPWG_PLUGINS_PATH .'TakeATour/', array('force_fallback'=>'en_UK'));
$template->set_filename('TAT_js_css', PHPWG_PLUGINS_PATH.'TakeATour/tpl/js_css.tpl');
$template->assign(
array(
'ADMIN_THEME' => $conf['admin_theme'],
)
);
$template->assign('ADMIN_THEME', $conf['admin_theme']);
$template->parse('TAT_js_css');
if (isset($TAT_restart) and $TAT_restart)
{
$TAT_restart=false;
@@ -58,8 +57,9 @@ function TAT_tour_setup()
}
$tat_path=str_replace(basename($_SERVER['SCRIPT_NAME']),'', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
$template->assign('TAT_path', $tat_path);
@include('tours/'.$tour_to_launch.'/config_preparse.inc.php');
$template->set_filename('TAT_tour_tpl', PHPWG_PLUGINS_PATH.'TakeATour/tours/'.$tour_to_launch.'/tour.tpl');
$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;
include($tour_to_launch.'/config.inc.php');
$template->set_filename('TAT_tour_tpl', $TOUR_PATH);
$template->parse('TAT_tour_tpl');
}
@@ -101,7 +101,7 @@ function TAT_no_photo_yet()
function TAT_no_photo_yet_prefilter($content, &$smarty)
{
$search = '<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
$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>
$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>
<div class="bigButton"><a href="{$next_step_url}">{\'I want to add photos\'|@translate}</a></div>';
return(str_replace($search, $replacement, $content));
}
@@ -114,7 +114,7 @@ function TAT_prompt($c13y)
$version_=str_replace('.','_',PHPWG_VERSION);
if (file_exists('tours/'.$version_.'/config.inc.php'))
{
$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>';
$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>';
}
}
@@ -1,3 +1,42 @@
<?php
/**********************************
* REQUIRED PATH TO THE TPL FILE */
$TOUR_PATH = PHPWG_PLUGINS_PATH.'TakeATour/tours/2_7_0/tour.tpl';
/*********************************/
/**********************
* Preparse part *
**********************/
$template->assign('TAT_index', make_index_url(array('section' => 'categories')));
$template->assign('TAT_search', get_root_url().'search.php');
//picture id
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['image_id'] = $matches[1];
}
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
{
$template->assign('TAT_image_id', $_GET['image_id']);
pwg_set_session_var('TAT_image_id', $_GET['image_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
{
$template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
}
else
{
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_image_id', $row['id']);
}
?>
@@ -1,31 +0,0 @@
<?php
$template->assign('TAT_index', make_index_url(array('section' => 'categories')));
$template->assign('TAT_search', get_root_url().'search.php');
//picture id
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['image_id'] = $matches[1];
}
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
{
$template->assign('TAT_image_id', $_GET['image_id']);
pwg_set_session_var('TAT_image_id', $_GET['image_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
{
$template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
}
else
{
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_image_id', $row['id']);
}
?>
+1 -1
View File
@@ -3,7 +3,7 @@
var tour = new Tour({
name: "2_7_0",
orphan: true,
onEnd: function (tour) {window.location = "admin.php?page=plugin-TakeATour&tour_ended=2_7_0"},
onEnd: function (tour) {window.location = "{/literal}{$ABS_U_ADMIN}{literal}admin.php?page=plugin-TakeATour&tour_ended=2_7_0"},
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>",
});
{/literal}{if $TAT_restart}tour.restart();{/if}{literal}
@@ -1,4 +1,11 @@
<?php
/**********************************
* REQUIRED PATH TO THE TPL FILE */
$TOUR_PATH = PHPWG_PLUGINS_PATH.'TakeATour/tours/first_contact/tour.tpl';
/*********************************/
if ( defined('IN_ADMIN') and IN_ADMIN )
{
/* first contact */
@@ -68,4 +75,65 @@ function TAT_FC_35_prefilter ($content, &$smarty)
return str_replace($search, $replacement, $content);
}
/**********************
* Preparse part *
**********************/
//picture id
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['image_id'] = $matches[1];
}
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
{
$template->assign('TAT_image_id', $_GET['image_id']);
pwg_set_session_var('TAT_image_id', $_GET['image_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
{
$template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
}
else
{
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_image_id', $row['id']);
}
//album id
if (isset($_GET['page']) and preg_match('/^album-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['cat_id'] = $matches[1];
}
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
if (isset($_GET['cat_id']) and pwg_get_session_var('TAT_cat_id')==null)
{
$template->assign('TAT_cat_id', $_GET['cat_id']);
pwg_set_session_var('TAT_cat_id', $_GET['cat_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_cat_id')))
{
$template->assign('TAT_cat_id', pwg_get_session_var('TAT_cat_id'));
}
else
{
$query = '
SELECT id
FROM '.CATEGORIES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_cat_id', $row['id']);
}
global $conf;
if ( isset($conf['enable_synchronization']) )
{
$template->assign('TAT_FTP', $conf['enable_synchronization']);
}
?>
@@ -1,59 +0,0 @@
<?php
//picture id
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['image_id'] = $matches[1];
}
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
{
$template->assign('TAT_image_id', $_GET['image_id']);
pwg_set_session_var('TAT_image_id', $_GET['image_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
{
$template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
}
else
{
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_image_id', $row['id']);
}
//album id
if (isset($_GET['page']) and preg_match('/^album-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['cat_id'] = $matches[1];
}
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
if (isset($_GET['cat_id']) and pwg_get_session_var('TAT_cat_id')==null)
{
$template->assign('TAT_cat_id', $_GET['cat_id']);
pwg_set_session_var('TAT_cat_id', $_GET['cat_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_cat_id')))
{
$template->assign('TAT_cat_id', pwg_get_session_var('TAT_cat_id'));
}
else
{
$query = '
SELECT id
FROM '.CATEGORIES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_cat_id', $row['id']);
}
global $conf;
if ( isset($conf['enable_synchronization']) )
{
$template->assign('TAT_FTP', $conf['enable_synchronization']);
}
?>
@@ -3,7 +3,7 @@
var tour = new Tour({
name: "first_contact",
orphan: true,
onEnd: function (tour) {window.location = "admin.php?page=plugin-TakeATour&tour_ended=first_contact"},
onEnd: function (tour) {window.location = "{/literal}{$ABS_U_ADMIN}{literal}admin.php?page=plugin-TakeATour&tour_ended=first_contact"},
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>",
});
{/literal}{if $TAT_restart}tour.restart();{/if}{literal}
+67 -67
View File
@@ -1,71 +1,71 @@
<?php
if ( defined('IN_ADMIN') and IN_ADMIN )
{
/* first contact */
add_event_handler('loc_end_element_set_global', 'TAT_FC_14');
add_event_handler('loc_end_picture_modify', 'TAT_FC_16');
add_event_handler('loc_end_picture_modify', 'TAT_FC_17');
add_event_handler('loc_end_cat_modify', 'TAT_FC_23');
add_event_handler('loc_end_themes_installed', 'TAT_FC_35');
}
/**********************************
* REQUIRED PATH TO THE TPL FILE */
function TAT_FC_14()
{
global $template;
$template->set_prefilter('batch_manager_global', 'TAT_FC_14_prefilter');
}
function TAT_FC_14_prefilter ($content, &$smarty)
{
$search = '<span class="wrap2';
$replacement = '{counter print=false assign=TAT_FC_14}<span {if $TAT_FC_14==1}id="TAT_FC_14"{/if} class="wrap2';
$content = str_replace($search, $replacement, $content);
$search = 'target="_blank">{\'Edit\'';
$replacement = '>{\'Edit\'';
return str_replace($search, $replacement, $content);
}
function TAT_FC_16()
{
global $template;
$template->set_prefilter('picture_modify', 'TAT_FC_16_prefilter');
}
function TAT_FC_16_prefilter ($content, &$smarty)
{
$search = '<strong>{\'Linked albums\'|@translate}</strong>';
$replacement = '<span id="TAT_FC_16"><strong>{\'Linked albums\'|@translate}</strong></span>';
return str_replace($search, $replacement, $content);
}
function TAT_FC_17()
{
global $template;
$template->set_prefilter('picture_modify', 'TAT_FC_17_prefilter');
}
function TAT_FC_17_prefilter ($content, &$smarty)
{
$search = '<strong>{\'Representation of albums\'|@translate}</strong>';
$replacement = '<span id="TAT_FC_17"><strong>{\'Representation of albums\'|@translate}</strong></span>';
return str_replace($search, $replacement, $content);
}
function TAT_FC_23()
{
global $template;
$template->set_prefilter('album_properties', 'TAT_FC_23_prefilter');
}
function TAT_FC_23_prefilter ($content, &$smarty)
{
$search = '<strong>{\'Lock\'|@translate}</strong>';
$replacement = '<span id="TAT_FC_23"><strong>{\'Lock\'|@translate}</strong></span>';
return str_replace($search, $replacement, $content);
}
function TAT_FC_35()
{
global $template;
$template->set_prefilter('themes', 'TAT_FC_35_prefilter');
}
function TAT_FC_35_prefilter ($content, &$smarty)
{
$search = '<a href="{$set_default_baseurl}{$theme.ID}" class="tiptip"';
$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}';
return str_replace($search, $replacement, $content);
}
$TOUR_PATH = PHPWG_PLUGINS_PATH.'TakeATour/tours/privacy/tour.tpl';
/*********************************/
/**********************
* Preparse part *
**********************/
//picture id
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['image_id'] = $matches[1];
}
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
{
$template->assign('TAT_image_id', $_GET['image_id']);
pwg_set_session_var('TAT_image_id', $_GET['image_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
{
$template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
}
else
{
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_image_id', $row['id']);
}
//album id
if (isset($_GET['page']) and preg_match('/^album-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['cat_id'] = $matches[1];
}
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
if (isset($_GET['cat_id']) and pwg_get_session_var('TAT_cat_id')==null)
{
$template->assign('TAT_cat_id', $_GET['cat_id']);
pwg_set_session_var('TAT_cat_id', $_GET['cat_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_cat_id')))
{
$template->assign('TAT_cat_id', pwg_get_session_var('TAT_cat_id'));
}
else
{
$query = '
SELECT id
FROM '.CATEGORIES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_cat_id', $row['id']);
}
global $conf;
if ( isset($conf['enable_synchronization']) )
{
$template->assign('TAT_FTP', $conf['enable_synchronization']);
}
?>
@@ -1,59 +0,0 @@
<?php
//picture id
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['image_id'] = $matches[1];
}
check_input_parameter('image_id', $_GET, false, PATTERN_ID);
if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
{
$template->assign('TAT_image_id', $_GET['image_id']);
pwg_set_session_var('TAT_image_id', $_GET['image_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
{
$template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
}
else
{
$query = '
SELECT id
FROM '.IMAGES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_image_id', $row['id']);
}
//album id
if (isset($_GET['page']) and preg_match('/^album-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['cat_id'] = $matches[1];
}
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
if (isset($_GET['cat_id']) and pwg_get_session_var('TAT_cat_id')==null)
{
$template->assign('TAT_cat_id', $_GET['cat_id']);
pwg_set_session_var('TAT_cat_id', $_GET['cat_id']);
}
elseif (is_numeric(pwg_get_session_var('TAT_cat_id')))
{
$template->assign('TAT_cat_id', pwg_get_session_var('TAT_cat_id'));
}
else
{
$query = '
SELECT id
FROM '.CATEGORIES_TABLE.'
ORDER BY RAND()
LIMIT 1
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$template->assign('TAT_cat_id', $row['id']);
}
global $conf;
if ( isset($conf['enable_synchronization']) )
{
$template->assign('TAT_FTP', $conf['enable_synchronization']);
}
?>
+1 -1
View File
@@ -3,7 +3,7 @@
var tour = new Tour({
name: "privacy",
orphan: true,
onEnd: function (tour) {window.location = "admin.php?tour_ended=privacy";},
onEnd: function (tour) {window.location = "{/literal}{$ABS_U_ADMIN}{literal}admin.php?tour_ended=privacy";},
template: "<div class='popover tour'>
<div class='arrow'></div>
<h3 class='popover-title'></h3>
+2 -2
View File
@@ -8,7 +8,7 @@
<legend>{'First Contact'|@translate}</legend>
<div class="TAT_description">{'first_contact_descrp'|@translate}</div>
<form action="{$F_ACTION}" method="post">
<input type="hidden" name="submited_tour" value="first_contact">
<input type="hidden" name="submited_tour_path" value=".../../admin/themes/first_contact">
<input type="hidden" name="pwg_token" value="{$pwg_token}">
<input type="submit" name="button2" id="button2" value="{'Start the Tour'|@translate}">
</form>
@@ -19,7 +19,7 @@
<legend>{'2.7 Tour'|@translate}</legend>
<div class="TAT_description">{'2_7_0_descrp'|@translate}</div>
<form action="{$F_ACTION}" method="post">
<input type="hidden" name="submited_tour" value="2_7_0">
<input type="hidden" name="submited_tour_path" value="tours/2_7_0">
<input type="hidden" name="pwg_token" value="{$pwg_token}">
<input type="submit" name="button2" id="button2" value="{'Start the Tour'|@translate}">
</form>