Skip to content
Snippets Groups Projects
Commit da835b6a authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #42624 add list of skins + update time in admin/index/update-skin

parent 30e36001
Branches
Tags
3 merge requests!1659Master,!1639Dev#42624 skin update button,!1638Dev#42624 skin update button
- ticket #42624 : bouton mettre à jour la skin
\ No newline at end of file
......@@ -112,4 +112,20 @@ class Admin_IndexController extends ZendAfi_Controller_Action {
public function heartbeatAction() {
$this->getHelper('ViewRenderer')->setNoRender();
}
public function updateSkinAction() {
$this->view->titre = $this->_('Mise à jour de la charte graphique');
$this->view->skins = [];
foreach(Class_Profil::getCurrentProfil()->getUpdatableSkins() as $skin_label)
$this->view->skins[] = (new Class_Entity())->updateAttributes(['Label' => $skin_label,
'UpdateTime' => $this->_getUpdateTime($skin_label)]);
}
protected function _getUpdateTime($skin_folder_name) {
return (new Class_Profil_SkinUpdateReader())
->setFolder($skin_folder_name)
->getUpdateTime();
}
}
\ No newline at end of file
<?php
echo $this->Admin_UpdateSkins($this->skins);
?>
......@@ -1149,6 +1149,11 @@ class Class_Profil extends Storm_Model_Abstract {
}
public function getUpdatableSkins() {
return $this->_getSkin()->getUpdatables();
}
/**
* Si un attribut n'est pas trouvé, regarde s'il n'est pas dans cfgSite.
* Permet de faire abstraction de CfgSite quand on va chercher les parametres
......
......@@ -117,8 +117,18 @@ class Class_Profil_Skin {
public function getAvailables() {
return $this->_getSkinsFrom([self::DEFAULT_PATH, $this->getExtraPath()]);
}
public function getUpdatables() {
return $this->_getSkinsFrom([$this->getExtraPath()]);
}
protected function _getSkinsFrom($paths) {
$skins = [];
foreach ([self::DEFAULT_PATH, $this->getExtraPath()] as $path)
foreach($paths as $path)
$skins = array_merge($skins, $this->getAvailablesIn('.' . $path));
return $skins;
}
......
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Profil_SkinUpdateReader {
use Trait_StaticFileWriter;
public static $skins_update_log = 'skins_update_log.json';
protected $_folder;
public function setFolder($folder) {
$this->_folder = $folder;
return $this;
}
public function getJson() {
return json_decode($this->getFileWriter()->getContents(PATH_TEMP . static::$skins_update_log), true);
}
public function getUpdateTime() {
if(!$this->_folder)
return '';
return ($json = $this->getJson())
? $json[$this->_folder]['updateTime']
: '';
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_Admin_UpdateSkins extends ZendAfi_View_Helper_BaseHelper {
public function Admin_UpdateSkins($skins) {
if(empty($skins)) {
return $this->_('Vous n\'avez pas de charte graphique d\'installée dans Bokeh');
}
$html = '';
foreach($skins as $skin)
$html .= $this->_tag('li', $this->_renderSkin($skin));
return $this->_tag('ul', $html);
}
protected function _renderSkin($skin) {
$header = $this->_tag('h2', $this->_('Charte graphique : %s', $skin->getLabel()));
$definitions = $this->_tag('dt', $this->_('Date et heure de dernière mise à jour'))
. $this->_tag('dd', $skin->getUpdateTime());
$content = $this->_tag('dl', $definitions);
return $header . $content;
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class IndexControllerUpdateSkinDispatchTest extends Admin_AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$file_system = (new Storm_FileSystem_Volatile())
->mkdir(Class_Profil_Skin::EXTRA_PATH . 'Valence');
Class_Profil_Skin::setFileSystem($file_system);
$file_writer = $this->mock();
Class_Profil_SkinUpdateReader::setFileWriter($file_writer);
$file_writer
->whenCalled('getContents')
->answers(json_encode(['Valence' => ['updateTime' => '25/04/2016 15:01:37']]));
$this->dispatch('admin/index/update-skin', true);
}
/** @test */
public function titleShouldBeMiseAJourDeLaCharteGraphique() {
$this->assertXPathContentContains('//h1', 'Mise à jour de la charte graphique');
}
/** @test */
public function listShouldContainsSkinValence() {
$this->assertXPathContentContains('//ul/li/h2', 'Charte graphique : Valence');
}
/** @test */
public function valenceShouldhaveBeenUpdatedOn25Slash04slash2016() {
$this->assertXPathContentContains('//ul/li/dl/dd', '25/04/2016 15:01:37');
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment