D7 CSS in PHP Files

mydatery posted 31st of January 2010 in Community Voice. 5 comments.

Well, you asked me to point it out so here it is:

 

 

administration/banners.php

// Functions
function getPreviewBlock($iBannerID) {
 $sPreview = MsgBox(_t('_Empty'));

 if ($_GET['action'] == 'preview' && $iBannerID > 0) {
  $aBannerInfo = db_arr("SELECT * FROM `sys_banners` WHERE `ID` = '{$iBannerID}'");
  $sBannerTitle = process_line_output($aBannerInfo['Title']);
  $sBannerPut = banner_put($aBannerInfo['ID'], 0);

  $sPreview = <<<EOF
<table cellspacing=1 cellpadding=1 width=90% height=200 align=center style="border: 1px solid #ccc;">
 {$sBannerTitle}
 <tr><td align=center bgcolor=white>{$sBannerPut}</td></tr>
</table>
EOF;
  $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $sPreview));
  return DesignBoxContent(_t('_Preview'), $sResult, 1);
 }
}

And: 

 

$sActionAdd = ($action == "modify") ? $sAsNew . '&nbsp;<input type=checkbox name=as_new />' : '';

 $sCustomPositions = <<<EOF
<table border=0 width=100% cellspacing=10 cellpading=20>
 <tr>
  <td colspan=5 align=center><input type=checkbox name="pos_top" {$sTopPosState} />{$sTopC}</td>
 </tr>
 <tr>
  <td colspan=2 align=center><input type=checkbox name="pos_left" {$sLeftPosState} />{$sLeftC}</td>
  <td>&nbsp;</td>
  <td colspan=2 align=center><input type=checkbox name="pos_right" {$sRightPosState} />{$sRightC}</td>
 </tr>

 

 

administration/db.php

  if ($_POST['savetype'] == 'server') {
   $sqlfile = BX_DIRECTORY_PATH_ROOT . 'backup/'.date("Y-m-d_H-i-s").'_'.$_POST['tbl'].'.sql';
   $file = fopen($sqlfile, 'w');
   fputs($file, $oNewBackup -> sInputs);
   $status_text .= "<hr size=1 /><font color='green'><center>{$sSuccDumpedIntoFileC} <b>{$sqlfile}</b></center></font>\n";
   fclose($file);
  }
  if ($_POST['savetype'] == 'show') {
   $status_text = "<center><textarea cols='100' rows='30' name='content' style='font-family: Arial; font-size: 11px' readonly='readonly'>" . $oNewBackup -> sInputs ."</textarea></center>";
  }

 

Should I even bother to comment on this one?  The entire php file is just a huge mess of css/html throughout it.  Would it be that hard to follow the standards on this and use a tmpl_uni/css/file for it? 

 

adminstration/help.php

<html>
<head>

<style type="text/css">

    .spec
 {
     float:left;
     width:80px;
     height:20px;
     position:relative;
     border: 1px solid silver;
  text-align : center;
 }

    .desc
 {
     float:left;
     width:360px;
     height:20px;
     position:relative;
     border: 1px solid silver;
 }

</style>

</head>

<body>

<div style="width:460px; position:relative;">
<h3><center>Do you want to change the Date Format for your site? It is possible, just follow the instructions.</h3>
</center><br>
<b>You need to switch some attributes.</b>
<br>
 1)To show a date in the Format: <b>Day.Month.YYYY</b>, input into the Short or Long Date Format <b>%d.%m.%Y</b>.
<br><br>
2)To show a date and time  - <b>Month/Day/Year Hours:Minutes:Seconds</b> input into the Long Date Format <b>%m/%d/%Y %H:%i:%s</b>.
<br><br>
3)To use PM or AM format for time input - <b>%I%p:%i:%s</b>. You will see time in this format <b>09am:43:12</b>.
<br><br>
4) you can use  different types of separators: <br><br>
<center>
<table border=1>
<tr >
 <td ><b>Separator</b></td>
 <td><b>Format</b></td>
 <td><b>Result</b></td>
</tr>
<tr align=center>
 <td>.</td>
 <td>Day.Month.YYYY</td>
 <td>%d.%m.%Y</td>

</tr>

<tr align=center>
 <td>/</td>
 <td>Month/Day/Year</td>
 <td>%m/%d/%Y</td>

</tr>
<tr align=center>
 <td>*</td>
 <td>Month*Day*Year</td>
 <td>%m*%d*%Y</td>

</tr>

<tr align=center>
 <td colspan=3 >some other separators:   -    :    ;    -- </b></td>

</tr>
</table>
</center>


<br>
<br>
<br>
<b>Use the list to form the date format on your liking.</b><br>

<br>
<div class="spec">Specifier</div>
<div class="desc">Description</div>

<div class="spec">%m</div>
<div class="desc">Month, numeric (01..12)</div>

<div class="spec">%w</div>
<div class="desc">Day of the week (0=Sunday..6=Saturday)</div>

<div class="spec">%d</div>
<div class="desc">Day of the month, numeric (00..31)</div>

<div class="spec">%Y</div>
<div class="desc">Year, numeric, 4 digits</div>

<div class="spec">%y</div>
<div class="desc">Year, numeric, 2 digits</div>

