We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Should I use a separate file

Development and Programming

Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

I have been developing a EE version of geshi and had a question. As of right now, I have a couple of different options for inserting the data into a table.

  1. Modify each language file to suit the table infrastructure and then use the insert_string by looping through all files. <– Slow so I know I won’t use this

  2. The same as above except put all languages into one big array and then insert each sub-array into the database. <– Worked just fine

  3. Export the contents of the table and then put each INSERT statement into the main ext.geshiee.php file.

My question is where should I actually put these sql statements. I have them currently under activate_extension, but adding these 86 lines with a lot of data makes the file size go up to about .97MB and I have not even started writing the main parse function. Should I take these statements and put them into another file or what. I just don’t want to slow the processing of the data by a large file.

Thanks for any help.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

What data are you putting into the database? I’d just leave the GeSHi languages as files within a geshi subfolder of the extensions folder. That way users can decide which languages they want to include, and can easily modify or update the languages.

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

That is what I was thinking about when I decided to go with the DB. Basically, it is a structure like:

LANG_ID LANG_NAME LANG_NAME_R LANG_DATA LANG_ACTIVE

I will be including a settings page where users will be able to configure each language with defaults. Then within the code segment start tag they will be able to modify the default values. From the structure above the user can activate/deactivate languages, modify the entire languge file, and add/delete languages without any programming knowledge or knowledge of how GeSHi works.

My idea behind this is to make it as simple as possible for the user without the user actually needing to know a lot about how these things work.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Cool. The best practice for the general question you are asking, though, is generally to keep it as one file. However, 1MB is very wasteful to include each page load. I’d say you’d be safe to take a page from the IP to Nation module and put your install and update queries in a separate file; just document it well.

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

I was thinking along the same lines. I hated that it increased the file size that much but that is a lot of data.

Maybe an ext.install_geshiee.php file with the main sql inserts in it and then any updates will be included in the ext.geshiee.php file unless it is a lot of data then I could always make an ext.update_geshiee.php file. Makes it a little confusing but like you said, as long as it is documented well there shouldn’t be a problem.

Thanks for the info and I just got my regex string working. Just a little tweaking of that and rewriting the geshi parse_code will at least let me put something up. Then I will just have to create the settings page. LOL

Thanks again.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

You won’t want to name it with ‘ext.’ otherwise it will be picked up by the Extension Manager as an extension of its own. Your ext.geshiee.php file’s installer should just include the dependent file in the install routine.

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Yeah. I noticed that. OOoops. LOL Good thing I caught it now instead of after I got everything finished.

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Hey. One more quick question. Do you think it would be wise to also have an extension hook into session_start which will cache all of the languages out of the DB to speed things up?

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Nevermind. I discovered what was slowing it down. Well, this plugin is working and now the configuration part begins. LOL

Things that I need to do:

  1. Write the settings page
  2. Cleanup the code
  3. Do some more testing

Once I get through part 2 done I will post a Beta release here for everyone to test. The parsing is a little slow but I am pretty sure there is just too much unneed GeSHi code in there. I basically took the parse_code function and then any function that came up as an error so I would only include the “required” functions.

Again, once I get all of these done I will get something up for testing.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.