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

Commit 1b1167c

Browse files
author
Charles Marion
committed
ENH: recent viewed use now cookies
user can select the language
1 parent b21c973 commit 1b1167c

File tree

14 files changed

+88
-18
lines changed

14 files changed

+88
-18
lines changed

application/AppController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ public function preDispatch()
5959
$this->view->logged=false;
6060
$this->logged=false;
6161
}
62-
$this->view->recentItems=$user->recentItems;
62+
$cookieData = $this->getRequest()->getCookie('recentItems');
63+
$this->view->recentItems=array();
64+
if(isset($cookieData))
65+
{
66+
$this->view->recentItems= unserialize($cookieData);
67+
}
68+
6369
$this->view->lang=Zend_Registry::get('configGlobal')->application->lang;
6470
//create a global javascript json array
6571
$jsonGlobal=array(

application/Bootstrap.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,22 @@ protected function _initConfig()
3030
Zend_Session::setId($_POST['sid']);
3131
}
3232
Zend_Session::start();
33-
$configGlobal = new Zend_Config_Ini(APPLICATION_CONFIG,'global');
33+
$configGlobal = new Zend_Config_Ini(APPLICATION_CONFIG,'global',true);
34+
if(isset($_COOKIE['lang']))
35+
{
36+
$configGlobal->application->lang=$_COOKIE['lang'];
37+
}
38+
39+
if(isset($_GET['lang']))
40+
{
41+
if($_GET['lang']!='en'&&$_GET['lang']!='fr')
42+
{
43+
$_GET['lang']='en';
44+
}
45+
$configGlobal->application->lang=$_GET['lang'];
46+
setcookie("lang", $_GET['lang'], time()+60*60*24*30*20,'/'); //30 days *20
47+
}
48+
3449
Zend_Registry::set('configGlobal', $configGlobal);
3550

3651
$configCore = new Zend_Config_Ini(CORE_CONFIG,'global');

application/controllers/ItemController.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ function viewAction()
3434
{
3535
throw new Zend_Exception("This iutem doesn't exist.");
3636
}
37-
if(!isset($this->userSession->recentItems))
37+
$request = $this->getRequest();
38+
$cookieData = $request->getCookie('recentItems');
39+
$recentItems=array();
40+
if(isset($cookieData))
3841
{
39-
$this->userSession->recentItems=array();
40-
}
41-
42-
$tmp=array_reverse($this->userSession->recentItems);
42+
$recentItems= unserialize($cookieData);
43+
}
44+
$tmp=array_reverse($recentItems);
4345
$i=0;
4446
foreach($tmp as $key=>$t)
4547
{
@@ -54,9 +56,14 @@ function viewAction()
5456
unset($tmp[$key]);
5557
}
5658
}
57-
$this->userSession->recentItems=array_reverse($tmp);
58-
$this->userSession->recentItems[]=$itemDao;
59+
$recentItems=array_reverse($tmp);
60+
$recentItems[]=$itemDao;
61+
62+
setcookie("recentItems", serialize($recentItems), time()+60*60*24*30,'/'); //30 days
5963
$this->view->itemDao=$itemDao;
6064
}//end index
6165

62-
}//end class
66+
}//end class
67+
68+
/* pour la récupérer
69+
*/

