X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=nucleus%2Flibs%2FSKIN.php;h=99a5f61dbdff10a15dffed354d75d981ce4ed2fa;hb=d95ec12401c200ea0d3099276e3e6337bee7599a;hp=17679560fc8d72a5945a6aae853969e4531cc9bc;hpb=2359bf5e5dba90d81dd78483e37106970a62d0d7;p=nucleus-jp%2Fnucleus-next.git diff --git a/nucleus/libs/SKIN.php b/nucleus/libs/SKIN.php index 1767956..99a5f61 100644 --- a/nucleus/libs/SKIN.php +++ b/nucleus/libs/SKIN.php @@ -14,7 +14,7 @@ * * @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 $ + * @version $Id: SKIN.php 1784 2012-04-22 04:28:30Z sakamocchi $ */ if ( !function_exists('requestVar') ) @@ -337,24 +337,24 @@ class Skin // 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; 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 ( !$contents ) + // 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; @@ -368,9 +368,11 @@ class Skin Parser::setProperty('IncludeMode', $this->getIncludeMode()); Parser::setProperty('IncludePrefix', $this->getIncludePrefix()); + // call action handler $action_class = $this->action_class; $handler = new $action_class($type); + // register action handler to parser $actions = $handler->getDefinedActions($type); $parser = new Parser($actions, $handler); @@ -383,32 +385,32 @@ class Skin } /** - * 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, sql_real_escape_string($type)); + $query = "SELECT scontent FROM %s WHERE sdesc=%d and stype='%s';"; + $query = sprintf($query, sql_table('skin'), (integer) $this->id, sql_real_escape_string($skintype)); $res = sql_query($query); if ( sql_num_rows($res) == 0 ) { return FALSE; } + return sql_result($res, 0, 0); } /** - * 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 ) @@ -611,59 +613,59 @@ class Skin } /** - * Skin::getDefaultTypes() + * Skin::getDefaultTypes() * - * @param string void - * @return array default skin types + * @param string void + * @return array default skin types */ - public function getDefaultTypes() + public function getDefaultTypes() { - return call_user_func(array($this->action_class, 'getDefaultSkinTypes')); + return call_user_func(array($this->action_class, 'getDefaultSkinTypes')); } /** - * Skin::getAvailableTypes() + * Skin::getAvailableTypes() * * @param string void - * @return array registered skin types + * @return array registered skin types */ - public function getAvailableTypes() + public function getAvailableTypes() { - $default_skintypes = $this->getDefaultTypes(); - $query = "SELECT stype FROM %s WHERE sdesc=%d;"; - $query = sprintf($query, sql_table('skin'), (integer) $this->id); - - /* NOTE: force to put default types in the beginning */ - $in_default = array(); - $no_default = array(); - - $res = sql_query($query); - while ( $row = sql_fetch_array($res) ) - { - if ( !array_key_exists($row['stype'], $default_skintypes) ) - { - $no_default[$row['stype']] = FALSE; + $default_skintypes = $this->getDefaultTypes(); + $query = "SELECT stype FROM %s WHERE sdesc=%d;"; + $query = sprintf($query, sql_table('skin'), (integer) $this->id); + + /* NOTE: force to put default types in the beginning */ + $in_default = array(); + $no_default = array(); + + $res = sql_query($query); + while ( $row = sql_fetch_array($res) ) + { + if ( !array_key_exists($row['stype'], $default_skintypes) ) + { + $no_default[$row['stype']] = FALSE; + } + else + { + $in_default[$row['stype']] = $default_skintypes[$row['stype']]; + } + } + + return array_merge($in_default, $no_default); } - else - { - $in_default[$row['stype']] = $default_skintypes[$row['stype']]; - } - } - - return array_merge($in_default, $no_default); - } - - /** - * Skin::getAllowedActionsForType() - * Get the allowed actions for a skin type - * returns an array with the allowed actions - * - * @param string $type type of the skin - * @return array allowed action types - */ - public function getAllowedActionsForType($type) - { - return call_user_func(array($this->action_class, 'getDefinedActions'), $type); - } - + + /** + * Skin::getAllowedActionsForType() + * Get the allowed actions for a skin type + * returns an array with the allowed actions + * + * @param string $type type of the skin + * @return array allowed action types + */ + public function getAllowedActionsForType($type) + { + return call_user_func(array($this->action_class, 'getDefinedActions'), $type); + } + }