*
* @license http://nucleuscms.org/license.txt GNU General Public License
* @copyright Copyright (C) 2002-2009 The Nucleus Group
- * @version $Id: SKIN.php 1784 2012-04-22 04:28:30Z sakamocchi $
+<<<<<<< HEAD
+ * @version $Id: SKIN.php 1816 2012-05-03 01:40:10Z sakamocchi $
+=======
+ * @version $Id: SKIN.php 1886 2012-06-17 08:27:27Z sakamocchi $
+>>>>>>> skinnable-master
*/
-if ( !function_exists('requestVar') )
+if ( !function_exists('requestVar') )
{
exit;
}
$this->id = (integer) $id;
+<<<<<<< HEAD
/*
* NOTE: include needed action class
*/
+=======
+ /* NOTE: include needed action class */
+>>>>>>> skinnable-master
if ( $action_class != 'Actions' )
{
if ( !class_exists($action_class, FALSE)
{
global $manager;
- $manager->notify(
- 'PreAddSkin',
- array(
- 'name' => &$name,
- 'description' => &$desc,
- 'type' => &$type,
- 'includeMode' => &$includeMode,
- 'includePrefix' => &$includePrefix
- )
+ $data = array(
+ 'name' => &$name,
+ 'description' => &$desc,
+ 'type' => &$type,
+ 'includeMode' => &$includeMode,
+ 'includePrefix' => &$includePrefix
);
+ $manager->notify('PreAddSkin', $data);
$query = "INSERT INTO %s (sdname, sddesc, sdtype, sdincmode, sdincpref) VALUES (%s, %s, %s, %s, %s);";
$sdname = DB::quoteValue($name);
DB::execute($query);
$newid = DB::getInsertId();
- $manager->notify(
- 'PostAddSkin',
- array(
- 'skinid' => $newid,
- 'name' => $name,
- 'description' => $desc,
- 'type' => $type,
- 'includeMode' => $includeMode,
- 'includePrefix' => $includePrefix
- )
+ $data = array(
+ 'skinid' => $newid,
+ 'name' => $name,
+ 'description' => $desc,
+ 'type' => $type,
+ 'includeMode' => $includeMode,
+ 'includePrefix' => $includePrefix
);
+ $manager->notify('PostAddSkin', $data);
+
return $newid;
}
{
global $currentSkinName, $manager, $CONF, $DIR_NUCLEUS;
- $manager->notify("Init{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));
+ $data = array(
+ 'skin' => &$this,
+ 'type' => $type
+ );
+ $manager->notify("Init{$this->event_identifier}Parse", $data);
// include skin locale file for <%text%> tag if useable
- $this->includeLocaleFile(i18n::get_current_locale());
+ $this->includeTranslation();
// set output type
sendContentType($this->getContentType(), 'skin');
- // set skin name as global var (so plugins can access it)
+ /* FIX: should be obsoleted */
$currentSkinName = $this->getName();
+ // retrieve contents
$contents = FALSE;
+<<<<<<< HEAD
if ( $type != 'fileparse' )
{
- $contents = $this->getContent($type);
+ $contents = $this->getContentFromDB($type);
}
else if ( $path !== '' && i18n::strpos(realpath($path), realpath("$DIR_NUCLEUS/../")) == 0 )
{
- $contents = $this->getFileContent($path);
+ $contents = $this->getContentFromFile($path);
+=======
+ if ( $type == 'pluginadmin' )
+ {
+ $contents = $path;
}
-
- if ( !$contents )
+ else
+ {
+ if ( $type != 'fileparse' && $type != 'importAdmin')
+ {
+ $contents = $this->getContentFromDB($type);
+ }
+ else if ( $path !== '' && i18n::strpos(realpath($path), realpath("$DIR_NUCLEUS/../")) == 0 )
+ {
+ $contents = $this->getContentFromFile($path);
+ }
+>>>>>>> skinnable-master
+ }
+ // use base skin if this skin does not have contents
+ if ( $contents === FALSE )
{
- // use base skin if this skin does not have contents
$defskin = new SKIN($CONF['BaseSkin']);
- $contents = $defskin->getContent($type);
+ $contents = $defskin->getContentFromDB($type);
if ( !$contents )
{
echo _ERROR_SKIN;
}
}
- $manager->notify("Pre{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type, 'contents' => &$contents));
+ $data = array(
+ 'skin' => &$this,
+ 'type' => $type,
+ 'contents' => &$contents
+ );
+ $manager->notify("Pre{$this->event_identifier}Parse", $data);
// set IncludeMode properties of parser
Parser::setProperty('IncludeMode', $this->getIncludeMode());
Parser::setProperty('IncludePrefix', $this->getIncludePrefix());
+ // call action handler
$action_class = $this->action_class;
$handler = new $action_class($type);
- $actions = $handler->getDefinedActions($type);
- $parser = new Parser($actions, $handler);
-
- $handler->setParser($parser);
- $handler->setSkin($this);
+ // register action handler to parser
+ $parser = new Parser($handler);
+ $parser->setSkin($this);
$parser->parse($contents);
- $manager->notify("Post{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));
+ $data = array(
+ 'skin' => &$this,
+ 'type' => $type
+ );
+ $manager->notify("Post{$this->event_identifier}Parse", $data);
+
return;
}
/**
- * Skin::getContent()
- * Get content of the skin part from the database
+ * Skin::getContentFromDB()
*
- * @param string $type type of the skin (e.g. index, item, search ...)
- * @return string content of scontent
+ * @param string $skintype skin type
+ * @return string content for the skin type
*/
- public function getContent($type)
+ public function getContentFromDB($skintype)
{
$query = "SELECT scontent FROM %s WHERE sdesc=%d and stype=%s;";
- $query = sprintf($query, sql_table('skin'), (integer) $this->id, DB::quoteValue($type));
+ $query = sprintf($query, sql_table('skin'), (integer) $this->id, DB::quoteValue($skintype));
$res = DB::getValue($query);
return $res ? $res : '';
}
/**
- * Skin::getFileContent()
+ * Skin::getContentFromFile()
*
* @param string $fullpath fullpath to the file to parse
* @return mixed file contents or FALSE
*/
- public function getFileContent($fullpath)
+ public function getContentFromFile($fullpath)
{
$fsize = filesize($fullpath);
if ( $fsize <= 0 )
$res = DB::getValue($query);
$skintypeexists = !empty($res);
+<<<<<<< HEAD
$skintypevalue = ($content == true);
+=======
+ $skintypevalue = !empty($content);
+>>>>>>> skinnable-master
if( $skintypevalue && $skintypeexists )
{
'type' => $type,
'content' => &$content
);
+<<<<<<< HEAD
// PreUpdateSkinPart event
$manager->notify("PreUpdate{{$this->event_identifier}}Part", $data);
else if( $skintypevalue && !$skintypeexists )
{
$data = array(
- 'skinid' => $this->id,
- 'type' => $type,
- 'content' => &$content
+ 'skinid' => $this->id,
+ 'type' => $type,
+ 'content' => &$content
);
$manager->notify("PreAdd{$this->event_identifier}Part", $data);
}
else if( !$skintypevalue && $skintypeexists )
+=======
+ $manager->notify("PreUpdate{$this->event_identifier}Part", $data);
+ }
+ else if( $skintypevalue )
+ {
+ $data = array(
+ 'skinid' => $this->id,
+ 'type' => $type,
+ 'content' => &$content
+ );
+ $manager->notify("PreAdd{$this->event_identifier}Part", $data);
+ }
+ else if( $skintypeexists )
+>>>>>>> skinnable-master
{
$data = array(
- 'skinid' => $this->id,
- 'type' => $type
+ 'skinid' => $this->id,
+ 'type' => $type
);
+<<<<<<< HEAD
+=======
+>>>>>>> skinnable-master
$manager->notify("PreDelete{$this->event_identifier}Part", $data);
}
// delete old thingie
+<<<<<<< HEAD
$query = "DELETE FROM %s WHERE stype=%s and sdesc=%d";
+=======
+ $query = "DELETE FROM %s WHERE stype=%s and sdesc=%d;";
+>>>>>>> skinnable-master
$query = sprintf($query, sql_table('skin'), DB::quoteValue($type), (integer) $this->id);
DB::execute($query);
// write new thingie
if ( $content )
{
+<<<<<<< HEAD
$query = "INSERT INTO %s (scontent, stype, sdesc) VALUE (%s, %s, %d)";
+=======
+ $query = "INSERT INTO %s (scontent, stype, sdesc) VALUES (%s, %s, %d);";
+>>>>>>> skinnable-master
$query = sprintf($query, sql_table('skin'), DB::quoteValue($content), DB::quoteValue($type), (integer) $this->id);
DB::execute($query);
}
if( $skintypevalue && $skintypeexists )
{
$data = array(
+<<<<<<< HEAD
'skinid' => $this->id,
'type' => $type,
'content' => &$content
$manager->notify("PostAdd{$this->event_identifier}Part", $data);
}
else if( (!$skintypevalue) && $skintypeexists )
+=======
+ 'skinid' => $this->id,
+ 'type' => $type,
+ 'content' => &$content
+ );
+ $manager->notify("PostUpdate{$this->event_identifier}Part", $data);
+ }
+ else if( $skintypevalue )
+ {
+ $data = array(
+ 'skinid' => $this->id,
+ 'type' => $type,
+ 'content' => &$content
+ );
+ $manager->notify("PostAdd{$this->event_identifier}Part", $data);
+ }
+ else if( $skintypeexists )
+>>>>>>> skinnable-master
{
$data = array(
'skinid' => $this->id,
'type' => $type
);
+<<<<<<< HEAD
+=======
+>>>>>>> skinnable-master
$manager->notify("PostDelete{$this->event_identifier}Part", $data);
}
return;
}
/**
- * Skin::includeLocaleFile()
+ * Skin::includeTranslation()
*
- * @param string $locale locale name
+ * @param void
* @return void
*/
- private function includeLocaleFile($locale)
+ private function includeTranslation()
{
global $DIR_SKINS;
+ $locale = i18n::get_current_locale() . '.' . i18n::get_current_charset();
+
if( $this->includeMode == "normal" )
{
- $filename = "./locale/{$locale}.php";
+ $filename = "./locales/{$locale}.php";
}
- elseif( $this->includeMode == "skindir" )
+ else if( $this->includeMode == "skindir" )
{
if ( $this->includePrefix == '' )
{
- $filename = "{$DIR_SKINS}locale/{$locale}.php";
+ $filename = "{$DIR_SKINS}locales/{$locale}.php";
}
else
{
- $filename = "{$DIR_SKINS}{$this->includePrefix}locale/{$locale}.php";
+ $filename = "{$DIR_SKINS}{$this->includePrefix}locales/{$locale}.php";
}
}
else
}
/**
+<<<<<<< HEAD
* Skin::getDefaultTypes()
+=======
+ * Skin::getNormalTypes()
+>>>>>>> skinnable-master
*
* @param string void
* @return array default skin types
*/
+<<<<<<< HEAD
public function getDefaultTypes()
{
- return call_user_func(array($this->action_class, 'getDefaultSkinTypes'));
+ return call_user_func(array($this->action_class, 'getAvailableSkinTypes'));
+=======
+ public function getNormalTypes()
+ {
+ return call_user_func(array($this->action_class, 'getNormalSkinTypes'));
+>>>>>>> skinnable-master
}
/**
*/
public function getAvailableTypes()
{
+<<<<<<< HEAD
$default_skintypes = $this->getDefaultTypes();
+=======
+ $default_skintypes = $this->getNormalTypes();
+>>>>>>> skinnable-master
$query = "SELECT stype FROM %s WHERE sdesc=%d;";
$query = sprintf($query, sql_table('skin'), (integer) $this->id);
* Skin::getAllowedActionsForType()
* Get the allowed actions for a skin type
* returns an array with the allowed actions
+<<<<<<< HEAD
*
- * @param string $type type of the skin
+=======
+ * @return array allowed action types
+>>>>>>> skinnable-master
+ * @param string $skintype type of the skin
* @return array allowed action types
*/
- public function getAllowedActionsForType($type)
+ public function getAllowedActionsForType($skintype)
{
- return call_user_func(array($this->action_class, 'getDefinedActions'), $type);
+ $handler = new $this->action_class($skintype);
+ return $handler->getAvailableActions();
}
}