ApiModule.php 2.54 KB
Newer Older
raphael's avatar
raphael committed
1
2
3
4
5
6
7
<?php
/**
 * Api Module
*/

class ApiModule extends CWebModule
{
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
8
9
10
11
12
13
14
15
16
17
18
19
20

	private $_version = "v0.1.0";
	private $_versionDate = "20/09/2019";
	private $_keywords = "module,opensource,CO,communecter,api";
	private $_description = "oPEN Data an open systems";
	private $_pageTitle = "CO api";

	public function getVersion(){return $this->_version;}
	public function getVersionDate(){return $this->_versionDate;}
	public function getKeywords(){return $this->_keywords;}
	public function getDescription(){return $this->_description;}
	public function getPageTitle(){return $this->_pageTitle;}

raphael's avatar
raphael committed
21
22
23
24
25
26
27
28
29
30
31
32
	public function init()
	{
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		Yii::app()->setComponents(array(
		    'errorHandler'=>array(
		        'errorAction'=>'/'.$this->id.'/error'
		    )
		));
		
		Yii::app()->homeUrl = Yii::app()->createUrl($this->id);
Raphael's avatar
Modif    
Raphael committed
33
34
		Yii::app()->theme  = $this->getTheme();

raphael's avatar
raphael committed
35
36
		Yii::app()->language = (isset(Yii::app()->session["lang"])) ? Yii::app()->session["lang"] : 'fr';
		
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
37
38
39
40
41
42
43
44
45
46
		// import the module-level models and components
		Yii::app()->params["module"] = array(
			"name" => self::getPageTitle(),
			"parent" => "co2",
			"costumId"=>"",
			"overwrite" => array(
				"views" => array(),
				"assets" => array(),
				"controllers" => array(),
			));
raphael's avatar
raphael committed
47
48
49
		// import the module-level models and components
		$this->setImport(array(
			'citizenToolKit.models.*',
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
50
			'map.models.*',
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
51
			'news.models.*',
Tony Emma's avatar
Tony Emma committed
52
			'dda.models.*',
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
53
54
55
56
			'interop.models.*',
			'survey.models.*',
			Yii::app()->params["module"]["parent"].'.models.*',
			Yii::app()->params["module"]["parent"].'.components.*',
raphael's avatar
raphael committed
57
58
			$this->id.'.models.*',
			$this->id.'.components.*',
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
59
			$this->id.'.messages.*'
raphael's avatar
raphael committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
		));
	}

	public function beforeControllerAction($controller, $action)
	{
		if (parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}
	private $_assetsUrl;

	public function getAssetsUrl()
	{
		if ($this->_assetsUrl === null)
	        $this->_assetsUrl = Yii::app()->getAssetManager()->publish(
	            Yii::getPathOfAlias($this->id.'.assets') );
	    return $this->_assetsUrl;
	}
Raphael's avatar
Modif    
Raphael committed
83
84

	public function getTheme() {
Raph El's avatar
Raph El committed
85
		$theme = "CO2";
Raphael's avatar
Modif    
Raphael committed
86
87
88
		if (!empty(Yii::app()->params['theme'])) {
			$theme = Yii::app()->params['theme'];
		} else if (empty(Yii::app()->theme)) {
Raph El's avatar
Raph El committed
89
			$theme = "CO2";
Raphael's avatar
Modif    
Raphael committed
90
91
92
93
94
		}

		if(@$_GET["tpl"] == "iframesig"){ $theme = $_GET["tpl"]; }
		return $theme;
	}
raphael's avatar
raphael committed
95
}