Making .xml mod

Started by Owdy, June 07, 2005, 03:50:44 PM

Previous topic - Next topic

Owdy

I'm trying to change from .mod to.xml, but i have issues.

First, if i dont ad '<install for="xxx">' tag in package-info.xml file, install link wont appear in package manager. I dont want it to be version  spesific, why PaMa want that tag?

Second, heres my install.xml:
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>Owdy:my own mods</id>
<version>1.0</version>

<file name="$sourcedir/BoardIndex.php">

<operation>
<search position="replace"><![CDATA[
// Load the users online right now.
]]></search>
<add><![CDATA[
   // Load the users online today.
$forumtime = forum_time();
$midnight = ($forumtime) - (((date("H", $forumtime) + $modSettings['time_offset'])  * 3600) + (date("i", $forumtime) * 60) + (date("s", $forumtime)));

// Load the users online for the past 24 hours.
$result = db_query("
SELECT mem.ID_MEMBER, mem.realName, mem.memberName, mem.ID_GROUP, mem.showOnline, mem.avatar, mem.lastLogin, mem.posts, mg.onlineColor
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_GROUP))
WHERE mem.lastLogin >= '$midnight'
ORDER BY mem.lastLogin", __FILE__, __LINE__);

$today['users'] = array();
$today['num_users'] = 0;

$link = array();

while ($tmp = mysql_fetch_assoc($result))
{
$link []= '<a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '" style="color: ' . $tmp['onlineColor'] . ';">' . $tmp['realName'] . '</a>';
$today['num_users']++;
}

mysql_free_result($result);

$context['user_today'] = implode(', ', $link);
$context['num_users_today'] = $today['num_users'];

        trackStats(array('allOn' => $context['num_users_today']));

// Load the users online right now.

]]></add>
</operation>


<file name="$sourcedir/Stats.php">
<operation>
<search position="replace"><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, MAX(mostOn) AS mostOn, COUNT(date) AS numDays
]]></search>
<add><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, MAX(mostOn) AS mostOn, MAX(allOn) AS allOn, COUNT(date) AS numDays
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
'hits' => $row_months['hits'],
]]></search>
<add><![CDATA[
'all_members_online' => $row_months['allOn'],
'hits' => $row_months['hits'],
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, mostOn, hits
]]></search>
<add><![CDATA[
SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, mostOn, hits, allOn
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
'hits' => $row_days['hits']
]]></search>
<add><![CDATA[
'all_members_online' => $row_days['allOn'],
'hits' => $row_days['hits']
]]></add>
</operation>


<file name="$themedir/Stats.template.php">
<operation>
<search position="replace"><![CDATA[
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder" style="margin-bottom: 1ex;" id="stats">
<tr class="titlebg" valign="middle" align="center">
<td width="25%">', $txt['smf_stats_13'], '</td>
<td width="15%">', $txt['smf_stats_7'], '</td>
<td width="15%">', $txt['smf_stats_8'], '</td>
<td width="15%">', $txt['smf_stats_9'], '</td>
<td width="15%">', $txt['smf_stats_14'], '</td>';
]]></search>
<add><![CDATA[
<table border="0" width="100%" cellspacing="1" cellpadding="5" class="tborder" style="margin-bottom: 1ex;" id="stats">
<tr class="titlebg" valign="middle" align="center">
<td >', $txt['smf_stats_13'], '</td>
<td >', $txt['smf_stats_7'], '</td>
<td>', $txt['smf_stats_8'], '</td>
<td >', $txt['smf_stats_9'], '</td>
<td >', $txt['smf_stats_14'], '</td>
<td >', $txt['smf_stats_14bis'], '</td>';
]]></add>
</operation>

<search position="replace"><![CDATA[
<th align="left" width="25%">
<a name="', $month['id'], '" id="link_', $month['id'], '" href="', $month['href'], '" onclick="return expand_collapse(\'', $month['id'], '\', ', $month['num_days'], ');"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" id="img_', $month['id'], '" /> ', $month['month'], ' ', $month['year'], '</a>
</th>
<th align="center" width="15%">', $month['new_topics'], '</th>
<th align="center" width="15%">', $month['new_posts'], '</th>
<th align="center" width="15%">', $month['new_members'], '</th>
<th align="center" width="15%">', $month['most_members_online'], '</th>';
]]></search>
<add><![CDATA[
<th align="left" width="20%">
<a name="', $month['id'], '" id="link_', $month['id'], '" href="', $month['href'], '" onclick="return expand_collapse(\'', $month['id'], '\', ', $month['num_days'], ');"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" id="img_', $month['id'], '" /> ', $month['month'], ' ', $month['year'], '</a>
</th>
<th align="center" width="13%">', $month['new_topics'], '</th>
<th align="center" width="13%">', $month['new_posts'], '</th>
<th align="center" width="13%">', $month['new_members'], '</th>
<th align="center" width="13%">', $month['most_members_online'], '</th>
<th align="center" width="13%">', $month['all_members_online'], '</th>';
]]></add>
</operation>

