CVS edit link for Mehrpadin

I'm a freelance Web designer & Web developer, used to be a Delphi programmer from 99 to around 2003. I'm a SEO expert too, and I love Drupal, and always recommend it to well everyone! actually I create one or two Drupal themes every month so I'm Drupal geek? probably... anyway, I've designed a premium theme called mpFREE and tried to submit it here but my CVS account request was rejected, now again after weeks I got some time to give it a second try, and here's it ... (yes in a bit weird way! wow)

What's the nature of your CVS account request?
- Theme development, I swear!

Theme development, ok where's it? show me..
- Here is it, Sir: http://mehrpadin.net/demo/mpFREE/

Not W3C valid, right?
- No, it is, Sir, absolutely valid xHTML 1.0 & CSS 2.1

And with standard codes?
- Yes indeed.

How many regions it does have?
- 21, your highness.

Ok let me think
- Sure.

CommentFileSizeAuthor
#12 mpFREE-v1.zip83.33 KBmehrpadin
#11 mpFREE-v1.zip83.33 KBmehrpadin
#6 mpFREE.zip83.46 KBmehrpadin
#1 mpFREE.zip88.27 KBmehrpadin

Comments

mehrpadin’s picture

Assigned: Unassigned » mehrpadin
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new88.27 KB
avpaderno’s picture

Assigned: mehrpadin » Unassigned
Issue tags: +Theme review
avpaderno’s picture

Status: Needs review » Needs work
/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.7a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license

Files available from third-party sites should not be included in Drupal.org CVS.
In Drupal.org CVS the only accepted files are the ones licensed under GPL license v2+; compatible licenses are not accepted.

mehrpadin’s picture

Oh didn't know that, ok removed, so what to do now?

avpaderno’s picture

Oh didn't know that, ok removed, so what to do now?

Upload the modified theme in a new comment.

mehrpadin’s picture

StatusFileSize
new83.46 KB

Here's it.

avpaderno’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
		<?php if($bottom_left || $bottom_right) { 
?>

In such cases, use the alternative syntax of the control structures.
See then the Drupal coding standards to understand how a module code should be written; in particular see the namespace respect part.

function numreg_top($top_a, $top_b, $top_c, $top_d, $top_e) {
	$n = 0;
	if ($top_a) { $n++; }
	if ($top_b) { $n++; }
	if ($top_c) { $n++; }
	if ($top_d) { $n++; }
	if ($top_e) { $n++; }
	print $n;
}

Isn't there a more optimized way to write that code?

sreynen’s picture

kiamlaluno, can you give any more actionable feedback? I'd like to see this feedback clarified both to help Mehrpadin and to improve my own understanding of the standards that apply to CVS applications, so I might help review them.

The alternative syntax, not mentioned in the coding standards on control structures, apparently refers to this from php.net, i.e. using endif; instead of curly braces. Beyond not mentioning alternative syntax, the coding standards say "You are strongly encouraged to always use curly braces even in situations where they are technically optional," which seems to actually suggest not using alternative syntax. Is this an actual coding standard documented somewhere else or just a personal preference?

And "Isn't there a more optimized way to write that code?" seems pretty vague. Obviously you think there is something to improve, but since you didn't criticize anything specific, Mehrpadin (and anyone else using this feedback to improve their own coding) can only guess at what needs to change.

avpaderno’s picture

@sreynen: Thanks for pointing out I was not clear in what I reported; I will explain myself better.

The alternative syntax is the one normally used on themes, especially when the template needs to conditionally add HTML tags.
Code like the following (the fragment has been taken from a Drupal core theme)

      <?php if ($left): ?>
        <div id="sidebar-left" class="sidebar">
          <?php if ($search_box): ?><div class="block block-theme"><?php print $search_box ?></div><?php endif; ?>
          <?php print $left ?>
        </div>
      <?php endif; ?> 

is more readable than

      <?php if ($left) { ?>
        <div id="sidebar-left" class="sidebar">
          <?php if ($search_box) { ?><div class="block block-theme"><?php print $search_box ?></div><?php } ?>
          <?php print $left ?>
        </div>
      <?php } ?> 

It is more readable because it more visible where a conditional statement ends, and it is more readable because it is documented which conditional statement ends.
This is true where fragments of PHP code are mixed with HTML fragments; it is not true for modules, where the content of a module file is PHP code.

function numreg_top($top_a, $top_b, $top_c, $top_d, $top_e) {
    $n = 0;
    if ($top_a) { $n++; }
    if ($top_b) { $n++; }
    if ($top_c) { $n++; }
    if ($top_d) { $n++; }
    if ($top_e) { $n++; }
    print $n;
}

Considering that the function is called from the following code

		<?php if($top_a || $top_b || $top_c || $top_d || $top_e) { ?>
		<div style="clear:both"></div>
		<div id="top" class="in<?php print numreg_top($top_a, $top_b, $top_c, $top_d, $top_e); ?>">

the function could be replaced from the following code (I write it in the context where it is called)

		<?php if($top_a || $top_b || $top_c || $top_d || $top_e) { ?>
		<div style="clear:both"></div>
		<div id="top" class="in<?php print (bool) $top_a + (bool) $top_b + (bool) $top_c + (bool) $top_d + (bool) $top_e; ?>">

Effectively there is something wrong in the code; the function is printing the result, and so does the code that is invoking the function.

mehrpadin’s picture

StatusFileSize
new83.33 KB

Thank you both.

The editor I'm using has syntax highlighter hence easy to see where a conditional statement ends or starts, unfortunately it does not identify endif; and\or endwhile; that's why I used curly brackets. Having said that, maybe we should change the standards a little bit? Of coursed changed everything as requested.

Plus, thanks for the code.

@--}--;----

mehrpadin’s picture

StatusFileSize
new83.33 KB

Updated

avpaderno’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -Theme review

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.