Converting some mods from SMF. I wish to know what replaces $smfunc?
What are other differences that should be noted?
Found it. It is $db. $smcFunc['code'] is now $db>code.
What about $smfhooks? Is it now just $hook? Can anybody confirm this?
Remember that $smcFunc was a global variable, while $db is "local" and you need to:
$db = database();
before the first time you use it in a function. ;)
Also, not all the functions in $smcFunc have been replaced by database(), only those related to the database. The functions related to strings are in Utils, so for example $smcFunc['htmlspecialchars'] is now Utils::htmlspecialchars.
As far as I know $smfhooks has never been used in SMF... an example?
Thank you very much. This is a very useful information.
Oh yes. This relates to subforums mod that I am in the mid of converting. The code is as follows:
// get the hooks from database
$smfhooks = array();
$request = $smcFunc['db_query']('', '
SELECT variable, value FROM {db_prefix}settings
WHERE variable IN ({array_string:hooks})',
array('hooks' => array_keys($hooklist))
);
if($smcFunc['db_num_rows']($request) > 0)
{
while($row = $smcFunc['db_fetch_assoc']($request))
$smfhooks[$row['variable']] = $row['value'];
$smcFunc['db_free_result']($request);
}
// update the hooks
foreach($hooklist as $hookname => $value)
{
if(isset($smfhooks[$hookname]))
$smfhooks[$hookname] = trim($hooklist[$hookname] .','. trim(str_replace($value, '', $smfhooks[$hookname]), ','), ',');
else
$smfhooks[$hookname] = trim($value);
$smcFunc['db_insert']('replace', '
{db_prefix}settings',
array('variable' => 'string', 'value' => 'string'),
array($hookname, $smfhooks[$hookname]),
array()
);
}
So, is replacing it with $hook correct?
$smfhooks is a variable used by the subforums mod, so you can call it whatever you want. ;)
BTW, I'm not sure why you (I mean the mod) is doing a "raw" query to insert the hooks when there is the function add_integration_function.
This is enough:
$hooklist = array(
'integrate_pre_include' => '$sourcedir/SubForums/Subforums.php',
'integrate_admin_areas' => 'Subforums_AdminMenu',
'integrate_register' => 'Subforums_Register',
);
foreach($hooklist as $hook => $value)
add_integration_function($hook, $value);
I tried changing this $context['forum_name_html_safe'] = $smcFunc['htmlspecialchars'] to $context['forum_name_html_safe'] = Utils::htmlspecialchars but it causes error. System says: PHP Fatal error: Class 'Utils' not found.
Why is that? I already insert $db = database(); before it but the error remains.Got that one. It is Util without s.
What replaces $context['character_set'] in ElkArte?
Replace it with "UTF-8" since ElkArte is utf-8 only :)
Darn, I always exchange plurals... :-[
Thanks
@Spuds , UTF-8 did the trick.
No problem
@emanuele . I miss that all the time. ;) But I haven't the hook yet. I will change the hook to suggested, when this url problem is "fixed".
Anybody sees any problem with the url definition here?
global $SubforumFunc, $base_boardurl, $boardurl, $board_language, $language;
// define the url's
$base_boardurl = $boardurl;
$parts = parse_url($boardurl);
$boardurl = $parts['scheme'] .'://'. $_SERVER['SERVER_NAME'] .(!empty($parts['port']) ? ':'. $parts['port'] : '') . (!empty($parts['path']) ? $parts['path'] : '');
$board_language = $language;
Somehow, the subforum's url isn't respected. The mod is working except (I think) for this url part. :(