Added portal-wide settings in acp_portal.php;

Added language strings; 
Fixed XHTML parsing bug in adm/style/acp_portal_config.html;
This commit is contained in:
Marc Alexander
2010-04-06 14:55:53 +00:00
parent 62a28fead6
commit 04ca4b3acf
4 changed files with 175 additions and 78 deletions

View File

@@ -38,8 +38,8 @@
<!-- ENDIF -->
</fieldset>
<!-- END mods -->
<!-- IF SHOW_MODULE_OPTIONS -->
<form id="acp_portal_config" method="post" action="{U_ACTION}">
<!-- IF SHOW_MODULE_OPTIONS -->
<fieldset>
<legend>{L_MODULE_OPTIONS}</legend>
<dl>

View File

@@ -60,9 +60,15 @@ class acp_portal
'title' => 'ACP_PORTAL_GENERAL_TITLE',
'vars' => array(
'legend1' => 'ACP_PORTAL_GENERAL_INFO',
# 'portal_enable' => array('lang' => 'PORTAL_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
# 'portal_left_column_width' => array('lang' => 'PORTAL_LEFT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
# 'portal_right_column_width' => array('lang' => 'PORTAL_RIGHT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_enable' => array('lang' => 'PORTAL_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_left_column' => array('lang' => 'PORTAL_LEFT_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_right_column' => array('lang' => 'PORTAL_RIGHT_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_version_check' => array('lang' => 'PORTAL_VERSION_CHECK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_forum_index' => array('lang' => 'PORTAL_FORUM_INDEX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'legend2' => 'ACP_PORTAL_COLUMN_WIDTH_SETTINGS',
'portal_left_column_width' => array('lang' => 'PORTAL_LEFT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'portal_right_column_width' => array('lang' => 'PORTAL_RIGHT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
)
);

View File

