X-Git-Url: http://git.osdn.net/view?p=nucleus-jp%2Fnucleus-next.git;a=blobdiff_plain;f=nucleus%2Flibs%2FSKIN.php;h=55547bec866c04360491b3695608caf23b992cd9;hp=b82a1f452163a6ea675d1f6085c02dbd673cb0d1;hb=c90b0980cfa3e79cd4bc7eed551a64a5e2b02a5c;hpb=76029ba89c140d3cc8cda166a51321b57c820ab6 diff --git a/nucleus/libs/SKIN.php b/nucleus/libs/SKIN.php index b82a1f4..55547be 100644 --- a/nucleus/libs/SKIN.php +++ b/nucleus/libs/SKIN.php @@ -14,10 +14,14 @@ * * @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; } @@ -54,9 +58,13 @@ class Skin $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) @@ -277,16 +285,14 @@ class Skin { 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); @@ -298,17 +304,16 @@ class Skin 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; } @@ -324,10 +329,14 @@ class Skin { 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'); @@ -337,6 +346,7 @@ class Skin // retrieve contents $contents = FALSE; +<<<<<<< HEAD if ( $type != 'fileparse' ) { $contents = $this->getContentFromDB($type); @@ -344,6 +354,22 @@ class Skin else if ( $path !== '' && i18n::strpos(realpath($path), realpath("$DIR_NUCLEUS/../")) == 0 ) { $contents = $this->getContentFromFile($path); +======= + if ( $type == 'pluginadmin' ) + { + $contents = $path; + } + 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 ) @@ -357,7 +383,12 @@ class 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()); @@ -368,14 +399,16 @@ class Skin $handler = new $action_class($type); // register action handler to parser - $actions = $handler->getDefinedActions($type); - $parser = new Parser($actions, $handler); - - $handler->setParser($parser); - $handler->setSkin($this); + $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; } @@ -442,7 +475,11 @@ class Skin $res = DB::getValue($query); $skintypeexists = !empty($res); +<<<<<<< HEAD $skintypevalue = ($content == true); +======= + $skintypevalue = !empty($content); +>>>>>>> skinnable-master if( $skintypevalue && $skintypeexists ) { @@ -451,6 +488,7 @@ class Skin 'type' => $type, 'content' => &$content ); +<<<<<<< HEAD // PreUpdateSkinPart event $manager->notify("PreUpdate{{$this->event_identifier}}Part", $data); @@ -458,32 +496,57 @@ class Skin 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); } @@ -491,6 +554,7 @@ class Skin if( $skintypevalue && $skintypeexists ) { $data = array( +<<<<<<< HEAD 'skinid' => $this->id, 'type' => $type, 'content' => &$content @@ -511,12 +575,33 @@ class Skin $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; @@ -563,28 +648,30 @@ class Skin } /** - * 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 @@ -603,14 +690,24 @@ class Skin } /** +<<<<<<< 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 } /** @@ -621,7 +718,11 @@ class Skin */ 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); @@ -649,13 +750,18 @@ class Skin * 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(); } }