Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: [Unknown] on November 22, 2004, 03:26:37 AM

Title: Package SDK, anyone?
Post by: [Unknown] on November 22, 2004, 03:26:37 AM
More information can be found in the Package SDK: modification.xml (http://www.simplemachines.org/community/index.php?topic=299670.0) and Package SDK: package-info.xml (http://www.simplemachines.org/community/index.php?topic=299669.0) topics.


I understand that a lot of people would like to learn to write packages.  We're still working on documentation, but here's a bit that should at least help you get an idea for it.  Comments are very welcome - and if anyone wants to contribute more to it, please just click reply ;) .

The only notes I should make is that, one, this is for package *authors*, and two the included "test_modification.php" must be uploaded or run on your local webserver.

Thanks,
-[Unknown]
Title: Re: Package SDK, anyone?
Post by: Jerry on November 22, 2004, 03:49:26 AM
I think these are great tutorials :), I will have to take a better look at them tommorow afternoon geting late here :P
Title: Re: Package SDK, anyone?
Post by: Kirby on December 07, 2004, 06:05:04 PM
Hmm... thanks.
Title: Re: Package SDK, anyone?
Post by: OvermindDL1 on December 07, 2004, 09:14:59 PM
Yes, useful, but missing one things, it does not describe how to add files like pictures and such by using the xml file, I know how to do it by mod file, but what about xml?
Title: Re: Package SDK, anyone?
Post by: Jerry on December 07, 2004, 09:28:22 PM
I think you do it the same way as a mod file .tar.gz it with instructions for the package manager lol ;)
Title: Re: Package SDK, anyone?
Post by: OvermindDL1 on December 07, 2004, 09:59:13 PM
Not that, as stated above, what if I included some graphic files, how do I get the forum to store them from the archive to where I want it to place them?
Title: Re: Package SDK, anyone?
Post by: [Unknown] on December 07, 2004, 10:06:45 PM
Not that, as stated above, what if I included some graphic files, how do I get the forum to store them from the archive to where I want it to place them?

This is covered.... look in the avatars section, and just use the same method, except put them elsewhere.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: OvermindDL1 on December 08, 2004, 12:18:35 AM
Not section dependent, perhaps I should have spent more then a few minutes looking at it (get past the mod section)....
Title: Re: Package SDK, anyone?
Post by: purplepaisley68 on December 19, 2004, 08:54:22 AM
Does anyone have a windows method (that works) of creating gzip archives? I tried a few (Ultimate zip for one) that were mentioned in other threads but I couldn't get them to work, and uploading files to  server to gzip and download to test, editing making changes and redoing this is tedious and time consuming.
Title: Re: Package SDK, anyone?
Post by: [Unknown] on December 19, 2004, 08:55:48 AM
You can use zip files with the package manager as of RC1 or RC2... gzips can be created by several programs, such as TUGZip. (www.tugzip.com)

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: Jerry on December 19, 2004, 08:55:48 AM
http://www.akjerry.com/ezgz.zip
Thats what I use, I cant find the name, and don't use it often enough to find the name. ..  but it works fairly well :)
Title: Re: Package SDK, anyone?
Post by: Kirby on December 19, 2004, 12:34:30 PM
I use PowerArchiver 2004... works like a charm :)
EDIT: just tried TUGzip and I must say it is better than any archiver ive seen :P
Title: Re: Package SDK, anyone?
Post by: purplepaisley68 on December 22, 2004, 09:50:54 AM
Thanks for the tips. :)
Title: Re: Package SDK, anyone?
Post by: OvermindDL1 on December 23, 2004, 01:19:47 AM
www.7zip.com works perfectly for me, supports tar, gzip, zip, 7z, rar, ace, cab, etc... etc...
Title: Re: Package SDK, anyone?
Post by: Meriadoc on December 25, 2004, 09:42:28 PM
position="before|after|replace|end"

now, if I say before, will that <add> the code I want before what I searched for (logically in coding thought) or will what I searched for be before what I <add> (linguistically logical ;))?
Title: Re: Package SDK, anyone?
Post by: [Unknown] on December 26, 2004, 02:03:34 AM
You could have this:

search position="before"
add
search position="after"

So, linguistically.  You're just used to boardmod :P.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: Meriadoc on December 26, 2004, 02:22:54 AM
don't think i ever used boardmod... but thanks
Title: Re: Package SDK, anyone?
Post by: CapriSkye on January 01, 2005, 12:20:29 AM
im having trouble to get a simple mod package to work. i used the test modification file, and it says
The file you uploaded was parsed and the following results were returned.
then no error message. and when i tried to install it on local server, it says Modification parse error.
i looked at the syntax twice and just can't find any error  :D
the package i was testing on can be found here: http://open.38.com/personal/colorize.zip
any idea? thanks
Title: Re: Package SDK, anyone?
Post by: [Unknown] on January 02, 2005, 02:25:38 AM
404?  The test_modification.php file is meant to deal directly with .mod or .xml modification files, not with whole packages.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: CapriSkye on January 02, 2005, 03:03:58 AM
that'd be the reason, thanks unknown.

just a note, even slightest extra space would make the test fail, why? i thought space doesn't matter....
Title: Re: Package SDK, anyone?
Post by: EG on January 02, 2005, 12:00:09 PM
when I upload two simple Boardmods Ive made, just for things Ive changed on my forum,... to my testforum... it says this

Quote
Type Action                                                               Description
1      Execute Modification ./Sources/MoveTopic.php Failure

but if I click Proceed the mod works anyway :-\

why does it say Failure ?
Title: Re: Package SDK, anyone?
Post by: [Unknown] on January 02, 2005, 03:16:23 PM
when I upload two simple Boardmods Ive made, just for things Ive changed on my forum,... to my testforum... it says this

Quote
Type Action                                                               Description
1      Execute Modification ./Sources/MoveTopic.php Failure

but if I click Proceed the mod works anyway :-\

why does it say Failure ?

It may "works anyway", but it didn't make those changes because it failed.  Use the test_modification.php script for more detail.

Whitespace matters when CHANGING files, because you have to find what to change.  Whitespace only doesn't matter when actually RUNNING the PHP.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: EG on January 02, 2005, 09:43:09 PM
ok thanks,
thing is, it actually said failure, before it runs the mod...

it says failure when you upload the mod.. and then it gives the list of files its going to alter

on the really simple mod I wrote, it worked anyway, after clicking proceed

but on the more complicated one, it didnt :-\

how do you use test_modification.php ?

is there a readme file about it ?
Title: Re: Package SDK, anyone?
Post by: CapriSkye on January 02, 2005, 11:00:00 PM
you'll have to put test_modification.php on your server, or your local test forum
i put it under smf's home directory, and just call it like http://localhost/test_modification.php
Title: Re: Package SDK, anyone?
Post by: EG on January 05, 2005, 07:15:23 PM
RAH!

just worked out why sometimes they fail and sometimes they dont, when the search script itself is exactly the same, even when copy and pasting.

its all to do with spaces at the beginning of the line!

ok... Im stupid... but just thought Id pass this information on..

oh... and yeah

After in Board Mod = before in SDK Package..
Title: Re: Package SDK, anyone?
Post by: Jim Yarbro on January 10, 2005, 01:46:08 AM
Hey [Unknown] just a thought... It would probably be helpful if the package SDK included a index.php file for the main package folder with instructions on it to add the user's package server to their website. The person USING the SDK already knows how to because of the readme info, but anyone who tries to download the packages usually just get lost.

or at least, thast the problem I had till I created the index.html file at http://nrrds.com/packages/
Title: Re: Package SDK, anyone?
Post by: [Unknown] on January 10, 2005, 03:14:55 AM
People without url_fopen or with safe mode will just get redirected there, unable to download your packages.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: Jim Yarbro on January 10, 2005, 01:21:05 PM
interesting. so i should delete my index file then?
Title: Re: Package SDK, anyone?
Post by: [Unknown] on January 10, 2005, 07:24:36 PM
Well, the URL will look something like:

index.php?package-list&referer=http://someonesforum.com/

So, you could just see if $_GET['package-list'] is set.  Mind you, this is all from memory.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: [Unknown] on January 11, 2005, 04:43:26 AM
Everyone should read this about why xml packages are better than boardmod, if you need them:

http://www.simplemachines.org/community/index.php?topic=24009.0
(assuming they work as designed, they have had testing but I'll admit not as much as I wanted.)

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: Jim Yarbro on January 11, 2005, 08:08:10 AM
yeah thats part of why im moving all my mods to packages instead of the mod site stuff. Trying to get as much testing in as possible. I think better docs would be helpful too.

btw why do we have that modsite if the package manager works?
Title: Re: Package SDK, anyone?
Post by: Jerry on January 11, 2005, 06:58:07 PM
People would be lost without it ;)
Title: Re: Package SDK, anyone?
Post by: [Unknown] on January 11, 2005, 07:08:01 PM
You can browse the mod site with your package manager.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: Jerry on January 11, 2005, 07:23:22 PM
I just noticed, checked while I was posting. Nice edition :)
Title: Re: Package SDK, anyone?
Post by: Jim Yarbro on January 12, 2005, 04:13:59 AM
So is anyone working on the modsite? Cuz I'm not. I was gonna but my opinions seem to differ too greatly from the development team over what needs to happen with that page. Besides I got my own mods to work on. The music mod is getting kinda popular now and I have a lot of things I need to add to it.
Title: Re: Package SDK, anyone?
Post by: Louis (CSpotkill) on March 05, 2005, 08:32:41 PM
Took me awhile to find this darn SDK, but I'm glad I did :)

Anyway, I was just about to release a mod on my own package server, but as I was setting up the package server, I noticed an error in the packages_advanced.xml file:

Code: [Select]
<default-website title="My Website">http://www.mywebsite.tld/</default-author>
This should obviously be:
Code: [Select]
<default-website title="My Website">http://www.mywebsite.tld/</default-website>
Just a small copy/paste error, easily fixed :)

Edit: Also, you should probably use the example domains (example.com|example.net|example.org) since they were created for examples in technical documentation ;)
Title: Re: Package SDK, anyone?
Post by: [Unknown] on March 13, 2005, 07:42:54 PM
Fixed, I should probably update the first post soon.

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: Jim Yarbro on March 14, 2005, 08:13:15 AM
you may also want to add something about this package thing to the news rotator thinger up at the top of the page.
Title: Re: Package SDK, anyone?
Post by: Herman's Mixen on April 24, 2005, 11:36:00 AM
Fatal error: Call to a member function on a non-object in /home/httpd/burglar.pointclark.net/forum/Sources/PackageGet.php on line 210

i get this error when i go true my package-manager browse packages ??
Title: Re: Package SDK, anyone?
Post by: Herman's Mixen on April 25, 2005, 11:59:48 AM
it works now i gues... but for some strange reason i cant actually myself on my own package server !! it gives an error but when i go true an other domain where is smf also installed and goes true the package manager and browse true my server it seems to work ?? is here some kinda solution for ?
Title: Re: Package SDK, anyone?
Post by: Herman's Mixen on May 04, 2005, 02:51:37 PM
this is solved now !
Title: Re: Package SDK, anyone?
Post by: AtariKid on May 26, 2005, 12:37:19 AM
Flag to: AtariKid, nwowatcher

Ha!  Flagged myself and a buddy for future reference.   :P