<search position="replace"><![CDATA[
<tr class="windowbg2" valign="middle" align="left">
<td align="left" style="padding-left: 3ex;">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
<td align="center">', $day['new_topics'], '</td>
<td align="center">', $day['new_posts'], '</td>
<td align="center">', $day['new_members'], '</td>
<td align="center">', $day['most_members_online'], '</td>';
]]></search>
<add><![CDATA[
<tr class="windowbg" valign="middle" align="left">
<td align="left" style="padding-left: 3ex;">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
<td align="center">', $day['new_topics'], '</td>
<td align="center">', $day['new_posts'], '</td>
<td align="center">', $day['new_members'], '</td>
<td align="center">', $day['most_members_online'], '</td>
<td align="center">', $day['all_members_online'], '</td>';
]]></add>
</operation>

<search position="replace"><![CDATA[
"date",
"new_topics",
"new_posts",
"new_members",
"most_members_online",', empty($modSettings['hitStats']) ? '' : '
"hits",', '
]]></search>
<add><![CDATA[

          "date",
"new_topics",
"new_posts",
"new_members",
"most_members_online",', empty($modSettings['hitStats']) ? '' : '
"hits",
"all_members_online",]]></add>
</operation>

<file name="index.php">
<operation>
<search position="after"><![CDATA[
'boardrecount' => array('Admin.php', 'AdminBoardRecount'),
]]></search>
<add><![CDATA[
'chat' => array('Chat.php', 'Chat'),
'missio' => array('Missio.php', 'Missio'),
'rekisteriseloste' => array('Rekisteriseloste.php', 'Rekisteriseloste'),
]]></add>
</operation>


<file name="$sourcedir/Post.php">
<operation>
<search position="after"><![CDATA[
$post_errors[] = 'long_message';
]]></search>
<add><![CDATA[
if (isset($_POST['message']))
{
$smileyLimit = 3;

$prev = substr_count($_POST['message'], '[img') + substr_count($_POST['message'], '[IMG');
$tempmsg = doUBBC($_POST['message'], true);
if (substr_count($tempmsg, '<img') > ($prev + $smileyLimit))
$post_errors[] = 'smiley_limit';
}]]></add>
</operation>

<file name="$languagedir/index.finnish.php">
<operation>
<search position="replace"><![CDATA[
$txt['unread_topics_visit_none'] = 'Uusia viestej&auml; edellisen k&auml;yntisi j&auml;lkeen ei l&ouml;ytynyt.  <a href="' . $scripturl . '?action=unread;all">Klikkaa t&auml;st&auml; kokeillaksesi kaikkia lukemattomia viestej&auml;</a>.';
]]></search>
<add><![CDATA[
$txt['unread_topics_visit_none'] = 'Uusia viestejä edellisen k&auml;yntisi j&auml;lkeen ei l&ouml;ytynyt. Klikkaa <a href="' . $scripturl . '?action=unread;all"><b style="text-decoration:underline;color:red">t&auml;stä</b></a> kokeillaksesi kaikkia lukemattomia viestej&auml;.';
]]></add>
</operation>

<file name="$sourcedir/Subs.php">
<operation>
<search position="after"><![CDATA[
$code_to_from = array(
]]></search>
<add><![CDATA[
// Edit tag
'~\[edit\](.+?)\[/edit\]~i' => isset($disabled['edit']) ? '$1' : '<br /><br /><span style="font-size: xx-small; font-style:italic ">Muokkaus: $1</span>',
]]></add>
</operation>

<file name="$themedir/Post.template.php">
<operation>
<search position="after"><![CDATA[
'list' => array('code' => 'list', 'before' => '[list]\n[li]', 'after' => '[/li]\n[li][/li]\n[/list]', 'description' => $txt[261]),
]]></search>
<add><![CDATA[
// Edit tag
'edit' => array('code' => 'edit', 'before' => '[edit]', 'after' => '[/edit]', 'description' => 'Viestin muokkaus'),
]]></add>
</operation>

<file name="$languagedir/Modifications.finnish.php">
<operation>
<search position="replace"><![CDATA[
?>
]]></search>
<add><![CDATA[
$txt['error_smiley_limit'] = 'Suurin sallittu hymiömäärä viestiä kohden on kolme. Vähennä hymiöiden määrää ja yritä uudelleen.';
$txt['whoall_chat'] = 'Turisee <a href="' . $scripturl . '?action=chat">ch&auml;tiss&auml;</a>.';
$txt['whoall_missio'] = 'Katselee hoitajat.net <a href="' . $scripturl . '?action=missio">infoa</a>.';
$txt['whoall_rekisteriseloste'] = 'Lukee foorumin <a href="' . $scripturl . '?action=rekisteriseloste">rekisteriselostetta</a>.';
//OnLine Users Today
$txt['158bis'] = 'T&auml;n&auml;&auml;n paikalla olleet k&auml;ytt&auml;j&auml;t';
$txt['smf_stats_14bis'] = 'Päivän aikana vierailleita jäseniä';
?>
]]></add>
</operation>


Why PaMa gives modification parse error? What is wrong :(

Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Rik©

First your second question  ;D

Took a quick look at your code and found a little error...
Search for the next line in your modification.xml
"all_members_online",]]></add>

