Archive for the ‘Blitzaroo’ Category

Rendering Dojo Stylesheets with a view helper

Tuesday, October 26th, 2010

I’ve been fervently coding Blitzaroo the passed week and I ran into a rather annoying issue when using AJAX with the Zend Framework and Dojo. Take, for example, using AjaxContext to load content for a dijit.layout.TabContainer that houses several dijit.layout.ContentPane(s).

$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContexts(array(
    'overview' => 'html',
    'events' => 'html',
    'members' => 'html',
    'recruits' => 'html'))->initContext();

Now then, when the getHref() from a ContentPane is called they load the Ajax data which, in this case, happens to be a dojox.grid.DataGrid. The grid renders just fine without Ajax but when Ajax is used ZF fails to load the proper Stylesheets which need to be loaded manually. I thought, no big deal, I’ll just hit up $this->dojo()->{some method to spit out stylesheets} and to my dismay found that the method is protected. Why? I’m not quite sure. I went ahead and wrote a view helper to fix the problem which is merely a copy/paste of the _renderStylesheet() method but without requiring the Dojo container object. If there is another way around the issue I’m all ears!

class My_View_Helper_DojoStylesheets extends Zend_View_Helper_Abstract
{
        public function dojoStylesheets()
        {
                $dojo = $this->view->dojo();
                $isXhtml = $this->view->doctype()->isXhtml();
                
                if ($dojo->useCdn()) {
                        $base = $dojo->getCdnBase() . $dojo->getCdnVersion();
                } else {
                        $base = $dojo->_getLocalRelativePath();
                }
                
                $registeredStylesheets = $dojo->getStylesheetModules();
                foreach ($registeredStylesheets as $stylesheet) {
                        $themeName = substr($stylesheet, strrpos($stylesheet, '.') + 1);
                        $stylesheet = str_replace('.', '/', $stylesheet);
                        $stylesheets[] = $base . '/' . $stylesheet . '/' . $themeName . '.css';
                }
                
                foreach ($dojo->getStylesheets() as $stylesheet) {
                        $stylesheets[] = $stylesheet;
                }
                
                if ($dojo->registerDojoStylesheet()) {
                        $stylesheets[] = $base . '/dojo/resources/dojo.css';
                }
                
                if (empty($stylesheets)) {
                        return '';
                }
                
                array_reverse($stylesheets);
                $style = '';
                
                return $style;
        }
}

Now my {action}.ajax.phtml script is nice and happy.

// call the regular members action page - no need to duplicate code!
echo $this->render('team-manager/members.phtml');

// inlineScript contains all the formatters for the grid
echo $this->inlineScript();

// New view helper to include the data grid CSS files generated by my DataGrid view helper
echo $this->dojoStylesheets();

Blitzaroo event view teaser

Friday, March 5th, 2010

Two weeks ago I promised a screenshot on event signups and I finally have something worth showing. Stay tuned for more shots!

Blitzaroo signups

Thursday, March 4th, 2010

Dum da dum!

So, I spent most of last night working on event signups in Blitzaroo and I ran into a situation where I’m trying to decide what features I want to implement. This blog is my attempt to get the community involved so I’m going to throw up a little poll and see what you have to say. Let me elaborate on the options.

1. phpRaider

Signups should work exactly like phpRaider. There are three levels (accepted, queued, declined) and the freeze time determines when users can signup. If it’s past the freeze time all signups are disabled but users can still edit their note. The administrator can also automatically queue everyone.

2. Blitzaroo

I was tinkering around with with a combination of phpRaider features and new features. Levels will still exist (primary, alternate, declined) and I will keep the freeze time. I was planning on adding additional automatic signups such as:

  1. Let Blitzaroo handle signups automatically. This option would use an algorithm (currently unknown) to assign attendees based on various factors such as attendance, label (or role), and/or a roll of the dice. (Disables 2, 3, and 4)
  2. Allow users to choose their signup type. Gives users the ability to choose primary, alternate, or declined.
  3. Allow users to choose their own label. Gives users the ability to choose their role.
  4. Let the event coordinator handle signups. The event coordinator is required to assign signups types as well as labels. (Disables 1)

These are all checkable options and some can be used together.

Custom

If you choose this option please specify in the comments below what you think is the best way to handle signups.

[poll id="3"]