- noteworthy
Title: Re: Package SDK, anyone?
Post by: rudoka on June 02, 2005, 01:57:49 PM
   OK, so I am thinking on writing a package, and I ended up here.
   
   Unfortunately there are very few things on the forum about how to actually write a package or modification. Really, nothing specific.
    While this is a very good start and surely helpful on getting an idea of what a package is, I'm not sure it can help anyone write a complete package (from the scratch).

    Take me, for example. I thought that I did a fairly simple modifications, yet reading this *basic* SDK I can't even start to put my package together.
    Now, maybe I'm being a bit slow, and I the intent behind my criticism is to be constructive.

    So, here are my questions about packaging, with some ideas to include in the SDK. ;)

    First, my veyr first issue was how to modify the database, alter a table in it. I think there are quite  afew mods that add, alter tables in the databes. So it seems it's a quite basic part of a packaging.
    After looking at some already written mods, I found a tag <code> in the package-info.xml.  This is something that is never mentioned in the SDK, and doesn't appears nowhere in the examples. I think it would be a good idea to add it to the SDK, with some explanation on what it does.  (I know that I have to use this to alter the database ;))

    The next issue, would be with the themes, avatars and such. Mainly the themes. My mod is relying mainly on creating a theme. At least half of my modification can be done using a theme, and modifying only one template.
    My question follows. The  <require-file>  just copies the file to the destination or it installs the theme too? Because it seems that simply creating a folder and copying files in the thmees directory doesn't makes the SMF to "see" it as such. It needs to be installed by the SMF, from the admin section.
    So it's not clear to me what is happening there. How can I effecively add (NOT to replace the default!) a theme?

 
    The third issue, regards the uninstallation. I saw someone mentioning the changings to be reverseable or not. So how can I tell what is "reverseable" and what is not? Knowing a little more on how the uninstallation works, what happens then would be helpful I think.
    Of course following the reveresed logic, I suppsoe that if I search for A and replace with B, then at uninstallation the package system would search for B and replace with A. OK, the same with adding code.
    But let's get back to the database. What if I alter a table in database, with an ALTER query. I guess I should write a "cleanup" code for this.
    So, I think that at least some warnings should be issued about uninstallation already in the basic SDK. And who knows some advanced explanations would not hurt either, maybe in some *advanced* version.


    I refer back to what [Unknown] said in the first post. That this is for package *authors*. Even if I unerstand that "author" is meant as every average joe (making the modding accessible to everyone out there), the a Develompent Kit should be more inclusive.

   As a last thing, before everyone jumps on me. I understand that this is a preliminary version, put together in a hurry(maybe not?), and also understand that it takes time to do such thing.
   So really, I just tried to point out the areas where I'm in difficulty writing the package, and what info could help me (and others) to have an easier job.
   Of course, I do search around and use my head. ;) I wouldn't know what to complain about, if not.  :-\

Respectfully,
Rudolf
Title: Re: Package SDK, anyone?
Post by: Rik© on June 02, 2005, 04:35:17 PM
Well... if you take a good look at the sample package-info.xml and the package-info_advanced.xml you can see a line with the <code> tag.
Quote from: package-info.xml
   <!-- Installation, the key part of this file. -->
   <install>
      <readme>readme.txt</readme>
      <modification>install.xml</modification>
      <code>add_settings.php</code>
   </install>
And the (example) add_settings.php drops the data into your database....
All can be found in the SDK

Uninstalling the settings/data from the database is not mentioned in the SDK though...

But i know that if you ask for help with your package you will get it asap from [unknown] or SMF (staff-)members

Title: Re: Package SDK, anyone?
Post by: rudoka on June 02, 2005, 04:45:54 PM
oops  :-X
Somehow I missed that one. And the add_setting.php too. Somehow didn't suggested me the name of databases.
I guess I was a little too hasty. My fault.

Still, some explanations on the tags would be handy. Eve if it's a one liner. Just for the folks to know what is what. Maybe a quick-reference in the end?
I still don't know how could I miss that one?  ??? After I saw in one mod I looked carefully the SDK ... and saw nothing.  :'(

Anyway, If things go straight, maybe I can put together my package in the course of this week. Maybe an 0.1 alfa version? haha

Phew, thanks a lot for opening my eyes.  :)

Rudolf
Title: Re: Package SDK, anyone?
Post by: [Unknown] on June 03, 2005, 03:30:14 AM
Packages should also not be used to install themes...

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: rudoka on June 03, 2005, 11:22:53 AM
So, how do I install a theme?
I mean the package it's ready, everything works fine, installs and uninstalls perfectly (on a clean SMF), but it requires that the Display.template.php to be modified for the "thing" to be visible..
  I have two options here. One is to modify the default template file, through the modification.
  The second is to create a new theme, with this file.

  Obviously I like more the second option. I would leave the default as it is, and "install" a new one (as part of my modification, through the package).
  This would makes the things more customizeable, I think. people could still stick with the old "look", if they don't like the new one (won't be forced for all users to use it that way).

So. You can install avatars, smilies, and language files with packages, but you CAN'T install themes??!!  Why is that, what's the problem with the themes?
  Why couldn't the package manager handle themes? It would be possible even to upgrade them.

Rudolf
Title: Re: Package SDK, anyone?
Post by: Owdy on June 03, 2005, 11:24:50 AM
http://support.simplemachines.org/docs/themes.packaging.php
http://support.simplemachines.org/faq/?action=display&faq=57
Title: Re: Package SDK, anyone?
Post by: John Slater on June 04, 2005, 06:34:24 PM
Quote
This tells it what file to edit. Among others, you can use $sourcedir, $themedir, and $languagedir.
<file name="$sourcedir/Subs.php">

   <operation>

      The position attribute should tell the position relative to the code you want to add.
      <search position="before"><![CDATA[
Search for some code to add stuff after.
]]></search>

      The code to add in the described location.
      <add><![CDATA[
This is what to add.
]]></add>

   </operation>

</file>


I have a question about this bit here
Quote
      <search position="before"><![CDATA[
Search for some code to add stuff after.
]]></search>

Is that a mistake where you have said the search position before, and then said this will search for stuff after?

Just checking because i didnt understand it.
Title: Re: Package SDK, anyone?
Post by: [Unknown] on June 04, 2005, 10:06:20 PM
Search for this code before what I'm about to add:

code

Add:

other code

The search position is *relative to the code being added.*

-[Unknown]
Title: Re: Package SDK, anyone?
Post by: John Slater on June 05, 2005, 02:39:01 PM
Ok thanks, maybe you can help with this problem too please



http://www.simplemachines.org/community/index.php?topic=37885.0
Title: Re: Package SDK, anyone?
Post by: Dannii on June 24, 2005, 12:19:43 AM
If the boardmod style is depreciated now, why are the official forum updates in that format?
Title: Re: Package SDK, anyone?
Post by: codenaught on June 24, 2005, 12:37:18 AM
Well it is a lot easier to read. So I would imagine at least one reason is for someone who may need to install some parts manually that they can read what to do much clearer than the xml format.
Title: Re: Package SDK, anyone?
Post by: rudoka on June 24, 2005, 12:48:24 AM
Actually, I find the xml format a lot easier to read.  ;)
Title: Re: Package SDK, anyone?
Post by: fragalot on July 22, 2005, 10:39:06 AM
linux works great for gzip files aswell ;)
Title: Re: Package SDK, anyone?
Post by: Elmacik on October 22, 2005, 11:12:01 PM
test_modification.php in this package always returns empty..
i put it to forum directory, any other folders.. doesnt work. returns like this:


results:
1.
Title: Re: Package SDK, anyone?
Post by: JayBachatero on October 22, 2005, 11:37:42 PM
are you sure you are linking to the .xml file that you want to test?  thats what i use when i make mods.  you can try the upload file option.
Title: Re: Package SDK, anyone?
Post by: Elmacik on October 22, 2005, 11:47:37 PM
aha! got it !
i was trying to test packages :P
thanks
Title: Re: Package SDK, anyone?
Post by: nope on October 28, 2005, 06:22:57 PM
At first I was wondering all around: where is this da*n Package SDK?
I ended figuring out that I was browsing the topic as a guest and couldn't see the attachement.
Very confusing...  :o
Title: Re: Package SDK, anyone?
Post by: GC on January 06, 2006, 11:12:12 PM
Do you create this?
url/index.php?package-list&language=blah&ref=their forum

I'm creating a mod site for all my mods and I can't get the thing to connect. How do I make it visible? Can comeonet ell me hte php code or give me an index.php file that reads the XML? I'm a little lazy right now lol.
Title: Re: Package SDK, anyone?
Post by: Chris Curran on January 25, 2006, 10:41:36 AM
Shouldn't this be a "sticky" thread? I don't understand why it's not...
Title: Re: Package SDK, anyone?
Post by: DarkCloud14 on February 27, 2006, 04:51:54 AM
Uhm is it possible to tell the package system that it should install some things
only if the needed files are available ?!? Or uhm I've a modification with
english and german support. Now I'll do the german language modifications on
help.german.php only if the board admin has installed the german language package.

