Ejemplo n.º 1
0
    /**
     * Print dynamic buttons javascript
     */
    protected function render_scripts()
    {
        // get all screens from the registry
        $items = $this->policy->registry()->get_all();
        // make sure we got some items
        if (count($items)) {
            // new script helper
            $script = new ICE_Script();
            $script->begin_logic();
            foreach ($items as $item) {
                $conf = null;
                $icons = $item->icon()->config();
                if ($icons) {
                    $conf = sprintf('{%s}', $icons);
                }
                // menu button and maybe toolbar button
                ?>
				$('a#<?php 
                $this->render_id('menu', 'item', $item->property('name'));
                ?>
').button(<?php 
                print $conf;
                ?>
);
				<?php 
                if ($item->property('toolbar')) {
                    ?>
					$('a#<?php 
                    $this->render_id('toolbarbutton', $item->property('name'));
                    ?>
').button(<?php 
                    print $conf;
                    ?>
);
				<?php 
                }
            }
            $logic = $script->end_logic();
            $logic->set_property('alias', true);
            $logic->set_property('ready', true);
        } else {
            return null;
        }
        // begin rendering
        ?>
		<script type="text/javascript">
			<?php 
        print $script->export();
        ?>
		</script><?php 
    }