-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing up themes so there is only one active at a time
- Loading branch information
1 parent
74847d8
commit 17d4bb5
Showing
1 changed file
with
78 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,79 @@ | ||
<?php | ||
/** | ||
* Comment Template. | ||
* | ||
* @todo Implement .this needs to be sorted out. | ||
* | ||
* Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* @filesource | ||
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* @link http://infinitas-cms.org | ||
* @package sort | ||
* @subpackage sort.comments | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
* @since 0.5a | ||
*/ | ||
|
||
class Theme extends ManagementAppModel { | ||
var $name = 'Theme'; | ||
|
||
var $tablePrefix = 'core_'; | ||
|
||
var $hasMay = array( | ||
'Management.Route' | ||
); | ||
|
||
/** | ||
* Get the current Theme | ||
* | ||
* @param array $conditions | ||
* @return array $theme the current theme. | ||
*/ | ||
function getCurrnetTheme(){ | ||
|
||
$theme = Cache::read('currentTheme'); | ||
|
||
if ($theme == false) { | ||
$theme = $this->find( | ||
'first', | ||
array( | ||
'conditions' => array( | ||
'Theme.active' => 1 | ||
) | ||
) | ||
); | ||
} | ||
Cache::write('currentTheme', $theme, 'core'); | ||
|
||
return $theme; | ||
} | ||
|
||
function afterSave($created) { | ||
parent::afterSave($created); | ||
|
||
$this->__clearCache(); | ||
return true; | ||
} | ||
|
||
function afterDelete() { | ||
parent::afterDelete(); | ||
|
||
$this->__clearCache(); | ||
return true; | ||
} | ||
|
||
function __clearCache() { | ||
if (is_file(CACHE . 'core' . DS . 'current_theme')) { | ||
unlink(CACHE . 'core' . DS . 'current_theme'); | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
<?php | ||
/** | ||
* Comment Template. | ||
* | ||
* @todo Implement .this needs to be sorted out. | ||
* | ||
* Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* @filesource | ||
* @copyright Copyright (c) 2009 Carl Sutton ( dogmatic69 ) | ||
* @link http://infinitas-cms.org | ||
* @package sort | ||
* @subpackage sort.comments | ||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | ||
* @since 0.5a | ||
*/ | ||
|
||
class Theme extends ManagementAppModel { | ||
var $name = 'Theme'; | ||
|
||
var $tablePrefix = 'core_'; | ||
|
||
var $hasMay = array( | ||
'Management.Route' | ||
); | ||
|
||
/** | ||
* Get the current Theme | ||
* | ||
* @param array $conditions | ||
* @return array $theme the current theme. | ||
*/ | ||
function getCurrnetTheme(){ | ||
|
||
$theme = Cache::read('currentTheme'); | ||
|
||
if ($theme == false) { | ||
$theme = $this->find( | ||
'first', | ||
array( | ||
'conditions' => array( | ||
'Theme.active' => 1 | ||
) | ||
) | ||
); | ||
} | ||
Cache::write('currentTheme', $theme, 'core'); | ||
|
||
return $theme; | ||
} | ||
|
||
/** | ||
* Deactivate everything after making something else active | ||
*/ | ||
function afterSave($created) { | ||
parent::afterSave($created); | ||
|
||
$this->__clearCache(); | ||
return true; | ||
} | ||
|
||
function afterDelete() { | ||
parent::afterDelete(); | ||
|
||
$this->__clearCache(); | ||
return true; | ||
} | ||
|
||
function __clearCache() { | ||
if (is_file(CACHE . 'core' . DS . 'current_theme')) { | ||
unlink(CACHE . 'core' . DS . 'current_theme'); | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
?> |