[rfc] encouraging styled admin interfaces

Discussion corner for Developers of Serendipity.
Post Reply
winkiller
Regular
Posts: 77
Joined: Tue May 17, 2005 7:52 pm
Location: Munich, Germany
Contact:

[rfc] encouraging styled admin interfaces

Post by winkiller »

I've put together a small patch for /includes/admin/templates.inc.php that tells the user (using the theme selector) which theme has a styled admin interface. The fact that I'm the only one to contribute a theme with styled admin interface as of now beyond the default ones makes me a bit sad, and I wonder if people actually know that you can do it. (My main reason for doing it was to distinguish different blogs at first glance and not editing sth by mistake)

Main drawback is introducing a new constant.

Discuss.

Code: Select all

--- templates.inc.php	2005-07-08 16:31:58.000000000 +0200
+++ templates.inc.php	2005-11-08 11:54:01.000000000 +0100
@@ -95,6 +95,15 @@
             <td valign="top">
                 <?php echo AUTHOR;       ?>: <?php echo $info['author'];?><br />
                 <?php echo LAST_UPDATED; ?>: <?php echo $info['date'];  ?>
+<?php
+                if (@is_dir($serendipity['templatePath'] . $theme . '/admin')) {
+                    if (@is_readable($serendipity['templatePath'] . $theme . '/admin/style.css')) {
+                        if ($theme != 'default' && $theme != 'default-rtl') {
+                            echo '<br />'.CUSTOM_ADMIN_INTERFACE_AVAILABLE.'<br />';
+                        }
+                    }
+                }
+?>
             </td>
         </tr>
     </table>
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [rfc] encouraging styled admin interfaces

Post by garvinhicking »

I think you should move the detection of styled background into the fetchTemplate method, so that the output of it is not swamped with detection code?

I'd also make the check combined with "&&" instead of a 3-level nesting. And I'd make the check for $theme != 'default' before the /admin/style.css check, that saves you one filestat call.

Apart from that, I'm all for it. :-)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
winkiller
Regular
Posts: 77
Joined: Tue May 17, 2005 7:52 pm
Location: Munich, Germany
Contact:

Post by winkiller »

you're absolutely right.
And I'm a little confused, thus I wrote such strange things :/

perhaps this sounds more like a commit? then I'll do it (along with introducing the constant in the language files...

Code: Select all

--- functions.inc.php	2005-11-08 10:31:37.562500000 +0100
+++ functions.inc.php	2005-11-08 12:52:32.843750000 +0100
@@ -129,6 +129,14 @@
     foreach ($data as $k => $v) {
         $data[$k] = implode("\n", $v);
     }
+
+    if ( $theme != 'default' && $theme != 'default-rtl' 
+      && @is_dir($serendipity['templatePath'] . $theme . '/admin') 
+      && @is_readable($serendipity['templatePath'] . $theme . '/admin/style.css') ) {
+        $data['custom_admin_interface'] = CUSTOM_ADMIN_INTERFACE.': '.YES.'<br />';
+    } else {
+        $data['custom_admin_interface'] = '';
+    }
 
     return $data;
 }

Code: Select all

--- templates.inc.php	2005-11-08 12:33:38.171875000 +0100
+++ templates.inc.php	2005-11-08 12:53:43.609375000 +0100
@@ -94,7 +94,8 @@
             <td width="100" style="padding-left: 10px"><?php echo $preview; ?></td>
             <td valign="top">
                 <?php echo AUTHOR;       ?>: <?php echo $info['author'];?><br />
-                <?php echo LAST_UPDATED; ?>: <?php echo $info['date'];  ?>
+                <?php echo LAST_UPDATED; ?>: <?php echo $info['date'];  ?><br />
+                <?php echo $info['custom_admin_interface']; ?>
             </td>
         </tr>
     </table>
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

You're almost there :)

I'd write it like this:

Code: Select all

+        $data['custom_admin_interface'] = CUSTOM_ADMIN_INTERFACE.': '.YES.'<br />';
Only set this var to "YES" or "NO".

Code: Select all

+                <?php echo $info['custom_admin_interface']; ?>
Here you echo the CUSTOM_ADMIN_INTERFACE variable and the content. :)

And if possible please insert the new constant in all languages of lang/* :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
winkiller
Regular
Posts: 77
Joined: Tue May 17, 2005 7:52 pm
Location: Munich, Germany
Contact:

Post by winkiller »

you're the boss :P

*committed*

Completed At revision: 666

Evil...
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

HEhe, you stole that revision from me ;))

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply