ApiModule.php 2.8 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
			'interop.models.*',
			'survey.models.*',
Raph El's avatar
Raph El committed
55
56
57
			'costum.models.*',
			'places.models.*',
			'eco.models.*',
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
58
59
			Yii::app()->params["module"]["parent"].'.models.*',
			Yii::app()->params["module"]["parent"].'.components.*',
raphael's avatar
raphael committed
60
61
			$this->id.'.models.*',
			$this->id.'.components.*',
Tibor Katelbach's avatar
tweaks    
Tibor Katelbach committed
62
			$this->id.'.messages.*'
raphael's avatar
raphael committed
63
64
		));
	}
Raph El's avatar
Hotfix    
Raph El committed
65
66
67
68
	public function getParentAssetsUrl()
	{
		return ( @Yii::app()->params["module"]["parent"] ) ?  Yii::app()->getModule( Yii::app()->params["module"]["parent"] )->getAssetsUrl()  : self::getAssetsUrl();
	}
raphael's avatar
raphael committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

	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
90
91

	public function getTheme() {
Raph El's avatar
Raph El committed
92
		$theme = "CO2";
Raphael's avatar
Modif    
Raphael committed
93
94
95
		if (!empty(Yii::app()->params['theme'])) {
			$theme = Yii::app()->params['theme'];
		} else if (empty(Yii::app()->theme)) {
Raph El's avatar
Raph El committed
96
			$theme = "CO2";
Raphael's avatar
Modif    
Raphael committed
97
98
99
100
101
		}

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