application/layouts/layout.phtml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
<?php
1111
if (Zend_Registry::get("configGlobal")->smartoptimizer == 1)
1212
{
13-
echo '<link type="text/css" rel="stylesheet" href="' . $this->webroot . '/public/css/layout/main.css,view.css,jquery-ui.css,form.css,loginForm.css,jquery.treeTable.css" />';
13+
echo '<link type="text/css" rel="stylesheet" href="' . $this->webroot . '/public/css/layout/main.css,view.css,jquery-ui.css,form.css,loginForm.css,jquery.treeTable.css,jquery.cluetip.css" />';
1414
}
1515
else
1616
{
1717
echo '<link type="text/css" rel="stylesheet" href="' . $this->webroot . '/public/css/layout/main.css" />';
18+
echo '<link type="text/css" rel="stylesheet" href="' . $this->webroot . '/public/css/layout/jquery.cluetip.css" />';
1819
echo '<link type="text/css" rel="stylesheet" href="' . $this->webroot . '/public/css/layout/view.css" />';
1920
echo '<link type="text/css" rel="stylesheet" href="' . $this->webroot . '/public/css/layout/jquery-ui.css" />';
2021
echo '<link type="text/css" rel="stylesheet" href="' . $this->webroot . '/public/css/layout/form.css" />';
@@ -91,6 +92,18 @@
9192
<li>
9293
<a href="#" > <?= $this->t('Help') ?></a>
9394
</li>
95+
<li>
96+
<?php if($this->lang=='fr')
97+
{
98+
echo '<a href="'.$this->webroot.'?lang=en"><img src="'.$this->webroot.'/public/images/icons/english.png" alt="English"/>';
99+
}
100+
else
101+
{
102+
echo '<a href="'.$this->webroot.'?lang=fr"><img src="'.$this->webroot.'/public/images/icons/french.png" alt="French"/>';
103+
}
104+
?>
105+
</a>
106+
</li>
94107
</ul>
95108
</div>
96109
</div>
@@ -136,7 +149,7 @@
136149
echo '<ul>';
137150
foreach ($recentReverse as $item)
138151
{
139-
echo "<li><a href='{$this->webroot}/item/{$item->getKey()}'>{$item->getName()}</a></li>";
152+
echo "<li onclick=\"location.replace('{$this->webroot}/item/{$item->getKey()}');\" class='recentItem' title='". str_replace("'", '"', $item->getName())." | todo'><a href='{$this->webroot}/item/{$item->getKey()}'>".sliceRecentItem($item->getName())."</a></li>";
140153
}
141154
echo '</ul>';
142155
}
@@ -170,11 +183,12 @@
170183
<?php
171184
if (Zend_Registry::get("configGlobal")->smartoptimizer == 1)
172185
{
173-
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/layout/jquery.js,jquery-ui.js,main.js,jquery.treeTable.js"></script>';
186+
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/layout/jquery.js,jquery-ui.js,main.js,jquery.treeTable.js,jquery.cluetip.js"></script>';
174187
}
175188
else
176189
{
177190
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/layout/jquery.js"></script>';
191+
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/layout/jquery.cluetip.js"></script>';
178192
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/layout/jquery-ui.js"></script>';
179193
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/layout/main.js"></script>';
180194
echo '<script type="text/javascript" src="' . $this->webroot . '/public/js/layout/jquery.treeTable.js"></script>';
@@ -186,4 +200,15 @@
186200
<?php echo $this->json?>
187201
</div>
188202
</body>
189-
</html>
203+
</html>
204+
205+
<?php
206+
function sliceRecentItem($name)
207+
{
208+
if(strlen($name)>20)
209+
{
210+
$name=substr($name,0, 6).'...'.substr($name,strlen($name)-11);
211+
}
212+
return $name;
213+
}
214+
?>

application/views/feed/index.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="viewSideBar">
1111

1212
BlaBla
13-
<br/>
13+
<br/> <br/>
1414
<?php
1515
if(!empty($this->notifications))
1616
{

application/views/import/index.phtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
<?php
55
$this->headScript()->appendFile($this->webroot.'/public/js/import/import.index.js');
66
$this->headScript()->appendFile($this->webroot.'/public/js/jquery/jquery.form.js');
7-
$this->headScript()->appendFile($this->webroot.'/public/js/jquery/jquery.cluetip.js');
87

98
$this->headLink()->appendStylesheet($this->webroot.'/public/css/jquery/jquery.filetree.css');
10-
$this->headLink()->appendStylesheet($this->webroot.'/public/css/jquery/jquery.cluetip.css');
119
$this->headLink()->appendStylesheet($this->webroot.'/public/css/import/import.index.css');
1210
$this->headLink()->appendStylesheet($this->webroot.'/public/css/assetstore/assetstore.add.css');
1311

File renamed without changes.

public/css/layout/main.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ a:visited {
4040
border:none;
4141
}
4242

43+
a:active, li:active
44+
{
45+
outline: none;
46+
}
47+
48+
a:focus, li:focus
49+
{
50+
-moz-outline-style: none;
51+
}
52+
4353
/*-------------------------------------------------
4454
TOP
4555
-------------------------------------------------*/

public/images/icons/english.png

826 Bytes
Loading

public/images/icons/french.png

538 Bytes
Loading

0 commit comments

Comments
 (0)