Skip to content

Commit

Permalink
* [MOD] UI tweaks and set user preferences precedence over global set…
Browse files Browse the repository at this point in the history
…tings. Closes #528
  • Loading branch information
nuxsmin committed Apr 26, 2017
1 parent eadc04a commit 4eae489
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
12 changes: 7 additions & 5 deletions inc/SP/Controller/AccountSearchController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ public function getSearch()
|| $this->view->searchFavorites
|| $Search->isSortViews());

AccountsSearchItem::$accountLink = Session::getUserPreferences()->isAccountLink();
AccountsSearchItem::$topNavbar = Session::getUserPreferences()->isTopNavbar();
AccountsSearchItem::$optionalActions = Session::getUserPreferences()->isOptionalActions();
$UserPreferences = Session::getUserPreferences();

AccountsSearchItem::$accountLink = $UserPreferences->isAccountLink();
AccountsSearchItem::$topNavbar = $UserPreferences->isTopNavbar();
AccountsSearchItem::$optionalActions = $UserPreferences->isOptionalActions();
AccountsSearchItem::$wikiEnabled = Checks::wikiIsEnabled();
AccountsSearchItem::$dokuWikiEnabled = Checks::dokuWikiIsEnabled();
AccountsSearchItem::$isDemoMode = Checks::demoIsEnabled();
Expand Down Expand Up @@ -313,9 +315,9 @@ private function getGrid()
$GridPager->setFilterOn($this->filterOn);
$GridPager->setSourceAction(new DataGridActionSearch(self::ACTION_ACC_SEARCH));

$Preferences = Session::getUserPreferences();
$UserPreferences = Session::getUserPreferences();

$showOptionalActions = $Preferences->isOptionalActions() || $Preferences->isResultsAsCards() || Checks::resultsCardsIsEnabled();
$showOptionalActions = $UserPreferences->isOptionalActions() || $UserPreferences->isResultsAsCards() || ($UserPreferences->getUserId() === 0 && Checks::resultsCardsIsEnabled());

$Grid = new DataGrid();
$Grid->setId('gridSearch');
Expand Down
25 changes: 16 additions & 9 deletions inc/SP/Controller/MainController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class MainController extends ControllerBase implements ActionsInterface
* Constructor
*
* @param $template Template con instancia de plantilla
* @param string $page El nombre de página para la clase del body
* @param bool $initialize Si es una inicialización completa
* @param string $page El nombre de página para la clase del body
* @param bool $initialize Si es una inicialización completa
*/
public function __construct(Template $template = null, $page = '', $initialize = true)
{
Expand Down Expand Up @@ -138,26 +138,33 @@ protected function initialize()
*/
public function getResourcesLinks()
{
$jsVersionHash = md5(implode(Util::getVersion(true)));
$version = implode('', Util::getVersion(true));
$theme = DiFactory::getTheme();

$jsVersionHash = md5($version);
$this->view->append('jsLinks', Init::$WEBROOT . '/js/js.php?v=' . $jsVersionHash);
$this->view->append('jsLinks', Init::$WEBROOT . '/js/js.php?g=1&v=' . $jsVersionHash);

$themeInfo = DiFactory::getTheme()->getThemeInfo();
$themeInfo = $theme->getThemeInfo();

if (isset($themeInfo['js'])) {
$themeJsBase = urlencode(DiFactory::getTheme()->getThemePath() . DIRECTORY_SEPARATOR . 'js');
$themeJsBase = urlencode($theme->getThemePath() . DIRECTORY_SEPARATOR . 'js');
$themeJsFiles = urlencode(implode(',', $themeInfo['js']));

$this->view->append('jsLinks', Init::$WEBROOT . '/js/js.php?f=' . $themeJsFiles . '&b=' . $themeJsBase . '&v=' . $jsVersionHash);
}

$resultsAsCards = Init::isLoggedIn() && Session::getUserPreferences()->isResultsAsCards();
if (Init::isLoggedIn() && Session::getUserPreferences()->getUserId() > 0) {
$resultsAsCards = Session::getUserPreferences()->isResultsAsCards();
} else {
$resultsAsCards = Checks::resultsCardsIsEnabled();
}

$cssVersionHash = md5(implode(Util::getVersion(true)) . Checks::resultsCardsIsEnabled() . $resultsAsCards);
$cssVersionHash = md5($version . $resultsAsCards);
$this->view->append('cssLinks', Init::$WEBROOT . '/css/css.php?v=' . $cssVersionHash);

if (isset($themeInfo['css'])) {
if (Checks::resultsCardsIsEnabled() || $resultsAsCards) {
if ($resultsAsCards) {
$themeInfo['css'][] = 'search-card.min.css';
} else {
$themeInfo['css'][] = 'search-grid.min.css';
Expand All @@ -167,7 +174,7 @@ public function getResourcesLinks()
$themeInfo['css'][] = 'styles-wiki.min.css';
}

$themeCssBase = urlencode(DiFactory::getTheme()->getThemePath() . DIRECTORY_SEPARATOR . 'css');
$themeCssBase = urlencode($theme->getThemePath() . DIRECTORY_SEPARATOR . 'css');
$themeCssFiles = urlencode(implode(',', $themeInfo['css']));

$this->view->append('cssLinks', Init::$WEBROOT . '/css/css.php?f=' . $themeCssFiles . '&b=' . $themeCssBase . '&v=' . $jsVersionHash);
Expand Down
2 changes: 1 addition & 1 deletion inc/SP/Util/Util.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public static function getAppInfo($index = null)
*/
public static function getVersion($retBuild = false, $normalized = false)
{
$build = 17042002;
$build = 17042003;
$version = [2, 1, 7];

if ($normalized === true) {
Expand Down

0 comments on commit 4eae489

Please sign in to comment.