Location: PHPKode > projects > Web2.0 community/group web site > web20groups_pre-alpha-2/include/Controllers/IndexController.php
<?php
	
	class IndexController extends CommonCustomControllerAction
	{
		public function init()
		{
			parent::init();

		    $this->view->extra_styles= array(
                                                '/css/main.css',
                                                '/css/windowstyle.css',
                                            );
            $this->view->extra_scripts= array(
                                                '/js/main.js',
                                                '/js/mylib.inlineframe.class.js',
                                                '/js/mylib.menu.class.js'
                                            );
        }

		public function indexAction()
		{
			$this->addUserMenu();
			$this->createSubMenu();
			$this->fillViewVariables();
			$this->view->selected_commonmenu_item= 'Home' ;
		}

        public function noobjectsAction()
        {
        }

		protected function createSubMenu()
		{
			$this->submenu1_title= "What's new?";
            $objcount= -1;
            $this->add2Submenu1('B', 'blog posts', 'view the unread blog posts', 'blog', 'view');
            $this->add2Submenu1('V', 'videos', 'view the new videos', 'video', 'view');
            $this->add2Submenu1('G', 'galleries', 'view the unvisited galleries', 'gallery', 'view');

            $options= array('count' => 'yes');
            $objcount= DatabaseObject_Poll::getNewForUser($this->db, $this->user_id, $options);
            $this->add2Submenu1('P', 'polls', 'view the unvoted polls', 'poll', 'view', $objcount);

			$this->submenu2_title= "Starred Items";

            $this->add2Submenu2('V', 'videos', 'view the starred videos', 'video', 'view');
            $options= array('count' => 'yes');
            $objcount= DatabaseObject_BlogPost::getStarredByUser($this->db, $this->user_id, $options);
            $this->add2Submenu2('B', 'blog posts', 'view the starred blog posts', 'blog', 'view', $objcount);
            $this->add2Submenu2('G', 'galleries', 'view the starred galleries', 'gallery', 'view');
            $this->add2Submenu2('P', 'polls', 'view the starred polls', 'poll', 'view');

		}

        protected function add2Submenu1($objtype, $menuname, $menutitle, $controller, $action, $objcount=-1)
        {
            $menuindex= count($this->submenu1);
            if ($objcount == -1)
			    $objcount= DatabaseObject_Unread::GetObjectCount($this->db, $this->user_id, $objtype);
			$this->submenu1[$menuindex]->name=  ucwords($menuname). '('. $objcount . ')';
			$this->submenu1[$menuindex]->title= $menutitle;
			$this->submenu1[$menuindex]->url= $this->getUrl($action, $controller) .'/unread';

            if (($this->selected_submenu1_item == '') &&($objcount> 0)) {
				$this->selected_submenu1_item= $this->submenu1[$menuindex]->name;
                $this->view->content_src= $this->submenu1[$menuindex]->url;
            }
        }

        protected function add2Submenu2($objtype, $menuname, $menutitle, $controller, $action, $objcount= -1)
        {
            $menuindex= count($this->submenu2);
            if ($objcount == -1)
    		    $objcount= DatabaseObject_Starred::GetObjectCount($this->db, $this->user_id, $objtype);
			$this->submenu2[$menuindex]->name=  ucwords($menuname). '('. $objcount . ')';
			$this->submenu2[$menuindex]->title= $menutitle;
			$this->submenu2[$menuindex]->url= $this->getUrl($action, $controller) .'/starred';
        }
	}	
?>
Return current item: Web2.0 community/group web site