<?php
/**
 * Class Handle the right navigation and header related functions
 *
 * PHP version 5.0
 *
 * @category	Anova
 * @package		HeaderHandler
 * @author		selvaraj_47ag04
 * @copyright	Copyright (c) 2009 {@link http://www.agriya.com Agriya Infoway}
 * @license		http://www.agriya.com Agriya Infoway Licence
 * @version		SVN: $Id : $
 * @since 		2008-11-05
 */
class HeaderHandler extends FormHandler
	{
		public $_navigationArr = array();
		public $_clsActiveLink = ' clsActiveLink';
		public $_clsInActiveLink = ' clsInActiveLink';
		public $_currentPage = '';

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function HeaderHandler()
			{
				global $CFG, $LANG, $db;
				$this->setFormField('config_file_name', '');
				$this->setFormField('folder', '');
				$this->setFormField('act', '');
				$this->setFormField('uname', '');
				$this->setFormField('cid', '');
				$this->setFormField('cat_id', '');
				$this->setFormField('cat', '');
				$this->setFormField('parent_id', 0);
				$this->setFormField('qid', '');
				$this->setFormField('title', '');
				$this->setFormField('al', '');
				$this->setFormField('more_questions', '');
				$this->setFormField('search_debate', '');
				$this->setFormField('more_debates', '');
				$this->setFormField('subject', '');
				$this->setFormField('forum_topic', '');
				$this->setFormField('forum_id', '');
				$this->setFormField('title', '');
				$this->setFormField('mode', '');
				$this->setFormField('act', '');
				$this->setFormField('search_member', '');
				$this->setFormField('mode', '');
				$this->setFormField('task', '');
				$this->setFormField('srch', '');
				$this->setFormField('add', '');

				$this->sanitizeFormInputs($_REQUEST);
				//frequently used objects initialized
				if(isset($db) and $db)
					$this->setDBObject($db);
				$this->makeGlobalize($CFG, $LANG);
				//for highlighting
				$this->_currentPage = strtolower($this->CFG['html']['current_script_name']);
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function populateUserName()
			{
				if(!isMember())
					return;

				return str_replace('{user_name}', $this->CFG['user']['name'], $this->LANG['header_welcome_username']);
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function populateLanguageDetails()
			{
				global $smartyObj;

				$languages_array = readDirectory($this->CFG['site']['project_path']. 'languages/', 'dir');
				$arr = array();
				$show_languages = false;
				$inc = 0;
				foreach($languages_array as $key=>$value)
					{
						if(isset($this->CFG['translated_lang'][$value]) && $this->CFG['translated_lang'][$value]=='true' && is_file($this->CFG['site']['project_path']. 'languages/'.$value.'/config_language.inc.php'))
							{
								require_once(($this->CFG['site']['project_path']. 'languages/'.$value.'/config_language.inc.php'));
								$arr[$value] = $name;
								$inc++;
								if($inc > 1 && $this->CFG['lang']['is_multi_lang_support'])
								   $show_languages = true;
							}
					}
				$smartyObj->assign('smarty_available_languages', $arr);
				$smartyObj->assign('show_languages', $show_languages);
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function populateTemplateDetails()
			{
				global $smartyObj;
				////assign for populate the template list in header
				$dir_array = readDirectory($this->CFG['site']['project_path']. 'design/templates/', 'dir');
				$template_arr = array();
				$show_stylesheet=false;
				$inc=0;
				foreach($dir_array as $template)
					{
					   if(in_array($template, $this->CFG['html']['template']['allowed']))
						   {
								//Changed to dir since we are using many stylesheets for a style
								$css_array = readDirectory($this->CFG['site']['project_path'].'design/templates/'.$template.'/root/css/', 'dir');
								foreach($css_array as $css)
									{
									    if(in_array($css, $this->CFG['html']['stylesheet'][$template]['allowed']))
								            {
												$template_arr[$template][] = $css;
												$inc++;
											   	if($inc>1 && $this->CFG['html']['stylesheet']['screen']['is_style_support'])
											   		$show_stylesheet=true;
											}
									}
						   }
					}

				$smartyObj->assign('template_arr', $template_arr);
				$smartyObj->assign('show_stylesheet', $show_stylesheet);
				$smartyObj->assign('default_css_list_arr', $template_arr[$this->CFG['html']['template']['default']]);

			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function getNavClass($identifier)
			{
				$identifier = strtolower($identifier);
				return isset($this->_navigationArr[$identifier])?$this->_navigationArr[$identifier]:$this->_clsInActiveLink;
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function populateAdminTopNavigation()
			{
				global $smartyObj;

				if(!$this->chkAllowedModule(array()))
					return;

				$clsAdminActive = 'clsAdminActive';

				//main links
				$this->_navigationArr['top_'.$this->_currentPage] = $clsAdminActive;

				//config files
				$highlight_pages = array('editconfig', 'editconfigindex', 'editconfigmodule', 'editrightbarconfig', 'editmetadetails', 'editapiconfig', 'edittemplatesettings', 'logosettings');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_settings'] = $clsAdminActive;
					}

				$highlight_pages = array('ansvideoplayersettings', 'ansvideologo', 'ansvideoadvertisement');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_ansvideoplayersettings'] = $clsAdminActive;
					}

				$highlight_pages = array('manageanswers', 'questioncategory', 'viewanswers');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_manageanswers'] = $clsAdminActive;
					}

				$highlight_pages = array('forums', 'forumsaddtitle', 'forumstopics', 'forumstopiccreate', 'forumsresponses', 'forumsresponsecreate');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_forums'] = $clsAdminActive;
					}

				$highlight_pages = array('manageblogs', 'manageblogcategory');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_manageblogs'] = $clsAdminActive;
					}

				$highlight_pages = array('manageanswersmembers', 'adduser', 'editmembers', 'viewmembers', 'editrewardpoints');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_manageanswersmembers'] = $clsAdminActive;
					}

				$highlight_pages = array('latestnews');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_latestnews'] = $clsAdminActive;
					}

				$highlight_pages = array('managestaticpages','addnewsletter','orderrightbar');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_managestaticpages'] = $clsAdminActive;
					}

				$highlight_pages = array('reportbugs');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['top_bugs'] = $clsAdminActive;
					}

				$highlight_pages = array('managestats');
				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['managestats'] = $clsAdminActive;
					}

				$highlight_pages = array('languageexport', 'editemailtemplates', 'editlanguagefile', 'translate', 'verifytranslation');

				if(in_array($this->_currentPage, $highlight_pages))
					{
						$this->_navigationArr['managelanguages'] = $clsAdminActive;
					}

				$highlight_pages = array('managedebates', 'viewdebates', 'debatesorderrightbar');
				if(in_array($this->_currentPage, $highlight_pages))
					{

						$this->_navigationArr['top_managedebates'] = $clsAdminActive;
					}

				setTemplateFolder('admin/');
				$smartyObj->display('top_navigation_links.tpl');
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function populateAdminDefaultLeftNavigation()
			{
				global $smartyObj;

				if(!$this->chkAllowedModule(array()))
					return;

				//main links
				$this->_navigationArr['left_'.$this->_currentPage] = $this->_clsActiveLink;

				//export languages
				if($this->_currentPage=='languageexport')
					{
						if($this->getFormField('act'))
							$page = $this->getFormField('act');
						$this->_navigationArr['left_'.$this->_currentPage.'_'.$page] = $this->_clsActiveLink;
					}

				//edit config sublinks for config files
				if($this->_currentPage=='editconfig')
					{
						if (!$this->getFormField('config_file_name'))
							$this->setFormField('config_file_name', 'config');
						$page = $this->_currentPage.'_'.strtolower($this->getFormField('config_file_name'));
						$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
					}

				//edit config sublinks for questions
				if($this->_currentPage=='manageanswers')
					{
						if ($this->getFormField('mode') == 'search')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}
				//edit config sublinks for debates
				if($this->_currentPage=='managedebates')
					{
						if ($this->getFormField('mode') == 'search')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}
				if($this->_currentPage=='debatesorderrightbar')
					{
						$this->_navigationArr['left_'.$this->_currentPage] = '';
						$page = $this->_currentPage;
						$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
					}

				//edit config for viewanswer page
				if($this->_currentPage=='viewanswers')
					{
						$this->_navigationArr['left_'.$this->_currentPage] = '';
						$page = 'manageanswers';
						$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
					}


				//edit config sublinks for question categories
				if($this->_currentPage=='questioncategory')
					{
						if ($this->getFormField('mode') == 'add')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
						if ($this->getFormField('mode') == 'addsubcategory')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}

				//edit config sublinks for blogs
				if($this->_currentPage=='manageblogcategory')
					{
						if ($this->getFormField('task'))
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('task'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}

				//edit config sublinks for Videoplayer
			   if($this->_currentPage=='managebanner')
					{
						if ($this->getFormField('act'))
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('act'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}

				//edit config sublinks for forums
				if($this->_currentPage=='forums')
					{
						if ($this->getFormField('srch') == 'mosttopics')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('srch'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
						elseif ($this->getFormField('srch') == 'mostresponses')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('srch'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}

					}

				//edit config sublinks for forumstopics
				if($this->_currentPage=='forumstopics')
					{
						if ($this->getFormField('srch') == 'mostviews')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('srch'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
						elseif ($this->getFormField('srch') == 'mostresponse')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('srch'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}

					}
				//edit config sublinks for Videoplayer
				   if($this->_currentPage=='ansvideoadvertisement')
						{
							if ($this->getFormField('act') == 'add')
								{
									$this->_navigationArr['left_'.$this->_currentPage] = '';
									$page = $this->_currentPage.'_'.strtolower($this->getFormField('act'));
									$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
								}
						}

				//edit config sublinks for questions
				if($this->_currentPage=='manageavatars')
					{
						if ($this->getFormField('mode') == 'add')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}

				//edit config sublinks
				if($this->getFormField('act'))
					{
						$page = $this->_currentPage.'_'.strtolower($this->getFormField('act'));
						$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
					}

				//edit config sublinks for blogs

				if($this->getFormField('add'))
					{
						$this->_navigationArr['left_'.$this->_currentPage] = '';
						$page = $this->_currentPage.'_'.strtolower($this->getFormField('add'));
						$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
					}

				//for aco section module highlighting
				$acosection_arr = array('gaclacoobject');
				if(in_array($this->_currentPage, $acosection_arr))
					{
						$this->_navigationArr['left_gaclacosections'] = $this->_clsActiveLink;
					}

				if($this->_currentPage=='reportbugs')
					{
						if ($this->getFormField('mode') == 'add')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}
				//edit config sublinks for questions
				if($this->_currentPage=='managestats')
					{
						if ($this->getFormField('mode') == 'audio')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}

				if($this->_currentPage=='managepaymentplans')
					{
						if ($this->getFormField('mode') == 'add')
							{
								$this->_navigationArr['left_'.$this->_currentPage] = '';
								$page = $this->_currentPage.'_'.strtolower($this->getFormField('mode'));
								$this->_navigationArr['left_'.$page] = $this->_clsActiveLink;
							}
					}


				$smartyObj->assign('display_block', $this->hideOtherBlocks());
				setTemplateFolder('admin/');
				$smartyObj->display('left_navigation_links.tpl');
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function getMetaKeywords()
			{
				return isset($this->LANG['meta_'.$this->_currentPage.'_keywords'])?$this->LANG['meta_'.$this->_currentPage.'_keywords']:$this->CFG['html']['meta']['keywords'];
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function getMetaDescription()
			{
				return isset($this->LANG['meta_'.$this->_currentPage.'_description'])?$this->LANG['meta_'.$this->_currentPage.'_description']:$this->CFG['html']['meta']['description'];
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function getPageTitle()
			{
				return isset($this->LANG['meta_'.$this->_currentPage.'_title'])?$this->CFG['site']['title'].' :: '.$this->LANG['meta_'.$this->_currentPage.'_title']:$this->CFG['site']['title'];
			}

		/**
		 *
		 * @return 		void
		 * @access 		public
		 */
		public function hideOtherBlocks()
		     {
                 $currentPage = $this->_currentPage;

                if (in_array($currentPage, array('editconfig', 'editconfigindex', 'editconfigmodule', 'editrightbarconfig', 'editanswersconfig', 'editmetadetails', 'editapiconfig', 'edittemplatesettings', 'logosettings')))
					return 'settings_block';

				if (in_array($currentPage, array('ansvideoplayersettings', 'ansvideologo', 'ansvideoadvertisement')))
					return 'video_palyer_block';

				if (in_array($currentPage, array('manageanswers', 'viewanswers', 'questioncategory')))
					return 'answers_management_block';

				if (in_array($currentPage, array('forums', 'forumsaddtitle', 'forumsresponsecreate', 'forumsresponses', 'forumstopiccreate', 'forumstopics')))
					return 'forums_management_block';

				if (in_array($currentPage, array('manageblogs', 'manageblogcategory', 'blogcomment')))
					return 'blogs_management_block';

				if (in_array($currentPage, array('manageanswersmembers', 'editmembers', 'viewmembers', 'editrewardpoints', 'adduser')))
					return 'members_management_block';

				if (in_array($currentPage, array('managebanner')))
					return 'banner_management_block';

				if (in_array($currentPage, array('manageavatars')))
					return 'avatars_management_block';

				if (in_array($currentPage, array('managestaticpages', 'staticpage', 'addnewsletter', 'orderrightbar')))
					return 'staticpages_management_block';

				if (in_array($currentPage, array('latestnews')))
					return 'latest_news_block';

				if (in_array($currentPage, array('reportbugs')))
					return 'report_bugs_block';

				if (in_array($currentPage, array('managepaymentplans', 'viewplans')))
					return 'payments_block';

				if (in_array($currentPage, array('managestats')))
					return 'managestats_block';

				if (in_array($currentPage, array('languageexport', 'editemailtemplates', 'editlanguagefile', 'translate', 'verifytranslation')))
					return 'managelanguages_block';

				if (in_array($currentPage, array('managedebates', 'viewdebates', 'debatesorderrightbar')))
					return 'debates_management_block';
		     }

		/**
		 *
		 * @access public
		 * @return void
		 **/
		public function getAllSubCategories($cat_table, $parent_id, $cat_id, $for)
		    {
				if (!$parent_id)
					return ;

				$sql = 'SELECT cat_id, cat_name, seo_title, '.$for.' FROM '.$cat_table.
						' WHERE parent_id='.$this->dbObj->Param('parent_id').' AND status=\'1\''.
						' ORDER BY cat_name';

				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt, array($parent_id));
				if (!$rs)
					    trigger_db_error($this->dbObj);

				if ($count = $rs->PO_RecordCount())
					{
  						$getAllSubCategories_arr = array();
  						$inc = 1;
						while($row = $rs->FetchRow())
							{
								$getAllSubCategories_arr[$inc]['record'] = $row;
								$getAllSubCategories_arr[$inc]['class'] = 'clsInactive';
								if ($cat_id == $row['cat_id'])
									$getAllSubCategories_arr[$inc]['class'] = 'clsActive';
								if($for == 'total_questions')
									$getAllSubCategories_arr[$inc]['questions_category']['url'] = getAnovaUrl('questions', '?cat='.$row['seo_title'], 'dir/'.$row['seo_title'].'/');
								elseif($for == 'total_debates')
									$getAllSubCategories_arr[$inc]['questions_category']['url'] = getDebatesUrl('debates', '?cat='.$row['seo_title'], 'dir/'.$row['seo_title'].'/');
								$getAllSubCategories_arr[$inc]['row_cat_name_manual'] = stripString($row['cat_name']);

								$inc++;
							}
						return $getAllSubCategories_arr;
					}
				return ;
		    }

		/*
		 *
		 * @return 		void
		 * @access 		public
		 * @module		For html_header.php file
		 **/
		public function displayPopularVideoAudio($row)
			{
				$contentDetails = $this->getContentDetails($row);

				if (!$contentDetails)
					return false;

				$displayPopularVideoAudio_arr = array();
				$displayPopularVideoAudio_arr['question'] = wordWrapManual($contentDetails['question'], 20, 75);
				$displayPopularVideoAudio_arr['link'] =$contentDetails['link'];
				//increment popular video audio count
				$this->_popularVideoAudioCnt++;

				$type_id = $row['type_id'];
				$type_for = $row['type_for'];
				$popularId = 'popular_'.$type_id.'_'.$this->_popularVideoAudioCnt;
				//popular video audio url
				$displayPopularVideoAudio_arr['popularVideoAudioUrl'] = getAnovaUrl('ansviewvideo', '?pg='.$type_for.'_'.$type_id, '?pg='.$type_for.'_'.$type_id);
				$displayPopularVideoAudio_arr['popularType'] = $row['type'];
				$displayPopularVideoAudio_arr['popularHeight'] = '';
				if ($row['type'] == 'audio')
					{
						$displayPopularVideoAudio_arr['popularVideoAudioUrl'] = getAnovaUrl('ansviewaudio', '?pg='.$type_for.'_'.$type_id, '?pg='.$type_for.'_'.$type_id);
						$displayPopularVideoAudio_arr['popularHeight'] = 'height';
					}
				$displayPopularVideoAudio_arr['end_tr'] = false;
				if ($this->_popularVideoAudioCnt == 5)
					{
						$displayPopularVideoAudio_arr['end_tr'] = true;
					}
				$popurl = getAnovaUrl('popularviewvideo', '?pg='.$type_for.'_'.$type_id, '?pg='.$type_for.'_'.$type_id);
				$displayPopularVideoAudio_arr['popularId'] = $popularId;
				$displayPopularVideoAudio_arr['imgSrc'] = $contentDetails['imgSrc'];
				$displayPopularVideoAudio_arr['callAjax'] = 'ajaxpopularUpdateDiv(\''.$popurl.'\', \'selShowVideoPopular\');return false;';

				return $displayPopularVideoAudio_arr;
			}

		/**
		 *
		 * @access public
		 * @return void
		 **/
		public function showFeaturedDebates($users_table,$debate_table, $limit, $lang)
		    {
				global $smartyObj;
				$allowed_pages_array = array('debates.php', 'debatesResponse.php', 'debateCategories.php','debateTags.php');
				if(!displayBlock($allowed_pages_array))
					return;

				 $sql = 'SELECT debate_id, d.seo_title, d.description, d.best_response_id, d.total_againsts,d.date_featured,
						d.total_fors, (d.total_againsts+d.total_fors) AS totalResponse,
						d.featured, d.total_videos, d.total_audios, d.pcat_id, d.cat_id, d.status, d.user_id,'.
						$this->getUserTableField('display_name').' as asked_by, u.'.$this->getUserTableField('user_id').' as img_user_id,'.
						$this->getUserTableFields(array('name', 'image_path', 'gender', 't_height', 't_width', 's_height', 's_width', 'photo_server_url', 'photo_ext'), false).
						'subject, total_stars, TIMEDIFF(NOW(), date_asked) as date_asked, TIMEDIFF(date_closed, NOW()) as date_closed,
						IF(status=\'Open\' AND date_closed>=NOW(), 1, 0) is_open, video_id, audio_id
						FROM '.$debate_table.' AS d, '.$users_table.' AS u
						WHERE d.user_id = u.user_id AND u.usr_status = \'Ok\'
						AND d.featured <> \'0\'
						AND NOT EXISTS ( SELECT 1 FROM user_ignored AS ui WHERE ui.user_id ='.$this->CFG['user']['user_id'].'
						AND ui.ignored_id = d.user_id ) AND d.status NOT IN ( \'Blocked\', \'ToActivate\' ) ORDER BY date_featured DESC';
				if ($limit)
					$sql .= ' LIMIT 0,'.($limit + 1);
				$stmt = $this->dbObj->Prepare($sql);
				$rs = $this->dbObj->Execute($stmt);
				if (!$rs)
					 trigger_db_error($this->dbObj);
                $showFeaturedDebatesArray = array();
				if ($count = $rs->PO_RecordCount())
					{
						$i=1;
						while($row = $rs->FetchRow())
							{
								$showFeaturedDebatesArray[$i]['debatesResponse_class'] = 'clsActive';
								$showFeaturedDebatesArray[$i]['debatesResponse_url'] = getAnovaUrl('debatesresponse', '?title='.$row['seo_title'], '/'.$row['seo_title'].'/');
								$showFeaturedDebatesArray[$i]['debatesResponse_name'] = stripString($row['subject']);
								if ($i++ >= $limit)
	                      		break;
							}
					}
				if ($count = $rs->PO_RecordCount())
					{
						$showFeaturedDebatesMoreLink = getDebatesUrl('debates','?view=featured&sort=date&order=d&al=All&','featured/?sort=date&order=d&al=All&');
						$smartyObj->assign('showFeaturedDebatesMoreLink', $showFeaturedDebatesMoreLink);
					}
				$smartyObj->assign('showFeaturedDebatesArray', $showFeaturedDebatesArray);
				setTemplateFolder('general/', $this->CFG['admin']['index']['anova_module']);
				$smartyObj->display('showFeaturedDebates.tpl');
		    }
	}
?>