Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1169450
skin_eh.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Sep 26, 12:36 AM
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Sep 28, 12:36 AM (1 d, 13 h)
Engine
blob
Format
Raw Data
Handle
757704
Attached To
rINP In-Portal
skin_eh.php
View Options
<?php
/**
* @version $Id: skin_eh.php 12960 2009-12-20 13:11:53Z alex $
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined
(
'FULL_PATH'
)
or
die
(
'restricted access!'
);
class
SkinEventHandler
extends
kDBEventHandler
{
function
mapPermissions
()
{
parent
::
mapPermissions
();
$permissions
=
Array
(
'OnItemBuild'
=>
Array
(
'self'
=>
true
),
);
$this
->
permMapping
=
array_merge
(
$this
->
permMapping
,
$permissions
);
}
/**
* With "primary" special loads primary skin
*
* @param kEvent $event
* @return int
*/
function
getPassedID
(&
$event
)
{
if
(
$event
->
Special
==
'primary'
)
{
return
Array
(
'IsPrimary'
=>
1
);
}
return
parent
::
getPassedID
(
$event
);
}
/**
* Allows to set selected theme as primary
*
* @param kEvent $event
*/
function
OnSetPrimary
(&
$event
)
{
if
(
$this
->
Application
->
CheckPermission
(
'SYSTEM_ACCESS.READONLY'
,
1
))
{
$event
->
status
=
erFAIL
;
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 IsPrimary = 0'
;
$this
->
Conn
->
Query
(
$sql
);
$sql
=
'UPDATE '
.
$table_name
.
'
SET IsPrimary = 1
WHERE '
.
$id_field
.
' = '
.
$id
;
$this
->
Conn
->
Query
(
$sql
);
}
/**
* [HOOK] Compile stylesheet file based on theme definitions
*
* @param kEvent $event
*/
function
OnCompileStylesheet
(&
$event
)
{
$object
=&
$event
->
getObject
(
Array
(
'skip_autoload'
=>
true
)
);
$object
->
SwitchToLive
();
$ids
=
$event
->
MasterEvent
->
getEventParam
(
'ids'
);
if
(!
is_array
(
$ids
))
{
$ids
=
explode
(
','
,
$ids
);
}
if
(!
$ids
)
{
return
false
;
}
$skin_helper
=&
$this
->
Application
->
recallObject
(
'SkinHelper'
);
/* @var $skin_helper SkinHelper */
foreach
(
$ids
as
$id
)
{
$object
->
Load
(
$id
);
$skin_helper
->
compile
(
$object
);
}
}
}
Event Timeline
Log In to Comment