Merge lp:~edb/quam-plures/main_link_in_menu_widget into lp:quam-plures

Proposed by EdB
Status: Merged
Approved by: Tilman Blumenbach
Approved revision: 7621
Merged at revision: 7620
Proposed branch: lp:~edb/quam-plures/main_link_in_menu_widget
Merge into: lp:quam-plures
Diff against target: 788 lines (+289/-144)
8 files modified
qp_inc/plugins/_plugin.class.php (+1/-1)
qp_inc/templates/model/_template.class.php (+181/-115)
qp_inc/widgets/model/_widget.class.php (+1/-1)
qp_inc/widgets/views/_widget_list_available.view.php (+6/-7)
qp_install/_functions_create.php (+1/-1)
qp_install/_functions_install.php (+43/-19)
qp_plugins/menu_link_widget/_menu_link.widget.php (+8/-0)
qp_templates/photoblog/_template.class.php (+48/-0)
To merge this branch: bzr merge lp:~edb/quam-plures/main_link_in_menu_widget
Reviewer Review Type Date Requested Status
Tilman Blumenbach (community) Approve
EdB Needs Resubmitting
Lee Turner (community) Approve
Review via email: mp+71757@code.launchpad.net

Description of the change

http://forums.quamplures.net/viewtopic.php?f=11&t=889

This branch adds a "Main" option in the menu widget that points to $app_baseurl. This branch also fixes how you can't suggest a widget with params in a template. More on that at http://forums.quamplures.net/viewtopic.php?f=11&t=827

To test this branch you will need a template that suggests a widget with params, so I put some code in the forum thread that shows how to do that. Edit the template then create a new blog with that template and you will see the new "Main" widget installed with params.

To post a comment you must log in.
Revision history for this message
Lee Turner (leeturner) wrote :

Just downloading this now. Will test tonight or tomorrow.

L

Revision history for this message
Lee Turner (leeturner) wrote :

OK, this all looks cool as far as I can tell but I do have questions. The 'Main' menu option works fine although I never realised you couldn't change the text for those menu items. That might be something for us to look at in a different branch in the future. I am sure we will get someone saying they want to change 'Main' or 'Home' etc. However, for this branch this is all good.

The suggestive template code also looks good from what I could tell. The only question I have is how will template authors know about it and understand how to use it? Is this going to be in the phpdocs or something? The reason I ask is because (from what I can tell) the existence of an empty method (to provide a method signature and some phpdocs) means no widgets will be installed (basically the template is suggesting no widgets get installed) and this is probably not what the template author wants.

review: Needs Information
Revision history for this message
Lee Turner (leeturner) wrote :

Also, the reason I mentioned phpdocs is that it takes a little digging to figure out what codes and param names to return in the array. Without some guidance I am not sure the average template dev would know what they were looking for.

L

Revision history for this message
EdB (edb) wrote :

On "suggestive templates", the best way to show it will be with an example but I don't really have a good one handy. Yabs had a branch for a photoblog-like template that I haven't even really looked at. Perhaps we can use it to showcase this feature? Plus not using evo template names as defaults would be nice.

But yeah it's a completely undocumented feature at this point so I'm going to mark this "needs fixing" and give some effort on somehow coding up an example of usage. Not even sure if core installation will trigger this little routine or if we have to use canned widgets for that, so that's something to consider.

Worst-case would be using a combination of "create a new blog with {this} template and see {this page} in autodocs".

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

Autodocs is hard to trust right now because it doesn't get updated with each branch merge. Having said that, I don't think I went after making sure it is "friendlier than default" with regard to finding the params that matter.

IMHO examples will be much better than autodocs.

Revision history for this message
Lee Turner (leeturner) wrote :

Yeah, an example would be a good way to go. I am totally fine with how it all works though if you want me to approve it and have a separate branch for coding up the example etc?

L

Revision history for this message
EdB (edb) wrote :

Let me get some sort of example/explanation in. Couple of days for it I reckon...

7614. By EdB

photoblog uses the new feature, but another "bug" shows up and it still needs a sample post

Revision history for this message
EdB (edb) wrote :

Update: photoblog now installs it's own widgets, BUT we can't install the same widget name twice this way. The problem is that the widget name is used as a key and array_merge which means the later value for that key will overwrite the previous one (per php.net).

Also, the sample post about widgets needs to say something like "if you're writing templates check out how photoblog injects it's own widgets" or some such. That is easy, the first one is why it'll be another day or so.

Revision history for this message
Lee Turner (leeturner) wrote :

Is this the same widget per container or that we can't install the same widget across all containers?

L

7615. By EdB

multiple widgets with same type can be installed in the same container, re-ordered "add widget" list a bit

7616. By EdB

finished issue with multiple same-code widgets, documented for autodocs, updated sample post to say where to see an example

Revision history for this message
EdB (edb) wrote :

The problem was having 2 "menu_link" widgets in one container. Array keys as strings can't be duplicated is the problem. ('Header' => array( 'menu_link' => array( foo... ), 'menu_link' => array( bar... ) ) ) won't work due to that is how PHP is.

My solution was to give the widgets numeric keys then untangle them when we really want to install the widgets. Containers still go by string keys because (duh) we can't be having 2 containers called "Header" in the same template.

Also done is everything else. Sample post about widgets says check out photoblog template file, autodocs shows example and says some shit about it, and marginally related the order of widgets when adding new widgets is different.

review: Needs Resubmitting
Revision history for this message
Lee Turner (leeturner) wrote :

Downloaded and tested. Looking good from what I can see.

review: Approve
7617. By EdB

core to 7614

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

Will look at this tomorrow. It's almost 12 am here and I need some sleep.

7618. By EdB

core up to 7618

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

Hm, I'm wondering what's the purpose of this bit? :)

// do a mysql_real_escape_string to each $key and $value in 'params'
foreach( $settings['params'] as $key => $value )
{
    if( $DB->escape( $key ) != $key ) { die( 'invalid params key in widget: '.$key ); }
    if( $DB->escape( $value ) != $value ) { die( 'invalid params value in widget: '.$value ); }
}

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

Let's try out some review statuses. See last message,

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

One should always escape inputs to a db, but if we escape something we serialized it will put a \ before each " that serialize makes in the params field. So we can't escape if we want it to work. BUT we should escape before storing. The examples given frequently of why you need to escape involve putting extra commands into the mysql query string, which involve typically something that escaping will put a \ in front of.

Therefore I figured if we compare the escaped version to the original version and we detect a change we simply assume it is bad and die for it. A template author will see the problem and be mad, but a malicious author will not be able to distribute a template that is allowed to do (potentially) bad things ... even if it also blocks an occasional "good" use.

That is way too long for a comment in code though eh?

BTW I don't know how someone can do something malicious with a bad command in there, but if we don't at least check we open a door that might be exploitable.

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

Hm, I removed the die() bits and named a widget 'Menu" link' (note the double quote) -- everything seems to work safely...?

Revision history for this message
EdB (edb) wrote :

Yes, that is true. Then again adding a double-quote is not malicious behavior. The thing is if we do not check then we open a door, and the params for a widget simply do not need any of the characters that mysql_real_escape_string will escape. In other words a well-made template will never fail for that check, and a template made with malicious intent (even though I have no idea how that could happen) will not install.

One thing I'm about to push though is a change in the die() message. It should (and will) say "unacceptable character in widget key|value" but won't actually say what that problem is.

Also, no one will ever be able to say we are not escaping our database inputs :)

7619. By EdB

changed die() message if mysql_real_escape_string blocks a widget

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

Well, I'm willing to accept the code if you say that the die() will not be triggered _too_ frequently ;) On the other hand, aren't we escaping our database inputs as we are doing $DB->quote( serialize( ... ) ) anyway?

Just one note: Maybe better use debug_die()? That produces a "nice" Red Screen of Death.

Revision history for this message
EdB (edb) wrote :

Personally I don't think it will be, but perhaps SOMEWHERE I should document "do not use the characters that escaping will escape due to ... ". Auto-docs seems appropriate? BUT perhaps it doesn't matter given that you are correct: the DB->quote( whatever ) will do the escape thing prior to it entering the database.

Now I have to back up again in my head. hmmm... Originally it was "serialize then escape" which caused widgets with params to fail completely. I needed to get rid of escaping due to it was failing. See http://forums.quamplures.net/viewtopic.php?p=5670#p5670 for an example of what ended up in the database that did not work.

Clearly function quote($str) returns an escaped $str, yet what I see in the database now does not show slashes in front of the double-quote used to test. So the database is telling me it is not being escaped, yet obviously it is supposed to be.

MORE TESTING REQUIRED!

review: Needs Fixing
7620. By EdB

changed die() to debug_die(), added more info for autodocs

Revision history for this message
EdB (edb) wrote :
7621. By EdB

removed extraneous check, removed associated note in comments, change "ahve" to "have" in 3 places

Revision history for this message
EdB (edb) wrote :

removed extraneous check, removed associated note in comments, change "ahve" to "have" in 3 places

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

Works fine!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qp_inc/plugins/_plugin.class.php'
2--- qp_inc/plugins/_plugin.class.php 2011-02-04 04:06:29 +0000
3+++ qp_inc/plugins/_plugin.class.php 2011-08-27 14:11:25 +0000
4@@ -3078,7 +3078,7 @@
5 // Try default values:
6 $params = $this->get_coll_setting_definitions( $tmp_params = array('for_editing'=>true) );
7 if( isset( $params[$parname]['defaultvalue'] ) )
8- { // We ahve a default value:
9+ { // We have a default value:
10 return $params[$parname]['defaultvalue'] ;
11 }
12
13
14=== modified file 'qp_inc/templates/model/_template.class.php'
15--- qp_inc/templates/model/_template.class.php 2010-12-31 12:12:03 +0000
16+++ qp_inc/templates/model/_template.class.php 2011-08-27 14:11:25 +0000
17@@ -87,13 +87,13 @@
18 );
19
20 if( is_null($db_row) )
21- { // We are creating an object here:
22+ { // We are creating an object here:
23 $this->set( 'folder', $template_folder );
24 $this->set( 'name', $this->get_default_name() );
25 $this->set( 'type', $this->get_default_type() );
26 }
27 else
28- { // Wa are loading an object:
29+ { // Wa are loading an object:
30 $this->ID = $db_row->template_ID;
31 $this->name = $db_row->template_name;
32 $this->folder = $db_row->template_folder;
33@@ -112,7 +112,7 @@
34 {
35 // Look for containers in template file:
36 if( ! $this->discover_containers() )
37- { // Error messages already added.
38+ { // Error messages already added.
39 return false;
40 }
41
42@@ -134,25 +134,30 @@
43 global $DB, $Messages;
44 if( $default_widgets = $this->get_default_widgets( array( 'Blog' => & $edited_Blog ) ) )
45 { // we have widgets
46- foreach( $default_widgets as $container => $widgets )
47+ foreach( $default_widgets as $container => $numeric_key )
48 {
49 $count = 0;
50- foreach( $widgets as $widget => $settings )
51+ foreach( $numeric_key as $numeric_widget )
52 {
53- $settings = array_merge( array(
54- 'type' => 'widget',
55- 'params' => array(),
56- ), $settings );
57-
58- $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
59- VALUES(
60- '.$edited_Blog->ID.',
61- '.$DB->quote( $container ).',
62- '.( ++$count ).',
63- '.$DB->quote( $settings['type'] ).',
64- '.$DB->quote( $widget ).',
65- '.$DB->quote( $DB->escape( serialize( $settings['params'] ) ) ).' )' );
66-
67+ foreach( $numeric_widget as $widget => $settings )
68+ {
69+ $settings = array_merge( array(
70+ 'type' => 'widget',
71+ 'params' => array(),
72+ ), $settings );
73+
74+ $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
75+ VALUES(
76+ '.$edited_Blog->ID.',
77+ '.$DB->quote( $container ).',
78+ '.( ++$count ).',
79+ '.$DB->quote( $settings['type'] ).',
80+ '.$DB->quote( $widget ).',
81+ '.$DB->quote( serialize( $settings['params'] ) ).'
82+ )'
83+ );
84+
85+ }
86 }
87 }
88 $Messages->add( T_('Default widgets have been set-up for this blog.'), 'success' );
89@@ -161,9 +166,45 @@
90
91
92 /**
93- * Get default widgets for template
94- *
95- * @todo yabs > document params, default_widgets_structure
96+ * Get default widgets for new blog
97+ *
98+ * The new blog's template can suggest/select a list of widgets.
99+ * If it does not a default list is used.
100+ *
101+ * A template can suggest/select any widget by identifying the container, and
102+ * each widget's code and type. The code can be 'widget' or 'plugin'. If
103+ * 'plugin' and the plugin is not installed nothing bad happens. I think.
104+ *
105+ * <code>
106+ * $default_widgets = array(
107+ * 'Header' => array(),
108+ * 'Menu' => array(),
109+ * 'Sidebar' => array(),
110+ * );
111+ * $default_widgets['Header'][] = array(
112+ * 'title' => array(
113+ * 'type' => 'widget',
114+ * ),
115+ * );
116+ * $default_widgets['Menu'][] = array(
117+ * 'menu_link' => array(
118+ * 'type' => 'widget',
119+ * 'params' => array(
120+ * 'link_type'=>'ownercontact',
121+ * ),
122+ * ),
123+ * );
124+ * $default_widgets['Sidebar'][] = array(
125+ * 'calendar' => array(
126+ * 'type' => 'plugin',
127+ * ),
128+ * );
129+ * </code>
130+ *
131+ * A widget installed with only code and type will have default values for
132+ * any parameters it may have.
133+ *
134+ * @todo (EdB/7618): verify/ensure each widget needs to identify it's own param possibilities
135 *
136 * @return array widgets for each container
137 */
138@@ -174,80 +215,105 @@
139 'Blog' => & $Blog,
140 ), $params );
141
142+ // Containers
143 $default_widgets = array(
144- 'Page Top' => array(
145- 'bloglist' => array(
146- 'type' => 'widget',
147- 'params' => array(
148- 'coll_list_type' => ( $params['Blog']->get( 'in_bloglist' ) ? 'public' : 'owner' ),
149- ),
150- ),
151- ),
152-
153- 'Header' => array(
154- 'title' => array(
155- 'type' => 'widget',
156- ),
157- 'tagline' => array(
158- 'type' => 'widget',
159- ),
160- ),
161-
162- 'Menu' => array(
163- 'menu_link' => array(
164- 'type' => 'widget',
165- 'params' => array(
166- 'link_type'=>'home',
167- ),
168- ),
169- 'page_list' => array(
170- 'type' => 'widget',
171- ),
172- 'menu_link' => array(
173- 'type' => 'widget',
174- 'params' => array(
175- 'link_type'=>'ownercontact',
176- ),
177- ),
178- 'menu_link' => array(
179- 'type' => 'widget',
180- 'params' => array(
181- 'link_type'=>'login',
182- ),
183- ),
184- ),
185-
186- 'Sidebar' => array(
187- 'calendar' => array(
188- 'type' => 'plugin',
189- ),
190- 'title' => array(
191- 'type' => 'widget',
192- ),
193- 'longdesc' => array(
194- 'type' => 'widget',
195- ),
196- 'common_links' => array(
197- 'type' => 'widget',
198- ),
199- 'search_form' => array(
200- 'type' => 'widget',
201- ),
202- 'category_list' => array(
203- 'type' => 'widget',
204- ),
205- 'xml_feeds' => array(
206- 'type' => 'widget',
207- ),
208- ),
209- );
210-
211+ 'Page Top' => array(),
212+ 'Header' => array(),
213+ 'Menu' => array(),
214+ 'Sidebar' => array(),
215+ );
216+
217+ // Page Top widgets
218+ $default_widgets['Page Top'][] = array(
219+ 'bloglist' => array(
220+ 'type' => 'widget',
221+ 'params' => array(
222+ 'coll_list_type' => ( $params['Blog']->get( 'in_bloglist' ) ? 'public' : 'owner' ),
223+ ),
224+ ),
225+ );
226+ // Header widgets
227+ $default_widgets['Header'][] = array(
228+ 'title' => array(
229+ 'type' => 'widget',
230+ ),
231+ );
232+ $default_widgets['Header'][] = array(
233+ 'tagline' => array(
234+ 'type' => 'widget',
235+ ),
236+ );
237+ // Menu widgets
238+ $default_widgets['Menu'][] = array(
239+ 'menu_link' => array(
240+ 'type' => 'widget',
241+ 'params' => array(
242+ 'link_type'=>'home',
243+ ),
244+ ),
245+ );
246+ $default_widgets['Menu'][] = array(
247+ 'page_list' => array(
248+ 'type' => 'widget',
249+ ),
250+ );
251+ $default_widgets['Menu'][] = array(
252+ 'menu_link' => array(
253+ 'type' => 'widget',
254+ 'params' => array(
255+ 'link_type'=>'ownercontact',
256+ ),
257+ ),
258+ );
259+ $default_widgets['Menu'][] = array(
260+ 'menu_link' => array(
261+ 'type' => 'widget',
262+ 'params' => array(
263+ 'link_type'=>'login',
264+ ),
265+ ),
266+ );
267+ // Sidebar widgets with numeric keys
268+ $default_widgets['Sidebar'][] = array(
269+ 'calendar' => array(
270+ 'type' => 'plugin',
271+ ),
272+ );
273+ $default_widgets['Sidebar'][] = array(
274+ 'title' => array(
275+ 'type' => 'widget',
276+ ),
277+ );
278+ $default_widgets['Sidebar'][] = array(
279+ 'longdesc' => array(
280+ 'type' => 'widget',
281+ ),
282+ );
283+ $default_widgets['Sidebar'][] = array(
284+ 'common_links' => array(
285+ 'type' => 'widget',
286+ ),
287+ );
288+ $default_widgets['Sidebar'][] = array(
289+ 'search_form' => array(
290+ 'type' => 'widget',
291+ ),
292+ );
293+ $default_widgets['Sidebar'][] = array(
294+ 'category_list' => array(
295+ 'type' => 'widget',
296+ ),
297+ );
298+ $default_widgets['Sidebar'][] = array(
299+ 'xml_feeds' => array(
300+ 'type' => 'widget',
301+ ),
302+ );
303
304 return $default_widgets;
305-
306 }
307
308- /**
309+ /**
310 * Get default name for the template.
311 * Note: the admin can customize it.
312 */
313@@ -257,7 +323,7 @@
314 }
315
316
317- /**
318+ /**
319 * Get default type for the template.
320 */
321 function get_default_type()
322@@ -275,7 +341,7 @@
323 }
324
325
326- /**
327+ /**
328 * Get credits for linkback on credits page.
329 *
330 * Each template can and should provide an array for credits for domains/authors
331@@ -300,9 +366,9 @@
332 *
333 * 'pre' => T_('Design by') or T_('Inspired by') or T_('Ported by')
334 * 'text' => the linked text - your name or domain name for example
335- * 'post' => can be '' (empty), and can hold HTML if you want. Please keep it reasonably short!
336- * 'url' => REQUIRED (of course). Without a URL there is no linkback!
337- * 'title' => can be whatever you like, but should never be empty. Use the URL if nothing else.
338+ * 'post' => can be '' (empty), and can hold HTML if you want. Please keep it reasonably short!
339+ * 'url' => REQUIRED (of course). Without a URL there is no linkback!
340+ * 'title' => can be whatever you like, but should never be empty. Use the URL if nothing else.
341 *
342 * @return array The credits array (see above).
343 */
344@@ -356,7 +422,7 @@
345 * <code>
346 * $params = array_merge( array( // stop annoying validation errors when container is <ul> and empty
347 * 'container_start' => '<div id="%sco_name%" class="container">',
348- * 'container_end' => '</div>',
349+ * 'container_end' => '</div>',
350 * ), $params );
351 * </code>
352 *
353@@ -377,7 +443,7 @@
354
355 $params = array_merge( array( // stop annoying validation errors when container is <ul> and empty
356 'container_start' => '<div id="%sco_name%" class="container">',
357- 'container_end' => '</div>',
358+ 'container_end' => '</div>',
359 ), $params );
360
361 $sco_dom_ID = preg_replace( '~[^a-z0-9]~i', '', ucwords( $sco_name ) );
362@@ -443,7 +509,7 @@
363
364 // if( ! preg_match_all( '~ \$Template->container\( .*? (\' (.+?) \' )|(" (.+?) ") ~xmi', $file_contents, $matches ) )
365 if( ! preg_match_all( '~ (\$Template->|template_)container\( .*? ((\' (.+?) \')|(" (.+?) ")) ~xmi', $file_contents, $matches ) )
366- { // No containers in this file
367+ { // No containers in this file
368 continue;
369 }
370
371@@ -454,14 +520,14 @@
372 foreach( $container_list as $container )
373 {
374 if( empty($container) )
375- { // regexp empty match
376+ { // regexp empty match
377 continue;
378 }
379
380 $c++;
381
382 if( in_array( $container, $this->container_list ) )
383- { // we already have that one
384+ { // we already have that one
385 continue;
386 }
387
388@@ -475,7 +541,7 @@
389 }
390
391 if( empty($this->container_list) )
392- { // Display a warning:
393+ { // Display a warning:
394 $Messages->add( T_('No containers found in this template!'), 'note' );
395 }
396
397@@ -487,7 +553,7 @@
398 */
399 function get_containers()
400 {
401- /**
402+ /**
403 * @var DB
404 */
405 global $DB;
406@@ -515,7 +581,7 @@
407 $DB->begin();
408
409 if( parent::dbupdate() !== false )
410- { // Template updated, also save containers:
411+ { // Template updated, also save containers:
412 $this->db_save_containers();
413 }
414
415@@ -537,7 +603,7 @@
416 $DB->begin();
417
418 if( parent::dbinsert() )
419- { // Template saved, also save containers:
420+ { // Template saved, also save containers:
421 $this->db_save_containers();
422 }
423
424@@ -653,10 +719,10 @@
425
426
427 /**
428- * Get definitions for editable params
429- *
430- * @todo this is destined to be overridden by derived Template classes
431- *
432+ * Get definitions for editable params
433+ *
434+ * @todo this is destined to be overridden by derived Template classes
435+ *
436 * @see Plugin::GetDefaultSettings()
437 * @param local params like 'for_editing' => true
438 */
439@@ -669,8 +735,8 @@
440
441
442 /**
443- * Get a template specific param value from current Blog
444- *
445+ * Get a template specific param value from current Blog
446+ *
447 */
448 function get_setting( $parname )
449 {
450@@ -685,14 +751,14 @@
451 $value = $Blog->get_setting( $blog_setting_name );
452
453 if( ! is_null( $value ) )
454- { // We have a value for this param:
455+ { // We have a value for this param:
456 return $value;
457 }
458
459 // Try default values:
460 $params = $this->get_param_definitions( NULL );
461 if( isset( $params[$parname]['defaultvalue'] ) )
462- { // We ahve a default value:
463+ { // We have a default value:
464 return $params[$parname]['defaultvalue'] ;
465 }
466
467@@ -766,9 +832,9 @@
468
469 if( ( $return = T_( $string, $req_locale, array(
470 'ext_transarray' => & $this->_trans,
471- 'alt_basedir' => $templates_path.$this->folder.'/po/',
472+ 'alt_basedir' => $templates_path.$this->folder.'/po/',
473 ) ) ) == $string )
474- { // This template did not provide a translation - fallback to global T_():
475+ { // This template did not provide a translation - fallback to global T_():
476 return T_( $string, $req_locale );
477 }
478
479
480=== modified file 'qp_inc/widgets/model/_widget.class.php'
481--- qp_inc/widgets/model/_widget.class.php 2010-12-31 12:12:03 +0000
482+++ qp_inc/widgets/model/_widget.class.php 2011-08-27 14:11:25 +0000
483@@ -335,7 +335,7 @@
484 // Try default values:
485 $params = $this->get_param_definitions( NULL );
486 if( isset( $params[$parname]['defaultvalue'] ) )
487- { // We ahve a default value:
488+ { // We have a default value:
489 return $params[$parname]['defaultvalue'] ;
490 }
491
492
493=== modified file 'qp_inc/widgets/views/_widget_list_available.view.php'
494--- qp_inc/widgets/views/_widget_list_available.view.php 2010-12-31 12:12:03 +0000
495+++ qp_inc/widgets/views/_widget_list_available.view.php 2011-08-27 14:11:25 +0000
496@@ -19,7 +19,6 @@
497 echo '<h2><span class="right_icons">'.action_icon( T_('Cancel!'), 'close', regenerate_url( 'container' ) ).'</span>'
498 .sprintf(T_('Widgets available for insertion into &laquo;%s&raquo;'), $container ).'</h2>';
499
500-
501 $core_componentwidget_defs = array(
502 '*'.T_('General purpose widgets'),
503 'free_html',
504@@ -27,26 +26,26 @@
505 '*'.T_('Different ways of listing the blog contents'),
506 'item_list', // Universal Item List
507 'post_list', // Simple List
508+ 'page_list', // Simple List
509 'related_post_list', // Simple List
510- 'page_list', // Simple List
511 'link_list', // Simple List
512 'linkblog', // Simple List
513+ 'comment_list',
514 'media_index',
515- 'comment_list',
516 '*'.T_('Blog navigation'),
517+ 'bloglist',
518+ 'category_list',
519 'tag_cloud',
520- 'category_list',
521- 'common_links',
522 'search_form',
523- 'xml_feeds',
524 'menu_link',
525+ 'common_links',
526 '*'.T_('Meta info for the blog'),
527 'title',
528 'tagline',
529 'longdesc',
530 '*'.T_('Other'),
531- 'bloglist',
532 'user_tools',
533+ 'xml_feeds',
534 );
535 $i = 0;
536 $wiCache = get_Cache( 'WidgetCache');
537
538=== modified file 'qp_install/_functions_create.php'
539--- qp_install/_functions_create.php 2011-06-25 18:44:14 +0000
540+++ qp_install/_functions_create.php 2011-08-27 14:11:25 +0000
541@@ -980,7 +980,7 @@
542
543 <p>Widgets are placed in containers. Each container appears in a specific place in a template. If you change your blog template, the new template may not use the same containers as the previous one. Make sure you place your widgets in containers that exist in the specific template you are using.</p>
544
545-<p>Widgets can also be "hard-coded" into your template. If you know that you always want a certain widget in a certain place, forcing it through your template is a good idea.</p>
546+<p>Widgets can also be "hard-coded" into your template. All widgets for all containers need to be hard-coded as the template list will over-ride the default list. See the "photoblog" template\'s _template.class.php file for an example of this.</p>
547 '), $app_name ),
548 $now, $cat_appname );
549
550
551=== modified file 'qp_install/_functions_install.php'
552--- qp_install/_functions_install.php 2011-07-13 15:12:18 +0000
553+++ qp_install/_functions_install.php 2011-08-27 14:11:25 +0000
554@@ -511,74 +511,86 @@
555 // Add blog list to all blog Page Tops:
556 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
557 SELECT blog_ID, "Page Top", 1, "widget", "bloglist", \'a:5:{s:14:"coll_list_type";s:6:"public";s:11:"widget_name";s:9:"Blog List";}\'
558- FROM T_blogs' );
559+ FROM T_blogs
560+ WHERE blog_ID < 4' );
561
562 // Add title to all blog Headers:
563 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
564 SELECT blog_ID, "Header", 1, "widget", "title"
565- FROM T_blogs' );
566+ FROM T_blogs
567+ WHERE blog_ID < 4' );
568
569 // Add tagline to all blogs Headers:
570 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
571 SELECT blog_ID, "Header", 2, "widget", "tagline"
572- FROM T_blogs' );
573+ FROM T_blogs
574+ WHERE blog_ID < 4' );
575
576 // Add home link to all blogs Menus:
577 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
578 SELECT blog_ID, "Menu", 1, "widget", "menu_link", "'.$DB->escape(serialize(array('link_type'=>'home'))).'"
579- FROM T_blogs' );
580+ FROM T_blogs
581+ WHERE blog_ID < 4' );
582
583 // Add info pages to all blogs Menus:
584 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
585 SELECT blog_ID, "Menu", 2, "widget", "page_list"
586- FROM T_blogs' );
587+ FROM T_blogs
588+ WHERE blog_ID < 4' );
589
590 // Add contact link to all blogs Menus:
591 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
592 SELECT blog_ID, "Menu", 3, "widget", "menu_link", "'.$DB->escape(serialize(array('link_type'=>'ownercontact'))).'"
593- FROM T_blogs' );
594+ FROM T_blogs
595+ WHERE blog_ID < 4' );
596
597 // Add login link to all blogs Menus:
598 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
599 SELECT blog_ID, "Menu", 4, "widget", "menu_link", "'.$DB->escape(serialize(array('link_type'=>'login'))).'"
600- FROM T_blogs' );
601+ FROM T_blogs
602+ WHERE blog_ID < 4' );
603
604 // Add Calendar plugin to all blog Sidebars except blog A:
605 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
606 SELECT blog_ID, "Sidebar", 1, "plugin", "calendar"
607 FROM T_blogs
608- WHERE blog_ID > 1' );
609+ WHERE blog_ID > 1 AND blog_ID < 4' );
610
611 // Add title to all blog Sidebars:
612 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
613 SELECT blog_ID, "Sidebar", 2, "widget", "title"
614- FROM T_blogs' );
615+ FROM T_blogs
616+ WHERE blog_ID < 4' );
617
618 // Add longdesc to all blogs Sidebars:
619 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
620 SELECT blog_ID, "Sidebar", 3, "widget", "longdesc"
621- FROM T_blogs' );
622+ FROM T_blogs
623+ WHERE blog_ID < 4' );
624
625 // Add common links to all blogs Sidebars:
626 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
627 SELECT blog_ID, "Sidebar", 4, "widget", "common_links"
628- FROM T_blogs' );
629+ FROM T_blogs
630+ WHERE blog_ID < 4' );
631
632 // Add search form to all blogs Sidebars:
633 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
634 SELECT blog_ID, "Sidebar", 5, "widget", "search_form"
635- FROM T_blogs' );
636+ FROM T_blogs
637+ WHERE blog_ID < 4' );
638
639 // Add categories list to all blog Sidebars:
640 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
641 SELECT blog_ID, "Sidebar", 6, "widget", "category_list"
642- FROM T_blogs' );
643+ FROM T_blogs
644+ WHERE blog_ID < 4' );
645
646 // Add Random photo to blog Sidebars except blog B:
647 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
648 SELECT blog_ID, "Sidebar", 7, "widget", "media_index", \'a:11:{s:5:"title";s:12:"Random photo";s:10:"thumb_size";s:7:"fit-160";s:12:"thumb_layout";s:4:"grid";s:12:"grid_nb_cols";s:1:"1";s:5:"limit";s:1:"1";s:8:"order_by";s:4:"RAND";s:9:"order_dir";s:3:"ASC";s:7:"blog_ID";s:1:"4";s:11:"widget_name";s:12:"Random photo";s:16:"widget_css_class";s:0:"";s:9:"widget_ID";s:0:"";}\'
649 FROM T_blogs
650- WHERE blog_ID <> 2' );
651+ WHERE blog_ID <> 2 AND blog_ID < 4' );
652
653 // Add linkblog to blog Sidebars for blog A & B:
654 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
655@@ -589,24 +601,36 @@
656 // Add XML feeds to all blogs Sidebars:
657 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
658 SELECT blog_ID, "Sidebar", 9, "widget", "xml_feeds"
659- FROM T_blogs' );
660+ FROM T_blogs
661+ WHERE blog_ID < 4' );
662
663 // All blog Sidebar 2:
664 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
665 SELECT blog_ID, "Sidebar 2", 1, "widget", "post_list"
666- FROM T_blogs' );
667+ FROM T_blogs
668+ WHERE blog_ID < 4' );
669
670 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code )
671 SELECT blog_ID, "Sidebar 2", 2, "widget", "comment_list"
672- FROM T_blogs' );
673+ FROM T_blogs
674+ WHERE blog_ID < 4' );
675
676 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
677 SELECT blog_ID, "Sidebar 2", 3, "widget", "media_index", \'a:11:{s:5:"title";s:13:"Recent photos";s:10:"thumb_size";s:10:"crop-80x80";s:12:"thumb_layout";s:4:"grid";s:12:"grid_nb_cols";s:1:"3";s:5:"limit";s:1:"9";s:8:"order_by";s:9:"datestart";s:9:"order_dir";s:4:"DESC";s:7:"blog_ID";s:1:"4";s:11:"widget_name";s:11:"Photo index";s:16:"widget_css_class";s:0:"";s:9:"widget_ID";s:0:"";}\'
678- FROM T_blogs' );
679+ FROM T_blogs
680+ WHERE blog_ID < 4' );
681
682 $DB->query( 'INSERT INTO T_widget( wi_coll_ID, wi_sco_name, wi_order, wi_type, wi_code, wi_params )
683 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:"";}\'
684- FROM T_blogs' );
685+ FROM T_blogs
686+ WHERE blog_ID < 4' );
687+
688+ // Add widgets to blog #4
689+ $BlogCache = get_Cache( 'BlogCache' );
690+ $PhotoBlog = $BlogCache->get_by_ID( 4, false );
691+ $templateCache = get_Cache( 'TemplateCache');
692+ $_template = $templateCache->get_by_ID( 4 );
693+ $_template->CreateDefaultWidgets( $PhotoBlog );
694
695 task_end();
696 }
697
698=== modified file 'qp_plugins/menu_link_widget/_menu_link.widget.php'
699--- qp_plugins/menu_link_widget/_menu_link.widget.php 2011-01-08 03:31:49 +0000
700+++ qp_plugins/menu_link_widget/_menu_link.widget.php 2011-08-27 14:11:25 +0000
701@@ -47,6 +47,7 @@
702 $this->widget_title = '';
703 $this->menu_link_widget_link_types = array(
704 'home' => $this->T_('Blog home'),
705+ 'main' => $this->T_('Installation home'),
706 'arcdir' => $this->T_('Archive directory'),
707 'catdir' => $this->T_('Category directory'),
708 'latestcomments' => $this->T_('Latest comments'),
709@@ -117,6 +118,7 @@
710 function display( $params )
711 {
712 global $Blog;
713+ global $app_baseurl;
714
715 $this->init_display( $params );
716
717@@ -168,6 +170,12 @@
718 $title = $this->T_('register on this website');
719 break;
720
721+ case 'main':
722+ $url = $app_baseurl;
723+ $text = $this->T_('Main');
724+ $title = $this->T_('visit this site\'s home page');
725+ break;
726+
727 case 'home':
728 default:
729 $url = $Blog->get('url');
730
731=== modified file 'qp_templates/photoblog/_template.class.php'
732--- qp_templates/photoblog/_template.class.php 2010-08-07 15:42:57 +0000
733+++ qp_templates/photoblog/_template.class.php 2011-08-27 14:11:25 +0000
734@@ -61,6 +61,54 @@
735 return $template_linkbacks;
736 }
737
738+
739+ /**
740+ * @see Template::get_default_widgets()
741+ */
742+ function get_default_widgets( $params = array() )
743+ {
744+ // Containers
745+ $default_widgets = array(
746+ 'Page Top' => array(),
747+ 'Menu' => array(),
748+ );
749+ // Page Top widgets
750+ $default_widgets['Page Top'][] = array(
751+ 'bloglist' => array(
752+ 'type' => 'widget',
753+ 'params' => array(
754+ 'coll_list_type' => ( $params['Blog']->get( 'in_bloglist' ) ? 'public' : 'owner' ),
755+ ),
756+ ),
757+ );
758+ // Menu widgets
759+ $default_widgets['Menu'][] = array(
760+ 'menu_link' => array(
761+ 'type' => 'widget',
762+ 'params' => array(
763+ 'link_type' => 'main',
764+ 'widget_name' => 'Menu link',
765+ ),
766+ ),
767+ );
768+ $default_widgets['Menu'][] = array(
769+ 'menu_link' => array(
770+ 'type' => 'widget',
771+ 'params' => array(
772+ 'link_type' => 'ownercontact',
773+ 'widget_name' => 'Menu link',
774+ ),
775+ ),
776+ );
777+ $default_widgets['Menu'][] = array(
778+ 'user_tools' => array(
779+ 'type' => 'widget',
780+ ),
781+ );
782+
783+ return $default_widgets;
784+ }
785+
786 }
787
788 ?>

Subscribers

People subscribed via source and target branches