The ]]></add> should be on it's own line

Quote from: example modification file<!-- Add this text when we find it.  Note that it's on it's own line on purpose, and the CDATA keeps things clean. -->
         <add><![CDATA[
This is what to add.
]]></add>

Now your first question....
As far as i know you just use <install> in the package-info.xml....
Quote from: example modification file<!-- If you don't list a version, you can provide a version that will install on anything not listed. -->
   <install>
      <modification type="file">install.xml</modification>
   </install>

Greetz,
Rik©

Owdy

Quote from: Rik© on June 07, 2005, 04:20:47 PM


The ]]></add> should be on it's own line
Hmmm, are you sure. I think it dont have to be. Anyway, i tryed your way, no luck.


Quote
Now your first question....
As far as i know you just use <install> in the package-info.xml....
Ah, that was it. Thanks!
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

You're missing:

</file>
</modification>

At the end.

-[Unknown]

Owdy

#4
Darn, am i that blind. Thanks!!!

edit:
No, Test failure in first file. Checked that Boardindex code zillion times, its exactly the same as my workin .mod file. This isnt my day... Please tell me again why .xml is better that .mod?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

Did you try the test_modification.php from the Package SDK?

It's better because you can do more with it.  If what you want to do can be done with .mod, use that by all means.

-[Unknown]

Owdy

#6
Quote from: [Unknown] on June 07, 2005, 08:23:53 PM
Did you try the test_modification.php from the Package SDK?

Sweeet, i forgot that completely. Thanks!  :D

First question. install.xml
<file name="$sourcedir/BoardIndex.php">
<operation>
<search position="replace"><![CDATA[
// Load the users online right now.
]]></search>


Test_modification shows error, cant find:
// Load the users online right now\.

What is that '\.' ?
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

[Unknown]

It's adding it because of the .... you can ignore it.

-[Unknown]

Owdy

Okay, ignore then. I just dont understand why it wont find that. And many other things. Its same line what was in .mod file.

Current code:

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>Owdy:my own mods</id>
<version>1.0</version>

<file name="$sourcedir/BoardIndex.php">
<operation>
<search position="replace"><![CDATA[
// Load the users online right now.
]]></search>
<add><![CDATA[
// Load the users online today.
$forumtime = forum_time();
$midnight = ($forumtime) - (((date("H", $forumtime) + $modSettings['time_offset'])  * 3600) + (date("i", $forumtime) * 60) + (date("s", $forumtime)));

// Load the users online for the past 24 hours.
$result = db_query("
SELECT mem.ID_MEMBER, mem.realName, mem.memberName, mem.ID_GROUP, mem.showOnline, mem.avatar, mem.lastLogin, mem.posts, mg.onlineColor
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_GROUP))
WHERE mem.lastLogin >= '$midnight'
ORDER BY mem.lastLogin", __FILE__, __LINE__);

$today['users'] = array();
$today['num_users'] = 0;

$link = array();

while ($tmp = mysql_fetch_assoc($result))
{
$link []= '<a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '" style="color: ' . $tmp['onlineColor'] . ';">' . $tmp['realName'] . '</a>';
$today['num_users']++;
}

mysql_free_result($result);

$context['user_today'] = implode(', ', $link);
$context['num_users_today'] = $today['num_users'];

        trackStats(array('allOn' => $context['num_users_today']));

// Load the users online right now.


]]></add>
</operation>
</file>