At the moment I've the problem that I'll always get a Test failed if I don't have these files
(that's why I have an extra package for the german translation..)..
Ok I can install the Mod cause I know that it's only needed if you've german language installed,
but some other may panic and say omg the test failed  >:( contact the mod writer if you know what I mean..
Title: Re: Package SDK, anyone?
Post by: DarkCloud14 on March 01, 2006, 07:16:47 PM
Ok if someone wants to know how it works here's the solution that JayBachatero told me:

Quote
Use error="skip" like this
<file name="$languagedir/Modifications.{language}.php" error="skip">

Title: Re: Package SDK, anyone?
Post by: -X-ChiliSaus on March 04, 2006, 04:35:25 AM
Hello,
I am new to this, so I wanted to try out the "add_settings.php".

I uploaded it, and then when I loaded it in my browser, I get these 2 errors:
Quote
Warning: Missing argument 2 for db_query() in /home/ubernet/domains/ubernet.nl/public_html/smf/Sources/Subs.php on line 237

Warning: Missing argument 3 for db_query() in /home/ubernet/domains/ubernet.nl/public_html/smf/Sources/Subs.php on line 237
Could anyone help me with this?

Thanks in advance.
Title: Re: Package SDK, anyone?
Post by: JayBachatero on March 04, 2006, 02:52:00 PM
You need to have __FILE__, __LINE__ in the query.
Title: Re: Package SDK, anyone?
Post by: GTSdll on June 30, 2006, 04:50:36 AM
Ok if someone wants to know how it works here's the solution that JayBachatero told me:

Quote
Use error="skip" like this
<file name="$languagedir/Modifications.{language}.php" error="skip">

Is there a way to do that on the old modification format (boardmod) too?
If not, does SMF 1.0.x understand the new format?
Title: Re: Package SDK, anyone?
Post by: Gobo on July 21, 2006, 06:28:28 PM
hi

the sdk file dosent say anything about adding images to directories

so i was wondering if someone could kindly tell me what code i would use so that the mod file would install some images to the /Themes/images/ folder as well

Thanks
Title: Re: Package SDK, anyone?
Post by: JayBachatero on July 21, 2006, 06:47:44 PM
<require-file name="hello.gif" destination="$imagesdir/dirname" />
Title: Re: Package SDK, anyone?
Post by: Gobo on July 22, 2006, 02:24:27 PM
Thanks jay :D

hopefully I will have my mod up and running soon :D
Title: Re: Package SDK, anyone?
Post by: Rudolf on July 23, 2006, 12:50:26 AM
beware, if I remember good there's no such thing as $imagesdir
You have to put the path manually, like $themedir/images

But this might have changed in the latest release.
The ones the Package Manager recognize are: $sourcedir, $themedir, $languagedir
Title: Re: Package SDK, anyone?
Post by: Dannii on July 23, 2006, 01:49:17 AM
SMF 1.1 recognises: $boarddir $sourcedir $avatardir $avatars_dir $themedir $imagesdir $themes_dir $languagedir $languages_dir $smileysdir $smileys_dir.
Title: Re: Package SDK, anyone?
Post by: Rudolf on July 23, 2006, 05:07:11 AM
That's good to know.
Title: Re: Package SDK, anyone?
Post by: kuja on July 24, 2006, 01:46:30 AM
Does anyone have a windows method (that works) of creating gzip archives? I tried a few (Ultimate zip for one) that were mentioned in other threads but I couldn't get them to work, and uploading files to  server to gzip and download to test, editing making changes and redoing this is tedious and time consuming.

The common thing to do would be to use the gzip port for Windows. I'm sure a Googling for "gzip.exe" would yield some useful results.
Title: Re: Package SDK, anyone?
Post by: Dannii on July 24, 2006, 01:54:47 AM
Try 7zip. http://www.7-zip.org/
Title: Re: Package SDK, anyone?
Post by: John Slater on August 15, 2006, 10:16:29 AM
What are all the available paths? i was woundering if there is one for Current Theme, maybe $currentthemedir or something
Title: Re: Package SDK, anyone?
Post by: JayBachatero on August 15, 2006, 01:17:32 PM
SMF 1.1 recognises: $boarddir $sourcedir $avatardir $avatars_dir $themedir $imagesdir $themes_dir $languagedir $languages_dir $smileysdir $smileys_dir.

Those are the ones that are available.
Title: Re: Package SDK, anyone?
Post by: gamesmad on August 16, 2006, 03:36:31 AM
$themedir is available, $currentthemedir wouldnt be much use, because not all themes have the same elements and therefore all have different code.  If you want to install to a precise theme, you could use something like "$themedir . '/safgrey/' .".  Just an idea though.

Will
Title: Re: Package SDK, anyone?
Post by: Alan S on September 06, 2006, 10:49:28 AM
Pity i hadnt taken a look at this maybe 5 months ago , it might have made my struggle on learning how mod installs work alot easier lmao
Title: Re: Package SDK, anyone?
Post by: yutt on September 27, 2006, 10:25:28 PM
Would using this SDK still work for 1.1 mods?
Title: Re: Package SDK, anyone?
Post by: Daniel15 on September 27, 2006, 10:27:58 PM
Quote
Would using this SDK still work for 1.1 mods?
Yes, it should, nothing has really changed since SMF 1.0 ;)
Title: Re: Package SDK, anyone?
Post by: DarkCloud14 on October 19, 2006, 10:53:38 AM
Ok if someone wants to know how it works here's the solution that JayBachatero told me:

Quote
Use error="skip" like this
<file name="$languagedir/Modifications.{language}.php" error="skip">

Is there a way to do that on the old modification format (boardmod) too?
If not, does SMF 1.0.x understand the new format?

Jup at least 1.0.5 and up understand the new format for previous version it should work too but I'm not sure
Title: Re: Package SDK, anyone?
Post by: koji on October 27, 2006, 11:41:57 AM
In the example package-info.xml file, there is some <uninstall> tags.

Are we meant to create a reversal of the modification.xml file? If so is the file meant to be called uninstall.xml?

Actually are we meant to create an install.xml file ? It wasn't mentioned anywhere.
Code: [Select]
<install>
<readme>readme.txt</readme>
<modification>install.xml</modification> // shouldn't be this be: modification.xml ???
</install>

Thanks,
Title: Re: Package SDK, anyone?
Post by: Daniel15 on October 27, 2006, 11:49:14 AM
Quote
Jup at least 1.0.5 and up understand the new format for previous version it should work too but I'm not sure
Any version from the SMF 1.0 betas, actually... The first version I tested it with was SMF 1.0.1 :).

Quote
Actually are we meant to create an install.xml file ? It wasn't mentioned anywhere.
You only need the XML file if you make any changes to the SMF files. You can call the modification XML file whatever you want, it doesn't matter (the only file with a predefined name is package-info.xml). So, you could name it install.xml, or modification.xml. For SMFShop, I have three files: install_SMF1-0.xml (SMF 1.0), install_SMF1-1RC1.xml (SMF 1.1 RC1) and install_SMF1-1RC2.xml (SMF 1.1 RC2 and RC3)
Quote
Are we meant to create a reversal of the modification.xml file?
No, you don't need to. In the uninstall section, have a tag like:
Code: [Select]
<modification reverse="true">install.xml</modification>

This essentially does the modification in reverse, undoing all the changes :)
Title: Re: Package SDK, anyone?
Post by: koji on October 27, 2006, 11:57:04 AM
Thanks for the swift reply,

Ah I think I get it.  So you are saying that the uninstall file is the same as the install file, and it automatically reverses whatever actions took place during installation.

Cool!
Title: Re: Package SDK, anyone?
Post by: koji on October 28, 2006, 01:21:02 PM
I have a few questions:

If adding to the end of a file, should the content of the search tags be left empty?
Code: [Select]
<file name="$sourcedir/Subs.php">
 <operation>
  <search position="end"></search>
  <add><![CDATA[
Code to add.
]]></add>

If I want to add a folder of images where should I add it and how? I want the images to be available to all themes.

Would this package-info.xml tell the parser to copy all files in the package (except for readme, install and package-info) into a folder called signs in the forum root?
Code: [Select]
<type>modification</type>

<install>
<readme>readme.txt</readme>
<modification>my_mod.xml</modification>
<require-dir name="signs" destination="$boarddir" />
</install>
Or do I have to specify one file at a time?
Should I have my image files in a folder in the package archive? Or should all the files be loose?
Should images be installed into a theme specific folder or the forum root?

Finally, if a theme must be edited to view my mod, should I leave it to the user? Or should I include operations in the install.xml file to edit the current theme?

Thanks,
Title: Re: Package SDK, anyone?
Post by: Rudolf on October 28, 2006, 02:47:26 PM
You can use this syntax for the "end", which is basically like yours - an empty element:
Code: [Select]
<search position="end" />
<add><![CDATA[
Code to add.
]]>

Code: [Select]
<require-dir name="signs" destination="$boarddir" />will copy directory and all it's content to the specified path.

You should copy the images in the default theme's images folder, and use the $settings['default_images_url'] variable.

Finally the most logical thing would be to modify the default theme, and write a readme for modifying other themes. The default theme, is the only theme you can be sure everyone has.
If you have the time you can create the modified files for other themes and make them available for users, but in separate places, the same with languages. It is antipathetic to download a bunch of things I don't need and want.
Title: Re: Package SDK, anyone?
Post by: Daniel15 on October 28, 2006, 10:17:07 PM
Quote
If adding to the end of a file, should the content of the search tags be left empty?
Well, if you're modifying a Source file, you'd want to put the modification above the ?> tag.
Code: [Select]
<file name="$sourcedir/Subs.php">
 <operation>
  <search position="after"><![CDATA[
?>
]]></search>
  <add><![CDATA[
Code to add.
]]></add>

 
Code: [Select]
<require-dir name="signs" destination="$boarddir" />Will copy a 'signs' directory from the archive into the board directory (so signs/test.png in the archive ends up at {$boarddir}/signs/test.png).
Like Rudolf said, the images should be in the default theme images folder. If you like, put your images in a subdirectory (eg. Themes/default/images/signs). It just keeps things more organised :)

Almost all mods only modify the default theme. Usually, you'd write instructions on how to modify the themes, or the user would have to look in the XML file to see how to do it (or just upload the XML file to http://server.daniel15.com/smf_xml/modification.php?action=file and look for theme stuff :))

Hope this helps you :D
Title: Re: Package SDK, anyone?
Post by: JayBachatero on October 28, 2006, 10:20:57 PM
daniel15 the <search position="end" /> will add the data before the ?> ;).
Title: Re: Package SDK, anyone?
Post by: Daniel15 on October 28, 2006, 11:32:49 PM
Quote
daniel15 the <search position="end" /> will add the data before the ?>
Oh, OK, I didn't know that... I guess the Package Manager is smarter than I thought :P
Title: Re: Package SDK, anyone?
Post by: koji on October 31, 2006, 06:07:13 AM
Thanks,

However I cannot get the Package Manager to copy my images! The images never get extracted anywhere.

Code: [Select]
<install>
<readme>readme.txt</readme>
<modification>zodiac_starsigns.xml</modification>
<require-dir name="zodiac" destination="$themesdir/images" />
</install>

I've also tried $themesdir/default/images

EDIT:

OK I've got it to work using an absolute path. e.g.

<require-dir name="zodiac" destination="$boarddir/Themes/default/images" />

Is that the correct way to do it?

Oh and when uinstalling, that folder is not deleted.  Is that right?

What is the dynamic path to my images? Or should they be hard-coded to the default theme fodler?
Title: Re: Package SDK, anyone?
Post by: Laibeus Lord on November 01, 2006, 08:30:45 AM
How do you make it so that a package will edit all available themes installed??

Thanks.

UPDATE: nev mind, found it... I still have the package-info named package-info-advanced.php

^^
Title: Re: Package SDK, anyone?
Post by: Daniel15 on November 03, 2006, 03:51:56 AM
koji, I believe that it's $themedir, and not $themesdir ;)

Quote
Oh and when uinstalling, that folder is not deleted.  Is that right?
I think it should be deleted, but I'm not really sure...
Title: Re: Package SDK, anyone?
Post by: Gobo on November 07, 2006, 07:54:14 PM
Hi,

Im having a bit of a problem - hopefully someone can help me out.
Instead of storing the images in the theme directory I want to create a folder in the forum root and call all the images from there so that all themes can use them with ease.

Now wold this work?
Code: [Select]
<readme>readme.txt</readme>
<modification>modification.xml</modification>
<create-dir name="religiontabs" destination="$boarddir" />
<require-file name="Agnostic.png" destination="$boarddir/religiontabs" />
<require-file name="Athiest.png" destination="$boarddir/religiontabs" />

Also now the main problem that arises for me is I dont know how to specify the location for the images which are to be displayed in the profile template....currently my older mod uses this:
Code: [Select]
echo '
   Way of Life: ', $message['member']['options']['profile_way_of_life'] , ' <img src="', $settings['images_url'], '/', $message['member']['options']['profile_way_of_life'], '.png" /> <br />';

Now can someone please tell me how I will change the
Code: [Select]
<img src="', $settings['images_url'], '/', $message['member']['options']['profile_way_of_life'], '.png" />
part to pick the images up from the $boarddir/religiontabs

Thanks
Aku
Title: Re: Package SDK, anyone?
Post by: SleePy on November 07, 2006, 08:00:44 PM
the themes have a setting that goes to the default images:
$settings['default_images_url']

Very handy. I use it on my customized themes to save some space on images..
Title: Re: Package SDK, anyone?
Post by: Gobo on November 07, 2006, 08:02:12 PM
the themes have a setting that goes to the default images:
$settings['default_images_url']

Very handy. I use it on my customized themes to save some space on images..

