I dont know, where your problems come from.
Here is my complete functions_acronym.php
Code: Select all
<?php
/**
*
* @package acronym
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* automatic acronym insertion
*/
function acronym_pass($text)
{
$acronym_cache = new acronym_cache();
static $acronyms;
global $cache;
if (!isset($acronyms) || !is_array($acronyms))
{
// obtain_acronym_list is taking care of the users acronyms option and the board-wide option
$acronyms = $acronym_cache->obtain_acronym_list();
}
if (sizeof($acronyms))
{
return preg_replace($acronyms['match'], $acronyms['replace'], $text);
}
return $text;
}
/**
* Class for grabbing/handling acronym cached entries, extends acm_file or acm_db depending on the setup
* @package acm
*/
class acronym_cache extends acm
{//----------------------------------------------------------------------
// Acronym MOD - Begin Code Alteration
//
/**
* Obtain list of lexicon words for acronyms and build preg style replacement arrays for use by the
* calling script
*/
function obtain_acronym_list()
{
global $config, $user, $db;
/* if (!$user->optionget('viewcensors') && $config['allow_nocensors'])
{
return array();
}
*/
if (($acronyms = $this->get('_acronyms')) === false)
{
$sql = 'SELECT term_id, acronym, description, NOT ISNULL(long_desc) AS long_desc
FROM ' . LEXICON_TABLE . "
WHERE lang = '" . $user->data['user_lang'] . "'
ORDER BY LENGTH(TRIM(acronym)) DESC";
$result = $db->sql_query($sql);
$acronyms = array();
while ($row = $db->sql_fetchrow($result))
{
$firstspace = (!strstr($row['acronym'], ' ')? '(?:\s|^)+' : '');
$lastspace = (!strrchr($row['acronym'], ' ')? '[A-Za-z]*' : '');
$acronyms['match'][] = '#'. $firstspace. '([\w]*'. preg_quote($row['acronym'], '#'). $lastspace. ')#i';
$acronyms['replace'][] = $row['long_desc'] ?
' <acronym class="id' .$row['term_id']. '" title="' . $row['description'] . '"><b>\\1</b></acronym> ' :
' <acronym title="' . $row['description'] . '">\\1</acronym> ' ;
}
$db->sql_freeresult($result);
$this->put('_acronyms', $acronyms);
}
return $acronyms;
}
//
// Acronym MOD - End Code Alteration
//----------------------------------------------------------------------
}
?>
and here the lexicon.php with an additional trim for the term
Code: Select all
<?php
/*
* Addon for the Acronym mod
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$user->add_lang('mods/lexicon');
// End session management
// Recherche les lettres présentes dans le lexicon
$sql = "SELECT DISTINCT UPPER(LEFT(TRIM(term),1)) AS a FROM " . LEXICON_TABLE. " WHERE lang = '" . $user->lang['USER_LANG'] . "' ORDER BY a" ;
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not obtain lexicon data", "", __LINE__, __FILE__, $sql);
}
$abc_links = '';
$abc = array('#','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',$user->lang['LEXICON_ALL']);
$letter = request_var('letter', '');
$letter = ($letter == '0') ? '#' : $letter;
$letter = (!in_array($letter,$abc)) ? '' : $letter;
while($row = $db->sql_fetchrow($result))
{
$row['a'] = str_replace (array("Ä", "Ö", "Ü"), array("A", "O", "U"),$row['a']);
$alphabeth[] = in_array($row['a'], $abc) ? $row['a'] : '#';
}
foreach ($abc as $l) //make A-Z, link if entry
{
$abc_links .= (in_array($l, $abc) OR $l == $user->lang['LEXICON_ALL']) ?
"<a href='lexicon.php?letter=$l&' " . ($letter === $l ? "class='letter'>" : ">") .
"$l</a><span class='page-sep'>, </span>" :
"<span class='noabc'>$l</span><span class='page-sep'>, </span>" ;
}
$abc_links = str_replace('#&','0&',$abc_links);
$template->assign_vars(array(
"LEXICON_ABC" => $letter == $user->lang['LEXICON_ALL'] ? $user->lang['LEXICON_ALL_TERMS'] : sprintf($user->lang['LEXICON_ABC'], $letter),
"S_LETTER" => $letter ? true : false,
"ABC" => $abc_links
));
if($letter)
{
if($letter == $user->lang['LEXICON_ALL'])
{
$where = ' '; // Select entrys with letter
}
else
{
// Select entrys with letter
$where = " WHERE " . ($letter == "#" ?
$db->sql_in_set('LEFT(term,1)', $abc, true) : // all not-letters
"term LIKE '$letter%' AND lang = '" . $user->lang['USER_LANG']."'");
}
$sql = "SELECT TRIM(term) AS term, description, long_desc FROM " . LEXICON_TABLE . $where . " ORDER BY term";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not obtain term data", "", __LINE__, __FILE__, $sql);
}
while( $term_row = $db->sql_fetchrow($result) )
{
$template->assign_block_vars("term_row", array(
"TERM" => $term_row['term'],
"DESCRIPTION" => $term_row['description'],
"LONGTEXT" => $term_row['long_desc']
));
}
}
else {
// kein Buchstabe ausgewählt
}
// Output page
page_header($user->lang['LEXICON_TITLE'] . " - $letter");
$template->set_filenames(array(
"body" => "lexicon.html")
);
page_footer();
?>