<?php

class Project {
    public function __construct($id,$project){
		$this->id = $id;
		$this->project = $project;
		$this->getSites();
    }
	public function getSites() {
		if (!is_object($this->objSites)) {
			$arr = \getSites($this->id,false);
				//array_multisort($arrSites['color'], SORT_ASC, SORT_STRING);
			$i=0;
			if ($arr) {
				foreach($arr as $key => $item) {
					$id=$item['id'];
					$site=$item['site'];
					$this->objSites[] = new Sites($id,$site);
					$i++;
				}
			}
			$this->countSite = $i;
		}
	}
}

class Sites {
    public function __construct($id,$site){
		$this->id = $id;
		$this->site = $site;
		$this->getPages();
    }
	public function getPages() {
		if (!is_object($this->objPages)) {
			$arr = \getPages($this->id,false);
				//array_multisort($arrSites['color'], SORT_ASC, SORT_STRING);
			$i=0;
			if ($arr) {
				foreach($arr as $key => $item) {
					$id=$item['id'];
					$page=$item['page'];
					$description=$item['description'];
					$this->objPages[] = new Pages($id,$page,$description);
					$i++;
				}
			}
			$this->countPages = $i;
		}
	}
}

class Pages {
    public function __construct($id,$page,$description){
		$this->id = $id;
		$this->page = cleanUrl($page);
		$this->description = $description;
		$this->getKeyword();
    }
	public function getKeyword() {
		if (!is_object($this->objKeywords)) {
			$arr = \getKeywords($this->id,false);
				//array_multisort($arrSites['color'], SORT_ASC, SORT_STRING);
			$i=0;
			if ($arr) {
				foreach($arr as $key => $item) {
					$id=$item['id'];
					$keyword=$item['keyword'];
					$this->objKeywords[] = new Keywords($id,$keyword);
					$i++;
				}
			}

			$this->countKeywords= $i;
		}
	}
}

class Keywords {
    public function __construct($id,$keyword){
		$this->id = $id;
		$this->keyword = $keyword;
    }
}

class Result {
    public function __construct($site,$pages,$result,$hasMeta,$cntKey,$cntDes){
		$this->site = $site;
		$this->pages = $pages;
		$this->result = $result;
		$this->hasMeta = $hasMeta;
		$this->cntKey = $cntKey;
		$this->cntDes = $cntDes;
    }
}

?>