nice :D that should work perfectly - ill just store the images in the default and use the method u gave :D

Thanks
Title: Re: Package SDK, anyone?
Post by: ch3ster on November 16, 2006, 09:02:29 AM
thankssss thats better....
Title: Re: Package SDK, anyone?
Post by: Rasyr on November 18, 2006, 01:23:53 PM
Question

What could cause a Package to install zero byte files? The files in the zip are not zero byte, but it creates zero byte files for the two files involved.

Any help would be appreciated. If you are interested in checking out the Package I am having problems with, you can download it from here --> http://www.wizlair.net/index.php?action=tpmod;dl=item32  (Thantos gave me permission to update/improve it, and distribute it - just have to solve the Package problems....)


Title: Re: Package SDK, anyone?
Post by: Daniel15 on November 18, 2006, 10:51:06 PM
Quote
What could cause a Package to install zero byte files? The files in the zip are not zero byte, but it creates zero byte files for the two files involved.

Any help would be appreciated. If you are interested in checking out the Package I am having problems with, you can download it from here --> http://www.wizlair.net/index.php?action=tpmod;dl=item32  (Thantos gave me permission to update/improve it, and distribute it - just have to solve the Package problems....)
If you're using SMF 1.1 RC1, it's a known bug (upgrade to SMF 1.1 RC3)
Otherwise, is the directory it's trying to write to CHMODded to 0777?
Title: Re: Package SDK, anyone?
Post by: Rasyr on November 19, 2006, 07:21:29 AM
I am using 1.1 RC3.

This happened on both my local machine and on one of my websites (a website that installed new pages for other mods without problems).
Title: Re: Package SDK, anyone?
Post by: B Patterson on November 20, 2006, 05:47:00 PM
In the test_modification.php file, when dealing with template type stuff, it can cause the <pre> code to break the HTML.  In an effort to keep it right, here's a fix for it.

Around line 90 you change this:

<pre style="width: 98%; overflow: auto; border: 1px solid red;">', $action['search'], '</pre></li>';

To:

<pre style="width: 98%; overflow: auto; border: 1px solid red;">', str_replace('<', '&lt;', stripslashes($action['search'])), '</pre></li>';

It also takes away the slashes that make it not look like what you're searching for.
Title: Re: Package SDK, anyone?
Post by: BlueSteel on December 16, 2006, 11:23:16 PM
Hi,

I have done some modifications to my site.. and would like to try to find a utility to do 2 thing
1. Compare the files/Dirs
2. create a mod install file
2a. when parsing the differences ask me if i'd like to add each difference into the mod creation file

I think that this type of utility would be very benificial to those who make changes to their sites and then update their site to use a newer version of SMF or mod that may wipe out their existing changes..

I'd really hate to have to manually compare the files (using a compare utrility then have to go and manually create / copy / paste the original code from the original file and the same from the edited file and then work out and type in the correct syntaxes to do the search and replace/add/ delete  To me this seems like something that could be automated

But i can't find a tool to do this.. is there such a tool.. if not why not .. LOL
Title: Re: Package SDK, anyone?
Post by: 0897jhPEFUOIyG90 on December 17, 2006, 08:18:31 PM
BlueSteel,

Try the following:

http://www.gnu.org/software/diffutils/diffutils.html

Or for windows:

http://gnuwin32.sourceforge.net/packages/diffutils.htm

or

http://www.grigsoft.com/download-windiff.htm

edit: whoops, I just re-read your post and realised you are probably already aware of such tools, and were asking for an automated mod package generator, which would be a brilliant idea, just a pain to create.

Though Diff and Patch could achieve the desired effect, just outside the SMF package manager:

http://www.gnu.org/software/patch/patch.html
http://gnuwin32.sourceforge.net/packages/patch.htm
Title: Re: Package SDK, anyone?
Post by: Gobo on December 27, 2006, 02:15:22 PM
does the SMF mod creator work with 1.1.1 and is it recommended by the team?

http://sourceforge.net/projects/smfmc/

aku
Title: Re: Package SDK, anyone?
Post by: JayBachatero on December 27, 2006, 05:38:49 PM
Yea I recommend it.  I've used it in the past.
Title: Re: Package SDK, anyone?
Post by: BlueSteel on December 27, 2006, 05:47:38 PM
Can someone please post a tutorial on how to use it.. lol.. Thanks in advance
Title: Re: Package SDK, anyone?
Post by: Gobo on December 27, 2006, 05:51:10 PM
thanks

ill try it out now

blue steel it simply creates the XML files for you and then u have to package it up from what I can see

u pick the type of modification u want to make
search for text
replace or add after or before text
and so on and so forth

Also this makes things EASIER for u to do - it dosent generate code by itself - so u have to know what ur doing
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 02, 2007, 01:55:23 PM
I'm working on a mod package that provides repeating events to the calendar. My mods are passing the test_modifications.php tests, except for one. Below is the code from modifications.xml that is causing the trouble:
Code: [Select]
    <file name="$sourcedir/Calendar.php">
        <operation>
            <search position="replace"><![CDATA[
                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $start_time + $span * 86400) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "'
]]></search>
            <add><![CDATA[
                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $end_time) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "',
                    repeating = '" . htmlspecialchars($_REQUEST['repeating'], ENT_QUOTES) . "',
                    repeat1_parm1 = '" . htmlspecialchars($_REQUEST['repeat1_parm1'], ENT_QUOTES) . "',
                    repeat1_parm2 = '" . htmlspecialchars($_REQUEST['repeat1_parm2'], ENT_QUOTES) . "',
                    repeat2_parm1 = '" . htmlspecialchars($_REQUEST['repeat2_parm1'], ENT_QUOTES) . "',
                    repeat2_parm2 = '" . htmlspecialchars($_REQUEST['repeat2_parm2'], ENT_QUOTES) . "',
                    repeat2_parm3 = '" . htmlspecialchars($_REQUEST['repeat2_parm3'], ENT_QUOTES) . "',
                    repeat_end_type = '" . htmlspecialchars($_REQUEST['repeat_end_type'], ENT_QUOTES) . "'
]]></add>
        </operation>
</file>

When I run the test on this, I'm told that the search text cannot be found, however, I have cut & pastes the search text directly from the original source file, so, how could it be that it cannot be found? I've gone over this a few hundred times, so I obviously can't see the trees for the forest at this point. Anyone have an idea what's going on here?

tia,
Chris Curran
 
Title: Re: Package SDK, anyone?
Post by: niko on February 02, 2007, 02:10:59 PM
I think problem is blank line

