WIP EGroupware tutorial:

- Open autoload introduction tutorial from all apps
- Provide fallback tutorial
This commit is contained in:
Hadi Nategh 2015-10-09 15:09:34 +00:00
parent 5a08713cbc
commit 61db4b7559
4 changed files with 23 additions and 27 deletions

View File

@ -25,7 +25,7 @@ class home_tutorial_ui {
* Popup window to display youtube video * Popup window to display youtube video
* @param type $content * @param type $content
*/ */
function popup ($content) function popup ($content=null)
{ {
//Allow youtube frame to pass the CSP check //Allow youtube frame to pass the CSP check
egw_framework::csp_frame_src_attrs(array('www.youtube.com')); egw_framework::csp_frame_src_attrs(array('www.youtube.com'));
@ -38,7 +38,7 @@ class home_tutorial_ui {
{ {
// read tutorials json file to fetch data // read tutorials json file to fetch data
$tutorials = json_decode(self::getJsonData(), true); $tutorials = json_decode(self::getJsonData(), true);
$apps = array(); $apps = array('introduction' => lang('Introduction'));
foreach ($tutorials as $app => $val) foreach ($tutorials as $app => $val)
{ {
// show only apps user has access to them // show only apps user has access to them
@ -48,11 +48,15 @@ class home_tutorial_ui {
'apps' => $apps, 'apps' => $apps,
); );
// Check if the user has right to see the app's tutorial // Check if the user has right to see the app's tutorial
if (in_array($tuid_indx[0], array_keys($GLOBALS['egw_info']['user']['apps']))) if (in_array($tuid_indx[0], array_keys($GLOBALS['egw_info']['user']['apps'])) || $tuid_indx[0] === "introduction")
{ {
// fallback to english video
$tutorial = $tutorials[$tuid_indx[0]][$tuid_indx[1]][$tuid_indx[2]]? $tutorials[$tuid_indx[0]][$tuid_indx[1]][$tuid_indx[2]]:
$tutorials[$tuid_indx[0]]['en'][$tuid_indx[2]];
$content = array ( $content = array (
'src' => $tutorials[$tuid_indx[0]][$tuid_indx[1]][$tuid_indx[2]]['src'], 'src' => $tutorial['src'],
'title' => $tutorials[$tuid_indx[0]][$tuid_indx[1]][$tuid_indx[2]]['title'], 'title' => $tutorial['title']
); );
} }
else else
@ -80,7 +84,7 @@ class home_tutorial_ui {
$tutorials = json_decode(self::getJsonData(), true); $tutorials = json_decode(self::getJsonData(), true);
$lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
$response = egw_json_response::get(); $response = egw_json_response::get();
$response->data($tutorials[$_app][$lang]); $response->data($tutorials[$_app][$lang]?$tutorials[$_app][$lang]:$tutorials[$_app]['en']);
} }
/** /**
@ -103,8 +107,8 @@ class home_tutorial_ui {
if (!($json = egw_cache::getCache(egw_cache::TREE, 'home', 'egw_tutorial_json'))) if (!($json = egw_cache::getCache(egw_cache::TREE, 'home', 'egw_tutorial_json')))
{ {
$json = file_get_contents('http://www.egroupware.de/videos/tutorials.json'); $json = file_get_contents('http://www.egroupware.de/videos/tutorials.json');
// Cache the json object for one month // Cache the json object for two hours
egw_cache::addCache(egw_cache::TREE, 'home', 'egw_tutorial_json', $json, 3600 * 720); egw_cache::setCache(egw_cache::TREE, 'home', 'egw_tutorial_json', $json, 720);
} }
return $json; return $json;

View File

@ -99,8 +99,6 @@ app.classes.home = AppJS.extend(
// call parent // call parent
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.tutorial_autoload_popup();
this.et2.set_id('home.index'); this.et2.set_id('home.index');
this.et2.set_actions(this.et2.getArrayMgr('modifications').getEntry('home.index')['actions']); this.et2.set_actions(this.et2.getArrayMgr('modifications').getEntry('home.index')['actions']);
@ -790,20 +788,6 @@ app.classes.home = AppJS.extend(
} }
}, },
/**
* Open tutorial popup with a general video about egroupware
* the popup can be discarded for the next time show if user
* check the discard checkbox
*/
tutorial_autoload_popup:function()
{
var discarded = this.egw.preference('egw_tutorial_autoload', 'home');
if (!discarded)
{
this.egwTutorialPopup('home-'+this.egw.preference('lang')+'-0-a');
}
},
/** /**
* Function calls on discard checkbox and will set * Function calls on discard checkbox and will set
* the egw_tutorial_autoload preference * the egw_tutorial_autoload preference
@ -815,7 +799,7 @@ app.classes.home = AppJS.extend(
{ {
if (widget) if (widget)
{ {
this.egw.set_preference('home', 'egw_tutorial_autoload', widget.get_value()); this.egw.set_preference('common', 'egw_tutorial_autoload', widget.get_value());
} }
} }
}); });

View File

@ -10,10 +10,10 @@
<button align="left" statustext="Close this window" label="Close" id="button[close]" onclick="window.close()" image="close" background_image="1"/> <button align="left" statustext="Close this window" label="Close" id="button[close]" onclick="window.close()" image="close" background_image="1"/>
<hbox disabled="@discardbox"> <hbox disabled="@discardbox">
<menulist> <menulist>
<menupopup id="apps" label="Applications" statustext="Please select application name" options="Please select" onchange="app.home.tutorial_appChange"/> <menupopup id="apps" label="Applications" statustext="Please select application name" onchange="app.home.tutorial_appChange"/>
</menulist> </menulist>
<menulist> <menulist>
<menupopup id="tutorials" label="Tutorilas" statustext="Please select a tutorial" options="Please select" onchange="app.home.tutorial_tutorialsChange"/> <menupopup id="tutorials" label="Tutorilas" statustext="Please select a tutorial" onchange="app.home.tutorial_tutorialsChange"/>
</menulist> </menulist>
</hbox> </hbox>
<hbox disabled="!@discardbox" class="discard_checkbox"> <hbox disabled="!@discardbox" class="discard_checkbox">

View File

@ -172,6 +172,14 @@ var fw_browser = Class.extend({
// Remove escape timeout // Remove escape timeout
clearTimeout(self.ajaxLoaderDivTimeout); clearTimeout(self.ajaxLoaderDivTimeout);
} }
// Open tutorial popup with an introduction video about egroupware
// the popup can be discarded for the next time show if user
// check the discard checkbox
if (!egw.preference('egw_tutorial_autoload', 'common'))
{
egw.open_link(egw.link('/index.php', 'menuaction=home.home_tutorial_ui.popup&tuid=introduction-'+egw.preference('lang')+'-0-a'),'_blank','750x580');
}
}); });
// Check whether the given url is a pseudo url which should be executed // Check whether the given url is a pseudo url which should be executed