<file name="$sourcedir/Stats.php">
<operation>
<search position="replace"><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, MAX(mostOn) AS mostOn, COUNT(date) AS numDays
]]></search>
<add><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, MAX(mostOn) AS mostOn, MAX(allOn) AS allOn, COUNT(date) AS numDays
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
'hits' => $row_months['hits'],
]]></search>
<add><![CDATA[
'all_members_online' => $row_months['allOn'],
'hits' => $row_months['hits'],
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, mostOn, hits
]]></search>
<add><![CDATA[
SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, mostOn, hits, allOn
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
'hits' => $row_days['hits']
]]></search>
<add><![CDATA[
'all_members_online' => $row_days['allOn'],
'hits' => $row_days['hits']
]]></add>
</operation>

</file>


<file name="$themedir/Stats.template.php">
<operation>
<search position="replace"><![CDATA[
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder" style="margin-bottom: 1ex;" id="stats">
<tr class="titlebg" valign="middle" align="center">
<td width="25%">', $txt['smf_stats_13'], '</td>
<td width="15%">', $txt['smf_stats_7'], '</td>
<td width="15%">', $txt['smf_stats_8'], '</td>
<td width="15%">', $txt['smf_stats_9'], '</td>
<td width="15%">', $txt['smf_stats_14'], '</td>';
]]></search>
<add><![CDATA[
<table border="0" width="100%" cellspacing="1" cellpadding="5" class="tborder" style="margin-bottom: 1ex;" id="stats">
<tr class="titlebg" valign="middle" align="center">
<td >', $txt['smf_stats_13'], '</td>
<td >', $txt['smf_stats_7'], '</td>
<td>', $txt['smf_stats_8'], '</td>
<td >', $txt['smf_stats_9'], '</td>
<td >', $txt['smf_stats_14'], '</td>
<td >', $txt['smf_stats_14bis'], '</td>';
]]></add>
</operation>

<search position="replace"><![CDATA[
<th align="left" width="25%">
<a name="', $month['id'], '" id="link_', $month['id'], '" href="', $month['href'], '" onclick="return expand_collapse(\'', $month['id'], '\', ', $month['num_days'], ');"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" id="img_', $month['id'], '" /> ', $month['month'], ' ', $month['year'], '</a>
</th>
<th align="center" width="15%">', $month['new_topics'], '</th>
<th align="center" width="15%">', $month['new_posts'], '</th>
<th align="center" width="15%">', $month['new_members'], '</th>
<th align="center" width="15%">', $month['most_members_online'], '</th>';
]]></search>
<add><![CDATA[
<th align="left" width="20%">
<a name="', $month['id'], '" id="link_', $month['id'], '" href="', $month['href'], '" onclick="return expand_collapse(\'', $month['id'], '\', ', $month['num_days'], ');"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" id="img_', $month['id'], '" /> ', $month['month'], ' ', $month['year'], '</a>
</th>
<th align="center" width="13%">', $month['new_topics'], '</th>
<th align="center" width="13%">', $month['new_posts'], '</th>
<th align="center" width="13%">', $month['new_members'], '</th>
<th align="center" width="13%">', $month['most_members_online'], '</th>
<th align="center" width="13%">', $month['all_members_online'], '</th>';
]]></add>
</operation>

<search position="replace"><![CDATA[
<tr class="windowbg2" valign="middle" align="left">
<td align="left" style="padding-left: 3ex;">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
<td align="center">', $day['new_topics'], '</td>
<td align="center">', $day['new_posts'], '</td>
<td align="center">', $day['new_members'], '</td>
<td align="center">', $day['most_members_online'], '</td>';
]]></search>
<add><![CDATA[
<tr class="windowbg" valign="middle" align="left">
<td align="left" style="padding-left: 3ex;">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
<td align="center">', $day['new_topics'], '</td>
<td align="center">', $day['new_posts'], '</td>
<td align="center">', $day['new_members'], '</td>
<td align="center">', $day['most_members_online'], '</td>
<td align="center">', $day['all_members_online'], '</td>';
]]></add>
</operation>

<search position="replace"><![CDATA[
"date",
"new_topics",
"new_posts",
"new_members",
"most_members_online",', empty($modSettings['hitStats']) ? '' : '
"hits",', '
]]></search>
<add><![CDATA[

          "date",
"new_topics",
"new_posts",
"new_members",
"most_members_online",', empty($modSettings['hitStats']) ? '' : '
"hits",
"all_members_online",
]]></add>
</operation>
</file>
<file name="index.php">
<operation>
<search position="after"><![CDATA[
'boardrecount' => array('Admin.php', 'AdminBoardRecount'),
]]></search>
<add><![CDATA[
'chat' => array('Chat.php', 'Chat'),
'missio' => array('Missio.php', 'Missio'),
'rekisteriseloste' => array('Rekisteriseloste.php', 'Rekisteriseloste'),
]]></add>
</operation>

