Non-Standardized Coding of Files

mydatery posted 28th of January 2010 in Community Voice. 13 comments.

Okay, doing up a site for someone and ran into this problem.  It's one of those things that you hate because as soon as you see it you know it's going to be a file hunt to finally figure out where the thing is controlled from and how to fix it.  Specifically, we're talking about appearance/layout items that you think would be in the CSS files but as soon as you firebug it you know it's a waste of time to look in the CSS.

This time, it was the thumbnails on the Friends.  It was missing it's left border and if I adjusted the margin it flew into that dang repeat crap it does.   Bascially, when you firebug it you see this and you know the hunt is on:

 

element.style {
float:none;
}
That in and of itself tells you that the item is controlled in the PHP files and NOT in the CSS where it would be so easy to change.  Of course, we were looking at a "My Account" page and also the Viewfriends.php page.  But they weren't the same exact issue and they weren't handled the same way.  But it was the same task as both were element styles. 
Now, when I changed the float to left on the one and put a text-align:center on the other, it fixed both problems in FB, but I had to find out where they were.  Only one way, find the <div> that's being called specifically and adjust it.  In this instance we were looking for 2 of them.
browse_nick and thumbnail_block
Doesn't seem to hard, right?  This took hours to hunt down.  Why?  Because we had to start with the base page file and go through all the files called to finally figure it out.  Take a look at finding thumbnail_block for the member.php page.  Here's what it calls:
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'members.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'news.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'sharing.inc.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolBulletins.php' );
require_once( BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolClassifieds.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolEvents.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolGroups.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolPageView.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolSharedMedia.php' );
if(file_exists( BX_DIRECTORY_PATH_ROOT . 'last_visitors_member.php' ))
require_once( BX_DIRECTORY_PATH_ROOT . 'last_visitors_member.php' );
 
if(file_exists( BX_DIRECTORY_PATH_CLASSES . 'BxDolLastVisitorsManagerAddon.php' )) 
 require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolLastVisitorsManagerAddon.php' );
What does that mean?  That we have to start with member.php and look at the files it calls.  Of course, we think we're lucky as we find one instance of thumbnail_block in the member.php file. 
We find:
$ret = '';
  $ret .= '<div class="thumbnail_block" style="float:' . $float . '; ">';
   $ret .= "<a href=\"{$this->aConfSite['url']}upload_media.php\">";
    $ret .= '<img src="' . getTemplateIcon( 'spacer.gif' ) . '" style="' . $style . '" alt="' . process_line_output( $aFileName['med_title'] ) . '" />';
   $ret .= '</a>';
  $ret .= '</div>';
 
  return $ret;
The problem is, that's not it.  Nope, change it to:
$ret .= '<div class="thumbnail_block" style="float:left;">';
Does nothing for our problem the same as:
$ret .= '<div class="thumbnail_block">';
Did nothing. 
This means that the hunt is really on to find the solution.  Now, some files we're automatically eliminated as they had NOTHING to do with what we we're looking at.  Things like Groups, Events, Classifieds, header.inc.php and so on.  In the end this search was not as bad as some are.  Since the vast majority of files do NOT have thumbnail_block in them, it was a matter of just hunting for it with the search function in notepad++.  Finally, with 8 files opened and searched it was found:
inc/design.inc.php
//$bResDrawMargin = ($sCoupleImgEl != '') ? false : $bDrawMargin;
 $bResDrawMargin = $bDrawMargin;
 $ret = '';
 $ret .= '<div class="thumbnail_block" style="float:">';
  $ret .= "<a href=\"".getProfileLink($ID)."\">";
   $ret .= '<img src="' . getTemplateIcon( 'spacer.gif' ) . '" style="' . $sMarginsAddon . $style . '" alt="' . process_line_output( $aFileName['med_title'] ) . '" />' . $sCoupleImgEl;
   $ret .= getProfileOnlineStatus( $user_is_online, $bResDrawMargin, ($sCoupleImgEl!='') );
  $ret .= '</a>';
 $ret .= '</div>';
Yes, by changing it to:
//$bResDrawMargin = ($sCoupleImgEl != '') ? false : $bDrawMargin;
 $bResDrawMargin = $bDrawMargin;
 $ret = '';
 $ret .= '<div class="thumbnail_block">';
  $ret .= "<a href=\"".getProfileLink($ID)."\">";
   $ret .= '<img src="' . getTemplateIcon( 'spacer.gif' ) . '" style="' . $sMarginsAddon . $style . '" alt="' . process_line_output( $aFileName['med_title'] ) . '" />' . $sCoupleImgEl;
   $ret .= getProfileOnlineStatus( $user_is_online, $bResDrawMargin, ($sCoupleImgEl!='') );
  $ret .= '</a>';
 $ret .= '</div>';
(Removed the float reference on the <div class="thumbnail_block"> line of code.  That allowed the float to be called from the CSS files and NOT the php files.
Why in the world are you doing this Boonex?  I've been ripping for hours on this today.  Both to find the issue and then to check the site for any errors that have appeared from it.  Not a single issue is caused by removing the float from the php file, instead it resolved so many of them that it's ridiculous.  Why can't we get a standardized system here?
I understand that for somethings, like profile customization we need to drop the CSS commands into the php files so we can call it from the DB, but for something like this that is a standard item, a stupid thumbnail_block, we're forced to hunt through file after file after file after file after file to find it and correct it.  Yes, this was on a D6 site, not a D7, but D7 is no better about this.  In order for us, the members to help you develop Dolphin we need a set of standard rules/guidelines to follow.  As long as you are doing things that make no sense that deviate from the standards you have allegedly set for us to follow, it is impossible for us to help you get it where it needs to be.
So how about it Boonex, can you guys kill this practice of randomly placing CSS inside of php files and instead do it the way you want us to do it, placing layout code in the CSS files where it belongs?


 
Comments
·Oldest
·Top
Please login to post a comment.
mauricecano
I don't think Boonex is using any standardized format and each individual developer is implementing their own "standard" when they work on the code. I think some of the bugs clearly show this when the issue involves css. I put a Spy.css bug into TRAC, told them where to find the problem and how to correct it, and the thing has sat there for weeks even when a dev picked it up (still there as of today). They have to hunt through the code the same as us to find the issues.

If we had see more a concise program tree, development and standardization could really start but I don't think they even have that. To best standardize the program would be to place it into an existing framework (Zend perhaps) which would force standardization and make modifications/error hunting soooo much easier. I know this will not happen for D7 but lets hope for D8 that they do use a framework. Using the framework will provide simple standardization and professional urls. I hate how we have site.com/join.php where if we had a framework it would be site.com/join and the user would never see the *.php extension. Something to think about.
DosDawg
i would have to agree on this observation, i have said that for some time now. there is certainly no "UNITY" amongst the brothers with the code.

whats up!

Regards,
DosDawg
DosDawg
element.style {
float:none;
}

that tells me Javascript
mydatery
Correct. And that is using JS where it's not needed. To line up a simple thumbnail?

I just see it as another thing that is causing longer load times as more and more files are called to do the most basic of things. Just because you can use something somewhere doesn't always mean you should. Remember, work smarter, not harder. JS Should be used where traditional coding (CSS in this instance) can not be used to obtain a desired result. Lining up a thumbnail is NOT one of those instances. see more Just more server resources wasted.
mydatery
Personally, I don't care if they use Zend or develop their own. Just make the thing standard and only allow for exceptions when they are absolutely necessary, such as a DB call to gain specific settings (profile customization, transparency) and so on. Fix the dang background positions too. Is it really that hard to type background-position: fixed; in the CSS files?
mauricecano
I listed Zend has an example, that and I'm currently studying Zend so I fully support a decision to use Zend :)
houstonlively
Hard coding css is done all over the place in D7, and drives me nuts on a daily basis. I ticketed what I've found, but I know there's lots more.
kernelpaniker
Isn't one of the major points of having an external CSS file is so you don't have to hard code styles? It looks like someone was lazy that day....
CodeSatori
HTML in the middle of PHP code is icky, and should be avoided as far as possible. It's not that critical in rarely used areas or system-provided messages, but should really be outed to templating wherever reused HTML structures and dynamic data containers are involved.

Wherever I may have HTML in whatever I code, it's because a certain area was rushed through and I haven't yet gotten around to switching it to use templating. This is usually what you see in draft production when you are ironing see more out the basic workings of your code.
AlexT
This is very very very old code !
We tried to eliminate such code in Dolphin 7 as much as possible ! But there are a lot of such things, almost everywhere .. it was written for years ..
Dolphin 7 is much better than Dolphin 6 .. most of the functionality was moved to modules and templates was completely separated. But some old things are still in the code.

In the future we will get rid of such code at all !
mydatery
Yes it's (allegedly) old code. D6.1.6 which makes it about 6 months old roughly. Yes, you guys did this for years and we're still finding it everywhere in D7. Wastes of developer time as we attempt to locate this stuff that is buried in the files for no specific reason, waste of server resources to call up JS to do something that can be done with a simple line of CSS. Yes, JS is more resource intensive, requires more bandwidth, calling of at least 1 extra file and several lines of code versus

float:left;

11 see more characters vs. extra file and hundreds of lines of code minimum.
AlexT
I suppose this is parameter which is not used now (it need to be checked carefully), if you believe that it must be corrected - please submit it to trac. Also is this problem with UNI template or with your own ?
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.055972814559937