<?php
	if( !$this->user->is_logged ) {
		$this->redirect('home');
	}
	
	
	/*************************************************************************/
	// needed before proceeding
	require_once('_all-required-language.php');
	
	$this->load_langfile('global/global.php');	
	$this->load_langfile('inside/dashboard.php');

	/*************************************************************************/
	
	
	require_once('_all-required-dashboard.php');
	

	/*************************************************************************/
	
	$D->cadsearch = '';
	if ($this->param('q')) $D->cadsearch = $this->db1->e($this->param('q'));
	
	$D->cadShort = 0;
	if (!empty($D->cadsearch) && strlen($D->cadsearch)<=3) $D->cadShort = 1;

	$D->doSearch = 0;

	if (!empty($D->cadsearch) && $D->cadShort==0) {
	
		$listpages = $this->db2->fetch_all("
		SELECT pages.* FROM pages 
		WHERE 
		status=1 
		AND (title LIKE '%".$D->cadsearch."%' OR description LIKE '%".$D->cadsearch."%') 
		ORDER BY num_likes DESC
		");
		
		$D->doSearch = 1;
	
		$D->htmlPages = '';
		
		foreach($listpages as $onepage) {
			$D->idpage = $onepage->idpage;
			$D->codepage = $onepage->code;
			$D->pageverified = $onepage->verified;
			$D->numlikespage = $onepage->num_likes;
			$D->numpostspage = $onepage->num_posts;
			$D->titlepage = stripslashes($onepage->title);
			$D->urlpage = $onepage->url;
			$D->status = $onepage->status;
			$D->avatarpage = $onepage->avatar_page;
			$D->nameCategory = stripslashes($this->network->getNameCatPage($onepage->idsubcategory));
			$D->isMyPage = $onepage->idowner == $this->user->id ? TRUE : FALSE;
			$D->htmlPages .= $this->load_template('__dashboard-one-page.php', FALSE);
		}
		
		unset($listpages, $onepage);
		
	}
	
	/*************************************************************************/

	$D->optionactive = 11;
	$D->tab_active = 3;
	$this->load_template('dashboard-pages-search.php');
?>