Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit ebfbede

Browse files
author
Charles Ma
committed
ENH: fixed bug #291 Added dynamic help
1 parent 323d892 commit ebfbede

File tree

23 files changed

+641
-192
lines changed

23 files changed

+641
-192
lines changed

core/AppController.php

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ public function preDispatch()
174174

175175
$this->view->recentItems = $recentItems;
176176
$check = $this->_getParam('checkRecentItem');
177-
}
178-
$user->Dao->lastAction = date('c');
177+
}
179178
}
180179
else
181180
{
@@ -197,9 +196,14 @@ public function preDispatch()
197196
else
198197
{
199198
Zend_Registry::set('userSession', null);
199+
$user = null;
200200
}
201201

202202
$this->view->lang = Zend_Registry::get('configGlobal')->application->lang;
203+
204+
$this->view->isStartingGuide = $this->isStartingGuide();
205+
$this->view->isDynamicHelp = $this->isDynamicHelp();
206+
203207
//create a global javascript json array
204208
$jsonGlobal = array(
205209
"webroot" => $this->view->webroot,
@@ -208,6 +212,9 @@ public function preDispatch()
208212
"needToLog" => false,
209213
"currentUri" => $this->getRequest()->REQUEST_URI,
210214
"lang" => Zend_Registry::get('configGlobal')->application->lang,
215+
"dynamichelp" => $this->isDynamicHelp(),
216+
"dynamichelpAnimate" => $this->isDynamicHelp() && isset($_GET['first']),
217+
"startingGuide" => $this->isStartingGuide(),
211218
"Yes" => $this->t('Yes'),
212219
"No" => $this->t('No'));
213220

@@ -247,8 +254,81 @@ public function preDispatch()
247254

248255
$this->view->json = array(
249256
"global" => $jsonGlobal, "login" => $login, 'feed' => $feed, "browse" => $browse);
257+
258+
// Init Dynamic Help (the order makes sense for the animation)
259+
if($this->isDemoMode())
260+
{
261+
$this->addDynamicHelp('.loginLink', "<b>Authenticate.</b><br/><br/>Demo Administrator:<br/>- Login: admin@kitware.com<br/>- Password: admin<br/><br/>
262+
Demo User:<br/>-Login: user@kitware.com<br/>-Password: useryour information.", 'bottom left', 'top right');
263+
}
264+
265+
if($this->logged)
266+
{
267+
$this->addDynamicHelp('#startingGuideLink', 'Show the <b>Starting Guide</b>. You can disable these messages from this panel.');
268+
}
269+
else
270+
{
271+
$this->addDynamicHelp('.HeaderLogo', 'The <b>MIDAS Platform</b> integrates multimedia server technology with open-source data analysis and visualization clients.');
272+
}
273+
274+
275+
$this->addDynamicHelp('.HeaderSearch', '<b>Quick search</b>. Use this tool to quickly find information and data.');
276+
$this->addDynamicHelp('li.uploadFile a', '<b>Upload</b> files, data using this button.');
277+
278+
if($this->logged)
279+
{
280+
$this->addDynamicHelp('#topUserName', '<b>Manage</b> your information.', 'bottom left', 'top right');
281+
}
282+
else
283+
{
284+
$this->addDynamicHelp('.registerLink', '<b>Register</b> to create your personnal space.', 'bottom left', 'top right');
285+
}
286+
287+
$this->addDynamicHelp('.SideBar ul:first', '<b>Navigation menu</b>. Browse, explore and manage data.');
288+
250289
Zend_Loader::loadClass("JsonComponent", BASE_PATH.'/core/controllers/components');
251290
} // end preDispatch()
291+
292+
/** show dynamic help ? */
293+
function isDynamicHelp()
294+
{
295+
if($this->isDemoMode())
296+
{
297+
return true;
298+
}
299+
try
300+
{
301+
$dynamichelp = Zend_Registry::get('configGlobal')->dynamichelp;
302+
if($dynamichelp && $this->userSession != null && $this->userSession->Dao != null)
303+
{
304+
return $this->userSession->Dao->getDynamichelp() == 1;
305+
}
306+
return $dynamichelp == 1;
307+
}
308+
catch (Zend_Exception $exc)
309+
{
310+
$this->getLogger()->warn($exc->getMessage());
311+
return false;
312+
}
313+
}
314+
315+
/** show starting guide ? */
316+
function isStartingGuide()
317+
{
318+
try
319+
{
320+
if($this->userSession != null && $this->userSession->Dao != null && isset($_GET['first']))
321+
{
322+
return $this->userSession->Dao->getDynamichelp() == 1;
323+
}
324+
return false;
325+
}
326+
catch (Zend_Exception $exc)
327+
{
328+
$this->getLogger()->warn($exc->getMessage());
329+
return false;
330+
}
331+
}
252332

253333
/** get server's url */
254334
function getServerURL()
@@ -277,6 +357,17 @@ public function isTestingEnv()
277357
return Zend_Registry::get('configGlobal')->environment == 'testing';
278358
}
279359