<div class="spec">%b</div>
<div class="desc">Abbreviated month name (Jan..Dec)</div>

<div class="spec">%H</div>
<div class="desc">Hour (00..23)</div>

<div class="spec">%I</div>
<div class="desc">Hour (01..12)</div>

<div class="spec">%p</div>
<div class="desc">AM or PM</div>

<div class="spec">%i</div>
<div class="desc">Minutes, numeric (00..59)</div>

<div class="spec">%s</div>
<div class="desc">Seconds (00..59)</div>
</div>

</body>
</html>

 

 

Next up: 

 

administration/notifies.php

<html>
<head>

<style type="text/css">

    .spec
 {
     float:left;
     width:80px;
     height:20px;
     position:relative;
     border: 1px solid silver;
  text-align : center;
 }

    .desc
 {
     float:left;
     width:360px;
     height:20px;
     position:relative;
     border: 1px solid silver;
 }

</style>

</head>

<body>

<div style="width:460px; position:relative;">
<h3><center>Do you want to change the Date Format for your site? It is possible, just follow the instructions.</h3>
</center><br>
<b>You need to switch some attributes.</b>
<br>
 1)To show a date in the Format: <b>Day.Month.YYYY</b>, input into the Short or Long Date Format <b>%d.%m.%Y</b>.
<br><br>
2)To show a date and time  - <b>Month/Day/Year Hours:Minutes:Seconds</b> input into the Long Date Format <b>%m/%d/%Y %H:%i:%s</b>.
<br><br>
3)To use PM or AM format for time input - <b>%I%p:%i:%s</b>. You will see time in this format <b>09am:43:12</b>.
<br><br>
4) you can use  different types of separators: <br><br>
<center>
<table border=1>
<tr >
 <td ><b>Separator</b></td>
 <td><b>Format</b></td>
 <td><b>Result</b></td>
</tr>
<tr align=center>
 <td>.</td>
 <td>Day.Month.YYYY</td>
 <td>%d.%m.%Y</td>

</tr>

<tr align=center>
 <td>/</td>
 <td>Month/Day/Year</td>
 <td>%m/%d/%Y</td>

</tr>
<tr align=center>
 <td>*</td>
 <td>Month*Day*Year</td>
 <td>%m*%d*%Y</td>

</tr>

<tr align=center>
 <td colspan=3 >some other separators:   -    :    ;    -- </b></td>

</tr>
</table>
</center>


<br>
<br>
<br>
<b>Use the list to form the date format on your liking.</b><br>

<br>
<div class="spec">Specifier</div>
<div class="desc">Description</div>

<div class="spec">%m</div>
<div class="desc">Month, numeric (01..12)</div>

<div class="spec">%w</div>
<div class="desc">Day of the week (0=Sunday..6=Saturday)</div>

<div class="spec">%d</div>
<div class="desc">Day of the month, numeric (00..31)</div>

<div class="spec">%Y</div>
<div class="desc">Year, numeric, 4 digits</div>

<div class="spec">%y</div>
<div class="desc">Year, numeric, 2 digits</div>

<div class="spec">%b</div>
<div class="desc">Abbreviated month name (Jan..Dec)</div>

<div class="spec">%H</div>
<div class="desc">Hour (00..23)</div>

<div class="spec">%I</div>
<div class="desc">Hour (01..12)</div>

<div class="spec">%p</div>
<div class="desc">AM or PM</div>

<div class="spec">%i</div>
<div class="desc">Minutes, numeric (00..59)</div>

<div class="spec">%s</div>
<div class="desc">Seconds (00..59)</div>
</div>

</body>
</html>

 

 

This is where it gets really old for us.  It's been preached, prodded, beaten and persecuted into us to follow the rules & guidelines as we develop add-ons, mods & hacks to D to assist with it's development and keep things in an orderly fashion for all to follow.  But, when D7 gets released we find the same stuff going on in it's files that has happened in the earlier versions.  CSS/HTML being dumped into PHP files where it does not need to be.  I'll agree, some things do, for instance when the CSS is being called from the DB due to a customer background or layout in a members profile.  But for a page that will always resolve the same exact way there is no need to dump it in these PHP files and then force us to go hunting it down line by line when we need to make a simple layout change/adjustment.

 

In a previous blog talking about this with D6 it was recommended that we find the issues of it and post them in Trac.  Can you picture the number of hours it will take to go through all of D7's files?

 

 

 
Comments
·Oldest
·Top
Please login to post a comment.
houstonlively
There's also a bunch of styling done in various js files. It's not just the php files. I suppose some of that is necessary, because there are some things you just don't want people messing with, but a lot of the styling has no business being in php and js files.
AlexT
http://www.boonex.com/trac/dolphin/ticket/1802
mydatery
Alex, I only looked in the administration/ directory and only a few files in it, how about if we make the ticket that ALL D7 folders & files get checked and any/all non-required CSS/html be removed from them and placed in the proper place. This being a hard rule across the board will be instrumental in setting up a standardized CMS.
AlexT
Yes, I have made general ticket, which says that we need to get rid of such code at all.
bizzi
Mr Datery, Shut up goof.
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
PET:0.055934906005859