Page 1 of 1

[rfc] encouraging styled admin interfaces

Posted: Tue Nov 08, 2005 12:03 pm
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>

Re: [rfc] encouraging styled admin interfaces

Posted: Tue Nov 08, 2005 12:33 pm
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

Posted: Tue Nov 08, 2005 12:59 pm
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>

Posted: Tue Nov 08, 2005 1:09 pm
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

Posted: Tue Nov 08, 2005 1:45 pm
by winkiller
you're the boss :P

*committed*

Completed At revision: 666

Evil...

Posted: Tue Nov 08, 2005 2:11 pm
by garvinhicking
HEhe, you stole that revision from me ;))

Regards,
Garvin