360+
/** Add a qtip help in the page
361+
*
362+
* @param type $selector (javascript selector)
363+
* @param type $text
364+
* @param type $location
365+
* @param type $arrow
366+
*/
367+
public function addDynamicHelp($selector, $text, $location = 'bottom right', $arrow = 'top left')
368+
{
369+
$this->view->json['dynamicHelp'][] = array('selector' => $selector, 'text' => htmlspecialchars($text) , 'my' => $arrow, 'at' => $location);
370+
}
280371
/** check if demo mode is set */
281372
public function isDemoMode()
282373
{

core/configs/application.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ processing=onthefly
2727
defaultlicense=1
2828
;Demo Mode (only works with MySql)
2929
demomode=0
30+
;Enable Dynamic help
31+
dynamichelp=1
32+
3033

3134
[module]
3235

core/controllers/AdminController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ function indexAction()
9898
$formArray['lang']->setValue($applicationConfig['global']['application.lang']);
9999
$formArray['smartoptimizer']->setValue($applicationConfig['global']['smartoptimizer']);
100100
$formArray['timezone']->setValue($applicationConfig['global']['default.timezone']);
101+
if(isset($applicationConfig['global']['dynamichelp']))
102+
{
103+
$formArray['dynamichelp']->setValue($applicationConfig['global']['dynamichelp']);
104+
}
101105
$this->view->selectedLicense = $applicationConfig['global']['defaultlicense'];
102106
$this->view->configForm = $formArray;
103107

@@ -125,6 +129,7 @@ function indexAction()
125129
$applicationConfig['global']['smartoptimizer'] = $this->_getParam('smartoptimizer');
126130
$applicationConfig['global']['default.timezone'] = $this->_getParam('timezone');
127131
$applicationConfig['global']['defaultlicense'] = $this->_getParam('licenseSelect');
132+
$applicationConfig['global']['dynamichelp'] = $this->_getParam('dynamichelp');
128133
$this->Component->Utility->createInitFile(BASE_PATH.'/core/configs/application.local.ini', $applicationConfig);
129134
echo JsonComponent::encode(array(true, 'Changed saved'));
130135
}

core/controllers/CommunityController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ function indexAction()
241241
$communities = $this->Component->Sortdao->arrayUniqueDao($communities);
242242

243243
$this->view->userCommunities = $communities;
244+
245+
$this->addDynamicHelp('.communityList:first', 'List of current projects/communities hosted on MIDAS.', 'top right', 'bottom left');
246+
$this->addDynamicHelp('.createCommunity', 'Manage your own community or project.');
244247
}//end index
245248

246249
/** View a community*/
@@ -319,6 +322,12 @@ function viewAction()
319322

320323
$this->view->customJSs = Zend_Registry::get('notifier')->callback('CALLBACK_CORE_GET_COMMUNITY_VIEW_JSS', array());
321324
$this->view->customCSSs = Zend_Registry::get('notifier')->callback('CALLBACK_CORE_GET_COMMUNITY_VIEW_CSSS', array());
325+
326+
$this->addDynamicHelp('#tabDataLink', 'Public and Private Data hosted by the community.');
327+
$this->addDynamicHelp('#tabFeedLink', 'What\'s new?');
328+
$this->addDynamicHelp('#tabInfoLink', 'Description of the community.');
329+
$this->addDynamicHelp('#tabSharedLink', 'Data shared to the member of the community.');
330+
322331
} //end index
323332

324333
/** Delete a community*/

core/controllers/FeedController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function indexAction()
4646
}
4747
setcookie('newFeed'.$this->userSession->Dao->getKey(), strtotime("now"), time() + 60 * 60 * 24 * 300, '/'); //30 days
4848
}
49+
50+
$this->addDynamicHelp('.feedContainer', 'The <b>Feed</b> shows recent actions and events.', 'top right', 'bottom left');
4951
}
5052

5153
/** get delete a feed */

core/controllers/IndexController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function init()
3535
*/
3636
function indexAction()
3737
{
38-
$this->_forward('index', "feed");
38+
$this->_redirect("/feed");
3939
} // end method indexAction
4040

4141
/** no javascript*/

core/controllers/UserController.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,24 @@ function logoutAction()
138138
$this->_redirect('/');
139139
} //end logoutAction
140140

141+
/** Set user's starting guide value */
142+
function startingguideAction()
143+
{
144+
$this->disableLayout();
145+
$this->disableView();
146+
if($this->logged && isset($_POST['value']))
147+
{
148+
$value = 0;
149+
if($_POST['value'] == 1)
150+
{
151+
$value = 1;
152+
}
153+
$this->userSession->Dao->setDynamichelp($value);
154+
$user = $this->User->load($this->userSession->Dao->getKey());
155+
$user->setDynamichelp($value);
156+
$this->User->save($user);
157+
}
158+
}
141159

142160
/** Register a user */
143161
function registerAction()
@@ -152,13 +170,14 @@ function registerAction()
152170

153171
$this->userSession->Dao = $this->User->createUser(trim($form->getValue('email')), $form->getValue('password1'), trim($form->getValue('firstname')), trim($form->getValue('lastname')));
154172

155-
$this->_redirect("/");
173+
$this->_redirect("/feed?first=true");
156174
}
157175
$this->view->form = $this->getFormAsArray($form);
158176
$this->disableLayout();
159177
$this->view->jsonRegister = JsonComponent::encode(array(
160178
'MessageNotValid' => $this->t('The e-mail is not valid'), 'MessageNotAvailable' => $this->t('This e-mail is not available'), 'MessagePassword' => $this->t('Password too short'), 'MessagePasswords' => $this->t('The passwords are not the same'), 'MessageLastname' => $this->t('Please set your lastname'), 'MessageTerms' => $this->t('Please validate the terms of service'), 'MessageFirstname' => $this->t('Please set your firstname')
161179
));
180+
162181
} //end register
163182

164183
/** Login action */
@@ -230,11 +249,11 @@ function loginAction()
230249

231250
if(isset($previousUri) && strpos($previousUri, $this->view->webroot) !== false && strpos($previousUri, "logout") === false)
232251
{
233-
$this->_redirect(substr($previousUri, strlen($this->view->webroot)));
252+
$this->_redirect(substr($previousUri, strlen($this->view->webroot)).'?first=true');
234253
}
235254
else
236255
{
237-
$this->_redirect("/");
256+
$this->_redirect("/feed?first=true");
238257
}
239258
}
240259
} // end method login

core/controllers/components/DemoComponent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function reset()
7373
$applicationConfig = parse_ini_file(BASE_PATH.'/core/configs/application.ini', true);
7474
$applicationConfig['global']['defaultassetstore.id'] = $assetstoreDao->getKey();
7575
$applicationConfig['global']['demomode'] = true;
76+
$applicationConfig['global']['dynamichelp'] = true;
7677
$applicationConfig['global']['environment'] = 'development';
7778
$applicationConfig['global']['application.name'] = 'MIDAS - Demo';
7879
$applicationConfig['global']['application.description'] = '';

core/controllers/forms/AdminForm.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ public function createConfigForm()
4848
->addValidator('NotEmpty', true);
4949

5050
$smartoptimizer = new Zend_Form_Element_Checkbox("smartoptimizer");
51+
$dynamichelp = new Zend_Form_Element_Checkbox("dynamichelp");
5152

5253

5354
$submit = new Zend_Form_Element_Submit('submitConfig');
5455
$submit ->setLabel('Save configuration');
5556

56-
$form->addElements(array($keywords, $description, $timezone, $environment, $lang, $name, $smartoptimizer, $submit));
57+
$form->addElements(array($dynamichelp, $keywords, $description, $timezone, $environment, $lang, $name, $smartoptimizer, $submit));
5758
return $form;
5859
}
5960
} // end class

core/database/upgrade/3.1.2.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
class Upgrade_3_1_2 extends MIDASUpgrade
4+
{
5+
public function preUpgrade()
6+
{
7+
}
8+
9+
public function mysql()
10+
{
11+
}
12+
13+
public function pgsql()
14+
{
15+
}
16+
17+
public function postUpgrade()
18+
{
19+
$this->addTableField('user', 'dynamichelp', 'tinyint(4)', ' integer', 1);
20+
}
21+
}
22+
?>
23+
24+

0 commit comments

Comments
 (0)