</file>
<file name="$sourcedir/Post.php">
<operation>
<search position="after"><![CDATA[
$post_errors[] = 'long_message';
]]></search>
<add><![CDATA[
if (isset($_POST['message']))
{
$smileyLimit = 3;

$prev = substr_count($_POST['message'], '[img') + substr_count($_POST['message'], '[IMG');
$tempmsg = doUBBC($_POST['message'], true);
if (substr_count($tempmsg, '<img') > ($prev + $smileyLimit))
$post_errors[] = 'smiley_limit';
}]]></add>
</operation>
</file>


<file name="$sourcedir/Subs.php">
<operation>
<search position="after"><![CDATA[
$code_to_from = array(
]]></search>
<add><![CDATA[
// Edit tag
'~\[edit\](.+?)\[/edit\]~i' => isset($disabled['edit']) ? '$1' : '<br /><br /><span style="font-size: xx-small; font-style:italic ">Muokkaus: $1</span>',
]]></add>
</operation>
</file>

<file name="$themedir/Post.template.php">
<operation>
<search position="after"><![CDATA[
'list' => array('code' => 'list', 'before' => '[list]\n[li]', 'after' => '[/li]\n[li][/li]\n[/list]', 'description' => $txt[261]),
]]></search>
<add><![CDATA[
// Edit tag
'edit' => array('code' => 'edit', 'before' => '[edit]', 'after' => '[/edit]', 'description' => 'Viestin muokkaus'),
]]></add>
</operation>
</file>


<file name="$languagedir/index.finnish.php">
<operation>
<search position="replace"><![CDATA[
$txt['unread_topics_visit_none'] = 'Uusia viestej&auml; edellisen k&auml;yntisi j&auml;lkeen ei l&ouml;ytynyt.  <a href="' . $scripturl . '?action=unread;all">Klikkaa t&auml;st&auml; kokeillaksesi kaikkia lukemattomia viestej&auml;</a>.';
]]></search>
<add><![CDATA[
$txt['unread_topics_visit_none'] = 'Uusia viestejä edellisen k&auml;yntisi j&auml;lkeen ei l&ouml;ytynyt. Klikkaa <a href="' . $scripturl . '?action=unread;all"><b style="text-decoration:underline;color:red">t&auml;stä</b></a> kokeillaksesi kaikkia lukemattomia viestej&auml;.';
]]></add>
</operation>
</file>


<file name="$languagedir/Modifications.finnish.php">
<operation>
<search position="replace"><![CDATA[
?>
]]></search>
<add><![CDATA[
$txt['error_smiley_limit'] = 'Suurin sallittu hymiömäärä viestiä kohden on kolme. Vähennä hymiöiden määrää ja yritä uudelleen.';
$txt['whoall_chat'] = 'Turisee <a href="' . $scripturl . '?action=chat">ch&auml;tiss&auml;</a>.';
$txt['whoall_missio'] = 'Katselee hoitajat.net <a href="' . $scripturl . '?action=missio">infoa</a>.';
$txt['whoall_rekisteriseloste'] = 'Lukee foorumin <a href="' . $scripturl . '?action=rekisteriseloste">rekisteriselostetta</a>.';
//OnLine Users Today
$txt['158bis'] = 'T&auml;n&auml;&auml;n paikalla olleet k&auml;ytt&auml;j&auml;t';
$txt['smf_stats_14bis'] = 'Päivän aikana vierailleita jäseniä';
?>
]]></add>
</operation>
</file>

</modification>


Only thing works is that index.finnish part. I dont get this.  :(
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rudoka

Here's how I wrote my own mod using the .xml type

Write a separate xml file for every file you are modifying, and include it in it's own package. That way you have more chances to see where you have the issues. OR if you have eveyrwhere you can work on them one by one.

  But let me explain myself better.
  For example, the modifications for the BoardIndex.php you could put in one file and name it BoardIndex.xml. This you include in a separate package-info.xml file. This way you have a package just just for modifying that one file. Try to open it with the PaMa, and install it (on a test forum).
  The same with every other file you modify. In the end you will have a couple of file whcih you can simply include in one package by installing them in consecutive <install> commands in the package-info.xml. Or you can merge them together when you know everything is fine.

   This is how I worked my mod, and was definitely easier to see my errors, or what wasn't working where. Now, I know this does not answer your problems but you can try working this way.
   Right now I don't have time to  look at the code more seriously, but a few hours later I come back and I'll spend some time with it. It is a good way to learn for me too. ;)


Rudolf

Owdy

The test_modification.php shows where errors are, i just don understand why it wont find lines i ad.
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rudoka

Right, there is the test_modification.php too. I haven't used it before, but now I tested it myself.

There are some errors, as you could already notice.   ;)
Here is the first error:

<search position="replace"><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, MAX(mostOn) AS mostOn, COUNT(date) AS numDays
]]></search>


Replace it with:
<search position="replace"><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts, MAX(mostOn) AS mostOn, COUNT(date) AS numDays
]]></search>


First problem is that in the first code the data to search is the sql queryline + \n + 5 tabs.
In my Stat.php there are only two tabs in the next line. Anyway the way I suggest will search only  for that one line + \n characater. Should do the trick.
But, it also seems that you have some mod installed, because in my original Stat.php, the sqlquery line looks like this:
SELECT
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts,
MAX(mostOn) AS mostOn

I have no COUNT(date) AS numDays and the MAX(mostOn) AS mostOn it's on a new line. If I delete from the mod the first one and send the second one on the next line then it is OK. So it seems that there is a conflict with some other mod. Plus the white space issue again.
Pretty messed up situation, as I see it.

A quick look at the other errosr says to me that the problem is the same with all.

Rudolf

Owdy

QuotePretty messed up situation, as I see it.

I run SMF 1.1, so i have totally differend code. ;) All my mods are in that file. Those lines work perfectly in .mod file, so its not tabs or else. But thanks for trying to help.   :)
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rudoka

   Here is my modification of the code, there is no error whatsoever in this. But you must consider the fact that it's based on SMF 1.0.3 without modifications. Just the very basic default original code.  :)
   You will have to adapt to the 1.0.4, or 1.1.

  I can't seem to attach the file, probably I don't have the permission. So I had to paste here.
  Take a good look at the code, especially notice that I moved the ]]</search> parts in the beginning of the line. I think it would be a good practice if you put it so, always.
  Later in the code there were some tabs missing from the front of the lines, and some tabs in plus after the CDATA[[. All whitespace problems.



<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>Owdy:owdymod</id>
<version>1.0</version>

<file name="$sourcedir/BoardIndex.php">
<operation>
<search position="replace"><![CDATA[
// Load the users online right now.
]]></search>
<add><![CDATA[
// Load the users online today.
$forumtime = forum_time();
$midnight = ($forumtime) - (((date("H", $forumtime) + $modSettings['time_offset'])  * 3600) + (date("i", $forumtime) * 60) + (date("s", $forumtime)));

// Load the users online for the past 24 hours.
$result = db_query("
SELECT mem.ID_MEMBER, mem.realName, mem.memberName, mem.ID_GROUP, mem.showOnline, mem.avatar, mem.lastLogin, mem.posts, mg.onlineColor
FROM {$db_prefix}members AS mem
LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = mem.ID_GROUP OR (mem.ID_GROUP = 0 AND mg.ID_GROUP = mem.ID_POST_GROUP))
WHERE mem.lastLogin >= '$midnight'
ORDER BY mem.lastLogin", __FILE__, __LINE__);

$today['users'] = array();
$today['num_users'] = 0;

$link = array();

while ($tmp = mysql_fetch_assoc($result))
{
$link []= '<a href="' . $scripturl . '?action=profile;u=' . $tmp['ID_MEMBER'] . '" style="color: ' . $tmp['onlineColor'] . ';">' . $tmp['realName'] . '</a>';
$today['num_users']++;
}

mysql_free_result($result);

$context['user_today'] = implode(', ', $link);
$context['num_users_today'] = $today['num_users'];

        trackStats(array('allOn' => $context['num_users_today']));

// Load the users online right now.


]]></add>
</operation>
</file>

<file name="$sourcedir/Stats.php">
<operation>
<search position="replace"><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts,
MAX(mostOn) AS mostOn
]]></search>
<add><![CDATA[
YEAR(date) AS stats_year, MONTH(date) AS stats_month, SUM(hits) AS hits, SUM(registers) AS registers, SUM(topics) AS topics, SUM(posts) AS posts,
MAX(mostOn) AS mostOn, MAX(allOn) AS allOn, COUNT(date) AS numDays
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
'hits' => $row_months['hits'],
]]></search>
<add><![CDATA[
'all_members_online' => $row_months['allOn'],
'hits' => $row_months['hits'],
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, mostOn, hits
]]></search>
<add><![CDATA[
SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, mostOn, hits, allOn
]]></add>
</operation>

<operation>
<search position="replace"><![CDATA[
'hits' => $row_days['hits']
]]></search>
<add><![CDATA[
'all_members_online' => $row_days['allOn'],
'hits' => $row_days['hits']
]]></add>
</operation>

</file>


