- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Great idea if you need one ID per element and want your code to be CSS-compliant ;)
Admin
border:0px solid #A7A9AC;
Invisible solid grey borders? The invisible pink unicorn would approve.
Admin
Surely TRWTF is PHP?
Admin
$FileClassArr versus $FileCLassArr
Admin
No, I didn't write this article. There's no unicorns.
Admin
PHP: Hosing Programmers
Admin
Arr!
Admin
Obviously this was an effort to allow future styling of the individual items. You know that shitty IE does not support the CSS nth-child selector, right? Also this code works with literally thousands of files, which would be very impractical if you'd have to write it by hand with child selectors.
People on this site lack an understanding of what is required in the business. It's best to add such code from the start so that when you later want to refine the layout you can adjust the CSS with a select few PHP commands. I shall use this snippet in my lecture on design patterns to show our students how they can write reusable CSS with very little PHP thrown in. It is good to have an illustrating case that exemplifies the need for generated CSS.
Admin
Admin
That's why wrote
on the first line, to evade this problem. This line must have been elided by the editor in an effort to make me look bad.
Admin
Nah, can't really assess the WTFiness here without knowing what's actually in that array (telling us they're "files" is vague and probably misleading) and what the developer is trying to achieve. Have to admit it doesn't look promising all the same.
Using a for rather than a foreach in this case is certainly wasteful though.
Admin
At least he didn't use the shorttag.
Admin
FTFY
Admin
Admin
Admin
Bah, everyone knows that the IPU is nothing but a fake monster, only The Flying Spagetti actually exists.
Admin
Admin
TRWTF is Arial.
Admin
I have to side with the original coder here.
As we all know code duplication is bad, so they decided to copy the code using a loop, so that the core problem of code duplication is eliminated: if they now want to change all pages they only have to change the code in the loop.
Way better than code duplication!
Admin
Recursive Acronym?
Admin
Having just experienced what some have assured me is good PHP CGI, I can declare that there is no such thing as good PHP CGI.
Web development is a hopelessly confused mess, and anyone who thinks it's programming is dead wrong. It's nothing like programming, and calling it such is really detrimental to the art and science of programming.
Admin
This developer surely missed his chance to increase his number of LOCs
Admin
Ohh, calm down mister fancy pants. Finish your books, clean up your room and get to bed. You have college tomorrow.
And stop pretending you are do god damn smarter than everyone. Cause you'll never find a job.
Admin
Any takers for a bet on whether the classes are used like this?
... or that these classes aren't even used?
Admin
Well, I was able to hold back the tears, barely. Then I saw some comments here siding with the original coder or imploding the array and the dam broke.
Admin
Admin
This does give a clue as to its origin. I'll bet these CSS definitions were originally for id tags: #file_1, #file_2 and so on. Of course, these would have to be unique.
So someone said to the author of this mess, "Why are you repeating this CSS for every ID? Why not use a CSS class?"
So the author of this mess converted it to use classes...
...but why rewrite all that good code? Especially since we have to be able to control every element individually.
Come on, you've all seen them: Those CSS books that recommend "id on every element"; CSS defined by "id"; and subtly dis-recommend classes because they can control multiple elements.
You know, the books published by, "WTF Publishers".
Admin
9/10, would definitely read again.
Admin
I'll point out there's a nice typo ($FileClassArr vs $FileCLassArr a couple lines later) that would make things even worse.
I will also point out that PHP is not to blame here. Is could have been written this incompetently in any language.
Admin
Either my sarcasm detector is malfunctioning, or you sir are a contributor to problem. The loop is going to generate the same CSS regardless of individual item. You're STILL going to have to manually add code to customize specific items. The submitted code does nothing toward your stated goal of allowing for customization of individual items; it simply generates a ton of wasted CSS for no particular reason.
Admin
Any of the CSS preprocessors (less) can do this, without having to resort to php.
Admin
I can't believe I am seeing this. 'Invisible pink unicorn'? Really? Are some so called adults still clinging to these outdated belief systems and fantasies?
By now, I thought even children could tell you that invisible unicorns are clearly purple.
Admin
Admin
"files" is not misleading. That's exactly what they are. Pictures of files on a tabletop.
Admin
Sadly, this unavoidable truth has forced me to decorate generic HTML widgets (like, say, a Tab Container) with CSS classes like this
in order to have semi-sane CSS rules.
Admin
PHP is the new Visual Basic.
Admin
Admin
Looks like someone went to the Microsoft Office school of HTML.
Seriously, do an HTML export of a bunch of bulleted lists in office 2007 or 2010, just about each and every element will have it's own stylesheet.
That one was a royal pain to clean up. (regular expressions are my friend)
Admin
Admin
All of these files have the same style. There is no excuse for not defining a single class and having all the files use that.
Note that every file will be importing the CSS for potentially hundreds of files (depending on how many we are talking about), only one block of which they actually need.
Admin
TRWTF is the code missing a class for the FILE_NOT_FOUND.
Admin
Do you really align attributes content when you write HTML? If so, I insist that you should also align the "tab-navbar" from the UL element. Otherwise it's not feng shui enough.
Admin
#my-comment:before { background: #bad; content:' Actually that's a good way to keep the appearance of your files flexible.
I'd go one step further and create copies of the background image on the fly, just in case you want a different background image for one of the files. '; }
Admin
Nope, there are definitely plenty of includes getting thrown around.
Admin
What purpose is this going to server?
Admin
How can you be sure that there are no unicorns if they're invisible? "I didn't see any invisible unicorns." Well, duh.
Admin
Reading this makes we wonder if the programmer was thinking that down the road he's going to modify the loop to say things like:
Then I cried, too.
Admin
Reminds me when we were starting out with moving our documentation web-wide. We generated simple html using a DEC VAX (it was a long time ago) and ftp'ed it into place on the website itself.
Then the stupid clown who called herself development manager decided she wanted to contribute to the site. So she opened the html in Word, did her edits and saved it. Not only did it add shitloads of cruft, but it completely fucked up the careful formatting that we had lovingly designed.
The good news is that it inoculated me against using Word.
Admin
Why are you misting up? Are you wearing your glasses in a sauna?
Admin
This code needs improvement, not enterprisy enough!
Now, this is a powerful implementation!