Try modifying it to like: (Don't copy from here because I think tabs are replaced by spaces)
Code: [Select]
<![CDATA[                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $start_time + $span * 86400) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "']]></search>
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 02, 2007, 02:13:47 PM
Thanks, but that's not it. I've got dozens of other mods formatted the same way (i.e. blank lines) that seem to work perfectly (I did try it just to be 101% sure though). I'm wondering if there isn't a special char that's botching up the search engine in there...

I think problem is blank line

Try modifying it to like: (Don't copy from here because I think tabs are replaced by spaces)
Code: [Select]
<![CDATA[                    startDate = '" . strftime('%Y-%m-%d', $start_time) . "',
                    endDate = '" . strftime('%Y-%m-%d', $start_time + $span * 86400) . "',
                    title = '" . $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "']]></search>

Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 02, 2007, 04:18:40 PM
I found the problem; Calendar.php has tabs embedded in it....

Thanks, but that's not it. I've got dozens of other mods formatted the same way (i.e. blank lines) that seem to work perfectly (I did try it just to be 101% sure though). I'm wondering if there isn't a special char that's botching up the search engine in there...

Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 02, 2007, 04:52:44 PM
OK, I've got the basic mod package for repeating Calendar events working and installing to a clean system without errors. Now, I need to be able to modify the Calendar table structure and create another table; should I do that with an external script, or is there a better mechanism for that?

thanks,
Chris Curran
 
Title: Re: Package SDK, anyone?
Post by: Daniel15 on February 02, 2007, 10:25:40 PM
OK, I've got the basic mod package for repeating Calendar events working and installing to a clean system without errors. Now, I need to be able to modify the Calendar table structure and create another table; should I do that with an external script, or is there a better mechanism for that?

thanks,
Chris Curran
 
An external script, ran via a <code> tag in the package-info.xml file.
A basic script:
Code: [Select]
<?php
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');

// Your queries here
?>


As an example, a query to add a table:
Code: [Select]
// Shop items table
db_query("
CREATE TABLE IF NOT EXISTS {$db_prefix}shop_items (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
`desc` TEXT NOT NULL,
`price` DECIMAL(8,2) UNSIGNED NOT NULL,
`module` TINYTEXT NOT NULL,
`stock` SMALLINT NOT NULL,
`info1` TEXT NOT NULL,
`info2` TEXT NOT NULL,
`info3` TEXT NOT NULL,
`info4` TEXT NOT NULL,
`input_needed` TINYINT UNSIGNED DEFAULT '1' NOT NULL,
`can_use_item` TINYINT UNSIGNED DEFAULT '1' NOT NULL,
`delete_after_use` TINYINT(1) UNSIGNED DEFAULT '1' NOT NULL,
`image` TINYTEXT NOT NULL,
`category` SMALLINT NOT NULL,
PRIMARY KEY (`id`)
)", __FILE__, __LINE__);

And a query to modify add a column to a table, if it doesn't already exist:
Code: [Select]
//add money columns to members table, if they don't already exist
$result = db_query("SHOW COLUMNS FROM {$db_prefix}members LIKE 'money'", __FILE__, __LINE__);
if (mysql_num_rows($result) == 0)
db_query("ALTER TABLE {$db_prefix}members ADD `money` DECIMAL(9, 2) UNSIGNED DEFAULT '0.00' NOT NULL", __FILE__, __LINE__);
mysql_free_result($result);

Make sure the queries do NOT have a semicolon ( ; ) on the end, otherwise your script will die with a "Hacking attempt..." message. Additionally, do not put the database name in backticks (eg. `{$db_prefix}members`), or you'll get an "Invalid Database Name ''" message when running the script by itself (SSI.php already adds the backticks).
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 02, 2007, 11:45:25 PM
Thanks Daniel! Worked like a charm.....
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 03, 2007, 11:46:59 AM
I found the problem; Calendar.php has tabs embedded in it....

Coming back to this....

What is the official stance from the SMF developer team regarding the use of tab characters (0x09) embedded in the source code?

While working on a recent (huge) mod, I discovered portions of my mod did not work. After spinning my wheels for a bit, I found that the original source file (/Sources/Calendar.php) contained tab characters - embedded. This was the only file that I encountered with this and it was in only a few places. But it was enough to really screw things up (the mod search engine)! How? Cross-platform text editors and copy/pasting from one window to the other.... (details available).

Are the tabs in Calendar.php in error, or do we have to worry about this in all future mod efforts?

cheers,
Chris
Title: Re: Package SDK, anyone?
Post by: niko on February 03, 2007, 02:18:47 PM
SMF uses tab indentation. Check from settings of your program that it uses tabs instead of spaces.
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 03, 2007, 04:55:04 PM
The settings that are added via 'add_settings.php'. Where do they show up at on the screen for user input (e.g. to turn an option on/off)?

thanks,
Chris
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 03, 2007, 05:28:56 PM
Never mind... I found ModSettings.php. Geez, doc crew, could you have hid that info any better?

The settings that are added via 'add_settings.php'. Where do they show up at on the screen for user input (e.g. to turn an option on/off)?

thanks,
Chris
Title: Re: Package SDK, anyone?
Post by: JayBachatero on February 03, 2007, 10:23:24 PM
I found the problem; Calendar.php has tabs embedded in it....

Coming back to this....

What is the official stance from the SMF developer team regarding the use of tab characters (0x09) embedded in the source code?

While working on a recent (huge) mod, I discovered portions of my mod did not work. After spinning my wheels for a bit, I found that the original source file (/Sources/Calendar.php) contained tab characters - embedded. This was the only file that I encountered with this and it was in only a few places. But it was enough to really screw things up (the mod search engine)! How? Cross-platform text editors and copy/pasting from one window to the other.... (details available).

Are the tabs in Calendar.php in error, or do we have to worry about this in all future mod efforts?

cheers,
Chris
It is strongly recommended that you use tabs (\t) in your source files.  Also use the BSD/Allman Style for indentation as well.  Not K&R style.
http://en.wikipedia.org/wiki/Indent_style
Title: Re: Package SDK, anyone?
Post by: Daniel15 on February 03, 2007, 11:05:54 PM
I found the problem; Calendar.php has tabs embedded in it....

Coming back to this....

What is the official stance from the SMF developer team regarding the use of tab characters (0x09) embedded in the source code?

While working on a recent (huge) mod, I discovered portions of my mod did not work. After spinning my wheels for a bit, I found that the original source file (/Sources/Calendar.php) contained tab characters - embedded. This was the only file that I encountered with this and it was in only a few places. But it was enough to really screw things up (the mod search engine)! How? Cross-platform text editors and copy/pasting from one window to the other.... (details available).

Are the tabs in Calendar.php in error, or do we have to worry about this in all future mod efforts?

cheers,
Chris
It is strongly recommended that you use tabs (\t) in your source files.  Also use the BSD/Allman Style for indentation as well.  Not K&R style.
http://en.wikipedia.org/wiki/Indent_style
The full guidelines are available at http://custom.simplemachines.org/mods/guidelines.php :)

Quote
Never mind... I found ModSettings.php. Geez, doc crew, could you have hid that info any better?
I agree, we need more developer documentation...We'll try to work on some in the near future :)
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 04, 2007, 12:09:16 AM
Quote
The full guidelines are available at http://custom.simplemachines.org/mods/guidelines.php :)

Excuse me? I have been using what little doc there is posted here: http://custom.simplemachines.org/mods/

When I click on "Coding Guidelines" I am taken here: http://docs.simplemachines.org/index.php?topic=218

These are the coding guidelines I used, and for anyone to come in now and say there is another set of guidelines that isn't shown to anyone until AFTER the code is written is, well, it's BS. I've been using K&R indentation almost 30 years. Aside from BSD/Allman being a horrible waste of space, why isn't this coding style request documented out front where people will see it BEFORE they submit 2000+ line mods??? Hey, I have an idea! Why not put the docs and coding style requirements in the SDK like a real SDK should have.... Lame. Real lame.

 
Title: Re: Package SDK, anyone?
Post by: Kela on February 13, 2007, 08:39:48 AM
Here is DTD for package-info.xml: http://www.simplemachines.org/xml/package-info
Here is DTD for install.xml: http://www.simplemachines.org/xml/modification

Anyone need something more?  ???
Title: Re: Package SDK, anyone?
Post by: B Patterson on February 13, 2007, 09:05:20 AM
Quote
These are the coding guidelines I used, and for anyone to come in now and say there is another set of guidelines that isn't shown to anyone until AFTER the code is written is, well, it's BS. I've been using K&R indentation almost 30 years. Aside from BSD/Allman being a horrible waste of space, why isn't this coding style request documented out front where people will see it BEFORE they submit 2000+ line mods??? Hey, I have an idea! Why not put the docs and coding style requirements in the SDK like a real SDK should have.... Lame. Real lame.

If you're using a good editor, it's a simple Find & Replace in your code.  Find any "    " sets of spaces (or however denote an indent to you) and replace with a "\t" charcter, as long as its' between <![CDATA[]]> tags.  Edit Plus can do this, notepad++ can do this.  Not too difficult.
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 14, 2007, 08:28:32 AM
bpat,

Thanks for the input, but you're not replying to what you quoted. The post you quoted concerns the very sticky issue of brace placement/indentation. It appears the doc crew has made some progress in this area since my post, so I won't comment further.

Regarding tabs... Yes, well, it's not that easy for a number of reasons. For starters, how to replace spaces with tabs isn't what I was asking - I know regex like the back of my hand. Literally - I wrote compilers for HP in the 80's. My "problem" was that a SMF source file I was working on had mixed spaces and tabs in the file - it wasn't consistent. It's the lack of consistency that caused the problem. I don't expect to have to load up a file in my editor (TSE) and have to start an editing session by replacing spaces with tabs. Who does?

Lastly, I don't care for tabs in source files. It causes all kinds of style problems. Try it - load up a SMF source and set your tabs to 4 - notice how rotten ugly everything is? SMF sources appear to be using a tab size of 8 - that's OK, but many programmers use different sizes and those who don't use 8 will have to guess around until they hit it on 8 all the time guessing at what it's supposed to look like (and it's not just about 8 or 4 - 5, 3 and 2 are also common values used for tab size). Now, if you're one of those non-8 folks, then you probably won't be making a permanent change to the default tab size in your editor. Lets presume you load up a file and forget to change the tab size of your editor (it's a 2000+ line mod, so it's very possible that you'll load up and not be anywhere near original SMF code to see that the tabs are not lining up). You start editing the source with your tabs set to 4, then save it out. The formatting of that file is now all screwed up. Tabs in general are a PITA, but if SMF wants tabs in the source, I'll play along.

cheers,
Chris
Title: Re: Package SDK, anyone?
Post by: B Patterson on February 14, 2007, 09:23:34 AM
Code: [Select]
I hear what you're saying.  And I understand.  Except that your argument doesn't hold water (well, the latter part).

The spaces vs. tabs in one file is an issue, and I agree with you there.

The other part about having 8,4,5,3,2 tab spacing messing up the code, that's wrong.  What is a tab character?  "\t".  So if it's a character, and each program can interpret it differently with 8,4,5,3, or 2 character spacing.  But, when it comes down to it your code essentially looks like:

[code]
function something($var) {
\tglobal $vars;

\tif(something != something_else) {
\t\techo 'I don\'t equal!!';
\t}
}

So the program interprets the "\t" character to be what it is and define a length.  So if you use whatever spacing you want, as long as the tabs aren't converted to spaces, it won't matter what tab-spacing you use to mod on.

I personally mod on a tab-spacing of 2.  I find it easier to read.  And yet every mod I've done works.  I use tabs, not spaces.  Both of my mods (although I have more) work perfectly fine.  It's just a matter of properly defining how many tabs there are, not how far indented it is.  You won't screw up the formatting of the file.  It should be program independent.[/code]
Title: Re: Package SDK, anyone?
Post by: Dannii on February 14, 2007, 11:37:02 PM
There shouldn't be a mix of tabs and spaces in any of the SMF files (for indents, of course spaces are needed elsewhere). Where did you see the mix?
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 16, 2007, 02:03:50 PM
bpat,

Yea, it can mess things up. I'm off at a star party right now doing things like this: http://www.planetcurran.com/astro/camp-03.jpg

I didn't want you to think I was ignoring you. When I get back I'll reply in full...

cheers,
Chris
Title: Re: Package SDK, anyone?
Post by: Chris Curran on February 16, 2007, 02:04:36 PM
There shouldn't be a mix of tabs and spaces in any of the SMF files (for indents, of course spaces are needed elsewhere). Where did you see the mix?

I think it was Calendar.php but I can't swear to it right now. I'll touch base with you when I get back to clarify.

cheers,
Chris
Title: Re: Package SDK, anyone?
Post by: Jack.R.Abbit™ on March 01, 2007, 10:54:01 AM
all due respect but if you had paid attention to any of the existing source you were modifying you may have noticed that your style was different.  This should have taken place around line 10 or 20 of your mod... not at line 2000.  I personally dislike the style as well.  I dislike tabs... but I do switch my editor (Homesite) before I start.  I also dislike the {} on their own line because of the way they look... however, I do believe it makes it easier for mod writers to come along and alter the control statement, etc.  But the style is what it is... and that is the chosen style for SMF source.

BTW, I look forward to trying out your cal mod.  Repeating events is something that has been talked about for a long time... and attempted several times.  They never seem to see daylight.
Title: Re: Package SDK, anyone?
Post by: Chris Curran on March 01, 2007, 03:07:35 PM
Jack,

Well, I don't completely disagree with you. Only partly. :) Yes, I could/should have caught that I was using a different coding style, but, I wasn't aware that there was a specified coding style wrt brace placement. However, when a project *requires* a certain style, IMHO, it should state that up front and not rely on any programmer to notice what style is being used and hope that they conform to it. I'm happy to use whatever style a project requires.

Tabs... and CR/LF.... I've been using the same editor since the mid eighties - QEdit then its later upgrade, TSE32 (The Semware Editor, 32 bit version). Working on SMF mods with my trusty old friend has been a real PITA and somewhat of a learning lesson. I've made some config changes to TSE that I think now bring me into conformance with SMF standards (it looks like SMF uses LF instead of CR/LF?).

A good bit of this is pent up frustration with the SMF mod dev process in general. I don't want to sound too critical because it appears that the doc crew is trying hard to get things right. Also, the mod approval process could use a revamp. Write a mod, post it and hope that someone looks at in some undetermined amount of time, and oh, btw, don't ask about the status of the mod approval or you get scolded and pushed to the bottom of the pile. The SMF mod approval process should be accountable - for *both* sides of the process.

I've gone back through my code and modified the offending braces and modified the repeating UI a bit. That has lead to another problem with testing of my mod (using test_modification.php). My current problem is this:

Code: [Select]
    <file name="$themedir/Post.template.php">
        <operation>
            <search position="replace"><![CDATA[
    // Now some javascript to hide the additional options on load...
    if (!empty($settings['additional_options_collapsable']) && !$context['show_additional_options'])
        echo '
        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
            swapOptions();
        // ]]></script>';
]]></search>
            <add><![CDATA[
    // Now some javascript to hide the additional options on load...
    if (!empty($settings['additional_options_collapsable']) && !$context['show_additional_options'])
        echo '
        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
            swapOptions();
        // ]]></script>';

    if ($context['event']['repeating']=='0')
        echo '
        <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
            swapEndDate(\'none\');
        // ]]></script>';
]]></add>
        </operation>

    </file>

The search phase fails. I have compared the org source file to my xml code using a hex viewer - they compare byte for byte. No missing tabs, spaces or LF's. Here is the error msg:

Code: [Select]

// Now some javascript to hide the additional options on load\.\.\.
if \(\!empty\(\$settings\['additional_options_collapsable'\]\) && \!\$context\['show_additional_options'\]\)
echo '
\\<\!-- // --\>\<\!\[CDATA\[
swapOptions\(\);
// \';
\]\]\>



Via the normal process of removal, I narrowed it down to this failing:

Code: [Select]
        ...snip...
        <operation>
            <search position="replace"><![CDATA[
        // ]]></script>';
]]></search>
        ...snip...

It doesn't seem to like having "// ]]></script>';" in the search clause. Note the error msg above too - the line after "swapOptions()". Is the "]]" from the </script> statement messing up the search engine?

cheers,
Chris
 
Title: Re: Package SDK, anyone?
Post by: Rudolf on March 01, 2007, 05:38:53 PM
You can't nest CDATA tags.
The solution is to escape the closing ]]> for the CDATA of the Javascript code.
example of javascript code (In <add>, <search> and other tags):
Code: [Select]
<add><![CDATA[
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[

//some javascript code

// ]]>]]<![CDATA[></script>
]]></add>
Title: Re: Package SDK, anyone?
Post by: JayBachatero on March 02, 2007, 01:55:04 AM
I've seen people do this.
Code: [Select]
        ...snip...
        <operation>
            <search position="replace"><![CDATA[
        // ]]' . '></script>';
]]></search>
        ...snip...
Concatenate the ] and >.
Title: Re: Package SDK, anyone?
Post by: Daniel15 on March 02, 2007, 02:43:04 AM
Quote
(it looks like SMF uses LF instead of CR/LF?).
Yeah, I believe that it does. As far as I know, Windows is the only OS that likes using CR/LF, most others use just LF (with the exception of Mac, which uses just CR).
A good editor should transparently convert them (if the file uses LF, it uses LF. If the file uses CR/LF, it uses CR/LF). :)
Title: Re: Package SDK, anyone?
Post by: Chris Curran on March 02, 2007, 09:21:32 AM
Thanks Rudolf and Jay. I never got either form to work in a search clause. Ultimately I changed what I was looking for.

