|
From: Jon O. <jon...@us...> - 2008-11-01 18:01:03
|
Update of /cvsroot/mxbb/core/includes In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv22439 Modified Files: mx_functions_style.php Log Message: Here we go. Updated style init, with less code, hopefully doing the same ;) Index: mx_functions_style.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_style.php,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** mx_functions_style.php 1 Nov 2008 15:30:27 -0000 1.106 --- mx_functions_style.php 1 Nov 2008 18:00:59 -0000 1.107 *************** *** 231,235 **** if (!empty($this->module_template_path)) { ! // ?? if (!file_exists($mx_root_path . $this->module_template_path . 'gecko.css')) { --- 231,238 ---- if (!empty($this->module_template_path)) { ! // ! // for mx_phpbb3 ! // ! /* if (!file_exists($mx_root_path . $this->module_template_path . 'gecko.css')) { *************** *** 238,241 **** --- 241,245 ---- $temppath = str_replace('overall_footer', 'overall_footer_plugin', $temppath); } + */ return $temppath; *************** *** 692,760 **** // ! // Setup style // if ( !$init_override ) { if ( $this->data['user_id'] != ANONYMOUS && $this->data['user_style'] > 0 ) { ! // ! // Get Style data. ! // ! switch (PORTAL_BACKEND) ! { ! case 'internal': ! $style = $mx_request_vars->post('user_style', MX_TYPE_INT, $this->data['user_style']); ! break; ! case 'phpbb2': ! $user_style = $mx_request_vars->post('user_style', MX_TYPE_INT, $this->data['user_style']); ! //If user have other style in mxp then the one from phpBB not to have forum page and modules graphics will be messaed up ! //Anonymouse users should see all block graphic corect ! //Query MXP style_id corepondent to phpBB themes_id ! $sql = "SELECT m.themes_id ! FROM " . MX_THEMES_TABLE . " AS m, " . THEMES_TABLE . " AS t ! WHERE t.themes_id = " . (int) $user_style . " ! AND t.template_name = m.template_name"; ! ! if ($row = $db->sql_fetchrow($db->sql_query($sql))) ! { ! $style = $row['themes_id']; //User style ! } ! else ! { ! $style = $portal_config['default_style']; ! } ! break; ! case 'phpbb3': ! $user_style = $mx_request_vars->post('user_style', MX_TYPE_INT, $this->data['user_style']); ! //If user have other style in mxp then the one from phpBB not to have forum page and modules graphics will be messaed up ! //Anonymouse users should see all block graphic corect ! //Query phpBB style_id corepondent to mxp themes_id ! $sql = "SELECT m.themes_id ! FROM " . MX_THEMES_TABLE . " AS m, " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t ! WHERE s.style_id = " . (int) $user_style . " ! AND t.template_path = m.template_name ! AND t.template_id = s.template_id"; ! ! if ($row = $db->sql_fetchrow($db->sql_query($sql))) ! { ! $style = $row['themes_id']; //User style ! } ! else ! { ! $style = $portal_config['default_style']; ! } ! break; ! } ! ! if ( $theme = $this->_setup_style($style) ) ! { ! return; ! } } } - $style = $mx_request_vars->post('default_style', MX_TYPE_INT, $init_style); - $theme = $this->_setup_style($style); ! return; } --- 696,713 ---- // ! // Setup MXP Style // + $user_style = 0; if ( !$init_override ) { if ( $this->data['user_id'] != ANONYMOUS && $this->data['user_style'] > 0 ) { ! $user_style = $mx_request_vars->post('user_style', MX_TYPE_INT, $this->data['user_style']); } } ! $init_style = $mx_request_vars->post('default_style', MX_TYPE_INT, $init_style); ! ! $theme = $this->_setup_style($init_style, $user_style); } *************** *** 766,933 **** * @return unknown */ ! function _setup_style($style) { global $db, $board_config, $portal_config, $template, $phpbb_root_path, $mx_root_path, $theme; // ! // Get Style data. // ! switch (PORTAL_BACKEND) { ! case 'internal': ! $sql = "SELECT * ! FROM " . MX_THEMES_TABLE . " ! WHERE portal_backend = '" . PORTAL_BACKEND . "' ! AND themes_id = " . (int) $style; ! break; ! case 'phpbb2': ! $sql = "SELECT bbt.* ! FROM " . MX_THEMES_TABLE . " mxt, " . THEMES_TABLE . " bbt ! WHERE mxt.template_name = bbt.template_name ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND mxt.themes_id = " . (int) $style; ! break; ! case 'phpbb3': ! $sql = "SELECT mxt . *, stt . * , bbt . * ! FROM " . MX_THEMES_TABLE . " AS mxt, " . STYLES_TEMPLATE_TABLE . " AS stt, " . STYLES_TABLE . " AS bbt ! WHERE mxt.themes_id = " . (int) $style . " ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND stt.template_id = bbt.template_id ! AND bbt.style_name = mxt.template_name"; ! break; } ! if ( !($result = $db->sql_query($sql, 120)) ) { ! mx_message_die(CRITICAL_ERROR, "Could not query database for theme info", '', __LINE__, __FILE__, $sql); } // ! // Use default style if custom style doesn't exist. // ! if ( !($row = $db->sql_fetchrow($result)) ) { switch (PORTAL_BACKEND) { case 'internal': ! $sql = "SELECT * ! FROM " . MX_THEMES_TABLE . " ! WHERE portal_backend = '" . PORTAL_BACKEND . "' ! AND themes_id = " . (int) $style; ! break; case 'phpbb2': ! $sql = "SELECT mxt.*, bbt.* ! FROM " . MX_THEMES_TABLE . " mxt, " . THEMES_TABLE . " bbt ! WHERE mxt.style_name = bbt.template_name ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND bbt.themes_id = " . (int) $style; ! break; case 'phpbb3': ! //Try standard style name ! $sql = "SELECT mxt . *, stt . * , bbt . * ! FROM " . MX_THEMES_TABLE . " AS mxt, " . STYLES_TEMPLATE_TABLE . " AS stt, " . STYLES_TABLE . " AS bbt ! WHERE mxt.themes_id = " . (int) $style . " ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND stt.template_id = bbt.template_id ! AND bbt.style_name = mxt.template_name"; ! //If not standard style name or with spaces try someting else ! if ( !$db->sql_fetchrow($db->sql_query($sql) ) ) ! { ! $sql = "SELECT mxt . *, stt . * , bbt . * ! FROM " . MX_THEMES_TABLE . " AS mxt, " . STYLES_TEMPLATE_TABLE . " AS stt, " . STYLES_TABLE . " AS bbt ! WHERE mxt.themes_id = " . (int) $style . " ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND stt.template_id = bbt.template_id ! AND stt.template_path = mxt.template_name"; ! } ! break; } ! if ( !($result = $db->sql_query($sql)) ) { ! mx_message_die(CRITICAL_ERROR, "Could not query database for theme info", '', __LINE__, __FILE__, $sql); } if ( !($row = $db->sql_fetchrow($result)) ) { ! $style = $portal_config['default_style']; ! ! switch (PORTAL_BACKEND) ! { ! case 'internal': ! $sql = "SELECT * ! FROM " . MX_THEMES_TABLE . " ! WHERE portal_backend = '" . PORTAL_BACKEND . "' ! AND themes_id = " . (int) $style; ! break; ! case 'phpbb2': ! $sql = "SELECT bbt.* ! FROM " . MX_THEMES_TABLE . " mxt, " . THEMES_TABLE . " bbt ! WHERE mxt.style_name = bbt.style_name ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND mxt.themes_id = " . (int) $style; ! break; ! case 'phpbb3': ! //Try standard style name ! $sql = "SELECT mxt . *, stt . * , bbt . * ! FROM " . MX_THEMES_TABLE . " AS mxt, " . STYLES_TEMPLATE_TABLE . " AS stt, " . STYLES_TABLE . " AS bbt ! WHERE mxt.themes_id = " . (int) $style . " ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND stt.template_id = bbt.template_id ! AND bbt.style_name = mxt.template_name"; ! //If not standard style name or with spaces try someting else ! if ( !$db->sql_fetchrow($db->sql_query($sql) ) ) ! { ! $sql = "SELECT mxt . *, stt . * , bbt . * ! FROM " . MX_THEMES_TABLE . " AS mxt, " . STYLES_TEMPLATE_TABLE . " AS stt, " . STYLES_TABLE . " AS bbt ! WHERE mxt.themes_id = " . (int) $style . " ! AND mxt.portal_backend = '" . PORTAL_BACKEND . "' ! AND stt.template_id = bbt.template_id ! AND stt.template_path = mxt.template_name"; ! } ! break; ! } ! ! if ( !($result = $db->sql_query($sql, 120)) ) ! { ! mx_message_die(CRITICAL_ERROR, 'Could not query database for theme info'); ! } ! ! // ! // Last desperate try... ! // ! if ( !($row = $db->sql_fetchrow($result)) ) ! { ! switch (PORTAL_BACKEND) ! { ! case 'internal': ! $sql = 'SELECT * ! FROM ' . MX_THEMES_TABLE; ! break; ! case 'phpbb2': ! $sql = 'SELECT * ! FROM ' . THEMES_TABLE; ! break; ! case 'phpbb3': ! $sql = "SELECT mxt.*, bbt.*, stt.* ! FROM " . MX_THEMES_TABLE . " mxt, " . STYLES_TABLE . " bbt, " . STYLES_TEMPLATE_TABLE . " stt ! WHERE mxt.template_name = stt.template_path"; ! break; ! } ! ! if ( !($result = $db->sql_query_limit($sql, 1)) ) ! { ! mx_message_die(CRITICAL_ERROR, 'Could not query database for theme info'); ! } ! ! if ( !($row = $db->sql_fetchrow($result)) ) ! { ! mx_message_die(CRITICAL_ERROR, "Could not get MX-Publisher style data for themes_id [$style]"); ! } ! } } - } ! $db->sql_freeresult($result); // --- 719,786 ---- * @return unknown */ ! function _setup_style($init_style, $user_style = 0) { global $db, $board_config, $portal_config, $template, $phpbb_root_path, $mx_root_path, $theme; + $row = false; + // ! // Are we trying a userstyle? // ! if ($user_style) { ! $row = $this->_style_query($user_style); } ! // ! // ...or a Custom Page/AdminCP Style ! // ! if (!$row) { ! $row = $this->_style_query($init_style); } // ! // Seems like we need to try the default style // ! if (!$row) ! { ! $row = $this->_style_query($portal_config['default_style']); ! } ! ! // ! // Last desperate try... ! // ! if (!$row) { switch (PORTAL_BACKEND) { case 'internal': ! $sql = 'SELECT * ! FROM ' . MX_THEMES_TABLE; ! break; case 'phpbb2': ! $sql = 'SELECT * ! FROM ' . THEMES_TABLE; ! break; case 'phpbb3': ! $sql = "SELECT bbt.*, stt.* ! FROM " . MX_THEMES_TABLE . " mxt, " . STYLES_TABLE . " bbt, " . STYLES_TEMPLATE_TABLE . " stt ! WHERE mxt.template_name = stt.template_path"; ! break; } ! if ( !($result = $db->sql_query_limit($sql, 1)) ) { ! mx_message_die(CRITICAL_ERROR, 'Could not query database for theme info - desperate try'); } if ( !($row = $db->sql_fetchrow($result)) ) { ! mx_message_die(CRITICAL_ERROR, "Could not get MX-Publisher style data for themes_id [$init_style]"); } ! $db->sql_freeresult($result); ! } // *************** *** 995,998 **** --- 848,852 ---- } } + // // Load images *************** *** 1000,1003 **** --- 854,858 ---- $this->_load_phpbb_images(); $this->_load_mxbb_images(); + // // Load backend specific style defs. *************** *** 1011,1014 **** --- 866,914 ---- * Enter description here... * + * @param unknown_type $style + * @return unknown + */ + function _style_query($style) + { + global $db, $board_config, $portal_config, $template, $phpbb_root_path, $mx_root_path, $theme; + + switch (PORTAL_BACKEND) + { + case 'internal': + $sql = "SELECT * + FROM " . MX_THEMES_TABLE . " + WHERE portal_backend = '" . PORTAL_BACKEND . "' + AND themes_id = " . (int) $style; + break; + case 'phpbb2': + $sql = "SELECT bbt.* + FROM " . MX_THEMES_TABLE . " mxt, " . THEMES_TABLE . " bbt + WHERE mxt.style_name = bbt.style_name + AND mxt.portal_backend = '" . PORTAL_BACKEND . "' + AND mxt.themes_id = " . (int) $style; + break; + case 'phpbb3': + $sql = "SELECT stt . * , bbt . * + FROM " . MX_THEMES_TABLE . " AS mxt, " . STYLES_TEMPLATE_TABLE . " AS stt, " . STYLES_TABLE . " AS bbt + WHERE bbt.style_name = mxt.style_name + AND mxt.portal_backend = '" . PORTAL_BACKEND . "' + AND stt.template_id = bbt.template_id + AND mxt.themes_id = " . (int) $style; + break; + } + + if ( !($result = $db->sql_query($sql, 120)) ) + { + mx_message_die(CRITICAL_ERROR, "Could not query database for theme info", '', __LINE__, __FILE__, $sql); + } + + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + return $row; + } + + /** + * Enter description here... + * * @access private * @return unknown |