@@ -41,8 +41,30 @@ $lang = array_merge($lang, array(
// Common
$lang = array_merge($lang, array(
// ACP - General Settings
'ACP_PORTAL_GENERAL_TITLE' => 'Portal administration',
'ACP_PORTAL_GENERAL_TITLE_EXP' => 'Thank you for choosing Board3 Portal! This is where you can manage your portal page. The options below let you customize the various general settings. The links on the left-hand side allow you to customize in detail every aspect of your portal experience.',
'ACP_PORTAL_GENERAL_SETTINGS' => 'General settings',
'PORTAL_ENABLE' => 'Enable Portal',
'PORTAL_ENABLE_EXP' => 'Turns the whole portal on or off.',
'PORTAL_LEFT_COLUMN' => 'Enable left column',
'PORTAL_LEFT_COLUMN_EXP' => 'Switch to no if you wish to turn off the left column',
'PORTAL_RIGHT_COLUMN' => 'Enable right column',
'PORTAL_RIGHT_COLUMN_EXP' => 'Switch to no if you wish to turn off the right column',
'PORTAL_VERSION_CHECK' => 'Versioncheck on Portal',
'PORTAL_FORUM_INDEX' => 'Forum Index (Forum list)',
'PORTAL_FORUM_INDEX_EXP' => 'Display this block on the portal.',
'ACP_PORTAL_COLUMN_WIDTH_SETTINGS' => 'Left and right column width settings',
'PORTAL_LEFT_COLUMN_WIDTH' => 'Width of the left column',
'PORTAL_LEFT_COLUMN_WIDTH_EXP' => 'Change the width of the left column in pixels; recommended value is 180',
'PORTAL_RIGHT_COLUMN_WIDTH' => 'Width of the right column',
'PORTAL_RIGHT_COLUMN_WIDTH_EXP' => 'Change the width of the right column in pixels; recommended value is 180',
'POSTERS' => 'Posters',
// Search engine names
'SEARCH_A9' => 'A9.com',
'SEARCH_ACRONYM_FINDER' => 'AcronymFinder',
'SEARCH_ALEXA' => 'Alexa',
@@ -55,7 +77,7 @@ $lang = array_merge($lang, array(
'SEARCH_CREATIVE_COMMONS' => 'Crative Commons',
'SEARCH_EBAY' => 'Ebay',
'SEARCH_GOOGLE' => 'Google',
'SEARCH_LIVE' => 'Windows Live',
'SEARCH_LIVE' => 'Bing',
'SEARCH_LYCOS' => 'Lycos',
'SEARCH_MININOVA' => 'Mininova',
'SEARCH_REFERENCE' => 'Reference.com',
@@ -71,7 +93,7 @@ $lang = array_merge($lang, array(
// paypal
'PORTAL_PAY_ACC' => 'Paypal Account',
'PORTAL_PAY_ACC_EXPLAIN' => 'Gib deine e-mail-Adresse an, die du bei Paypal benutzt, z.B. xxx@xxx.com',
'PORTAL_PAY_ACC_EXP' => 'Gib deine e-mail-Adresse an, die du bei Paypal benutzt, z.B. xxx@xxx.com',
// User menu
'UM_LOG_ME_IN' => 'Mich bei jedem Besuch automatisch anmelden',
@@ -177,7 +199,7 @@ $lang = array_merge($lang, array(
//
// Example:
// 'PAGE_ABOUT' => 'About us', /* Main page title */
// 'PAGE_ABOUT_EXPLAIN' => 'Contact information here.', /* Explanation, page sub-title */
// 'PAGE_ABOUT_EXP' => 'Contact information here.', /* Explanation, page sub-title */
//
$lang = array_merge($lang, array(
));

View File

@@ -17,11 +17,7 @@ if (!defined('IN_PHPBB'))
// Get portal config
function obtain_portal_config()
{
global $db, $cache;
if (($portal_config = $cache->get('portal_config')) !== true)
{
$portal_config = $cached_portal_config = array();
global $db;
$sql = 'SELECT config_name, config_value
FROM ' . PORTAL_CONFIG_TABLE;
@@ -34,9 +30,6 @@ function obtain_portal_config()
}
$db->sql_freeresult($result);
$cache->put('portal_config', $cached_portal_config);
}
return $portal_config;
}
@@ -64,18 +57,18 @@ function set_portal_config($config_name, $config_value)
}
// fetch post for news & announce
function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0)
function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_length, $time, $type, $start = 0, $invert = false)
{
global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield, $bbcode, $portal_config, $config;
$posts = array();
$post_time = ($time == 0) ? '' : 'AND t.topic_time > ' . (time() - $time * 86400);
$forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$forum_from = (strpos($forum_from, ',') !== FALSE) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
$str_where = '';
$topic_icons = array(0);
$have_icons = 0;
if( $permissions == TRUE )
if($permissions == true)
{
$disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
}
@@ -84,21 +77,27 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
$disallow_access = array();
}
if($invert == true)
{
$disallow_access = array_merge($disallow_access, $forum_from);
$forum_from = array();
}
$global_f = 0;
if( sizeof($forum_from) )
if(sizeof($forum_from))
{
$disallow_access = array_diff($forum_from, $disallow_access);
if( !sizeof($disallow_access) )
if(!sizeof($disallow_access))
{
return array();
}
foreach( $disallow_access as $acc_id)
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "t.forum_id = $acc_id OR ";
if( $type == 'announcements' && $global_f < 1 && $acc_id > 0 )
if($type == 'announcements' && $global_f < 1 && $acc_id > 0)
{
$global_f = $acc_id;
}
@@ -106,39 +105,39 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
}
else
{
foreach( $disallow_access as $acc_id )
foreach($disallow_access as $acc_id)
{
$acc_id = (int) $acc_id;
$str_where .= "t.forum_id <> $acc_id AND ";
}
}
switch( $type )
switch($type)
{
case "announcements":
$topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . '))';
$str_where = ( strlen($str_where) > 0 ) ? 'AND (t.forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
$topic_type = '((t.topic_type = ' . POST_ANNOUNCE . ') OR (t.topic_type = ' . POST_GLOBAL . '))';
$str_where = (strlen($str_where) > 0) ? 'AND (t.forum_id = 0 OR (' . trim(substr($str_where, 0, -4)) . '))' : '';
$user_link = 't.topic_poster = u.user_id';
$post_link = 't.topic_first_post_id = p.post_id';
$topic_order = 't.topic_time DESC';
break;
case "news":
$topic_type = 't.topic_type = ' . POST_NORMAL;
$str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
$user_link = ( $portal_config['portal_news_style'] ) ? 't.topic_poster = u.user_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
$post_link = ( $portal_config['portal_news_style'] ) ? 't.topic_first_post_id = p.post_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
$topic_order = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
$user_link = ($portal_config['portal_news_style']) ? 't.topic_poster = u.user_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
$post_link = ($portal_config['portal_news_style']) ? 't.topic_first_post_id = p.post_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
$topic_order = ($portal_config['portal_news_show_last']) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
break;
case "news_all":
$topic_type = '( t.topic_type <> ' . POST_ANNOUNCE . ' ) AND ( t.topic_type <> ' . POST_GLOBAL . ')';
$str_where = ( strlen($str_where) > 0 ) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
$user_link = ( $portal_config['portal_news_style'] ) ? 't.topic_poster = u.user_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
$post_link = ( $portal_config['portal_news_style'] ) ? 't.topic_first_post_id = p.post_id' : (( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
$topic_order = ( $portal_config['portal_news_show_last'] ) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
$topic_type = '(t.topic_type <> ' . POST_ANNOUNCE . ') AND (t.topic_type <> ' . POST_GLOBAL . ')';
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
$user_link = ($portal_config['portal_news_style']) ? 't.topic_poster = u.user_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_poster_id = u.user_id' : 't.topic_poster = u.user_id' ) ;
$post_link = ($portal_config['portal_news_style']) ? 't.topic_first_post_id = p.post_id' : (($portal_config['portal_news_show_last']) ? 't.topic_last_post_id = p.post_id' : 't.topic_first_post_id = p.post_id' ) ;
$topic_order = ($portal_config['portal_news_show_last']) ? 't.topic_last_post_time DESC' : 't.topic_time DESC' ;
break;
}
if( $type == 'announcements' && $global_f < 1 )
if($type == 'announcements' && $global_f < 1)
{
$sql = 'SELECT
forum_id
@@ -151,8 +150,9 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
forum_id';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if( !sizeof( $row ) )
if(!sizeof($row))
{
return array();
}
@@ -225,7 +225,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
$sql_array['SELECT'] .= ', tp.topic_posted';
$sql = $db->sql_build_query('SELECT', $sql_array);
if ($number_of_posts <> 0)
if ($number_of_posts != 0)
{
$result = $db->sql_query_limit($sql, $number_of_posts, $start);
}
@@ -234,18 +234,12 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
$result = $db->sql_query($sql);
}
// Instantiate BBCode if need be
if ($bbcode_bitfield !== '')
{
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
}
$i = 0;
while ( $row = $db->sql_fetchrow($result) )
while ($row = $db->sql_fetchrow($result))
{
$attachments = array();
if( $config['allow_attachments'] && $row['post_id'] )
if(($auth->acl_get('u_download') && ($auth->acl_get('f_download', $row['forum_id']) || $row['forum_id'] == 0)) && $config['allow_attachments'] && $row['post_id'])
{
// Pull attachment data
$sql2 = 'SELECT *
@@ -268,32 +262,30 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
if (($text_length != 0) && (strlen($len_check) > $text_length))
{
$message = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
$message = str_replace(array("\n", "\r"), array('<br />', "\n"), $row['post_text']);
$message = get_sub_taged_string($message, $row['bbcode_uid'], $maxlen);
$posts[$i]['striped'] = true;
}
else
{
$message = censor_text( str_replace("\n", '<br/> ', $row['post_text']) );
$message = str_replace("\n", '<br/> ', $row['post_text']);
}
// Second parse bbcode here
if ($row['bbcode_bitfield'])
{
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
}
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) + (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) + (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
$message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
if (!empty($attachments))
{
parse_attachments($row['forum_id'], $message, $attachments, $update_count);
}
$message = smiley_text($message); // Always process smilies after parsing bbcodes
if( $global_f < 1 )
if($global_f < 1)
{
$global_f = $row['forum_id'];
}
$topic_icons[] = $row['enable_icons'];
$have_icons = ( $row['icon_id'] > 0 ) ? 1 : $have_icons;
$have_icons = ($row['icon_id'] > 0) ? 1 : $have_icons;
$posts[$i] = array_merge($posts[$i], array(
'post_text' => ap_validate($message),
@@ -324,11 +316,12 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
$posts['global_id'] = $global_f;
$i++;
}
$db->sql_freeresult($result);
$posts['topic_icons'] = ( (max($topic_icons) > 0 ) && $have_icons ) ? true : false;
$posts['topic_icons'] = ((max($topic_icons) > 0) && $have_icons) ? true : false;
$posts['topic_count'] = $i;
if( $global_f < 1 )
if($global_f < 1)
{
return array();
}
@@ -369,15 +362,34 @@ function get_end_bbtag($tag, $bbuid)
$etag = '';
for($i=0;$i<strlen($tag);$i++)
{
if ($tag[$i] == '[') $etag .= $tag[$i] . '/';
if ($tag[$i] == '[')
{
$etag .= $tag[$i] . '/';
}
else if (($tag[$i] == '=') || ($tag[$i] == ':'))
{
if ($tag[1] == '*') $etag .= ':m:'.$bbuid.']';
else if (strpos($tag, 'list')) $etag .= ':u:'.$bbuid.']';
else $etag .= ':'.$bbuid.']';
if ($tag[1] == '*')
{
$etag .= ':m:'.$bbuid.']';
}
else if (substr($tag, 0, 6) == '[list=')
{
$etag .= ':o:'.$bbuid.']';
}
else if (substr($tag, 0, 5) == '[list')
{
$etag .= ':u:'.$bbuid.']';
}
else
{
$etag .= ':'.$bbuid.']';
}
break;
}
else $etag .= $tag[$i];
else
{
$etag .= $tag[$i];
}
}
return $etag;
}
@@ -420,7 +432,10 @@ function get_sub_taged_string($str, $bbuid, $maxlen)
while((strlen($ntext) < $cnt) && (strlen($sl) > 0))
{
$sr = '';
if (substr($sl, 0, 1) == '[') $sr = substr($sl,0,strpos($sl,']')+1);
if (substr($sl, 0, 1) == '[')
{
$sr = substr($sl,0,strpos($sl,']')+1);
}
/* GESCHLOSSENE HTML-TAGS BEACHTEN */
if (substr($sl, 0, 2) == '<!')
{
@@ -441,7 +456,10 @@ function get_sub_taged_string($str, $bbuid, $maxlen)
$j = 0;
foreach ($arr as $elem)
{
if (strcmp($elem[1],$sr) != 0) $tarr[$j++] = $elem;
if (strcmp($elem[1],$sr) != 0)
{
$tarr[$j++] = $elem;
}
}
$arr = $tarr;
}
@@ -462,15 +480,21 @@ function get_sub_taged_string($str, $bbuid, $maxlen)
$sl = substr($sl, strlen($sr), strlen($sl)-strlen($sr));
}
$ret = trim($ret) . '...';
$ap = '';
foreach ($arr as $elem)
{
$ap = $elem[1] . $ap;
}
$ret .= $ap;
$ret .= $ap;
$ret = trim($ret);
if(substr($ret, -4) == '<!--')
{
$ret .= ' -->';
}
$ret = add_endtag($ret);
$ret = $ret . '...';
return $ret;
}
@@ -487,7 +511,7 @@ function generate_portal_pagination($base_url, $num_items, $per_page, $start_ite
{
global $template, $user;
switch( $type )
switch($type)
{
case "announcements":
$pagination_type = 'ap';
@@ -598,7 +622,52 @@ function format_birthday($date, $format = false)
}
unset($lang_dates['May_short']);
return strtr(@date(str_replace('|', '', $format), $date), $lang_dates);
// We need to create a UNIX timestamp for date()
$day = substr($date, 0, strpos($date, '-'));
$month = substr($date, (strpos($date, '-')+1), 2);
$year = substr($date, -4);
$birthday_time = mktime(0, 0, 0, $month, $day, $year);
return strtr(@date(str_replace('|', '', $format), $birthday_time), $lang_dates);
}
/**
* Check if table exists
* @copyright (c) 2007 phpBB Group
*
* @param string $table_name The table name to check for
* @return bool true if table exists, else false
*/
function sql_table_exists($table_name)
{
global $db;
$db->sql_return_on_error(true);
$result = $db->sql_query_limit('SELECT * FROM ' . $db->sql_escape($table_name), 1);
$db->sql_return_on_error(false);
if ($result)
{
$db->sql_freeresult($result);
return true;
}
return false;
}
/**
* check for invalid link tag at the end of a cut string
*/
function add_endtag ($message = '')
{
$check = (int) strripos($message, '<!-- m --><a ');
$check_2 = (int) strripos($message, '</a><!--');
if(((isset($check) && $check > 0) && ($check_2 <= $check)) || ((isset($check) && $check > 0) && !isset($check_2)))
{
$message .= '</a><!-- m -->';
}
return $message;
}
// Mini Cal.