<file name="$themedir/Stats.template.php">
<operation>
<search position="replace"><![CDATA[
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder" style="margin-bottom: 1ex;" id="stats">
<tr class="titlebg" valign="middle" align="center">
<td width="25%">', $txt['smf_stats_13'], '</td>
<td width="15%">', $txt['smf_stats_7'], '</td>
<td width="15%">', $txt['smf_stats_8'], '</td>
<td width="15%">', $txt['smf_stats_9'], '</td>
<td width="15%">', $txt['smf_stats_14'], '</td>';
]]></search>
<add><![CDATA[
<table border="0" width="100%" cellspacing="1" cellpadding="5" class="tborder" style="margin-bottom: 1ex;" id="stats">
<tr class="titlebg" valign="middle" align="center">
<td >', $txt['smf_stats_13'], '</td>
<td >', $txt['smf_stats_7'], '</td>
<td>', $txt['smf_stats_8'], '</td>
<td >', $txt['smf_stats_9'], '</td>
<td >', $txt['smf_stats_14'], '</td>
<td >', $txt['smf_stats_14bis'], '</td>';
]]></add>
</operation>

<search position="replace"><![CDATA[
<th align="left" width="25%">
<a name="', $month['id'], '" id="link_', $month['id'], '" href="', $month['href'], '" onclick="return expand_collapse(\'', $month['id'], '\', ', $month['num_days'], ');"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" id="img_', $month['id'], '" /> ', $month['month'], ' ', $month['year'], '</a>
</th>
<th align="center" width="15%">', $month['new_topics'], '</th>
<th align="center" width="15%">', $month['new_posts'], '</th>
<th align="center" width="15%">', $month['new_members'], '</th>
<th align="center" width="15%">', $month['most_members_online'], '</th>';
]]></search>
<add><![CDATA[
<th align="left" width="20%">
<a name="', $month['id'], '" id="link_', $month['id'], '" href="', $month['href'], '" onclick="return expand_collapse(\'', $month['id'], '\', ', $month['num_days'], ');"><img src="', $settings['images_url'], '/', $month['expanded'] ? 'collapse.gif' : 'expand.gif', '" alt="" border="0" id="img_', $month['id'], '" /> ', $month['month'], ' ', $month['year'], '</a>
</th>
<th align="center" width="13%">', $month['new_topics'], '</th>
<th align="center" width="13%">', $month['new_posts'], '</th>
<th align="center" width="13%">', $month['new_members'], '</th>
<th align="center" width="13%">', $month['most_members_online'], '</th>
<th align="center" width="13%">', $month['all_members_online'], '</th>';
]]></add>
</operation>

<search position="replace"><![CDATA[
<tr class="windowbg2" valign="middle" align="left">
<td align="left" style="padding-left: 3ex;">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
<td align="center">', $day['new_topics'], '</td>
<td align="center">', $day['new_posts'], '</td>
<td align="center">', $day['new_members'], '</td>
<td align="center">', $day['most_members_online'], '</td>';
]]></search>
<add><![CDATA[
<tr class="windowbg" valign="middle" align="left">
<td align="left" style="padding-left: 3ex;">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>
<td align="center">', $day['new_topics'], '</td>
<td align="center">', $day['new_posts'], '</td>
<td align="center">', $day['new_members'], '</td>
<td align="center">', $day['most_members_online'], '</td>
<td align="center">', $day['all_members_online'], '</td>';
]]></add>
</operation>

<search position="replace"><![CDATA[
"date",
"new_topics",
"new_posts",
"new_members",
"most_members_online",', empty($modSettings['hitStats']) ? '' : '
"hits",', '
]]></search>
<add><![CDATA[

          "date",
"new_topics",
"new_posts",
"new_members",
"most_members_online",', empty($modSettings['hitStats']) ? '' : '
"hits",
"all_members_online",
]]></add>
</operation>
</file>
<file name="index.php">
<operation>
<search position="after"><![CDATA[
'boardrecount' => array('Admin.php', 'AdminBoardRecount'),
]]></search>
<add><![CDATA[
'chat' => array('Chat.php', 'Chat'),
'missio' => array('Missio.php', 'Missio'),
'rekisteriseloste' => array('Rekisteriseloste.php', 'Rekisteriseloste'),
]]></add>
</operation>

</file>
<file name="$sourcedir/Post.php">
<operation>
<search position="after"><![CDATA[
$post_errors[] = 'long_message';
]]></search>
<add><![CDATA[
if (isset($_POST['message']))
{
$smileyLimit = 3;

$prev = substr_count($_POST['message'], '[img') + substr_count($_POST['message'], '[IMG');
$tempmsg = doUBBC($_POST['message'], true);
if (substr_count($tempmsg, '<img') > ($prev + $smileyLimit))
$post_errors[] = 'smiley_limit';
}]]></add>
</operation>
</file>


