Merge lp:~quam-plures-core/quam-plures/html5_step_one into lp:quam-plures

Proposed by EdB
Status: Superseded
Proposed branch: lp:~quam-plures-core/quam-plures/html5_step_one
Merge into: lp:quam-plures
Diff against target: 1963 lines (+477/-860)
27 files modified
qp_inc/_application.php (+3/-4)
qp_inc/_core/model/__core.install.php (+1/-1)
qp_inc/templates/model/_template.class.php (+1/-1)
qp_inc/templates/views/_coll_sel_template.view.php (+1/-2)
qp_inc/templates/views/_coll_template.view.php (+1/-2)
qp_inc/templates/views/_template.form.php (+6/-8)
qp_install/_functions_create.php (+13/-26)
qp_install/_functions_dbupgrade.php (+234/-579)
qp_install/_functions_install.php (+22/-25)
qp_install/index.php (+179/-195)
qp_plugins/xml_feeds_widget/_xml_feeds.widget.php (+0/-1)
qp_templates/_sitemap/_template.class.php (+1/-1)
qp_templates/asevo/_template.class.php (+1/-1)
qp_templates/basic/_template.class.php (+1/-1)
qp_templates/custom/_template.class.php (+1/-1)
qp_templates/evocamp/_template.class.php (+1/-1)
qp_templates/evopress/_template.class.php (+1/-1)
qp_templates/glossyblue/_template.class.php (+1/-1)
qp_templates/intense/_template.class.php (+1/-1)
qp_templates/miami_blue/_template.class.php (+1/-1)
qp_templates/natural_pink/_template.class.php (+1/-1)
qp_templates/nifty_corners/_template.class.php (+1/-1)
qp_templates/photoblog/_template.class.php (+1/-1)
qp_templates/pixelgreen/_template.class.php (+1/-1)
qp_templates/pluralism/_template.class.php (+1/-1)
qp_templates/terrafirma/_template.class.php (+1/-1)
qp_templates/vastitude/_template.class.php (+1/-1)
To merge this branch: bzr merge lp:~quam-plures-core/quam-plures/html5_step_one
Reviewer Review Type Date Requested Status
EdB Needs Fixing
Tilman Blumenbach (community) Approve
Review via email: mp+51054@code.launchpad.net

This proposal has been superseded by a proposal from 2011-06-17.

Description of the change

Started looking at the app_nonces branch and figured I'd better get this into merge immediately. Basically, seems to me that app_nonces doesn't address a better way to handle dbase upgrades - it just jumps on where that other app left off. This needed to do database upgrades in order to do what it does, and IMHO it does it way better.

Key changes other than that are primarily associated with templates. Instead of 'normal' and 'feed', we now have 'xhtml', 'feed', and 'other'. One day we'll be able to add 'html5' without issue. This branch then applies 'other' to the sitemap so it doesn't show up in lists of useful templates ... which makes sense. THERE IS NOTHING ACTUALLY GOING TOWARDS HTML5 IN THIS BRANCH! The name is functional for me because it is the first step in getting what I'm doing with html5 into core. I actually can use html5 templates, but not the full scope of that wanna-be "standard".

Anyway http://forums.quamplures.net/viewtopic.php?f=6&t=673 covers it and so much more :)

To post a comment you must log in.
Revision history for this message
EdB (edb) wrote :

Oops. 2 bugs found and fixed. Sorry 'bout dat :(

7595. By EdB

new stuff in core now here - woohoo!

Revision history for this message
Yabs (yabs) wrote :

We need to get someone who's into html5 to review this :-S

¥

Revision history for this message
EdB (edb) wrote :

Bad name - it doesn't do anything about html5 ... other than "get ready". It changes displaying template types from 'normal' to 'xhtml' so that one day we can have 'html5' as well. It also creates a new type 'other' for pretty much the sitemap template because that one is neither display nor feed.

The biggest thing it does is the database update method which we discussed a bit in the forums. Each database activity increments the counter by one, and it uses another Setting to keep track of that. I forget exactly, but basically "goal" and "progress". When they are equal things are good, otherwise the upgrader crashed.

7596. By EdB

+core updates

Revision history for this message
Yabs (yabs) wrote :

Ok, I'll grab and test when I get a moment

¥

Revision history for this message
EdB (edb) wrote :

Is anyone looking at this? If so please hold off - sorry :(

In working multiple issues at the same time I observed that I should not have removed "task_end()" and would like to restore that BUT I need to test it for both upgrading and installing anew. I figured since I know of the issue now I ought to first let peeps know this isn't really as done as it should be before tinkering some more.

Marking "needs fixing" even though technically it doesn't need fixing, and will do a "resubmit" when I get it where I think it should be (again).

review: Needs Fixing
7597. By EdB

restored "task_end()", fixed bug, tidied up code

Revision history for this message
EdB (edb) wrote :

All better? Restored the "task_end()" function, fixed a really sloppy bug or two I still had in there, and did some tidying up of code. The index.php file SUCKED in terms of how tabbage was randomly thrown in with an intent to confuse :(

Tested as an upgrade, but just now I realized I didn't test it as a fresh installation. Should be no problem but I won't do a "resubmit" until I test it to prove it doesn't suck.

Revision history for this message
EdB (edb) wrote :

Upgrades from the zip without issue, installs without issue. Yay!

review: Needs Resubmitting
7598. By EdB

adding recent core updates

7599. By EdB

youtube patch

Revision history for this message
Tilman Blumenbach (tblue) wrote :

Not tested yet, but I've looked at the diff.

Line 1053-1056: It should be possible to reduce that to one SQL query:

  UPDATE T_templates__template SET template_type = 'other' WHERE template_name = 'Sitemap'

Revision history for this message
Tilman Blumenbach (tblue) wrote :

Apart from that, everything seems to work. :)

review: Approve
Revision history for this message
EdB (edb) wrote :

I'll look at that when I get home, which in theory is tomorrow but in truth probably won't be for 3 or 4 days.

Plus for some reason I had a thought that there is a possible condition out there in the wilds that is not covered properly by this branch. That is to say, a real world installation that upgrades (after and assuming merging this branch as-is) would experience a problem of some sort. The second problem is I can't remember what the first problem is. Anyway when I had the thought I thought "OMG that simply won't do ... you have to remember this and look at the code when you can".

So now I'll have to change this to a status other than in merge so it doesn't get merged. Or just say "don't merge this yet" because once again they're sending me messages probably telling me I have to drive to San Bernadino CA on the 15th even though I'm supposed to be home on the 13th. Which is completely impossible from where I am right now.

Love driving, but not the crap that surrounds the job.

review: Needs Fixing
Revision history for this message
Tilman Blumenbach (tblue) wrote :

Heh, okay, install and upgrade seemed to work for me here. :) Changed status to Work in Progress.

Revision history for this message
EdB (edb) wrote :

I just now remembered the problem. non-public template that says whatever the current type for a public-side template is would not be upgraded, so I want to make sure if the template says the original word that we (a) work and (b) flag them in some way that a template edit would be a smart thing.

Also I hope you've really drilled down on the upgrade portion. That was really what I wanted to get done with this branch. Each database action increments a temporary counter that needs to match the final database number. If we crash during upgrade we would know exactly where, if we don't then we're good. That was the idea anyway.

Your status change was better :)

Revision history for this message
Tilman Blumenbach (tblue) wrote :

Ah, I will take a closer look at the upgrade bits soon. I *think* it looked fine, though.

Revision history for this message
Tilman Blumenbach (tblue) wrote :

Do you mind moving branch ownership to quam-plures-core so I can make changes if necessary?

Revision history for this message
Tilman Blumenbach (tblue) wrote :

Okay, I have some changes locally but can't push them (see above).

7600. By Tilman Blumenbach

Merged trunk

7601. By Tilman Blumenbach

Code optimizations

7602. By Tilman Blumenbach

Minor fixes

7603. By EdB

see http://forums.quamplures.net/viewtopic.php?f=6&t=673&p=5498#p5498 :)

7604. By EdB

provide notification if a template still has "normal" for the type

7605. By EdB

adding dracones branch

7606. By EdB

clean up posting and validating XHTML

7607. By EdB

committing core commits :)

7608. By EdB

core up, core in

7609. By EdB

core to 7614

7610. By EdB

core up to 7618

7611. By EdB

core to 7620

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qp_inc/_application.php'
2--- qp_inc/_application.php 2010-12-31 12:53:51 +0000
3+++ qp_inc/_application.php 2011-06-17 09:28:39 +0000
4@@ -22,14 +22,13 @@
5 * Release date (ISO)
6 * @global string
7 */
8-$app_date = '2011-01-01'; // ground zero
9+$app_date = '2011-03-21'; // a randomly selected day
10
11 /**
12 * This is used to check if the database is up to date.
13- *
14- * This will be incrememented by with each change in {@link upgrade_dbase_tables()}
15+ * This will be incrememented by 1 with each change in {@link upgrade_dbase_tables()}
16 */
17-$app_db_version = 0;
18+$app_db_version = 4;
19
20 /**
21 * Is displayed on the login screen:
22
23=== modified file 'qp_inc/_core/model/__core.install.php'
24--- qp_inc/_core/model/__core.install.php 2010-12-31 12:12:03 +0000
25+++ qp_inc/_core/model/__core.install.php 2011-06-17 09:28:39 +0000
26@@ -114,7 +114,7 @@
27 "CREATE TABLE T_templates__template (
28 template_ID int(10) unsigned NOT NULL auto_increment,
29 template_name varchar(32) NOT NULL,
30- template_type enum('normal','feed') NOT NULL default 'normal',
31+ template_type enum('xhtml','feed','other') NOT NULL default 'xhtml',
32 template_folder varchar(32) NOT NULL,
33 PRIMARY KEY template_ID (template_ID),
34 UNIQUE template_folder( template_folder ),
35
36=== modified file 'qp_inc/templates/model/_template.class.php'
37--- qp_inc/templates/model/_template.class.php 2010-12-31 12:12:03 +0000
38+++ qp_inc/templates/model/_template.class.php 2011-06-17 09:28:39 +0000
39@@ -262,7 +262,7 @@
40 */
41 function get_default_type()
42 {
43- return (substr($this->folder,0,1) == '_' ? 'feed' : 'normal');
44+ return (substr( $this->folder,0,1 ) == '_' ? 'feed' : 'xhtml' );
45 }
46
47
48
49=== modified file 'qp_inc/templates/views/_coll_sel_template.view.php'
50--- qp_inc/templates/views/_coll_sel_template.view.php 2010-12-31 12:12:03 +0000
51+++ qp_inc/templates/views/_coll_sel_template.view.php 2011-06-17 09:28:39 +0000
52@@ -23,10 +23,9 @@
53 $TemplateCache = & get_Cache( 'TemplateCache' );
54 $TemplateCache->load_all();
55
56-// TODO: this is like touching private parts :>
57 foreach( $TemplateCache->cache as $Template )
58 {
59- if( $Template->type != 'normal' )
60+ if( $Template->type == 'feed' || $Template->type == 'other' )
61 { // This template cannot be used here...
62 continue;
63 }
64
65=== modified file 'qp_inc/templates/views/_coll_template.view.php'
66--- qp_inc/templates/views/_coll_template.view.php 2010-12-31 12:12:03 +0000
67+++ qp_inc/templates/views/_coll_template.view.php 2011-06-17 09:28:39 +0000
68@@ -36,10 +36,9 @@
69 $TemplateCache = & get_Cache( 'TemplateCache' );
70 $TemplateCache->load_all();
71
72- // TODO: this is like touching private parts :>
73 foreach( $TemplateCache->cache as $Template )
74 {
75- if( $Template->type != 'normal' )
76+ if( $Template->type == 'feed' || $Template->type == 'other' )
77 { // This template cannot be used here...
78 continue;
79 }
80
81=== modified file 'qp_inc/templates/views/_template.form.php'
82--- qp_inc/templates/views/_template.form.php 2010-12-31 12:12:03 +0000
83+++ qp_inc/templates/views/_template.form.php 2011-06-17 09:28:39 +0000
84@@ -50,14 +50,12 @@
85 $Form->text_input( 'template_name', $edited_Template->name, 32, T_('Template name'), T_('As seen by blog owners'), array( 'required'=>true ) );
86
87 $Form->radio( 'template_type',
88- $edited_Template->type,
89- array(
90- array( 'normal', T_( 'Normal' ), T_( 'Normal template for general browsing' ) ),
91- array( 'feed', T_( 'XML Feed' ), T_( 'Special system template for XML feeds like RSS and Atom' ) ),
92- ),
93- T_( 'Template type' ),
94- true // separate lines
95- );
96+ $edited_Template->type, array(
97+ array( 'xhtml', T_( 'XHTML' ), T_( 'XHTML (trans or strict) template for general browsing' ) ),
98+ array( 'feed', T_( 'XML Feed' ), T_( 'Special system template for XML feeds like RSS and Atom' ) ),
99+ array( 'other', T_( 'Other' ), T_( 'Template for anything other than general browsing or syndication feeds' ) ),
100+ ), T_( 'Template type' ), true // separate lines
101+ );
102
103 if( $template_containers = $edited_Template->get_containers() )
104 {
105
106=== modified file 'qp_install/_functions_create.php'
107--- qp_install/_functions_create.php 2011-01-29 22:04:06 +0000
108+++ qp_install/_functions_create.php 2011-06-17 09:28:39 +0000
109@@ -82,8 +82,7 @@
110 "('order-cheap-pills'), ('buy-xenadrine'), ('xxx'), ".
111 "('paris-hilton'), ('parishilton'), ('camgirls'), ('adult-models')";
112 $DB->query( $query );
113- echo "OK.<br />\n";
114-
115+ task_end();
116
117 // highest order of permissions for group #1
118 echo 'Creating default groups... ';
119@@ -142,7 +141,7 @@
120 $Group_Users->set( 'perm_templates', 0 );
121 $Group_Users->set( 'perm_files', 'view' );
122 $Group_Users->dbinsert();
123- echo "OK.<br />\n";
124+ task_end();
125
126 echo 'Creating user field definitions... ';
127 $DB->query( "
128@@ -175,10 +174,9 @@
129 ( 'msn_im', 'MSN IM', 'text', 'note', 'none' ),
130 ( 'skype', 'Skype ID', 'text', 'note', 'none' ),
131 ( 'yahoo_im', 'Yahoo IM', 'text', 'note', 'none' );" );
132- echo "OK.<br />\n";
133-
134-
135- task_begin('Creating default users (one per group)...');
136+ task_end();
137+
138+ echo 'Creating default users (one per group)...';
139 global $timestamp, $default_locale;
140
141 $User_Admin = new User();
142@@ -236,7 +234,6 @@
143 $User_Demo->set_datecreated( installer_timestamp() );
144 $User_Demo->set_Group( $Group_Users );
145 $User_Demo->dbinsert();
146-
147 task_end();
148
149 // added in Phoenix-Alpha
150@@ -254,8 +251,7 @@
151 ( 3000, 'Sidebar link' ),
152 ( 4000, 'Reserved' ),
153 ( 5000, 'Reserved' ) " );
154- echo "OK.<br />\n";
155-
156+ task_end();
157
158 // added in Phoenix-Beta
159 echo 'Creating default file types... ';
160@@ -282,7 +278,7 @@
161 (16, 'mp4', 'MPEG video', 'video/mp4', 'mp4.png', 'browser', 1),
162 (17, 'mov', 'Quicktime video', 'video/quicktime', 'mov.png', 'browser', 1)
163 " );
164- echo "OK.<br />\n";
165+ task_end();
166
167 if( ! empty( $current_locale ) )
168 { // Make sure the user sees his new system localized.
169@@ -300,7 +296,7 @@
170 .$DB->quote( $locales[$current_locale]['messages'] ).', '
171 .$DB->quote( $locales[$current_locale]['priority'] ).', '
172 .' 1)' );
173- echo 'OK.<br />', "\n";
174+ task_end();
175 }
176
177 create_default_settings();
178@@ -506,9 +502,7 @@
179 T_('This blog shows photos...'),
180 sprintf( $default_blog_longdesc, $blog_shortname, $blog_more_longdesc ),
181 4, 'photo', 1 ); // template ID, type, num_posts
182-
183- echo "OK.<br />\n";
184-
185+ task_end();
186
187 global $query, $timestamp;
188
189@@ -541,9 +535,7 @@
190
191 // Create categories for photoblog
192 $cat_photo_album = cat_create( 'Owen Michael', 'NULL', $blog_photoblog_ID );
193-
194- echo "OK.<br />\n";
195-
196+ task_end();
197
198 echo 'Creating sample posts and comments... ';
199
200@@ -1051,10 +1043,6 @@
201 $DB->query( $query );
202
203
204-
205-
206-
207-
208 // Insert a post into blog #1:
209 $now = date('Y-m-d H:i:s',installer_timestamp());
210 $edited_Item = new Item();
211@@ -1080,7 +1068,6 @@
212 $DB->query( $query );
213
214
215-
216 // Insert a post into blog #1:
217 $now = date('Y-m-d H:i:s',installer_timestamp());
218 $edited_Item = new Item();
219@@ -1164,7 +1151,7 @@
220 $edit_File = new File( 'collection', 1, 'qp-logo_337x76.jpg' );
221 $edit_File->link_to_Item( $edited_Item );
222
223- echo "OK.<br />\n";
224+ task_end();
225
226
227 echo 'Creating default group/blog permissions... ';
228@@ -1188,7 +1175,7 @@
229 ( $blog_linkblog_ID, ".$Group_Bloggers->ID.", 1, 'published,deprecated,protected,private,draft', 0, 0, 0, 0, 1, 1, 0 ),
230 ( $blog_linkblog_ID, ".$Group_Users->ID.", 1, '', 0, 0, 0, 0, 0, 0, 0 )";
231 $DB->query( $query );
232- echo "OK.<br />\n";
233+ task_end();
234
235 /*
236 // Note: we don't really need this any longer, but we might use it for a better default setup later...
237@@ -1202,7 +1189,7 @@
238 ( $blog_a_ID, ".$User_Demo->ID.", 1,
239 'published,deprecated,protected,private,draft', 1, 1, 0, 0, 1, 1, 1 )";
240 $DB->query( $query );
241- echo "OK.<br />\n";
242+ task_end();
243 */
244
245 install_basic_widgets();
246
247=== modified file 'qp_install/_functions_dbupgrade.php'
248--- qp_install/_functions_dbupgrade.php 2010-12-31 12:12:03 +0000
249+++ qp_install/_functions_dbupgrade.php 2011-06-17 09:28:39 +0000
250@@ -19,130 +19,6 @@
251
252 load_funcs('_core/_param.funcs.php');
253
254-
255-/**
256- * Create a DB version checkpoint
257- *
258- * This is useful when the next operation might timeout or fail!
259- * The checkpoint will allow to restart the script and continue where it stopped
260- *
261- * @param string version of DB at checkpoint
262- */
263-function set_upgrade_checkpoint( $version )
264-{
265- global $DB, $script_start_time, $locale;
266-
267- echo "Creating DB schema version checkpoint at $version... ";
268-
269- $query = "UPDATE T_settings
270- SET set_value = '$version'
271- WHERE set_name = 'db_version'";
272- $DB->query( $query );
273-
274-
275- $elapsed_time = time() - $script_start_time;
276-
277- echo "OK. (Elapsed upgrade time: $elapsed_time seconds)<br />\n";
278- flush();
279-
280- $max_exe_time = ini_get( 'max_execution_time' );
281- if( $max_exe_time && $elapsed_time > $max_exe_time - 10 )
282- { // Max exe time not disabled and we're reaching the end
283- echo 'We are reaching the time limit for this script. Please click <a href="index.php?locale='.$locale.'&amp;action=upgradedb">continue</a>...';
284- // Dirty temporary solution:
285- exit(0);
286- }
287-}
288-
289-
290-/**
291- * @return boolean Does a given index key name exist in DB?
292- */
293-function db_index_exists( $table, $index_name )
294-{
295- global $DB;
296-
297- $index_name = strtolower($index_name);
298-
299- foreach( $DB->get_results('SHOW INDEX FROM '.$table) as $row )
300- {
301- if( strtolower($row->Key_name) == $index_name )
302- {
303- return true;
304- }
305- }
306-
307- return false;
308-}
309-
310-
311-/**
312- * @param string Table name
313- * @param array Column names
314- * @return boolean Does a list of given column names exist in DB?
315- */
316-function db_cols_exist( $table, $col_names )
317-{
318- global $DB;
319-
320- foreach( $col_names as $k => $v )
321- $col_names[$k] = strtolower($v);
322-
323- foreach( $DB->get_results('SHOW COLUMNS FROM '.$table) as $row )
324- if( ($key = array_search(strtolower($row->Field), $col_names)) !== false )
325- unset( $col_names[$key] );
326-
327- return count($col_names) == 0;
328-}
329-
330-/**
331- * Drops a column, if it exists.
332- */
333-function db_drop_col( $table, $col_name )
334-{
335- global $DB;
336-
337- if( ! db_col_exists($table, $col_name) )
338- return false;
339-
340- $DB->query( 'ALTER TABLE '.$table.' DROP COLUMN '.$col_name );
341-}
342-
343-/**
344- * Add a column, if it does not already exist.
345- * If it exists already, a "ALTER TABLE" statement will get executed instead.
346- *
347- * @return boolean True if the column has been added, False if not.
348- */
349-function db_add_col( $table, $col_name, $col_desc )
350-{
351- global $DB;
352-
353- if( db_col_exists($table, $col_name) )
354- { // Column exists already, make sure it's the same.
355- $DB->query( 'ALTER TABLE '.$table.' MODIFY COLUMN '.$col_name.' '.$col_desc );
356- return false;
357- }
358-
359- $DB->query( 'ALTER TABLE '.$table.' ADD COLUMN '.$col_name.' '.$col_desc );
360-}
361-
362-
363-/**
364- * Add an INDEX. If another index with the same name already exists, it will
365- * get dropped before.
366- */
367-function db_add_index( $table, $name, $def )
368-{
369- global $DB;
370- if( db_index_exists($table, $name) )
371- {
372- $DB->query( 'ALTER TABLE '.$table.' DROP INDEX '.$name );
373- }
374- $DB->query( 'ALTER TABLE '.$table.' ADD INDEX '.$name.' ('.$def.')' );
375-}
376-
377-
378 /**
379 * Converts languages in a given table into according locales
380 *
381@@ -185,9 +61,9 @@
382 { // we have an old two letter lang code to convert
383 // and it doesn't match the default locale
384 foreach( $locales as $newlkey => $v )
385- { // loop given locales
386+ { // loop given locales
387 if( substr($newlkey, 0, 2) == strtolower($lkey) ) # TODO: check if valid/suitable
388- { // if language matches, update
389+ { // if language matches, update
390 $converted = $DB->query( "
391 UPDATE $table
392 SET $columnlang = '$newlkey'
393@@ -201,475 +77,260 @@
394 if( !$converted )
395 { // we have nothing converted yet, setting default:
396 $DB->query( "UPDATE $table
397- SET $columnlang = '$default_locale'
398+ SET $columnlang = '$default_locale'
399 WHERE $columnlang = '$lkey'" );
400 echo 'forced to default locale \''. $default_locale. '\'<br />';
401 }
402 }
403 echo "\n";
404-} // convert_lang_to_locale(-)
405-
406-
407-/**
408- * upgrade_dbase_tables(-)
409+}
410+
411+
412+/**
413+ * Add a column, if it does not already exist.
414+ * If it exists already, a "ALTER TABLE" statement will get executed instead.
415+ *
416+ * @return boolean True if the column has been added, False if not.
417+ */
418+function db_add_col( $table, $col_name, $col_desc )
419+{
420+ global $DB;
421+
422+ if( db_col_exists($table, $col_name) )
423+ { // Column exists already, make sure it's the same.
424+ $DB->query( 'ALTER TABLE '.$table.' MODIFY COLUMN '.$col_name.' '.$col_desc );
425+ return false;
426+ }
427+
428+ $DB->query( 'ALTER TABLE '.$table.' ADD COLUMN '.$col_name.' '.$col_desc );
429+}
430+
431+
432+/**
433+ * Add an INDEX. If another index with the same name already exists, it will
434+ * get dropped before.
435+ */
436+function db_add_index( $table, $name, $def )
437+{
438+ global $DB;
439+ if( db_index_exists($table, $name) )
440+ {
441+ $DB->query( 'ALTER TABLE '.$table.' DROP INDEX '.$name );
442+ }
443+ $DB->query( 'ALTER TABLE '.$table.' ADD INDEX '.$name.' ('.$def.')' );
444+}
445+
446+
447+/**
448+ * @param string Table name
449+ * @param array Column names
450+ * @return boolean Does a list of given column names exist in DB?
451+ */
452+function db_cols_exist( $table, $col_names )
453+{
454+ global $DB;
455+
456+ foreach( $col_names as $k => $v )
457+ $col_names[$k] = strtolower($v);
458+
459+ foreach( $DB->get_results('SHOW COLUMNS FROM '.$table) as $row )
460+ if( ($key = array_search(strtolower($row->Field), $col_names)) !== false )
461+ unset( $col_names[$key] );
462+
463+ return count($col_names) == 0;
464+}
465+
466+/**
467+ * Drops a column, if it exists.
468+ */
469+function db_drop_col( $table, $col_name )
470+{
471+ global $DB;
472+
473+ if( ! db_col_exists($table, $col_name) )
474+ return false;
475+
476+ $DB->query( 'ALTER TABLE '.$table.' DROP COLUMN '.$col_name );
477+}
478+
479+
480+/**
481+ * @return boolean Does a given index key name exist in DB?
482+ */
483+function db_index_exists( $table, $index_name )
484+{
485+ global $DB;
486+
487+ $index_name = strtolower($index_name);
488+
489+ foreach( $DB->get_results('SHOW INDEX FROM '.$table) as $row )
490+ {
491+ if( strtolower($row->Key_name) == $index_name )
492+ {
493+ return true;
494+ }
495+ }
496+
497+ return false;
498+}
499+
500+
501+/**
502+ * Create a DB version checkpoint
503+ *
504+ * This increments table.db_upgrade during an upgrade cycle. It starts matching
505+ * table.db_version and end matching $app_db_version. If the upgrader crashes
506+ * this value lets us pick up exactly where we left off :)
507+ *
508+ * @param string version of DB at checkpoint
509+ */
510+function set_upgrade_checkpoint( $version )
511+{
512+ global $DB, $script_start_time, $locale;
513+
514+ $DB->query( "UPDATE T_settings SET set_value = '$version' WHERE set_name = 'db_upgrade'" );
515+
516+ $max_exe_time = ini_get( 'max_execution_time' );
517+ $elapsed_time = time() - $script_start_time;
518+ if( $max_exe_time && $elapsed_time > $max_exe_time - 10 )
519+ { // Max exe time not disabled and we're reaching the end
520+ echo 'We are reaching the time limit for this script. Please click <a href="index.php?locale='.$locale.'&amp;action=upgradedb">continue</a>...';
521+ // Dirty temporary solution:
522+ exit(0);
523+ }
524+
525+ task_end();
526+
527+}
528+
529+
530+/**
531+ * Upgrade database tables
532+ *
533+ * This is a process. Life is a process. Therefore this is life.
534 */
535 function upgrade_dbase_tables()
536 {
537- global $app_db_config, $app_db_tableprefix;
538- global $app_baseurl, $old_db_version, $app_db_version, $app_name;
539- global $Group_Admins, $Group_Special, $Group_Bloggers, $Group_Users;
540- global $locales, $default_locale;
541+ global $old_db_version;
542 global $DB;
543- global $admin_url;
544-
545- // new DB-delta functionality
546- global $schema_queries, $inc_path;
547+ global $app_name;
548+ global $app_db_version;
549+ global $schema_queries;
550
551 // Load DB schema from modules
552 load_db_schema();
553-
554 load_funcs('_core/model/db/_upgrade.funcs.php');
555
556-
557+ // BEGIN installation status checks...
558 echo '<p>'.T_('Checking DB schema version...').' ';
559- $old_db_version = get_db_version();
560
561- if( empty($old_db_version) )
562+ // are we not installed?
563+ $old_db_version = get_db_version( 'version' );
564+ if( $old_db_version === NULL )
565 {
566- printf( T_( '<p><strong>OOPS! %s doesn\'t seem to be installed yet.</strong></p>' ), $app_name );
567- return;
568+ printf( T_( '<strong>OOPS! %s doesn\'t seem to be installed yet.</strong></p>' ), $app_name );
569+ return;
570 }
571
572+ // are we too old to rock and roll or too young to die?
573 echo $old_db_version, ' : ';
574-
575- if( $old_db_version < 9700 ) debug_die( T_('This version is too old!') );
576- if( $old_db_version > $app_db_version ) debug_die( T_('This version is too recent! We cannot downgrade to the version you are trying to install...') );
577+ if( $old_db_version < 0 )
578+ {
579+ debug_die( T_('This version is too old!') );
580+ }
581+ if( $old_db_version > $app_db_version )
582+ {
583+ debug_die( T_('This version is too recent! We cannot downgrade to the version you are trying to install...') );
584+ }
585+
586+ // did we crash while upgrading?
587+ $cur_db_version = get_db_version( 'upgrade' );
588+ if( $cur_db_version === NULL )
589+ { // Initialize current DB version (upgrade process):
590+ $cur_db_version = $old_db_version;
591+ $DB->query( "INSERT INTO T_settings (set_name, set_value) VALUES ('db_upgrade', '0')" );
592+ }
593+ else if( $cur_db_version != $old_db_version )
594+ {
595+ echo T_('It looks like we crashed while upgrading. We will try to pick up where we left off').'<br />';
596+ echo sprintf( T_('You had version %s and crashed at version %s on the way to version %s.'), $old_db_version, $cur_db_version, $app_db_version ).' ... ';
597+ }
598+
599 echo "OK.<br />\n";
600-
601-
602- // Try to obtain some serious time to do some serious processing (5 minutes)
603- @set_time_limit( 300 );
604-
605-
606- if( $old_db_version < 9800 )
607- { // 2.5.0 .... only ever happened in cvs?
608- echo 'Upgrading blogs table... ';
609- db_drop_col( 'T_blogs', 'blog_commentsexpire' );
610- echo "OK.<br />\n";
611-
612- echo 'Upgrading items table... ';
613- $DB->query( "ALTER TABLE T_items__item
614- CHANGE COLUMN post_urltitle post_urltitle VARCHAR(210) NULL DEFAULT NULL,
615- CHANGE COLUMN post_order post_order DOUBLE NULL,
616- ADD COLUMN post_titletag VARCHAR(255) NULL DEFAULT NULL AFTER post_urltitle" );
617- echo "OK.<br />\n";
618-
619- echo 'Creating keyphrase table... ';
620- $query = "CREATE TABLE T_track__keyphrase (
621- keyp_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
622- keyp_phrase VARCHAR( 255 ) NOT NULL,
623- PRIMARY KEY ( keyp_ID ),
624- UNIQUE keyp_phrase ( keyp_phrase )
625- )";
626- $DB->query( $query );
627- echo "OK.<br />\n";
628-
629- echo 'Upgrading hitlog table... ';
630- $query = "ALTER TABLE T_hitlog
631- CHANGE COLUMN hit_ID hit_ID INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
632- CHANGE COLUMN hit_datetime hit_datetime DATETIME NOT NULL DEFAULT '2000-01-01 00:00:00',
633- ADD COLUMN hit_keyphrase_keyp_ID INT UNSIGNED DEFAULT NULL AFTER hit_referer_dom_ID,
634- ADD INDEX hit_remote_addr ( hit_remote_addr ),
635- ADD INDEX hit_sess_ID ( hit_sess_ID )";
636- $DB->query( $query );
637- echo "OK.<br />\n";
638-
639- echo 'Upgrading sessions table... ';
640- $DB->query( "ALTER TABLE T_sessions
641- ALTER COLUMN sess_lastseen SET DEFAULT '2000-01-01 00:00:00',
642- ADD COLUMN sess_hitcount INT(10) UNSIGNED NOT NULL DEFAULT 1 AFTER sess_key,
643- ADD KEY sess_user_ID (sess_user_ID)" );
644- echo "OK.<br />\n";
645-
646- echo 'Creating goal tracking table... ';
647- $DB->query( "CREATE TABLE T_track__goal(
648- goal_ID int(10) unsigned NOT NULL auto_increment,
649- goal_name varchar(50) default NULL,
650- goal_key varchar(32) default NULL,
651- goal_redir_url varchar(255) default NULL,
652- goal_default_value double default NULL,
653- PRIMARY KEY (goal_ID),
654- UNIQUE KEY goal_key (goal_key)
655- )" );
656-
657- $DB->query( "CREATE TABLE T_track__goalhit (
658- ghit_ID int(10) unsigned NOT NULL auto_increment,
659- ghit_goal_ID int(10) unsigned NOT NULL,
660- ghit_hit_ID int(10) unsigned NOT NULL,
661- ghit_params TEXT default NULL,
662- PRIMARY KEY (ghit_ID),
663- KEY ghit_goal_ID (ghit_goal_ID),
664- KEY ghit_hit_ID (ghit_hit_ID)
665- )" );
666- echo "OK.<br />\n";
667-
668- set_upgrade_checkpoint( '9800' );
669- }
670-
671-
672- if( $old_db_version < 9900 )
673- { // 3.0 part 1
674- task_begin( 'Updating keyphrases in hitlog table... ' );
675- flush();
676- load_class( 'sessions/model/_hit.class.php' );
677- $sql = 'SELECT hit_ID, hit_referer
678- FROM T_hitlog
679- WHERE hit_referer_type = "search"
680- AND hit_keyphrase_keyp_ID IS NULL'; // this line just in case we crashed in the middle, so we restart where we stopped
681- $rows = $DB->get_results( $sql, OBJECT, 'get all search hits' );
682- foreach( $rows as $row )
683- {
684- $keyphrase = Hit::extract_keyphrase_from_referer( $row->hit_referer );
685- if( empty( $keyphrase ) )
686- {
687- continue;
688- }
689-
690- $DB->begin();
691-
692- $sql = 'SELECT keyp_ID
693- FROM T_track__keyphrase
694- WHERE keyp_phrase = '.$DB->quote($keyphrase);
695- $keyp_ID = $DB->get_var( $sql, 0, 0, 'Get keyphrase ID' );
696-
697- if( empty( $keyp_ID ) )
698- {
699- $sql = 'INSERT INTO T_track__keyphrase( keyp_phrase )
700- VALUES ('.$DB->quote($keyphrase).')';
701- $DB->query( $sql, 'Add new keyphrase' );
702- $keyp_ID = $DB->insert_id;
703- }
704-
705- $DB->query( 'UPDATE T_hitlog
706- SET hit_keyphrase_keyp_ID = '.$keyp_ID.'
707- WHERE hit_ID = '.$row->hit_ID, 'Update hit' );
708-
709- $DB->commit();
710- echo ". \n";
711- }
712- task_end();
713-
714- task_begin( 'Upgrading widgets table... ' );
715- $DB->query( "ALTER TABLE T_widget
716- CHANGE COLUMN wi_order wi_order INT(10) NOT NULL" );
717- task_end();
718-
719- task_begin( 'Upgrading Files table... ' );
720- $DB->query( "ALTER TABLE T_files
721- CHANGE COLUMN file_root_type file_root_type enum('absolute','user','collection','shared','skins') not null default 'absolute'" );
722- task_end();
723-
724- set_upgrade_checkpoint( '9900' );
725- }
726-
727- if( $old_db_version < 9910 )
728- { // 3.0 part 2
729-
730- task_begin( 'Upgrading Blogs table... ' );
731- $DB->query( "ALTER TABLE T_blogs CHANGE COLUMN blog_name blog_name varchar(255) NOT NULL default ''" );
732- task_end();
733-
734- task_begin( 'Adding new Post Types...' );
735- $DB->query( "
736- REPLACE INTO T_items__type( ptyp_ID, ptyp_name )
737- VALUES ( 1500, 'Intro-Main' ),
738- ( 1520, 'Intro-Cat' ),
739- ( 1530, 'Intro-Tag' ),
740- ( 1570, 'Intro-Sub' ),
741- ( 1600, 'Intro-All' ) " );
742- task_end();
743-
744- task_begin( 'Creating table for User field definitions' );
745- $DB->query( "CREATE TABLE T_plugin_sharedfields (
746- psf_ID int(10) unsigned NOT NULL,
747- psf_type char(8) NOT NULL,
748- psf_name varchar(255) collate latin1_general_ci NOT NULL,
749- PRIMARY KEY (psf_ID)
750- )" );
751- task_end();
752-
753- task_begin( 'Creating default field definitions...' );
754- $DB->query( "
755- INSERT INTO T_plugin_sharedfields (psf_fieldname, psf_label, psf_type, psf_note, psf_validate)
756- VALUES ( 'address_1', 'Address 1', 'text', '', 'none' ),
757- ( 'address_2', 'Address 2', 'text', '', 'none' ),
758- ( 'city', 'City', 'text', '', 'none' ),
759- ( 'county', 'County', 'text', '', 'none' ),
760- ( 'state', 'State', 'text', '', 'none' ),
761- ( 'province', 'Province', 'text', '', 'none' ),
762- ( 'postal_code', 'Postal Code', 'text', '', 'none' ),
763- ( 'nation', 'Nation', 'text', '', 'none' ),
764- ( 'home_phone', 'Home Phone', 'text', '', 'phone' ),
765- ( 'cell_phone', 'Cell Phone', 'text', '', 'phone' ),
766- ( 'home_fax', 'Home FAX', 'text', '', 'phone' ),
767- ( 'birthday', 'Birthday', 'text', '', 'none' ),
768- ( 'gender', 'Gender', 'text', '', 'none' ),
769- ( 'avatar_ID', 'Avatar File #', 'text', '', 'number' ),
770- ( 'digg_url', 'Digg', 'text', '', 'url' ),
771- ( 'facebook', 'Facebook', 'text', '', 'url' ),
772- ( 'flickr', 'Flickr', 'text', '', 'url' ),
773- ( 'linkdin', 'LinkedIn', 'text', '', 'url' ),
774- ( 'myspace', 'Myspace', 'text', '', 'url' ),
775- ( 'stumble', 'StumbleUpon', 'text', '', 'url' ),
776- ( 'twitter', 'Twitter', 'text', '', 'url' ),
777- ( 'youtube', 'YouTube', 'text', '', 'url' ),
778- ( 'aol_aim', 'AOL AIM', 'text', '', 'none' ),
779- ( 'icq_id', 'ICQ ID', 'text', '', 'none' ),
780- ( 'jabber', 'Jabber', 'text', '', 'none' ),
781- ( 'msn_im', 'MSN IM', 'text', '', 'none' ),
782- ( 'skype', 'Skype ID', 'text', '', 'none' ),
783- ( 'yahoo_im', 'Yahoo IM', 'text', '', 'none' );" );
784- task_end();
785-
786- task_begin( 'Creating table for User fields...' );
787- $DB->query( "CREATE TABLE T_plugin_sharedvalues (
788- psv_ID int(10) unsigned NOT NULL auto_increment,
789- psv_user_ID int(10) unsigned NOT NULL,
790- psv_psf_fieldname VARCHAR(32) NOT NULL,
791- psv_userfieldvalue VARCHAR(255) NOT NULL,
792- PRIMARY KEY (psv_ID)
793- )" );
794- task_end();
795-
796- set_upgrade_checkpoint( '9910' );
797- }
798-
799- if( $old_db_version < 9920 )
800- { // 3.1
801- task_begin( 'Upgrading Posts table... ' );
802- // This is for old posts that may have a post type of NULL which should never happen. ptyp 1 is for regular posts
803- $DB->query( "UPDATE T_items__item
804- SET post_ptyp_ID = 1
805- WHERE post_ptyp_ID IS NULL" );
806- $DB->query( "ALTER TABLE T_items__item
807- CHANGE COLUMN post_ptyp_ID post_ptyp_ID int(10) unsigned NOT NULL DEFAULT 1" );
808- task_end();
809-
810- task_begin( 'Upgrading Categories table... ' );
811- $DB->query( "ALTER TABLE T_categories
812- CHANGE COLUMN cat_name cat_name varchar(255) NOT NULL,
813- CHANGE COLUMN cat_description cat_description varchar(255) NULL DEFAULT NULL" );
814- db_add_col( 'T_categories', 'cat_order', 'int(11) NULL DEFAULT NULL AFTER cat_description' );
815- db_add_index( 'T_categories', 'cat_order', 'cat_order' );
816-
817- $DB->query( "UPDATE T_categories
818- SET cat_order = cat_ID" );
819- task_end();
820-
821- task_begin( 'Upgrading widgets table... ' );
822- db_add_col( 'T_widget', 'wi_enabled', 'tinyint(1) NOT NULL DEFAULT 1 AFTER wi_order' );
823- task_end();
824- }
825- if( $old_db_version < 9930 )
826- { // 3.1 continued
827- task_begin( 'Updating item types...' );
828- $DB->query( "
829- REPLACE INTO T_items__type ( ptyp_ID, ptyp_name )
830- VALUES ( 3000, 'Sidebar link' )" );
831- echo "OK.<br />\n";
832- task_end();
833-
834- task_begin( 'Updating items table...' );
835- $DB->query( "ALTER TABLE T_items__item ENGINE=innodb" ); // fp> hum... this originally was a test :)
836- task_end();
837-
838- task_begin( 'Creating versions table...' );
839- $DB->query( "CREATE TABLE T_items__version (
840- iver_itm_ID INT UNSIGNED NOT NULL ,
841- iver_edit_user_ID INT UNSIGNED NOT NULL ,
842- iver_edit_datetime DATETIME NOT NULL ,
843- iver_status ENUM('published','deprecated','protected','private','draft','redirected') NULL ,
844- iver_title TEXT NULL ,
845- iver_content MEDIUMTEXT NULL ,
846- INDEX iver_itm_ID ( iver_itm_ID )
847- ) ENGINE = innodb" );
848- task_end();
849-
850- task_begin( 'Updating group permissions...' );
851- $DB->query( "UPDATE T_groups
852- SET grp_perm_xhtml_css_tweaks = 1
853- WHERE grp_ID <= 3" );
854- task_end();
855-
856- set_upgrade_checkpoint( '9930' );
857- }
858-
859- if( $old_db_version < 9940 )
860- { // 3.2
861- task_begin( 'Updating hitlog table...' );
862- $DB->query( "ALTER TABLE T_hitlog ADD COLUMN hit_serprank INT UNSIGNED DEFAULT NULL AFTER hit_keyphrase_keyp_ID" );
863- task_end();
864-
865- task_begin( 'Updating versions table...' );
866- $DB->query( "ALTER TABLE T_items__version
867- CHANGE COLUMN iver_edit_user_ID iver_edit_user_ID INT UNSIGNED NULL" );
868- task_end();
869- }
870-
871- if( $old_db_version < 9950 )
872- { // 3.3
873- task_begin( 'Altering Blogs table... ' );
874- $DB->query( "ALTER TABLE T_blogs CHANGE COLUMN blog_shortname blog_shortname varchar(255) default ''" );
875- task_end();
876-
877- task_begin( 'Altering default dates... ' );
878- $DB->query( "ALTER TABLE T_links
879- ALTER COLUMN link_datecreated SET DEFAULT '2000-01-01 00:00:00',
880- ALTER COLUMN link_datemodified SET DEFAULT '2000-01-01 00:00:00'" );
881- $DB->query( "ALTER TABLE T_cron__task
882- ALTER COLUMN ctsk_start_datetime SET DEFAULT '2000-01-01 00:00:00'" );
883- $DB->query( "ALTER TABLE T_cron__log
884- ALTER COLUMN clog_realstart_datetime SET DEFAULT '2000-01-01 00:00:00'" );
885- task_end();
886-
887- task_begin( 'Altering Items table... ' );
888- $DB->query( "ALTER TABLE T_items__item
889- ADD COLUMN post_metadesc VARCHAR(255) NULL DEFAULT NULL AFTER post_titletag,
890- ADD COLUMN post_metakeywords VARCHAR(255) NULL DEFAULT NULL AFTER post_metadesc,
891- ADD COLUMN post_editor_code VARCHAR(32) NULL COMMENT 'Plugin code of the editor used to edit this post' AFTER post_varchar3" );
892- task_end();
893-
894- task_begin( 'Forcing AutoP posts to html editor...' );
895- $DB->query( 'UPDATE T_items__item
896- SET post_editor_code = "html"
897- WHERE post_renderers = "default"
898- OR post_renderers LIKE "%qp_auto_p%"' );
899- task_end();
900-
901- set_upgrade_checkpoint( '9950' );
902- }
903-
904- if( $old_db_version < 9960 )
905- { // 3.3
906-
907- echo "Renaming tables...";
908- $DB->save_error_state();
909- $DB->halt_on_error = false;
910- $DB->show_errors = false;
911- $DB->query( "ALTER TABLE {$app_db_tableprefix}users_fields RENAME TO T_plugin_sharedvalues" );
912- $DB->restore_error_state();
913- echo "OK.<br />\n";
914-
915- // fp> The following is more tricky to do with CHARACTER SET. During upgrade, we don't know what the admin actually wants.
916- task_begin( 'Making sure all tables use desired storage ENGINE...' );
917- foreach( $schema_queries as $table_name=>$table_def )
918- {
919- if( $DB->query( 'SHOW TABLES LIKE \''.$table_name.'\'' )
920- && preg_match( '/ ENGINE = ([a-z]+) /is', $table_def[1], $matches ) )
921- { // If the table exists and has an ENGINE definition:
922- echo $table_name.':'.$matches[1].'<br />';
923- $DB->query( "ALTER TABLE $table_name ENGINE = ".$matches[1] );
924- }
925- }
926- task_end();
927-
928- set_upgrade_checkpoint( '9960' );
929- }
930-
931-
932- // --- QUAM PLURES UPGRADES ---
933- // NOTE: This is for reference ONLY!
934-
935- if( $old_db_version < 100000 )
936- { // 0.0.0
937- task_begin( 'Updating widgets table...' );
938- $DB->query( "ALTER TABLE T_widget
939- CHANGE COLUMN wi_type wi_type ENUM('widget', 'core', 'plugin') NOT NULL DEFAULT 'widget'" );
940- $DB->query( "UPDATE T_widget SET wi_type='widget' WHERE NOT( wi_type='plugin' )" );
941- $DB->query( "ALTER TABLE T_widget
942- CHANGE COLUMN wi_type wi_type ENUM('widget', 'plugin') NOT NULL DEFAULT 'widget'" );
943- task_end();
944-
945- // rename skins to templates
946- task_begin( 'Renaming skins to templates...' );
947- $DB->query( "ALTER TABLE T_blogs CHANGE blog_skin_ID blog_template_ID INT( 10 ) UNSIGNED NOT NULL DEFAULT 1" );
948- $DB->query( "ALTER TABLE T_files
949- CHANGE file_root_type file_root_type ENUM( 'absolute', 'user', 'collection', 'shared', 'skins', 'templates' )
950- CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'absolute'" );
951- $DB->query( "UPDATE T_files SET file_root_type='templates' WHERE file_root_type='skins'" );
952- $DB->query( "ALTER TABLE T_files
953- CHANGE file_root_type file_root_type ENUM( 'absolute', 'user', 'collection', 'shared', 'templates' )
954- CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'absolute'" );
955- $DB->query( "ALTER TABLE {$app_db_tableprefix}skins__container CHANGE sco_skin_ID sco_template_ID INT( 10 ) UNSIGNED NOT NULL" );
956- $DB->query( "RENAME TABLE {$app_db_tableprefix}skins__container TO {$app_db_tableprefix}templates__container" );
957-
958- $DB->query( "ALTER TABLE {$app_db_tableprefix}skins__skin
959- CHANGE skin_ID template_ID INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT,
960- CHANGE skin_name template_name VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
961- CHANGE skin_type template_type ENUM( 'normal', 'feed' ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'normal',
962- CHANGE skin_folder template_folder VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL" );
963- $DB->query( "ALTER TABLE {$app_db_tableprefix}skins__skin
964- DROP INDEX skin_folder, ADD UNIQUE template_folder ( template_folder ),
965- DROP INDEX skin_name, ADD INDEX template_name ( template_name )" );
966- $DB->query( "RENAME TABLE {$app_db_tableprefix}skins__skin TO {$app_db_tableprefix}templates__template" );
967-
968- task_end();
969-
970- // Spyware removed, kill associated setting
971- task_begin( 'Killing b2evolution.net polling times... ' );
972- $DB->query( "
973- DELETE FROM T_settings
974- WHERE set_name = 'evonet_last_attempt'
975- OR set_name = 'evonet_last_update'" );
976- task_end();
977-
978- set_upgrade_checkpoint( '100000' );
979- }
980- if( $old_db_version < 100010 )
981- { // 0.0.0, part #2
982- task_begin( 'Updating user table...' );
983- $DB->query( 'ALTER TABLE T_users MODIFY user_pass CHAR(40) NOT NULL' );
984- task_end();
985-
986- task_begin( 'Adding salts to user passwords...' );
987- $DB->query( 'UPDATE T_users SET user_pass = SHA1( CONCAT( user_login, user_pass ) )' );
988- task_end();
989-
990- set_upgrade_checkpoint( '100010' );
991- }
992-
993-
994- /*
995- * ADD UPGRADES HERE.
996- *
997- * ALL DB CHANGES MUST BE EXPLICITELY CARRIED OUT. DO NOT RELY ON SCHEMA UPDATES!
998- * Schema updates do not survive after several incremental changes.
999- *
1000- * NOTE: every change that gets done here, should bump {@link $app_db_version} (by 100).
1001- */
1002-
1003- // Just in case, make sure the db schema version is upto date at the end.
1004- if( $old_db_version != $app_db_version )
1005- { // Update DB schema version to $app_db_version
1006- set_upgrade_checkpoint( $app_db_version );
1007- }
1008-
1009-
1010-
1011-
1012- // This has to be at the end because plugin install may fail if the DB schema is not current (matching Plugins class).
1013- // Only new default plugins will be installed, based on $old_db_version.
1014- // dh> NOTE: if this fails (e.g. fatal error in one of the plugins), it will not get repeated
1015- install_basic_plugins( $old_db_version );
1016-
1017-
1018- /*
1019- * Check to make sure the DB schema is up to date:
1020- */
1021+ // END installation status checks...
1022+
1023+ // Try to obtain some serious time to do some serious processing (5 minutes and 57 seconds)
1024+ @set_time_limit( 357 );
1025+
1026+ // ---------------------------------------------------------------------------
1027+ // BEGIN UPGRADES FROM V0.0.0 ($app_db_version = 0)
1028+ // ---------------------------------------------------------------------------
1029+
1030+ // ---------------------------------------------------------------------------
1031+ // BEGIN BRANCH: html5_step_one
1032+ // https://code.launchpad.net/~edb/quam-plures/html5_step_one
1033+ // ---------------------------------------------------------------------------
1034+
1035+ if( $old_db_version < 1 )
1036+ { // change the template_type options...
1037+ echo 'Upgrading templates__template table (1 of 4) ... ';
1038+ db_add_col( "T_templates__template", "template_type", "ENUM('xhtml', 'normal', 'feed', 'other') NOT NULL DEFAULT 'xhtml'" );
1039+ set_upgrade_checkpoint( '1' );
1040+ }
1041+
1042+ if( $old_db_version < 2 )
1043+ { // change "normal" types to "xhtml"
1044+ echo 'Upgrading templates__template table (2 of 4) ... ';
1045+ $DB->query( "UPDATE T_templates__template SET template_type = REPLACE( template_type, 'normal', 'xhtml' )" );
1046+ set_upgrade_checkpoint( '2' );
1047+ }
1048+
1049+ if( $old_db_version < 3 )
1050+ { // if Sitemap is installed change the type to "other"
1051+ echo 'Upgrading templates__template table (3 of 4) ... ';
1052+ $DB->query( "UPDATE T_templates__template SET template_type = 'other' WHERE template_name = 'Sitemap'" );
1053+ set_upgrade_checkpoint( '3' );
1054+ }
1055+
1056+ if( $old_db_version < 4 )
1057+ { // change the template_type options again...
1058+ echo 'Upgrading templates__template table (4 of 4) ... ';
1059+ db_add_col( "T_templates__template", "template_type", "ENUM('xhtml', 'feed', 'other') NOT NULL DEFAULT 'xhtml'" );
1060+ set_upgrade_checkpoint( '4' );
1061+ }
1062+
1063+ // ---------------------------------------------------------------------------
1064+ // END BRANCH: html5_step_one
1065+ // ---------------------------------------------------------------------------
1066+
1067+ /*****************************************************************************
1068+ * ADD UPGRADES HERE! *
1069+ * Remember changing the DB schema, too! This provides for fully automatic *
1070+ * upgrades when there were changes but the DB version seems to be *
1071+ * up-to-date. Look at the following files: *
1072+ * qp_inc/_core/model/__core.install.php *
1073+ * qp_inc/sessions/model/_sessions.install.php *
1074+ *****************************************************************************/
1075+
1076+ // ---------------------------------------------------------------------------
1077+ // THE FOLLOWING STUFF GETS DONE AFTER ALL THE DATABASE CHANGES ARE DONE
1078+ // ---------------------------------------------------------------------------
1079+
1080+ // set db_version to match what our last upgrade value said we were at
1081+ $end_of_upgrade = get_db_version( 'upgrade' );
1082+ $DB->query( "UPDATE T_settings SET set_value = '$end_of_upgrade' WHERE set_name = 'db_version'" );
1083+
1084+ // double-check our upgrade against our target
1085+ if( $end_of_upgrade != $app_db_version )
1086+ { // This is a serious problem that should never reach production!
1087+ // It means that our branch-work wasn't done well, so fix it :)
1088+ debug_die( 'The end of the upgrade process did not get us where we needed to be! '.$end_of_upgrade.' vs '.$app_db_version );
1089+ }
1090+
1091+ // Check to make sure the DB schema is up to date:
1092 $upgrade_db_deltas = array(); // This holds changes to make, if any (just all queries)
1093-
1094 foreach( $schema_queries as $table => $query_info )
1095- { // For each table in the schema, check diffs...
1096+ { // For each table in the schema, check diffs...
1097 foreach( db_delta( $query_info[1], array('drop_column', 'drop_index') ) as $table => $queries )
1098 {
1099 foreach( $queries as $qinfo )
1100@@ -689,7 +350,6 @@
1101 else
1102 {
1103 // delta queries have to be confirmed or executed now..
1104-
1105 $confirmed_db_upgrade = param('confirmed', 'integer', 0); // force confirmation
1106 $upgrade_db_deltas_confirm_md5 = param( 'upgrade_db_deltas_confirm_md5', 'string', '' );
1107
1108@@ -720,12 +380,8 @@
1109 $Form->hidden( 'upgrade_db_deltas_confirm_md5', md5(implode( '', $upgrade_db_deltas )) );
1110 $Form->hidden( 'action', $action );
1111 $Form->hidden( 'locale', $locale );
1112-
1113-
1114- echo '<p>'.T_('The version number is correct, but we have detected changes in the database schema. This can happen with CVS versions...').'</p>';
1115-
1116+ echo '<p>'.T_('The version number is correct, but we have detected changes in the database schema. This can happen with <abbr title="Version Control System">VCS</abbr> versions...').'</p>';
1117 echo '<p>'.T_('The following database changes will be carried out. If you are not sure what this means, it will probably be alright.').'</p>';
1118-
1119 echo '<ul>';
1120 foreach( $upgrade_db_deltas as $l_delta )
1121 {
1122@@ -746,5 +402,4 @@
1123 return true;
1124 }
1125
1126-
1127 ?>
1128
1129=== modified file 'qp_install/_functions_install.php'
1130--- qp_install/_functions_install.php 2010-12-31 12:12:03 +0000
1131+++ qp_install/_functions_install.php 2011-06-17 09:28:39 +0000
1132@@ -121,7 +121,7 @@
1133 */
1134 require_once dirname(__FILE__).'/_functions_create.php';
1135
1136- if( $old_db_version = get_db_version() )
1137+ if( ( $old_db_version = get_db_version( 'version' ) ) !== NULL )
1138 {
1139 echo '<p><strong>';
1140 printf( T_('OOPS! It seems %s is already installed!'), $app_name );
1141@@ -197,27 +197,22 @@
1142
1143
1144 /**
1145- * Begin install task.
1146- * This will offer other display methods in the future
1147- */
1148-function task_begin( $title )
1149-{
1150- echo $title;
1151-}
1152-
1153-
1154-/**
1155 * End install task.
1156 * This will offer other display methods in the future
1157 */
1158 function task_end()
1159 {
1160- echo "OK.<br />\n";
1161+ echo T_('OK.')."<br />\n";
1162 flush();
1163 }
1164
1165
1166-function get_db_version()
1167+/**
1168+ * Get DB version
1169+ *
1170+ * returns either the database version or the version during upgrading
1171+ */
1172+function get_db_version( $which )
1173 {
1174 global $DB;
1175
1176@@ -227,13 +222,13 @@
1177
1178 $r = NULL;
1179
1180- if( db_col_exists( 'T_settings', 'set_name' ) )
1181- { // we have new table format (since 0.9)
1182+ if( $which == 'version' )
1183+ { // actual value (after successful install or upgrade)
1184 $r = $DB->get_var( 'SELECT set_value FROM T_settings WHERE set_name = "db_version"' );
1185 }
1186- else
1187- {
1188- $r = $DB->get_var( 'SELECT db_version FROM T_settings' );
1189+ if( $which == 'upgrade' )
1190+ { // value while upgrading (matches db_version when done)
1191+ $r = $DB->get_var( 'SELECT set_value FROM T_settings WHERE set_name = "db_upgrade"' );
1192 }
1193
1194 $DB->restore_error_state();
1195@@ -292,7 +287,7 @@
1196 $DB->query( $query );
1197 }
1198 }
1199- echo "OK.<br />\n";
1200+ task_end();
1201
1202 }
1203
1204@@ -349,7 +344,7 @@
1205 $DB->query(
1206 "INSERT INTO T_settings (set_name, set_value)
1207 VALUES ".implode( ', ', $insertvalues ) );
1208- echo "OK.<br />\n";
1209+ task_end();
1210 }
1211
1212
1213@@ -387,8 +382,7 @@
1214 template_install( 'vastitude' );
1215 template_install( '_atom' );
1216 template_install( '_rss2' );
1217-
1218- echo "OK.<br />\n";
1219+ task_end();
1220 }
1221
1222
1223@@ -420,7 +414,9 @@
1224 // each plugin (which may then use (User)Settings in PluginInit (through Plugin::__get)).
1225 $GLOBALS['Plugins'] = & $Plugins_admin;
1226
1227- if( $old_db_version < 0001 )
1228+ // Tblue> 0001 is octal notation and _could_ lead to unwanted side effects
1229+ // in the future (if changed).
1230+ if( $old_db_version < 1 )
1231 {
1232 install_plugin( 'adsense_plugin' ); // 'toolbars'
1233 install_plugin( 'archives_plugin' ); // 'widgets' - one day this turns into a widget :)
1234@@ -621,7 +617,7 @@
1235 SELECT blog_ID, "Sidebar 2", 4, "widget", "free_html", \'a:5:{s:5:"title";s:9:"Sidebar 2";s:7:"content";s:162:"This is the "Sidebar 2" container. You can place any widget you like in here. In the evo toolbar at the top of this page, select "Customize", then "Blog Widgets".";s:11:"widget_name";s:9:"Free HTML";s:16:"widget_css_class";s:0:"";s:9:"widget_ID";s:0:"";}\'
1236 FROM T_blogs' );
1237
1238- echo "OK.<br />\n";
1239+ task_end();
1240 }
1241
1242
1243@@ -810,7 +806,7 @@
1244 on delete restrict
1245 on update restrict' );
1246
1247- echo "OK.<br />\n";
1248+ task_end();
1249 }
1250
1251
1252@@ -841,4 +837,5 @@
1253 }
1254
1255 }
1256+
1257 ?>
1258
1259=== modified file 'qp_install/index.php'
1260--- qp_install/index.php 2011-02-07 05:27:47 +0000
1261+++ qp_install/index.php 2011-06-17 09:28:39 +0000
1262@@ -146,35 +146,32 @@
1263 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1264 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>">
1265 <head>
1266- <title><?php
1267- printf( /* TRANS: %s: Application name */ T_('%s installer'), $app_name );
1268- if( $title )
1269- {
1270- echo ': ', $title;
1271- }
1272- ?></title>
1273- <link rel="icon" href="../favicon.ico" type="image/x-icon"/>
1274- <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
1275- <meta name="viewport" content="width = 750" />
1276- <link href="../qp_rsc/css/support_install.css" rel="stylesheet" type="text/css" />
1277+<title><?php
1278+ printf( /* TRANS: %s: Application name */ T_('%s installer'), $app_name );
1279+ if( $title )
1280+ {
1281+ echo ': ', $title;
1282+ }
1283+?></title>
1284+<link rel="icon" href="../favicon.ico" type="image/x-icon"/>
1285+<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
1286+<meta name="viewport" content="width = 750" />
1287+<link href="../qp_rsc/css/support_install.css" rel="stylesheet" type="text/css" />
1288 </head>
1289
1290 <body>
1291
1292- <div class="wrapper">
1293- <?php display_locale_selector(); ?>
1294- <div class="menu_top">
1295- <?php echo T_('Current installation') ?>:
1296- <a href="index.php?locale=<?php echo $default_locale ?>"><?php echo T_('Install menu') ?></a>
1297- </div>
1298+<div class="wrapper">
1299+<?php display_locale_selector(); ?>
1300+<div class="menu_top">
1301+<?php echo T_('Current installation') ?>:
1302+<a href="index.php?locale=<?php echo $default_locale ?>"><?php echo T_('Install menu') ?></a>
1303+</div>
1304
1305 <?php
1306-
1307 block_open();
1308-
1309 if( $app_config_is_done || (($action != 'start') && ($action != 'default') && ($action != 'conf')) )
1310 { // Connect to DB:
1311-
1312 $tmp_db_config = $app_db_config;
1313
1314 // We want a friendly message if we can't connect:
1315@@ -206,8 +203,8 @@
1316 {
1317 die( '<div class="error"><p class="error"><strong>'
1318 .sprintf( T_('The minimum requirement for this version of %s is %s version %s '
1319- .'but you are trying to use version %s!'),
1320- $app_name, 'MySQL', '5.0', $mysql_version )
1321+ .'but you are trying to use version %s!'),
1322+ $app_name, 'MySQL', '5.0', $mysql_version )
1323 .'</strong></p></div>' );
1324 }
1325 }
1326@@ -219,8 +216,8 @@
1327 {
1328 die( '<div class="error"><p class="error"><strong>'
1329 .sprintf( T_( 'The minimum requirement for this version of %s is %s version %s but you are '
1330- .'trying to use version %s!'),
1331- $app_name, 'PHP', '5.0', phpversion() )
1332+ .'trying to use version %s!'),
1333+ $app_name, 'PHP', '5.0', phpversion() )
1334 .'</strong></p></div>' );
1335 }
1336
1337@@ -240,15 +237,10 @@
1338 switch( $action )
1339 {
1340 case 'conf':
1341- /*
1342- * -----------------------------------------------------------------------------------
1343- * Write conf file:
1344- * -----------------------------------------------------------------------------------
1345- */
1346+ /* Write conf file */
1347 display_locale_selector();
1348
1349 block_open();
1350-
1351 param( 'conf_db_user', 'string', true );
1352 param( 'conf_db_password', '', true );
1353 param( 'conf_db_name', 'string', true );
1354@@ -259,15 +251,16 @@
1355
1356 // Connect to DB:
1357 $DB = new DB( array(
1358- 'user' => $conf_db_user,
1359- 'password' => $conf_db_password,
1360- 'name' => $conf_db_name,
1361- 'host' => $conf_db_host,
1362- 'aliases' => $app_db_config['aliases'],
1363- 'use_transactions' => $app_db_config['use_transactions'],
1364- 'table_options' => $app_db_config['table_options'],
1365- 'connection_charset' => $app_db_config['connection_charset'],
1366- 'halt_on_error' => false ) );
1367+ 'user' => $conf_db_user,
1368+ 'password' => $conf_db_password,
1369+ 'name' => $conf_db_name,
1370+ 'host' => $conf_db_host,
1371+ 'aliases' => $app_db_config['aliases'],
1372+ 'use_transactions' => $app_db_config['use_transactions'],
1373+ 'table_options' => $app_db_config['table_options'],
1374+ 'connection_charset' => $app_db_config['connection_charset'],
1375+ 'halt_on_error' => false )
1376+ );
1377 if( $DB->error )
1378 { // restart conf
1379 echo '<p class="error">'.T_('It seems that the database config settings you entered don\'t work. Please check them carefully and try again...').'</p>';
1380@@ -321,12 +314,12 @@
1381 <p><strong><?php printf( T_('We cannot automatically create or update your config file [%s]!'), $conf_filepath ); ?></strong></p>
1382 <p><strong><?php echo T_('You need to update the config file manually:') ?></strong></p>
1383 <ol>
1384- <li><?php echo T_('Create a new text file with a text editor.') ?></li>
1385- <li><?php echo T_('Copy the contents from the box below.') ?></li>
1386- <li><?php echo T_('Paste them into your local text editor. <strong>ATTENTION: make sure there is ABSOLUTELY NO WHITESPACE after the final <code>?&gt;</code> in the file.</strong> Any space, tab, newline or blank line at the end of the conf file may prevent cookies from being set when you try to log in later.') ?></li>
1387- <li><?php echo T_('Save the file locally under the name <code>_main_config.php</code>') ?></li>
1388- <li><?php echo T_('Upload the file to your server, into the <code>/qp_config</code> folder.') ?></li>
1389- <li><?php printf( T_('When done <a %s>call the installer</a> again. The installer will rerun tests to connect to your database.'), 'href="index.php?locale='.$default_locale.'"') ?></li>
1390+ <li><?php echo T_('Create a new text file with a text editor.') ?></li>
1391+ <li><?php echo T_('Copy the contents from the box below.') ?></li>
1392+ <li><?php echo T_('Paste them into your local text editor. <strong>ATTENTION: make sure there is ABSOLUTELY NO WHITESPACE after the final <code>?&gt;</code> in the file.</strong> Any space, tab, newline or blank line at the end of the conf file may prevent cookies from being set when you try to log in later.') ?></li>
1393+ <li><?php echo T_('Save the file locally under the name <code>_main_config.php</code>') ?></li>
1394+ <li><?php echo T_('Upload the file to your server, into the <code>/qp_config</code> folder.') ?></li>
1395+ <li><?php printf( T_('When done <a %s>call the installer</a> again. The installer will rerun tests to connect to your database.'), 'href="index.php?locale='.$default_locale.'"') ?></li>
1396 </ol>
1397 <p><?php echo T_('This is how your _main_config.php should look like:') ?></p>
1398 <blockquote>
1399@@ -354,11 +347,7 @@
1400
1401 case 'start':
1402 case 'default':
1403- /*
1404- * -----------------------------------------------------------------------------------
1405- * Start of install procedure:
1406- * -----------------------------------------------------------------------------------
1407- */
1408+ /* Start of install procedure */
1409 if( $action == 'start' || !$app_config_is_done )
1410 {
1411 display_locale_selector();
1412@@ -378,7 +367,6 @@
1413 }
1414 else
1415 {
1416-
1417 // Set default params if not provided otherwise:
1418 param( 'conf_db_user', 'string', $app_db_config['user'] );
1419 param( 'conf_db_password', '', $app_db_config['password'] );
1420@@ -391,7 +379,6 @@
1421 $app_baseurl .= ':'.$_SERVER['SERVER_PORT'];
1422 $app_baseurl .= preg_replace( '#/qp_install(/(index.php)?)?$#', '', $ReqPath ).'/';
1423 param( 'conf_baseurl', 'string', $app_baseurl );
1424-
1425 ?>
1426
1427 <p><?php echo T_('The basic configuration file (<code>/qp_config/_main_config.php</code>) has not been created yet. If your server supports it, you can automatically generate it by filling out the form below.') ?></p>
1428@@ -399,61 +386,57 @@
1429 <p><?php printf( T_('This is the minimum info we need to set up %s on this server:'), $app_name ); ?></p>
1430
1431 <form class="fform" name="form" action="index.php" method="post">
1432- <input type="hidden" name="action" value="conf" />
1433- <input type="hidden" name="locale" value="<?php echo $default_locale; ?>" />
1434-
1435- <fieldset>
1436- <legend><?php echo T_('Blog settings') ?></legend>
1437- <?php
1438- form_text( 'conf_baseurl', $conf_baseurl, 50, T_('Website address'),
1439- sprintf( /* TRANS: %1$s: App name */
1440- T_('This is where %1$s and your blogs reside by default. '
1441- .'CHECK THIS CAREFULLY or not much will work. If you want to '
1442- .'test %1$s on your local machine, in order for login cookies '
1443- .'to work, you MUST use http://<strong>localhost</strong>/path... '
1444- .'Do NOT use your machine\'s name!' ), $app_name ),
1445- 120 );
1446- ?>
1447- </fieldset>
1448-
1449- <fieldset>
1450- <legend><?php echo T_('Database you want to install into') ?></legend>
1451- <p class="note"><?php
1452- printf( /* TRANS: %1$s: App name. */
1453- T_( '%1$s stores blog posts, comments, user permissions, etc. in a MySQL '
1454- .'database. You must create this database prior to installing %1$s '
1455- .'and provide the access parameters to this database below. If '
1456- .'you are not familiar with this, you can ask your hosting provider '
1457- .'to create the database for you.' ), $app_name );
1458- ?></p>
1459- <?php
1460- form_text( 'conf_db_host', $conf_db_host, 16, T_('MySQL Host/Server'), T_( 'Typically looks like "localhost" or "sql-6" or "sql-8.yourhost.net"...' ), 120 );
1461- form_text( 'conf_db_name', $conf_db_name, 16, T_('MySQL Database'), T_( 'Name of the MySQL database you have created on the server' ), 100);
1462- form_text( 'conf_db_user', $conf_db_user, 16, T_('MySQL Username'), sprintf( T_('Used by %s to access the MySQL database' ), $app_name ), 100 );
1463- form_text( 'conf_db_password', $conf_db_password, 16, T_('MySQL Password'), sprintf( T_('Used by %s to access the MySQL database' ), $app_name ), 100 ); // no need to hide this. nobody installs an application from a public place
1464- form_text( 'conf_db_tableprefix', $conf_db_tableprefix, 16, T_('MySQL tables prefix'), sprintf( T_('All DB tables will be prefixed with this. You need to change this only if you want to have multiple %s installations in the same DB.' ), $app_name ), 30 );
1465- ?>
1466- </fieldset>
1467-
1468- <div class="buttons">
1469- <input type="submit" name="submit" value="<?php echo T_('Update config file') ?>" class="search" />
1470- <input type="reset" value="<?php echo T_('Reset') ?>" class="search" />
1471- </div>
1472+ <input type="hidden" name="action" value="conf" />
1473+ <input type="hidden" name="locale" value="<?php echo $default_locale; ?>" />
1474+
1475+ <fieldset>
1476+ <legend><?php echo T_('Blog settings') ?></legend>
1477+ <?php
1478+ form_text( 'conf_baseurl', $conf_baseurl, 50, T_('Website address'),
1479+ sprintf( /* TRANS: %1$s: App name */
1480+ T_('This is where %1$s and your blogs reside by default. '
1481+ .'CHECK THIS CAREFULLY or not much will work. If you want to '
1482+ .'test %1$s on your local machine, in order for login cookies '
1483+ .'to work, you MUST use http://<strong>localhost</strong>/path... '
1484+ .'Do NOT use your machine\'s name!' ), $app_name ),
1485+ 120 );
1486+ ?>
1487+ </fieldset>
1488+
1489+ <fieldset>
1490+ <legend><?php echo T_('Database you want to install into') ?></legend>
1491+ <p class="note"><?php
1492+ printf( /* TRANS: %1$s: App name. */
1493+ T_( '%1$s stores blog posts, comments, user permissions, etc. in a MySQL '
1494+ .'database. You must create this database prior to installing %1$s '
1495+ .'and provide the access parameters to this database below. If '
1496+ .'you are not familiar with this, you can ask your hosting provider '
1497+ .'to create the database for you.' ), $app_name );
1498+ ?></p>
1499+ <?php
1500+ form_text( 'conf_db_host', $conf_db_host, 16, T_('MySQL Host/Server'), T_( 'Typically looks like "localhost" or "sql-6" or "sql-8.yourhost.net"...' ), 120 );
1501+ form_text( 'conf_db_name', $conf_db_name, 16, T_('MySQL Database'), T_( 'Name of the MySQL database you have created on the server' ), 100);
1502+ form_text( 'conf_db_user', $conf_db_user, 16, T_('MySQL Username'), sprintf( T_('Used by %s to access the MySQL database' ), $app_name ), 100 );
1503+ form_text( 'conf_db_password', $conf_db_password, 16, T_('MySQL Password'), sprintf( T_('Used by %s to access the MySQL database' ), $app_name ), 100 ); // no need to hide this. nobody installs an application from a public place
1504+ form_text( 'conf_db_tableprefix', $conf_db_tableprefix, 16, T_('MySQL tables prefix'), sprintf( T_('All DB tables will be prefixed with this. You need to change this only if you want to have multiple %s installations in the same DB.' ), $app_name ), 30 );
1505+ ?>
1506+ </fieldset>
1507+
1508+ <div class="buttons">
1509+ <input type="submit" name="submit" value="<?php echo T_('Update config file') ?>" class="search" />
1510+ <input type="reset" value="<?php echo T_('Reset') ?>" class="search" />
1511+ </div>
1512
1513 </form>
1514
1515 <?php
1516 break;
1517- }
1518 }
1519- // if config was already done, move on to main menu:
1520+ }
1521+ // if config was already done, move on to main menu:
1522
1523 case 'menu':
1524- /*
1525- * -----------------------------------------------------------------------------------
1526- * Menu
1527- * -----------------------------------------------------------------------------------
1528- */
1529+ /* Menu */
1530 param('conf_admin_login', 'string' );
1531 param('conf_admin_pass', 'string' );
1532 param('conf_admin_email', 'string' );
1533@@ -466,115 +449,116 @@
1534 ?>
1535 <h1><?php printf( T_('Install %s version %s'), $app_name, $app_version ); ?></h1>
1536
1537- <?php
1538- $old_db_version = get_db_version();
1539- ?>
1540+ <?php $old_db_version = get_db_version( 'version' ); ?>
1541
1542 <form action="index.php" method="post">
1543- <input type="hidden" name="locale" value="<?php echo $default_locale ?>" />
1544- <input type="hidden" name="confirmed" value="0" />
1545- <input type="hidden" name="installer_version" value="10" />
1546-
1547- <div id="op-newdb" class="op-group">
1548- <input type="radio" name="action" id="newdb" value="newdb"
1549- <?php
1550- // fp> change the above to 'newdbsettings' for an additional settings screen.
1551- if( is_null($old_db_version) )
1552- {
1553- echo 'checked="checked"';
1554- }
1555- ?>
1556- />
1557- <label for="newdb" class="option"><?php
1558- printf( T_('<strong>New Install</strong>: Install %s database tables.'), $app_name );
1559- ?></label>
1560- <div class="options">
1561- <h3><?php echo T_('Admin account details' ); ?></h3>
1562- <?php
1563- if( !empty( $msg ) )
1564- {
1565- echo '<p class="error">'.implode( '<br />', $msg ).'</p>';
1566- }
1567- form_text( 'conf_admin_login', $conf_admin_login, 50, T_('Login'), T_('This will be used to create your admin account.' ), 80 );
1568- form_text( 'conf_admin_pass', $conf_admin_pass, 50, T_('Password'), T_('We advise you use a strong password' ), 80 );
1569- form_text( 'conf_admin_email', $conf_admin_email, 50, T_('Your email'), T_('This will be used to receive notifications for comments on your blog, etc.' ), 80 );
1570- ?></div>
1571- <div class="options">
1572- <h3><?php echo T_('Example posts' ); ?></h3>
1573- <input type="checkbox" name="create_sample_contents" id="create_sample_contents" value="1" checked="checked" />
1574- <label for="create_sample_contents"><?php
1575- printf( T_('Also install sample blogs &amp; sample contents. The sample posts explain '
1576- .'several features of %s. This is highly recommended for new users.'),
1577- $app_name );
1578- ?></label>
1579- </div>
1580- </div>
1581-
1582- <?php if( $app_db_version )
1583+ <input type="hidden" name="locale" value="<?php echo $default_locale ?>" />
1584+ <input type="hidden" name="confirmed" value="0" />
1585+ <input type="hidden" name="installer_version" value="10" />
1586+
1587+ <div id="op-newdb" class="op-group">
1588+ <input type="radio" name="action" id="newdb" value="newdb"
1589+ <?php
1590+ // fp> change the above to 'newdbsettings' for an additional settings screen.
1591+ if( is_null($old_db_version) )
1592+ {
1593+ echo 'checked="checked" ';
1594+ }
1595+ ?>
1596+ />
1597+ <label for="newdb" class="option"><?php
1598+ printf( T_('<strong>New Install</strong>: Install %s database tables.'), $app_name );
1599+ ?></label>
1600+
1601+ <div class="options">
1602+ <h3><?php echo T_('Admin account details' ); ?></h3>
1603+ <?php
1604+ if( !empty( $msg ) )
1605+ {
1606+ echo '<p class="error">'.implode( '<br />', $msg ).'</p>';
1607+ }
1608+ form_text( 'conf_admin_login', $conf_admin_login, 50, T_('Login'), T_('This will be used to create your admin account.' ), 80 );
1609+ form_text( 'conf_admin_pass', $conf_admin_pass, 50, T_('Password'), T_('We advise you use a strong password' ), 80 );
1610+ form_text( 'conf_admin_email', $conf_admin_email, 50, T_('Your email'), T_('This will be used to receive notifications for comments on your blog, etc.' ), 80 );
1611+ ?></div>
1612+
1613+ <div class="options">
1614+ <h3><?php echo T_('Example posts' ); ?></h3>
1615+ <input type="checkbox" name="create_sample_contents" id="create_sample_contents" value="1" checked="checked" />
1616+ <label for="create_sample_contents"><?php
1617+ printf( T_('Also install sample blogs &amp; sample contents. The sample posts explain '
1618+ .'several features of %s. This is highly recommended for new users.'),
1619+ $app_name );
1620+ ?></label>
1621+ </div>
1622+
1623+ </div>
1624+
1625+ <?php
1626+ if( $app_db_version !== NULL )
1627+ {
1628+ ?>
1629+ <div id="op-dbupgrade" class="op-group">
1630+ <input type="radio" name="action" id="dbupgrade" value="dbupgrade"
1631+ <?php
1632+ if( !is_null($old_db_version) && $old_db_version < $app_db_version )
1633 {
1634- ?>
1635- <div id="op-dbupgrade" class="op-group">
1636- <input type="radio" name="action" id="dbupgrade" value="dbupgrade"
1637- <?php
1638- if( !is_null($old_db_version) && $old_db_version < $app_db_version )
1639- {
1640- echo 'checked="checked"';
1641- }
1642- ?>
1643- />
1644- <label for="dbupgrade"><?php
1645- printf( /* TRANS: %1$s: App name. */ T_('<strong>Upgrade from a previous version of %1$s</strong>'), $app_name );
1646- ?></label>
1647- <p class="options"><?php
1648- echo sprintf( T_('Upgrade your '
1649+ echo 'checked="checked" ';
1650+ }
1651+ ?>
1652+ />
1653+ <label for="dbupgrade"><?php
1654+ printf( /* TRANS: %1$s: App name. */ T_('<strong>Upgrade from a previous version of %1$s</strong>'), $app_name );
1655+ ?></label>
1656+ <p class="options"><?php
1657+ echo sprintf( T_('Upgrade your '
1658 .'%1$s database tables in order to make them compatible with the current '
1659 .'version.'), $app_name ).'</p><p class="options">'
1660- .T_('<strong>WARNING:</strong> If you have modified your database, '
1661- .'this operation may fail. Make sure you have a backup.');
1662- ?></p>
1663- </div>
1664- <?php
1665- }
1666+ .T_('<strong>WARNING:</strong> If you have modified your database, '
1667+ .'this operation may fail. Make sure you have a backup.');
1668+ ?></p>
1669+ </div>
1670+ <?php
1671+ }
1672
1673- if( $app_allow_dbase_reset == 1 )
1674- {
1675- ?>
1676- <div class="op-deletedb"><input type="radio" name="action" id="deletedb" value="deletedb" />
1677- <label for="deletedb"><strong><?php printf( T_('Delete %s tables'), $app_name ); ?></strong></label>
1678- <p class="options"><?php
1679- printf( /* TRANS: %1$s: App name. */
1680- T_('If you have installed %1$s tables before and wish to start anew, '
1681+ if( $app_allow_dbase_reset == 1 )
1682+ {
1683+ ?>
1684+ <div class="op-deletedb"><input type="radio" name="action" id="deletedb" value="deletedb" />
1685+ <label for="deletedb"><strong><?php printf( T_('Delete %s tables'), $app_name ); ?></strong></label>
1686+ <p class="options"><?php
1687+ printf( /* TRANS: %1$s: App name. */
1688+ T_('If you have installed %1$s tables before and wish to start anew, '
1689 .'you must delete the %1$s tables before you can start a new installation. <br />'
1690 .'<strong>WARNING: All your %1$s tables and data will be lost!!!</strong> '
1691 .'Any non-%1$s tables will remain untouched though.'), $app_name );
1692- ?></p>
1693- <input type="radio" name="action" id="start" value="start" />
1694- <label for="start"><strong><?php echo T_('Change your base configuration'); ?></strong></label>
1695- <p class="options"><?php
1696- printf( T_('(see recap below): '
1697+ ?></p>
1698+ <input type="radio" name="action" id="start" value="start" />
1699+ <label for="start"><strong><?php echo T_('Change your base configuration'); ?></strong></label>
1700+ <p class="options"><?php
1701+ printf( T_('(see recap below): '
1702 .'You only want to do this in rare occasions where you may have moved '
1703 .'your %s files or database to a different location...'), $app_name );
1704- ?></p></div>
1705- <?php
1706- }
1707-
1708- if( $app_allow_dbase_reset != 1 )
1709- {
1710- echo '<div class="floatright"><a href="index.php?action=deletedb&amp;locale='.$default_locale.'">'.T_('Need to start anew?').' &raquo;</a></div>';
1711- }
1712- ?>
1713-
1714- <p>
1715- <input type="submit" value="&nbsp; <?php echo T_('GO!')?> &nbsp;"
1716- onclick="var dc = document.getElementById( 'deletedb' ); if( dc && dc.checked ) { if ( confirm( '<?php
1717- printf( /* TRANS: %s gets replaced by app name, usually "quamplures" */ TS_( 'Are you sure you want to delete your existing %s tables?\nDo you have a backup?' ), $app_name );
1718- ?>' ) ) { this.form.confirmed.value = 1; return true; } else return false; }" />
1719- </p>
1720- </form>
1721+ ?></p></div>
1722+ <?php
1723+ }
1724+
1725+ if( $app_allow_dbase_reset != 1 )
1726+ {
1727+ echo '<div class="floatright"><a href="index.php?action=deletedb&amp;locale='.$default_locale.'">'.T_('Need to start anew?').' &raquo;</a></div>';
1728+ }
1729+ ?>
1730+
1731+ <p>
1732+ <input type="submit" value="&nbsp; <?php echo T_('GO!')?> &nbsp;"
1733+ onclick="var dc = document.getElementById( 'deletedb' ); if( dc && dc.checked ) { if ( confirm( '<?php
1734+ printf( /* TRANS: %s gets replaced by app name, usually "quamplures" */ TS_( 'Are you sure you want to delete your existing %s tables?\nDo you have a backup?' ), $app_name );
1735+ ?>' ) ) { this.form.confirmed.value = 1; return true; } else return false; }" />
1736+ </p>
1737+
1738+ </form>
1739 <?php
1740-
1741 block_close();
1742-
1743 display_base_config_recap();
1744 break;
1745
1746
1747=== modified file 'qp_plugins/xml_feeds_widget/_xml_feeds.widget.php'
1748--- qp_plugins/xml_feeds_widget/_xml_feeds.widget.php 2010-12-31 12:12:03 +0000
1749+++ qp_plugins/xml_feeds_widget/_xml_feeds.widget.php 2011-06-17 09:28:39 +0000
1750@@ -125,7 +125,6 @@
1751 $TemplateCache = & get_Cache( 'TemplateCache' );
1752 $TemplateCache->load_by_type( 'feed' );
1753
1754- // TODO: this is like touching private parts :>
1755 foreach( $TemplateCache->cache as $Template )
1756 {
1757 if( $Template->type != 'feed' )
1758
1759=== modified file 'qp_templates/_sitemap/_template.class.php'
1760--- qp_templates/_sitemap/_template.class.php 2010-07-13 18:25:00 +0000
1761+++ qp_templates/_sitemap/_template.class.php 2011-06-17 09:28:39 +0000
1762@@ -32,7 +32,7 @@
1763 */
1764 function get_default_type()
1765 {
1766- return 'normal';
1767+ return 'other';
1768 }
1769
1770 }
1771
1772=== modified file 'qp_templates/asevo/_template.class.php'
1773--- qp_templates/asevo/_template.class.php 2010-08-07 15:42:57 +0000
1774+++ qp_templates/asevo/_template.class.php 2011-06-17 09:28:39 +0000
1775@@ -32,7 +32,7 @@
1776 */
1777 function get_default_type()
1778 {
1779- return 'normal';
1780+ return 'xhtml';
1781 }
1782
1783
1784
1785=== modified file 'qp_templates/basic/_template.class.php'
1786--- qp_templates/basic/_template.class.php 2010-08-07 15:42:57 +0000
1787+++ qp_templates/basic/_template.class.php 2011-06-17 09:28:39 +0000
1788@@ -32,7 +32,7 @@
1789 */
1790 function get_default_type()
1791 {
1792- return 'normal';
1793+ return 'xhtml';
1794 }
1795
1796
1797
1798=== modified file 'qp_templates/custom/_template.class.php'
1799--- qp_templates/custom/_template.class.php 2010-08-07 15:42:57 +0000
1800+++ qp_templates/custom/_template.class.php 2011-06-17 09:28:39 +0000
1801@@ -32,7 +32,7 @@
1802 */
1803 function get_default_type()
1804 {
1805- return 'normal';
1806+ return 'xhtml';
1807 }
1808
1809
1810
1811=== modified file 'qp_templates/evocamp/_template.class.php'
1812--- qp_templates/evocamp/_template.class.php 2010-08-07 15:42:57 +0000
1813+++ qp_templates/evocamp/_template.class.php 2011-06-17 09:28:39 +0000
1814@@ -32,7 +32,7 @@
1815 */
1816 function get_default_type()
1817 {
1818- return 'normal';
1819+ return 'xhtml';
1820 }
1821
1822
1823
1824=== modified file 'qp_templates/evopress/_template.class.php'
1825--- qp_templates/evopress/_template.class.php 2010-08-07 15:42:57 +0000
1826+++ qp_templates/evopress/_template.class.php 2011-06-17 09:28:39 +0000
1827@@ -32,7 +32,7 @@
1828 */
1829 function get_default_type()
1830 {
1831- return 'normal';
1832+ return 'xhtml';
1833 }
1834
1835
1836
1837=== modified file 'qp_templates/glossyblue/_template.class.php'
1838--- qp_templates/glossyblue/_template.class.php 2010-08-07 15:42:57 +0000
1839+++ qp_templates/glossyblue/_template.class.php 2011-06-17 09:28:39 +0000
1840@@ -32,7 +32,7 @@
1841 */
1842 function get_default_type()
1843 {
1844- return 'normal';
1845+ return 'xhtml';
1846 }
1847
1848
1849
1850=== modified file 'qp_templates/intense/_template.class.php'
1851--- qp_templates/intense/_template.class.php 2010-08-07 15:42:57 +0000
1852+++ qp_templates/intense/_template.class.php 2011-06-17 09:28:39 +0000
1853@@ -32,7 +32,7 @@
1854 */
1855 function get_default_type()
1856 {
1857- return 'normal';
1858+ return 'xhtml';
1859 }
1860
1861
1862
1863=== modified file 'qp_templates/miami_blue/_template.class.php'
1864--- qp_templates/miami_blue/_template.class.php 2010-08-07 15:42:57 +0000
1865+++ qp_templates/miami_blue/_template.class.php 2011-06-17 09:28:39 +0000
1866@@ -32,7 +32,7 @@
1867 */
1868 function get_default_type()
1869 {
1870- return 'normal';
1871+ return 'xhtml';
1872 }
1873
1874
1875
1876=== modified file 'qp_templates/natural_pink/_template.class.php'
1877--- qp_templates/natural_pink/_template.class.php 2010-08-07 15:42:57 +0000
1878+++ qp_templates/natural_pink/_template.class.php 2011-06-17 09:28:39 +0000
1879@@ -32,7 +32,7 @@
1880 */
1881 function get_default_type()
1882 {
1883- return 'normal';
1884+ return 'xhtml';
1885 }
1886
1887
1888
1889=== modified file 'qp_templates/nifty_corners/_template.class.php'
1890--- qp_templates/nifty_corners/_template.class.php 2010-08-07 15:42:57 +0000
1891+++ qp_templates/nifty_corners/_template.class.php 2011-06-17 09:28:39 +0000
1892@@ -32,7 +32,7 @@
1893 */
1894 function get_default_type()
1895 {
1896- return 'normal';
1897+ return 'xhtml';
1898 }
1899
1900
1901
1902=== modified file 'qp_templates/photoblog/_template.class.php'
1903--- qp_templates/photoblog/_template.class.php 2010-08-07 15:42:57 +0000
1904+++ qp_templates/photoblog/_template.class.php 2011-06-17 09:28:39 +0000
1905@@ -32,7 +32,7 @@
1906 */
1907 function get_default_type()
1908 {
1909- return 'normal';
1910+ return 'xhtml';
1911 }
1912
1913
1914
1915=== modified file 'qp_templates/pixelgreen/_template.class.php'
1916--- qp_templates/pixelgreen/_template.class.php 2010-08-07 15:42:57 +0000
1917+++ qp_templates/pixelgreen/_template.class.php 2011-06-17 09:28:39 +0000
1918@@ -32,7 +32,7 @@
1919 */
1920 function get_default_type()
1921 {
1922- return 'normal';
1923+ return 'xhtml';
1924 }
1925
1926
1927
1928=== modified file 'qp_templates/pluralism/_template.class.php'
1929--- qp_templates/pluralism/_template.class.php 2010-08-07 15:42:57 +0000
1930+++ qp_templates/pluralism/_template.class.php 2011-06-17 09:28:39 +0000
1931@@ -32,7 +32,7 @@
1932 */
1933 function get_default_type()
1934 {
1935- return 'normal';
1936+ return 'xhtml';
1937 }
1938
1939
1940
1941=== modified file 'qp_templates/terrafirma/_template.class.php'
1942--- qp_templates/terrafirma/_template.class.php 2010-08-07 15:42:57 +0000
1943+++ qp_templates/terrafirma/_template.class.php 2011-06-17 09:28:39 +0000
1944@@ -32,7 +32,7 @@
1945 */
1946 function get_default_type()
1947 {
1948- return 'normal';
1949+ return 'xhtml';
1950 }
1951
1952
1953
1954=== modified file 'qp_templates/vastitude/_template.class.php'
1955--- qp_templates/vastitude/_template.class.php 2010-08-07 15:42:57 +0000
1956+++ qp_templates/vastitude/_template.class.php 2011-06-17 09:28:39 +0000
1957@@ -32,7 +32,7 @@
1958 */
1959 function get_default_type()
1960 {
1961- return 'normal';
1962+ return 'xhtml';
1963 }
1964
1965

Subscribers

People subscribed via source and target branches