NetworkModule.php 4.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
<?php
/**
 * Communect Module
 *
 * @author Tibor Katelbach <oceatoon@mail.com>
 * @version 0.0.3
 *
*/

class NetworkModule extends CWebModule {
Raph El's avatar
Raph El committed
11
	private $_pageTitle = "Communecter:libre et connecté";
12 13 14 15 16 17 18 19 20 21
	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'
		    )
		));
Raph El's avatar
Raph El committed
22
		//var_dump("NETWORK INIT"); exit;
23 24 25 26 27
		Yii::app()->homeUrl = Yii::app()->createUrl($this->id);
		
		//sudo ln -s co2 network
		Yii::app()->theme = "network";
		Yii::app()->session["theme"] == "network";
Raph El's avatar
Raph El committed
28
		Yii::app()->session["network"] = "network";
29 30
		Yii::app()->params['networkParams'] = ( @Yii::app()->session["networkParams"] ) ? Yii::app()->session["networkParams"] : @$_GET["network"];
		
Raph El's avatar
Raph El committed
31
		Yii::app()->params['gulp'] = false;
32 33 34 35 36 37 38 39
		/*if(@$_GET["network"] ){
		    Yii::app()->theme = "network";
		    Yii::app()->params['networkParams'] = $_GET["network"];

		    Yii::app()->session["theme"] = "network";
		    Yii::app()->session["networkParams"] = $_GET["network"];
		} */

Raph El's avatar
Raph El committed
40 41 42 43 44 45
		if(@Yii::app()->request->cookies['lang'] && !empty(Yii::app()->request->cookies['lang']->value))
        	Yii::app()->language = (string)Yii::app()->request->cookies['lang'];
        else 
			Yii::app()->language = (isset(Yii::app()->session["lang"])) ? Yii::app()->session["lang"] : 'fr';

		//Yii::app()->language = (isset(Yii::app()->session["lang"])) ? Yii::app()->session["lang"] : 'fr';
46 47 48 49
		
		// import the module-level models and components
		$this->setImport(array(
			'citizenToolKit.models.*',
Raph El's avatar
Raph El committed
50
			//'ressources.models.*',
Raph El's avatar
Raph El committed
51 52
			//'classifieds.models.*'
			'eco.models.*',
Raph El's avatar
Hotfix  
Raph El committed
53
			'costum.models.*',
Raph El's avatar
Raph El committed
54
			'places.models.*',
Raph El's avatar
Raph El committed
55 56 57
			'chat.models.*',
			'interop.models.*',
			'survey.models.*',
Raph El's avatar
Raph El committed
58
			'dda.models.*',
Raph El's avatar
Raph El committed
59
			'news.models.*',
Raph El's avatar
Raph El committed
60
			'map.models.*',
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
			$this->id.'.models.*',
			$this->id.'.components.*',
			$this->id.'.messages.*',
		));
		/*$this->components =  array(
            'class'=>'CPhpMessageSource',
            'basePath'=>'/messages'
        );*/
	}

	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;
	}

Raph El's avatar
Raph El committed
92 93 94 95 96
	public function getParentAssetsUrl()
	{
		return ( @Yii::app()->params["module"]["parent"] ) ?  Yii::app()->getModule( Yii::app()->params["module"]["parent"] )->getAssetsUrl()  : self::getAssetsUrl();
	}
	
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
	/**
	 * Retourne le theme d'affichage de communecter.
	 * Si option "theme" dans paramsConfig.php : 
	 * Si aucune option n'est précisée, le thème par défaut est "ph-dori"
	 * Si option 'tpl' fixée dans l'URL avec la valeur "iframesig" => le theme devient iframesig
	 * Si option "network" fixée dans l'URL : theme est à network et la valeur du parametres fixe les filtres d'affichage
	 * @return type
	 */
	public function getTheme() {
		//$theme = "network";
		$theme = (@Yii::app()->session["theme"]) ? Yii::app()->session["theme"] : "network";
		//$theme = "notragora";
		if (!empty(Yii::app()->params['theme'])) {
			$theme = Yii::app()->params['theme'];
		} else if (empty(Yii::app()->theme)) {
			$theme = (@Yii::app()->session["theme"]) ? Yii::app()->session["theme"] : "network";
			//$theme = "network";
			//$theme = "notragora";
		}

		if(@$_GET["tpl"] == "iframesig"){ $theme = $_GET["tpl"]; }

		if(@$_GET["network"]) {
            $theme = "network";
            //Yii::app()->params['networkParams'] = $_GET["network"];
        }
        Yii::app()->session["theme"] = $theme;
Raph El's avatar
Raph El committed
124 125 126

        Rest::json(Yii::app()->session["theme"]); exit;
        //Yii::app()->session["network"]
127 128 129
		return $theme;
	}
}