<file name="$sourcedir/Subs.php">
<operation>
<search position="after"><![CDATA[
$code_to_from = array(
]]></search>
<add><![CDATA[
// Edit tag
'~\[edit\](.+?)\[/edit\]~i' => isset($disabled['edit']) ? '$1' : '<br /><br /><span style="font-size: xx-small; font-style:italic ">Muokkaus: $1</span>',
]]></add>
</operation>
</file>

<file name="$themedir/Post.template.php">
<operation>
<search position="after"><![CDATA[
'list' => array('code' => 'list', 'before' => '[list]\n[li]', 'after' => '[/li]\n[li][/li]\n[/list]', 'description' => $txt[261]),
]]></search>
<add><![CDATA[
// Edit tag
'edit' => array('code' => 'edit', 'before' => '[edit]', 'after' => '[/edit]', 'description' => 'Viestin muokkaus'),
]]></add>
</operation>
</file>


<file name="$languagedir/index.finnish.php">
<operation>
<search position="replace"><![CDATA[
$txt['unread_topics_visit_none'] = 'Uusia viestej&auml; edellisen k&auml;yntisi j&auml;lkeen ei l&ouml;ytynyt.  <a href="' . $scripturl . '?action=unread;all">Klikkaa t&auml;st&auml; kokeillaksesi kaikkia lukemattomia viestej&auml;</a>.';
]]></search>
<add><![CDATA[
$txt['unread_topics_visit_none'] = 'Uusia viestejä edellisen k&auml;yntisi j&auml;lkeen ei l&ouml;ytynyt. Klikkaa <a href="' . $scripturl . '?action=unread;all"><b style="text-decoration:underline;color:red">t&auml;stä</b></a> kokeillaksesi kaikkia lukemattomia viestej&auml;.';
]]></add>
</operation>
</file>


<file name="$languagedir/Modifications.finnish.php">
<operation>
<search position="replace"><![CDATA[
?>
]]></search>
<add><![CDATA[
$txt['error_smiley_limit'] = 'Suurin sallittu hymiömäärä viestiä kohden on kolme. Vähennä hymiöiden määrää ja yritä uudelleen.';
$txt['whoall_chat'] = 'Turisee <a href="' . $scripturl . '?action=chat">ch&auml;tiss&auml;</a>.';
$txt['whoall_missio'] = 'Katselee hoitajat.net <a href="' . $scripturl . '?action=missio">infoa</a>.';
$txt['whoall_rekisteriseloste'] = 'Lukee foorumin <a href="' . $scripturl . '?action=rekisteriseloste">rekisteriselostetta</a>.';
//OnLine Users Today
$txt['158bis'] = 'T&auml;n&auml;&auml;n paikalla olleet k&auml;ytt&auml;j&auml;t';
$txt['smf_stats_14bis'] = 'Päivän aikana vierailleita jäseniä';
?>
]]></add>
</operation>
</file>

</modification>


Rudolf

Owdy

Like i sayd, i have totally differend code. It isnt helping.
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rudoka

Quote from: Owdy on June 08, 2005, 01:03:02 PM
I run SMF 1.1, so i have totally differend code. ;) All my mods are in that file. Those lines work perfectly in .mod file, so its not tabs or else. But thanks for trying to help.   :)

So it turns out that the code is not that much different.
I solved all the problems (excpet one) by deleting the tabs from the <search> tags. Really. I just inserted some tabs  (the TAB key ;)) or deleted where I saw they are in plus.
   Maybe the 1.1 code is tabbed differently, but the code itself is pretty much the same as it is in 1.0.3. (In the places you're trying to modify!!)
Believe me or not, it is tabs!

Rudolf

rudoka

Ok ok, sorry for being stubborn.

Could you send me just the files you're trying to modify from the 1.1?
Hope I don't get the admins angry. Just the Stats.php for example. Surely I won't be able to upgrade my 1.0.4 with that one.
Just to see what's up.

If not ... well, then they should be helping you.

Rudolf

Owdy

Quote from: rudoka on June 08, 2005, 01:11:43 PM
Could you send me just the files you're trying to modify from the 1.1?
Sorry, but no. I have to deal this by my self.

I have to try it and triple check it later. I just dont understand why it is in tabs if .mod file work perfectly. Maybe im just too blind again ;D

Thanks
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

rudoka

As you wish.
That part with why the .mod works I don't understand either.

I wish you good luck,
Rudolf

Owdy

Yeah, this isnt big deal course .mod file works. I have time ;)
Former Lead Support Specialist

Tarvitsetko apua SMF foorumisi kanssa? Otan työtehtäviä vastaan, lue:http://www.simplemachines.org/community/index.php?topic=375918.0

Advertisement: