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

Proposed by EdB
Status: Merged
Merged at revision: 7596
Proposed branch: lp:~edb/quam-plures/fix_item_css
Merge into: lp:quam-plures
Diff against target: 53 lines (+12/-14)
2 files modified
qp_inc/items/items.ctrl.php (+5/-7)
qp_plugins/tinymce_plugin/_tinymce.plugin.php (+7/-7)
To merge this branch: bzr merge lp:~edb/quam-plures/fix_item_css
Reviewer Review Type Date Requested Status
Yabs (community) Approve
EdB Needs Resubmitting
Tilman Blumenbach (community) Needs Fixing
Review via email: mp+46436@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Tilman Blumenbach (tblue) wrote :

You should use $templates_path instead of $template_url when building the path for is_file() -- the latter may work for you, but it only does because allow_url_fopen is enabled. If it is disabled (as it should be!), your code does not work.

It makes more sense to check the local filesystem instead of an URL, anyway. :-)

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

Regarding qp_plugins/tinymce_plugin/_tinymce.plugin.php:

You also need to make sure $item_css_url and $content_css are always set. I would do the following: Only set $content_css to a non-empty string if the is_file() check evaluates to true (i. e. move the $content_css assignment into the if statement). If the check fails, set it to an empty string.

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

This was fun! While uploading to test on a real server I also figured out how to tell WAMP to turn that url_fopen thing off. (just click stuff :) )

Anyway problems solved, although I'm not sure about the bit in the TinyMCE code. I mean, it looks like it should be an if/else although one could say content_css is empty then give it a value inside the if, but there is also a note questioning the idea of a version number. So I'm still not sure what the whole thing is doing.

All I know is now if I have url_fopen off and I have an item.css it gets used on all items.ctrl.php pages, and it applies to the textarea when using TinyMCE (compliments of adding a global to that bit of code).

A wee bit more testing and a commit and a push and I'll follow this with a "check it out now" email.

review: Needs Fixing
lp:~edb/quam-plures/fix_item_css updated
7588. By EdB

replaced template_url with template_path in the "if" bits, pre-defined something as empty and changed it if need be, added a global to avoid throwing an error when using TinyMCE.

Revision history for this message
EdB (edb) wrote :

Ready for re-testing. Also learned something: item.css is ONLY for the admin side. Whether TinyMCE is engaged or not, that style sheet applies to everything in the admin side under items.ctrl.php. If item.css says "body background:red" then even the item list page will have a red background. So we need to do a bit more in this area, but there is a thread about that and it is outside the scope of this particular branch.

review: Needs Resubmitting
Revision history for this message
Yabs (yabs) wrote :

Just for kicks, the debug stuff should also be added to item.css so you can see changes ;)

¥

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

$content_css can still end up being undefined... Just put the

  $content_css = ''; // start this empty

before the

  if( ! empty( $Blog->template_ID) )

and everything will be fine. :-)

review: Needs Fixing
lp:~edb/quam-plures/fix_item_css updated
7589. By EdB

update from core

7590. By EdB

adding core changes

7591. By EdB

made content_css be '' before maybe adding something to it.

Revision history for this message
EdB (edb) wrote :

Added the '' bit to whichever file didn't have it even though it is/was outside the scope of this branch. No worries ... except for I think there is still something wrong. Something this branch did not create or expects to fix, but still... What does the 304 part of this line mean?

127.0.0.1 - - [date/time] "GET /localhost/path/tinymce_plugin/tiny_mce/plugins/noteaser/css/content.css?v=0.1 HTTP/1.1" 304 -

I guess I could google it but I'm kinda lazy today ;) The thing is I'm seeing a bunch of similar lines in my access.log file, but I don't get any "file not found" errors in either apache_error.log or php_error.log files. I forget which one, but one of those always gets "file not found", which is what this branch is fixing.

ANYWAY "resubmit" due to the error isn't getting logged, and, as we all know if( no_error_logged ) { life_is_good(); }

review: Needs Resubmitting
Revision history for this message
Yabs (yabs) wrote :

304 means "Not modified"

¥

review: Approve
lp:~edb/quam-plures/fix_item_css updated
7592. By EdB

new stuff in core now here - woohoo!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qp_inc/items/items.ctrl.php'
2--- qp_inc/items/items.ctrl.php 2010-12-31 12:12:03 +0000
3+++ qp_inc/items/items.ctrl.php 2011-03-08 04:41:44 +0000
4@@ -859,16 +859,14 @@
5 // Load the appropriate ITEM/POST styles depending on the blog's template:
6 if( ! empty( $Blog->template_ID) )
7 {
8+ $content_css = ''; // start this empty
9 $TemplateCache = & get_Cache( 'TemplateCache' );
10- /**
11- * @var Template
12- */
13 $Template = $TemplateCache->get_by_ID( $Blog->template_ID );
14- require_css( $templates_url.$Template->folder.'/item.css' ); // fp> TODO: this needs to be a param... "of course" -- if none: else item_default.css ?
15- // else: $item_css_url = $rsc_url.'css/item_base.css';
16+ if( is_file( $templates_path.$Template->folder.'/item.css' ) )
17+ {
18+ require_css( $templates_url.$Template->folder.'/item.css' );
19+ }
20 }
21-// else item_default.css ? is it still possible to have no template set?
22-
23
24 // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
25 $AdminUI->disp_html_head();
26
27=== modified file 'qp_plugins/tinymce_plugin/_tinymce.plugin.php'
28--- qp_plugins/tinymce_plugin/_tinymce.plugin.php 2010-09-25 12:29:17 +0000
29+++ qp_plugins/tinymce_plugin/_tinymce.plugin.php 2011-03-08 04:41:44 +0000
30@@ -480,16 +480,16 @@
31 // Load the appropriate ITEM/POST styles depending on the blog's template:
32 if( ! empty( $Blog->template_ID) )
33 {
34+ $content_css = ''; // start this empty
35 $TemplateCache = & get_Cache( 'TemplateCache' );
36- /**
37- * @var Template
38- */
39 $Template = $TemplateCache->get_by_ID( $Blog->template_ID );
40- $item_css_url = $templates_url.$Template->folder.'/item.css';
41- // else: $item_css_url = $rsc_url.'css/item_base.css';
42- $content_css = ','.$item_css_url; // fp> TODO: this needs to be a param... "of course" -- if none: else item_default.css ?
43+ global $templates_path;
44+ if( is_file( $templates_path.$Template->folder.'/item.css' ) )
45+ {
46+ $item_css_url = $templates_url.$Template->folder.'/item.css';
47+ $content_css = ','.$item_css_url;
48+ }
49 }
50- // else item_default.css -- is it still possible to have no template ?
51
52 $init_options[] = 'content_css : "'.$this->get_plugin_url().'editor.css?v='.($debug ? $localtimenow : $this->version )
53 .$content_css.'"';

Subscribers

People subscribed via source and target branches