CGridView: the summaryText maddnes!

I’m finishing entry phase of my first big project (first big project, where I’m key project manager and lead developer, to be precise). Right now I’m after four days of sleeping for 5 hours and coding for remaining 19 hours each day. My brain simply bowls. In this specific situation, I’ve crafted a helper method, which makes mad-laughing or mad-screaming, each time I see it.

All I had to do was to write a function, that will generate not-quite-standard summaryText for CGridView:

Page: {page} of {pages}. Position: {start}-{end} of {count}.

Of course, the easiest and most reasonable way would be:

echo 'Page: {page} of {pages}. Position: {start}-{end} of {count}.';

But, since I wanted to use CHtml helper methods and I was simply deadly tired, my brain felt into very special state of flux…

And I’ve come with something like that:

public static function summaryText()
    $summaryText = 'Page: ';

    $schizophrenicArray = array
        '{page}'=>' of ',
        '{pages}'=>'. Position: ',
        '{end}'=>' of ',

    foreach($schizophrenicArray as $pattern=>$text)
        $summaryText .= CHtml::tag('strong', array(), $pattern).$text;

    return $summaryText;

How do you like that? A $schizophrenicArray, huh? :]

Doctors, drivers and developers should be strictly banned by law from working longer than 8 hours! :]

Leave a Reply