Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Fri, Nov 21, 1:30 PM

in-portal

Index: branches/RC/core/units/themes/themes_tag_processor.php
===================================================================
--- branches/RC/core/units/themes/themes_tag_processor.php (revision 9235)
+++ branches/RC/core/units/themes/themes_tag_processor.php (revision 9236)
@@ -1,56 +1,61 @@
<?php
class ThemesTagProcessor extends kDBTagProcessor
{
function StylesheetFile($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params );
if (!$object->GetDBField('StyleName')) {
// no stylesheet is associated with current theme
return '';
}
$css_url = $this->Application->BaseURL('/kernel/stylesheets');
$css_path = rtrim( str_replace( $this->Application->BaseURL(), FULL_PATH.'/', $css_url), '/' );
$last_compiled = $object->GetDBField('LastCompiled');
$style_name = strtolower( $object->GetDBField('StyleName') );
if( file_exists($css_path.'/'.$style_name.'-'.$last_compiled.'.css') )
{
$ret = rtrim($css_url, '/').'/'.$style_name.'-'.$last_compiled.'.css';
}
else
{
// search for previously compiled stylesheet
$last_compiled = 0;
if( $dh = opendir($css_path) )
{
while( ($file = readdir($dh)) !== false )
{
if( preg_match('/(.*)-([\d]+).css/', $file, $rets) )
{
if( $rets[1] == $style_name && $rets[2] > $last_compiled ) $last_compiled = $rets[2];
}
}
closedir($dh);
}
if ($last_compiled) {
// found
$ret = $css_url.'/'.$style_name.'-'.$last_compiled.'.css';
}
else {
// not found
return '';
}
}
if (isset($params['file_only'])) return $ret;
return '<link rel="stylesheet" rev="stylesheet" href="'.$ret.'" type="text/css" media="screen" />';
}
+
+ function SelectedTheme($params)
+ {
+ $object =& $this->getObject($params);
+ return $object->GetDBField('ThemeId') == $this->Application->GetVar('m_theme');
+ }
}
-
?>
\ No newline at end of file
Property changes on: branches/RC/core/units/themes/themes_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.7.2.1
\ No newline at end of property
Index: branches/RC/core/units/themes/themes_eh.php
===================================================================
--- branches/RC/core/units/themes/themes_eh.php (revision 9235)
+++ branches/RC/core/units/themes/themes_eh.php (revision 9236)
@@ -1,73 +1,99 @@
<?php
class ThemesEventHandler extends kDBEventHandler {
/**
* Allows to override standart permission mapping
*
*/
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array(
'OnItemBuild' => Array('self' => true),
+ 'OnChangeTheme' => Array('self' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
/**
* Allows to set selected theme as primary
*
* @param kEvent $event
*/
function OnSetPrimary(&$event)
{
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
return;
}
$ids = $this->StoreSelectedIDs($event);
if ($ids) {
$id = array_shift($ids);
$this->setPrimary($id);
}
$this->clearSelectedIDs($event);
}
function setPrimary($id)
{
$id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
$sql = 'UPDATE '.$table_name.'
SET PrimaryTheme = 0';
$this->Conn->Query($sql);
$sql = 'UPDATE '.$table_name.'
SET PrimaryTheme = 1, Enabled = 1
WHERE '.$id_field.' = '.$id;
$this->Conn->Query($sql);
}
/**
* Set correct parent path for newly created categories
*
* @param kEvent $event
*/
function OnAfterCopyToLive(&$event)
{
$object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true));
/* @var $object kDBItem */
$object->Load($event->getEventParam('id'));
if ($object->GetDBField('PrimaryTheme')) {
$this->setPrimary($event->getEventParam('id'));
}
}
+
+ /**
+ * Allows to change the theme
+ *
+ * @param kEvent $event
+ */
+ function OnChangeTheme(&$event)
+ {
+ $this->Application->SetVar('m_theme', $this->Application->GetVar('theme'));
+ }
+
+ /**
+ * Apply system filter to themes list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $object =& $event->getObject();
+ /* @var $object kDBList */
+
+ $object->addFilter('enabled', '%1$s.Enabled = 1');
+ }
}
?>
\ No newline at end of file
Property changes on: branches/RC/core/units/themes/themes_eh.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.3.4.1
\ No newline at end of property

Event Timeline