From d95ec12401c200ea0d3099276e3e6337bee7599a Mon Sep 17 00:00:00 2001 From: sakamocchi Date: Mon, 30 Apr 2012 23:06:42 +0900 Subject: [PATCH] =?utf8?q?MERGE:=20=E3=83=AA=E3=83=93=E3=82=B8=E3=83=A7?= =?utf8?q?=E3=83=B31800=E3=80=82Skin=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AE2?= =?utf8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=AE=E5=90=8D=E5=89=8D?= =?utf8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit スキンの内容の取得先をデータベースとファイルから選択できるようにしているが、それをメソッド名に反映した。 Revision 1800: CHANGE: rename two methods related to retrieve skin contents and related modification rename: Skin::getContents() to Skin::getContentFromDB() Skin::getFileConten() to Skin::getContentFromFile() http://nucleuscms.svn.sourceforge.net/viewvc/nucleuscms?view=revision&revision=1800 --- nucleus/libs/SKIN.php | 124 +++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 61 deletions(-) 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); + } + } -- 2.11.0