Regarding the [add] clause. In the Post.template.php section of my mod xml I had to resort to this:

Code: [Select]
    if ($context['event']['repeating']=='0')
        echo '
        &lt;script language="JavaScript" type="text/javascript"&gt;&lt;![CDATA[
            swapEndDate(\'none\');
        // ]]&gt;&lt;/script&gt';

I found this form here: http://www.simplemachines.org/community/index.php?topic=121862.0

When I tried either of the forms proposed by you guys, it seemed to lose the end-tag and it ran on until it got real weird (reporting that it couldn't find text in files that I wasn't looking in, etc - acting like a compiler does when it has a missing "}" somewhere in the middle of the source file). However, in the Calendar.template.php section of the mod xml, I used the following and it seems to work (Rudolf's I think):

Code: [Select]
  if ($context['event']['repeating']=='0')
      echo '
      <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
          swapEndDate(\'none\');
      // ]]>]]<![CDATA[></script>';

Very odd. Very odd indeed....
 
Title: Re: Package SDK, anyone?
Post by: Chris Curran on March 02, 2007, 09:24:05 AM
Daniel,

You should re-read your post - it's sounds like a Monty Python routine! :) (that was a compliment). You should have worked on some of the Unix and proprietary systems that were floating around in the 70's and 80's - they used all sorts of EOL forms. Heck, even a few (e.g. Qantel) had no EOL char.

Now to the point of the post. Yes, any good editor can handle this, but that's not the question: What is the SMF standard regarding the line terminator? Personally, I edit php code on all three of the major platforms: Windows (CR/LF), Linux (LF) and OS/X (CR). Which form does SMF want?

cheers,
Chris
Title: Re: Package SDK, anyone?
Post by: Joshua Dickerson on March 02, 2007, 11:30:05 PM
LF please. (I will add it to the coding guidelines, even though we don't check for it)
Title: Re: Package SDK, anyone?
Post by: Chris Curran on March 07, 2007, 10:39:04 AM
LF please. (I will add it to the coding guidelines, even though we don't check for it)

10-4. Note that Calendar.template.php has a mix of CR/LF and LF EOL formats.... There may be more files like this, but I found this one last night. BTW, the mix of EOL formats causes trouble for editors that detect what EOL format to use (based on file contents). It bit me without me even knowing about it (http://tinyurl.com/yvuly4).
Title: Re: Package SDK, anyone?
Post by: 38753970 on March 17, 2007, 08:28:01 PM
I use PowerArchiver 2004... works like a charm  
Title: Re: Package SDK, anyone?
Post by: The One on March 20, 2007, 10:42:56 AM
I was wondering has anyone faced the issue I posted here http://www.simplemachines.org/community/index.php?topic=158794.0
Title: Re: Package SDK, anyone?
Post by: ShadowDragon on March 20, 2007, 11:57:55 AM
Is it possible that the "type"-element (with attributes modification, avatar, language) is undefined under the namespace ???
 
Title: Re: Package SDK, anyone?
Post by: The One on March 24, 2007, 01:08:09 AM
*chaining the "SMF Package Parser" thread (http://www.simplemachines.org/community/index.php?topic=140034.0) to this*
Title: Re: Package SDK, anyone?
Post by: trecool999 on April 21, 2007, 06:27:26 PM
Never mind, I did it anyway.
Title: Re: Package SDK, anyone?
Post by: FANCA on July 16, 2007, 01:02:59 AM
3Q~~
Title: Re: Package SDK, anyone?
Post by: Joshua Dickerson on July 16, 2007, 01:32:12 AM
3Q~~
What does that mean?
Title: Re: Package SDK, anyone?
Post by: Daniel15 on July 17, 2007, 08:16:46 AM
3Q~~
What does that mean?
I think it means thankyou? :P
Edit: http://www.urbandictionary.com/define.php?term=3Q
Title: Re: Package SDK, anyone?
Post by: Joshua Dickerson on July 17, 2007, 06:38:59 PM
*grumbles* How about using ENGLISH?! Even another real language would work just as well.
Title: Re: Package SDK, anyone?
Post by: Shean on July 31, 2007, 07:17:19 PM
Thanks
Title: Re: Package SDK, anyone?
Post by: j soft on August 08, 2007, 01:28:08 PM
very nice
404?  The test_modification.php file is meant to deal directly with .mod or .xml modification files, not with whole packages.

-[Unknown]

Thanks,,
Title: Re: Package SDK, anyone?
Post by: geminidomino on August 18, 2007, 10:46:02 PM
Sorry if I'm a little thick, but I don't see any tutorials or any other info...


[Edit] Nevermind... Linux Tiny-text, missed the attachment. Mea culpa. 
Title: Re: Package SDK, anyone?
Post by: BiGBLiZZ on August 20, 2007, 06:22:25 AM
Okay genius' let figure this out...

Same problem as an earlier post... I have a huge Mod written and ready, problem:  I use JS in the code, and it in-turn uses <[CDATA[ ...code here... ]]>

As you can tell there is a problem nesting CDATA lines.

Solution?  Oh, and no, unlike the other fix in this thread I can't add the JS to an already existing JS section of the file.  Will need something else...
Title: Re: Package SDK, anyone?
Post by: JayBachatero on August 20, 2007, 11:42:09 AM
What you can do is 1 user the .mod format or 2 use the chr() function and echo each char in the <![CDATA[.  Like
Code: [Select]
echo chr(60) . chr(33) . chr(91) . chr(67) . chr(68) . chr(65) . chr(85) . chr(65) . chr(91);
Title: Re: Package SDK, anyone?
Post by: RRasco on August 21, 2007, 11:23:12 AM
you could just add the function to a js file.
Title: Re: Package SDK, anyone?
Post by: Dannii on August 21, 2007, 12:01:57 PM
Just leave out the CDATA tags, Javascript doesn't need it as presumably you're not serving your webpages as xml.
Title: Re: Package SDK, anyone?
Post by: BiGBLiZZ on August 23, 2007, 03:52:50 PM
Okay, all great suggestions.  I shall give it a go!  Thanks!
Title: Re: Package SDK, anyone?
Post by: Phal on September 24, 2007, 05:25:37 AM
NOTE!!

I wasted 4 hours until I figured this out: All the files must be in the base directory of your .tar.gz file. Do not archive the directory containing your modification files!
Title: Re: Package SDK, anyone?
Post by: miseryshining on October 16, 2007, 01:07:04 PM
Can anyone tell me how to use multiple search keys? Is the syntax any different from

Code: [Select]
<search position="before">string1</search>
<search position="after">string2</search>
<add>something to add just before string2</add>

I'd expect it to add the new part right before string2 and i expect string2 to come after string1. Am i wrong?

Another question: Can I use regular expressions to search for non-unique patterns and add replace them / add some code? I've been using the old syntax till now, and it seems some things are harder to accomplish now.

example: i want to replace all instances of
Code: [Select]
<a href="', $scripturl, '?action=unread'with
Code: [Select]
<a href="', $scripturl, '?action=',$_REQUEST['action'].'in the following code:

Code: [Select]
<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[70], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="14%">
<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=starter', $context['sort_by'] == 'starter' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[109], $context['sort_by'] == 'starter' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="4%" align="center">
<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[110], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="4%" align="center">
<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=views', $context['sort_by'] == 'views' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[301], $context['sort_by'] == 'views' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td><td width="24%">
<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[111], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a>
</td>';

that was easy with the old method, but seems almost impossible now, unless you replace the whole thing, which wouldn't be the preferred way to do it, IMO.
Title: Re: Package SDK, anyone?
Post by: brianjw on November 18, 2007, 05:53:29 PM
Is it possible to make an uninstall package with no installs? If so, how?

Thanks,
brianjw

PS: Would something like
Code: [Select]
<code type="file" reverse="true">add_settings.php</code> work? with the reverse - ive only seen it on <modification></modification> tags.
Title: Re: Package SDK, anyone?
Post by: B Patterson on November 18, 2007, 08:07:36 PM
By nature in order to uninstall something, you have to install it... what is it you're trying to do?
Title: Re: Package SDK, anyone?
Post by: Daniel15 on November 18, 2007, 08:21:35 PM
Anyone wanting more detailed information about the XML files (package-info.xml and the modification XML files), check out http://www.smfmods.org/wiki/Category:Packages :D

Quote
Is it possible to make an uninstall package with no installs? If so, how?
How would it be uninstalled if it's not installed?

Quote
PS: Would something like
Code: [Select]
<code type="file" reverse="true">add_settings.php</code>
work? with the reverse - ive only seen it on <modification></modification> tags.
Nope, that won't work. You need your own remove_settings.php script.
Although, the SMF Coding Guidelines state that you're allowed to leave the settings in the database, just in case the user reinstalls the mod (all their settings will be preserved).
Title: Re: Package SDK, anyone?
Post by: brianjw on November 18, 2007, 08:29:25 PM
Well, this would be an uninstall only package (as in full uninstall) so if the person decides they want to remove all the database stuff too, they can but I want to do it without installing something before it. ;)

brianjw
Title: Re: Package SDK, anyone?
Post by: raisara on November 22, 2007, 06:47:58 AM
thanks  O:)
Title: Re: Package SDK, anyone?
Post by: sotosk on December 20, 2007, 10:06:18 PM
thnks
Title: Re: Package SDK, anyone?
Post by: Marook on December 27, 2007, 04:58:05 PM
Anyone maybe can explain how to add settings for the user. The setting should appear in the user profile and i couldn't figure out in which way those settings are stored in the db....
Title: Re: Package SDK, anyone?
Post by: Chriss Cohn on February 06, 2008, 02:56:31 PM
Hello, i want to change a certain line in my next mod which is in all language-variants of the "index.$language.php" file. Is there a way to make this easier as i do -> writing the same part for all files over and over again ?

Regards, Christian
Title: Re: Package SDK, anyone?
Post by: GenÇTürK on April 20, 2008, 12:25:17 PM
How can I add new mods
Title: Re: Package SDK, anyone?
Post by: brianjw on April 20, 2008, 01:45:30 PM
How can I add new mods
Make new mods or upload new mods to your website? Well creating is something you will have to learn. Uploading is announced in the http://docs.simplemachines.org (Simple Machines Documentation)
Title: Re: Package SDK, anyone?
Post by: GenÇTürK on April 30, 2008, 05:00:34 AM
How can I add new mods
Make new mods or upload new mods to your website? Well creating is something you will have to learn. Uploading is announced in the http://docs.simplemachines.org (Simple Machines Documentation)

Thanks,

But you didnt understant me,

I made new mod...It name is "Board İcon".. I want to share the mod. But I dont know how ı can share that.[(b]

Title: Re: Package SDK, anyone?
Post by: Aleksi "Lex" Kilpinen on April 30, 2008, 05:45:06 AM
How can I add new mods
Make new mods or upload new mods to your website? Well creating is something you will have to learn. Uploading is announced in the http://docs.simplemachines.org (Simple Machines Documentation)

Thanks,

But you didnt understant me,

I made new mod...It name is "Board İcon".. I want to share the mod. But I dont know how ı can share that.[(b]


http://custom.simplemachines.org/mods/index.php?action=postmod;sa=new
Title: Re: Package SDK, anyone?
Post by: assam_siddibapa on May 11, 2008, 05:35:06 PM
I installed it ... ads are visible to me but not other members ...... wat should i do
Title: Re: Package SDK, anyone?
Post by: Jumpmasterrt on May 15, 2008, 11:40:02 AM
Ok, so I ran into a few problems.

One, when I tried to install this package it came back as all errors.

Two, how do you change the dir that some things go in? I want to write mods of mods for specific themes etc but the $themedir is always "default". So if I wanted to write a mod for the Babylon theme, how would I tell the package to install it there instead of default?

Sorry if this is the wrong thread.
Title: Re: Package SDK, anyone?
Post by: Dannii on May 15, 2008, 12:25:15 PM
This isn't something you install in the package manager...
You could use: $themedir/../babylon
Title: Re: Package SDK, anyone?
Post by: Jumpmasterrt on May 15, 2008, 04:52:01 PM
Well, then that would be why then.... LOL So if it's not a PM package, how does it get installed and where does it run from? (I've looked for instructions but even the readme doesn't say)

Ok just for clarification it would be $themedir/Themes/babylon/index.template.php (if that was the file I wanted to mod)? Or just like you typed it or does it matter?
Title: Re: Package SDK, anyone?
Post by: Dannii on May 15, 2008, 11:46:32 PM
It isn't something you install and run. It's a collection of files that will help you write packages.

No that wouldn't work. You could try $boarddir/Themes/babylon/index.template.php but it's longer.
I think there's also a $themes_dir variable you could try.
Title: Re: Package SDK, anyone?
Post by: Jumpmasterrt on May 16, 2008, 05:17:11 PM
Ok I finally got it..... the "Modifications" folder is the example files. The "Server" folder is if I want to manage my own package server for OTHER people to download from and the only file that does anything in reference to package production is the test_modification.php which goes in the main dir so you can test your packages before submitting them.

I'm slow but trainable. ;)

Oh dang, that's right, the $boarddir values were all listed (in a language file I believe) and they set all the dir's for SMF, so if you run that whole string it should change it for that action. Yeah, it may be long but at least it should be safer.
Title: Re: Package SDK, anyone?
Post by: N3RVE on May 22, 2008, 02:41:21 PM
I'll start using $boarddir! I guess that tells SMF to start from the directory where the forum files reside!

As at now, I  use e.g; Themes/babylon/display.template.php
Title: Re: Package SDK, anyone?
Post by: [SiNaN] on May 29, 2008, 10:44:47 AM
What you can do is 1 user the .mod format or 2 use the chr() function and echo each char in the <![CDATA[.  Like
Code: [Select]
echo chr(60) . chr(33) . chr(91) . chr(67) . chr(68) . chr(65) . chr(85) . chr(65) . chr(91);

Jay, chr(85) should be chr(84).
Title: Re: Package SDK, anyone?
Post by: assam_siddibapa on June 02, 2008, 10:38:06 AM
I installed it ... ads are visible to me but not other members ...... wat should i do
any one
Title: Re: Package SDK, anyone?
Post by: lui2man2chun on June 06, 2008, 05:01:29 AM
 :) ;) :D >:( ;D :( :o
Title: Re: Package SDK, anyone?
Post by: afv on June 21, 2008, 09:06:54 AM
Hi,

I'm having a very very weird problem...

After trying to parse my package through http://www.smfhelper.info/forum/package.php I'm getting:

Quote
ERROR: The package-info.xml file is invalid!

Debugging Information
Error message: String could not be parsed as XML
Source: /home/bigguy/public_html/smfhelper/forum/package.php:133
Errors encountered while parsing XML file:

Stack Trace:
#0 /home/bigguy/public_html/smfhelper/forum/package.php(133): SimpleXMLElement->__construct('')
#1 /home/bigguy/public_html/smfhelper/forum/package.php(94): parsePackageInfoXML('/tmp/smf_xml/pa...', 'install', 'all')
#2 /home/bigguy/public_html/smfhelper/forum/package.php(756): parseArchive('/tmp/phpyaWABB', 'install', 'all')
#3 {main}

After hours searching for the error and comparing my files with other packages, I tried and found this:

Using a working package, I go to the parser and try to parse it. OK, no errors.

Now I unzip it and zip it again. Trying to parse it: the same error above! Same error with tar.gz too.

I think the files inside both zips are exactly the same... I'm using gzip on Linux.

Anyone with the same problem? I'll try ziping it on a Windows machine...

Thanks

edit:
I went into my virtual XP and zipped it using the default zipper and it works :-X
Time to replace my gzip ::)
Title: Re: Package SDK, anyone?
Post by: [SiNaN] on June 21, 2008, 09:23:37 AM
You should pack the files, not the folder containing files.

Edit:

Interesting...
Title: Re: Package SDK, anyone?
Post by: sub367 on August 28, 2008, 01:55:01 PM
i use rar
Title: Re: Package SDK, anyone?
Post by: bubo1991 on September 17, 2008, 04:45:31 PM
thx
Title: Re: Package SDK, anyone?
Post by: fahadsadah on October 26, 2008, 01:41:31 PM
Perfect, thanks.
Looked everywhere for one of these!
Title: Re: Package SDK, anyone?
Post by: Enqack on December 18, 2008, 09:36:33 AM

edit:
I went into my virtual XP and zipped it using the default zipper and it works :-X
Time to replace my gzip ::)
I was using Info-zip (on linux) and had the same issue with .zip files.   Running `zip -F  <filename>` to fix the zipfile allowed my package to be uploaded.
"  -F   fix zipfile (-FF try harder)"
Title: Re: Package SDK, anyone?
Post by: Akyhne on December 22, 2008, 05:28:22 PM
The code in Package SDK is bogus.. at least for SMF 1.1.7

ad_settings:
VALUES" . substr($string, 0, -1));

...should be
VALUES" . substr($string, 0, -1) , __FILE__, __LINE__);

... at least for SMF 1.1.7 packages.

I had the same error in two mods saying something like "invalid third parameter in db_query".

It should also be pointed out that this package example doesn't work with SMF 2.0
Title: Re: Package SDK, anyone?
Post by: H on December 23, 2008, 01:40:31 PM
The package SDK is unfortunately not maintained too well at the moment :)
Title: Re: Package SDK, anyone?
Post by: Dominic22 on December 23, 2008, 09:28:09 PM
Thank you so much. I hope I can learn to create modifications that would be so cool.

:) you are a SUPER HERO:)
Title: Re: Package SDK, anyone?
Post by: satrun77 on March 26, 2009, 06:28:56 PM
thanks :)
Title: Re: Package SDK, anyone?
Post by: nvcnvn on April 08, 2009, 01:47:16 AM
How can we design a mod just use one .xml file like in Vbb! It's will more convenient to user
Title: Re: Package SDK, anyone?
Post by: H on April 08, 2009, 03:23:17 PM
How can we design a mod just use one .xml file like in Vbb! It's will more convenient to user

The user should never need to see how many files are in the package as it is normally installed by the Package Manager (http://docs.simplemachines.org/index.php?board=49.0;sort=subject)
Title: Re: Package SDK, anyone?
Post by: [»|« №ōЯ »|«] on April 10, 2009, 03:04:51 AM
Thanks.... :)
Title: Re: Package SDK, anyone?
Post by: SoLoGHoST on May 10, 2009, 01:26:28 AM
Hello, sorry if this has already been asked and answered, but wondering on the $themedir.  Using this, does it point to the DEFAULT Theme Directory?  The reason for this is I need to modify the script.js file found only in the ./Themes/default/scripts directory.  So what is the best way to get to this directory all of the time?

Also, in my uninstall.php file, should I drop the columns that were installed with my MOD??  I can't remember where, but I read somewhere that dropping columns in a table is not recommended.

Thanks :)
Title: Re: Package SDK, anyone?
Post by: JBlaze on May 10, 2009, 01:28:37 AM
$themedir ALWAYS leads to the default theme :)
Title: Re: Package SDK, anyone?
Post by: SoLoGHoST on May 10, 2009, 01:30:21 AM
Thanks a bunch, also, on the uninstalling of MODS, should i drop the columns that were installed when installing the MOD?
Title: Re: Package SDK, anyone?
Post by: JBlaze on May 10, 2009, 01:34:28 AM
It is important that when uninstalling a mod, that everything that came with it is uninstalled.

whether it be files, directories, code, or database tables, columns and rows.

Title: Re: Package SDK, anyone?
Post by: SoLoGHoST on May 10, 2009, 01:35:08 AM
Ok, Thanks again :)  Exactly what I thought!
Title: Re: Package SDK, anyone?
Post by: Dannii on May 10, 2009, 01:52:33 AM
No, I disagree. People will very likely want to install your mod again, whether it's a new version, after they've upgraded SMF, after they've fixed a bug in something else, or whatever.

Do NOT undo database changes when uninstalling a mod. Instead provide a page with instructions for how to do it manually, or even better, provide a separate fulluninstall.php file that they can run themselves to remove everything if they choose to. Mention these options in the uninstall readme.

For example, my pretty URLs mod will not remove the database changes. I actually recommend that if people choose to stop using my mod they install the reverter package so that their links will not break. This wouldn't be possible if I undid the database changes.
Title: Re: Package SDK, anyone?
Post by: JBlaze on May 10, 2009, 01:56:39 AM
Thanks for pointing that out Dannii. I totally forgot about that.
Title: Re: Package SDK, anyone?
Post by: Garou on May 11, 2009, 10:22:31 AM
The only problem with that Dannii is the bug currently in 2.0 where mods fail on install if the DB's are already there. In which case if you want to use the db info you have stored you have to backup the db manually and delete it, install the mod again, then manually drop the original DB back over it.
Title: Re: Package SDK, anyone?
Post by: [SiNaN] on May 11, 2009, 10:30:04 AM
There are several workarounds for that bug.

One is, passing 'ignore' for the 'if_exists' parameter. This will however, will not update the table if the table definitions for the install script has changed and this causes other issues for your modification updates.

The other way is checking if the table exists or not manually and depending on the result you get, you either check each column for an update or create the table. This is how SimplePortal handles database changes in 2.2.x versions.
Title: Re: Package SDK, anyone?
Post by: Dannii on May 11, 2009, 10:49:57 AM
If the installing the mod when the tables are there already fails, then the mod is broken.
Title: Re: Package SDK, anyone?
Post by: [SiNaN] on May 11, 2009, 10:54:10 AM
Not really. There was a bug in SMF 2.0 RC1 that caused this.

Bug #2963: 'update', 'overwrite', and 'update_remove'  option for 'if_exists' on db_create_table function fails (http://dev.simplemachines.org/mantis/view.php?id=2963)
Title: Re: Package SDK, anyone?
Post by: KensonVsGaming on October 13, 2009, 05:09:01 PM
www.7zip.com works perfectly for me, supports tar, gzip, zip, 7z, rar, ace, cab, etc... etc...

Yes, I like 7zip! (except for windows 7, the unzipper you don't need to get a license for...)



And I will look at this at home, I have always wanted to do a mod!
Title: Re: Package SDK, anyone?
Post by: Arantor on October 13, 2009, 05:39:40 PM
Way to quote a 5 year old post, there...

Remember that all this tells you is how to put a mod together for the package manager, it won't teach you how to code in PHP to write that mod. (But that's what Coding Discussion is for, after all)
Title: Re: Package SDK, anyone?
Post by: ɔɔɔɔɔɔuɥoɾ on October 13, 2009, 06:13:32 PM
I just use a Java Mod Creator, lol.. no xml coding for me haha
Title: Re: Package SDK, anyone?
Post by: Arantor on October 13, 2009, 06:15:56 PM
That's great until the mods get bigger and you need to do file includes. Or you want to split it into multiple files like I do.
Title: Re: Package SDK, anyone?
Post by: ɔɔɔɔɔɔuɥoɾ on October 13, 2009, 06:29:03 PM
I wont be making any "big" mods anytime soon lol..
Title: Re: Package SDK, anyone?
Post by: Garou on October 18, 2009, 08:34:18 PM
SMFMC was interesting and Sheepy did a good job with it, though I actually prefer the XML ModMaker (http://sleepycode.com/index.php/action,modmake.html) and Packinfo Maker (http://sleepycode.com/index.php/action,packmake.html) on Sleepy's site. I just wish he'd make the code public, Id love to put it on my site.  8)

In any case all are good learning tools but once you get the hang of it, its just as easy to do by hand IMHO.
Title: Re: Package SDK, anyone?
Post by: Dimon4ik on February 24, 2010, 02:42:26 PM
Quote
I wont be making any "big" mods anytime soon lol..
Yes: it's simple to simply use your hands for small mods.
I done a whole lot of changes like this.

P.S. Theres changes are private, but I'm going to make some of them public in some time.
Title: Re: Package SDK, anyone?
Post by: Arantor on February 24, 2010, 02:50:25 PM
Interesting the way this has gone. I'm writing my biggest mod ever (and believe me, it's huge as mods go) but there is no way it could have been built by a package maker because it modifies so little of the actual SMF code and mostly adds its own.
Title: Re: Package SDK, anyone?
Post by: JBlaze on February 25, 2010, 02:44:22 AM
Well, as far as the XML files go for mods, they are pretty much alot of copy/paste. Very simple once you get the basic syntax down.
Title: Re: Package SDK, anyone?
Post by: Nitram on March 15, 2010, 01:36:26 PM
Thanks for these tutorials!
Title: Re: Package SDK, anyone?
Post by: CapadY on April 11, 2010, 06:29:43 AM
How long will it take before a MOD is aproved ????

It isn't realy a motivation when you don't hear anuthing for weeks.

Title: Re: Package SDK, anyone?
Post by: Arantor on April 11, 2010, 06:32:57 AM
As long as it takes. SlammedDime makes some comments about it - http://www.simplemachines.org/community/index.php?topic=375429.msg2578057#msg2578057
Title: Re: Package SDK, anyone?
Post by: Liam. on April 11, 2010, 06:53:06 AM
Rememeber that the SMF Team are all volunteers so aren't abliged to do anything. Wheras they always get to it sometime, they are still humans, so don't expect it instantly. Another thing to consider is that they have plenty of other mods pending approval aswell. Finally, smaller mods are generally quicker to get to, larger mods take longer.
Title: Re: Package SDK, anyone?
Post by: Arantor on April 11, 2010, 06:55:22 AM
In some cases though it's been *weeks* for even simple mods. See the comments from SlammedDime that I link above.
Title: Re: Package SDK, anyone?
Post by: Liam. on April 11, 2010, 06:59:05 AM
I've read that post ;) But the amazing use of the word "generally" comes in handy, as I used :P My other points still stand.
Title: Re: Package SDK, anyone?
Post by: eattheword on April 20, 2010, 06:21:55 AM
Can someone tell me where this 'test_modification.php' script can be found please?
Title: Re: Package SDK, anyone?
Post by: Arantor on April 20, 2010, 01:28:27 PM
Can someone tell me where this 'test_modification.php' script can be found please?

In the only attachment in the first post of this thread?
Title: Re: Package SDK, anyone?
Post by: caoyiqian on April 21, 2010, 02:33:45 AM
This is a very useful thread, I am looking for 'test_modification.php' script as well.
Title: Re: Package SDK, anyone?
Post by: Arantor on April 21, 2010, 06:17:21 AM
FFS

Seriously you like this thread but you didn't bother to actually LOOK AT THE ATTACHMENT IN THE FIRST POST?
Title: Re: Package SDK, anyone?
Post by: eattheword on April 30, 2010, 02:22:56 PM
Can someone tell me where this 'test_modification.php' script can be found please?

In the only attachment in the first post of this thread?

Umm, thanks. I've only been a member of a couple of SMF forums before and neither of those had attachments activated so it never crossed my mind that such a thing was available. Of course, now I know what to look for I see the OP does, indeed, have an attachment which I have now downloaded.


FFS

Seriously you like this thread but you didn't bother to actually LOOK AT THE ATTACHMENT IN THE FIRST POST?


Charmed, I'm sure, but perhaps this other user, like me, was simply not aware that you could have attachments on posts. We all learn and we all have to start somewhere.
Title: Re: Package SDK, anyone?
Post by: Arantor on April 30, 2010, 02:27:31 PM
I got annoyed because RIGHT AFTER I said where to look, the other person asked where to look. Had they actually read the post immediately before their own they'd have seen the answer.
Title: Re: Package SDK, anyone?
Post by: vinsci on June 26, 2011, 10:35:33 PM
Can someone tell me where this 'test_modification.php' script can be found please?

In the only attachment in the first post of this thread?

Note that the attachment is only visible if you are logged in to the forum.  IMHO, though, the package-sdk file is important enough to make it available in the downloads area as well, where it would be a lot easier to find to begin with.
Title: Re: Package SDK, anyone?
Post by: Joshua Dickerson on June 26, 2011, 11:56:39 PM
A lot of it should be added to the wiki and I have added a category for this.
Title: Re: Package SDK, anyone?
Post by: Zaine on August 22, 2011, 06:14:22 PM
Feel like I'm getting my head around this now.  2 Questions though. 

1) In an <operation><add></add></operation> CDATA section are you able to add variables in there?

I'm modifying an ini file that comes with a 3rd party library and I want to write out the SMF connection details into it so the application uses the SMF database, rather than having to set up another DB by hand.   I'm assuming you can't just put $db_name or {db_name} in the middle of a CDATA section though.  (It tried using $db_name and it does weird things!

2) The above ini file I'm wanting to modify is being added by a <require-dir> earlier on.  The tests performed on the package however fail because they are executed before the directory is unfolded into the target directory.  Is there any way around this?

I hope I'm not doing something really dumb here, but help would be appreciated :D
Title: Re: Package SDK, anyone?
Post by: SoLoGHoST on September 16, 2011, 12:01:58 PM
Ok, correct me if I'm wrong here, but you are requiring a directory within your package and than you want to edit a file that is in the directory after the directory is added to their server??  If yes to both of these, than you don't want to use any <operation> tags for this.

Within the package-info.xml file, create a <code>your php filepath that gets executed</code> tag.  Within this file...

Use file_get_contents (http://php.net/manual/en/function.file-get-contents.php) to open up the file.

Than use file_put_contents (http://php.net/manual/en/function.file-put-contents.php) to write whatever you want to the file.  You can get the prefix by using the $db_prefix from Settings.php.  Or you can use {db_prefix} to be written to that file as well.

Atleast, this is the method that I would try first, and not sure if the order matters, but you can place the <code> tag at the bottom within the <install> tag.  You can do a test to see if the file exists before you try to read from it, using file_exists (http://php.net/manual/en/function.file-exists.php)(path to the ini file), within your php file that gets executed within the <code></code> tag of package-info.xml.

Well, that would be my first approach to trying to do this atleast.  Haven't tested it, but seems likely to work if the ini file is included with your package...

Good Luck.

P.S. - Ofcourse, you can create an entirely separate package altogether and than do it your way.  But the user would need to install 2 packages to get it functioning properly.

EDIT:  Opps, didn't realize how old this post actually was....  Well, hope it helps anyways.
Title: Re: Package SDK, anyone?
Post by: Zaine on September 25, 2011, 10:36:58 AM
Thanks.  I could do it with that...   I'll have a go!
Title: Re: Package SDK, anyone?
Post by: Adren on February 25, 2012, 04:30:47 PM
nice help for me, thank you!
Title: Re: Package SDK, anyone?
Post by: antoncbr on May 30, 2012, 12:55:53 AM
Hi! I have lost a bit.... Is it possible to upload my mod to http://www.simplemachines.org/ ?
Title: Re: Package SDK, anyone?
Post by: Elmacik on May 30, 2012, 01:50:25 AM
@antoncbr, welcome to SMF!

See the Modifications Page (http://custom.simplemachines.org/mods/) to upload your mods for SMF and browse the others' mods. After your modification is inspected against Customization Approval Guidelines (http://wiki.simplemachines.org/smf/Customization_approval_guidelines) and is accepted to be approved, then it will be available for anyone to download from simplemachines.org. So you'd better check the guideliness before you submit your work.
Title: Re: Package SDK, anyone?
Post by: antoncbr on May 30, 2012, 10:44:40 AM
Thanks a lot !
Title: Re: Package SDK, anyone?
Post by: AlexGt on September 23, 2012, 04:18:21 AM
Hi In this morning I make a avatars package but I do not know how to put on the smf customize
Please help me
Title: Re: Package SDK, anyone?
Post by: NanoSector on September 23, 2012, 06:30:09 AM
Hi In this morning I make a avatars package but I do not know how to put on the smf customize
Please help me

http://custom.simplemachines.org/mods/index.php?action=postmod;sa=new :)
Title: Re: Package SDK, anyone?
Post by: AlexGt on September 23, 2012, 09:54:14 AM
Thanks but say : Warning: this mod is currently not approved!
Please do not use this mod unless you are completely sure of the consequences!

What can i do ? and to people say Sorry but no mod was found
Sorry for bad english... http://custom.simplemachines.org/mods/index.php?mod=3475
Title: Re: Package SDK, anyone?
Post by: NanoSector on September 23, 2012, 10:41:58 AM
People like me (Customizers) will need to check over your mod and approve it before it gets visible - I can see and interact with it, and send you PMs about it. You will receive one soon.