Commit b8465395 authored by thomas craipeau's avatar thomas craipeau
Browse files

yii 2 only

parent fedd94d4
......@@ -30,16 +30,16 @@ class NewsModule extends \yii\base\Module {
public function getAssetsUrl()
{
if ($this->_assetsUrl === null) {
Yii::$app->getAssetManager()->publish(
Yii::getPathOfAlias($this->id.'.assets') );
$this->_assetsUrl = Yii::$app->getAssetManager()->getPublishedUrl(Yii::getPathOfAlias($this->id.'.assets'));
Yii::$container->get('assetManager')->publish(
Yii::getAlias('@modules/'.$this->id.'/assets') );
$this->_assetsUrl = Yii::$container->get('assetManager')->getPublishedUrl(Yii::getAlias('@modules/'.$this->id.'/assets'));
}
return $this->_assetsUrl;
}
public function getParentAssetsUrl()
{
return ( @Yii::$app->params["module"]["parent"] ) ? Yii::$app->getModule( Yii::$app->params["module"]["parent"] )->getAssetsUrl() : $this->module->assetsUrl;
return ( @Yii::$container->get('yii\base\Module')->params["module"]["parent"] ) ? Yii::$container->get('yii\base\Module')->getModule( Yii::$container->get('yii\base\Module')->params["module"]["parent"] )->getAssetsUrl() : $this->module->assetsUrl;
}
public function beforeControllerAction($controller, $action)
......@@ -60,18 +60,18 @@ class NewsModule extends \yii\base\Module {
// you may place code here to customize the module or the application
Yii::$app->homeUrl = Yii::$app->urlManager->createUrl($this->id);
Yii::$container->get('yii\web\Application')->homeUrl = Yii::$container->get('urlManager')->createUrl($this->id);
//Apply theme
$themeName = $this->getTheme();
ThemeHelper::setWebsiteTheme($themeName);
if(@Yii::$app->request->cookies['lang'] && !empty(Yii::$app->request->cookies['lang']->value))
Yii::$app->language = (string)Yii::$app->request->cookies['lang'];
if(@Yii::$container->get('request')->cookies['lang'] && !empty(Yii::$container->get('request')->cookies['lang']->value))
Yii::$container->get('yii\web\Application')->language = (string)Yii::$container->get('request')->cookies['lang'];
else
Yii::$app->language = (isset(Yii::$app->session["lang"])) ? Yii::$app->session["lang"] : 'fr';
Yii::$container->get('yii\web\Application')->language = (isset(Yii::$container->get('session')["lang"])) ? Yii::$container->get('session')["lang"] : 'fr';
Yii::$app->params["module"] = array(
Yii::$container->get('yii\base\Module')->params["module"] = array(
"name" => self::getPageTitle(),
"parent" => "co2",
"overwriteList" => array(
......@@ -92,17 +92,13 @@ class NewsModule extends \yii\base\Module {
*/
public function getTheme() {
//$theme = "CO2";
$theme = (@Yii::$app->session["theme"]) ? Yii::$app->session["theme"] : "CO2";
$theme = (@Yii::$container->get('session')["theme"]) ? Yii::$container->get('session')["theme"] : "CO2";
//$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"] : "CO2";
//$theme = "CO2";
//$theme = "notragora";
if (!empty(Yii::$container->get('yii\base\Module')->params['theme'])) {
$theme = Yii::$container->get('yii\base\Module')->params['theme'];
}
Yii::$app->session["theme"] = $theme;
Yii::$container->get('session')["theme"] = $theme;
return $theme;
}
}
......@@ -41,18 +41,18 @@ class CoController extends CommunecterController {
'class' => ExtractProcessAction::class,
'options' => array(
// Tmp dir to store cached resized images
'cache_dir' => Yii::getPathOfAlias('webroot') . '/assets/',
'cache_dir' => Yii::getAlias('@webroot') . '/assets/',
// Web root dir to search images from
'base_dir' => Yii::getPathOfAlias('webroot') . '/',
'base_dir' => Yii::getAlias('@webroot') . '/',
)
),
'extractfile' => array (
'class' => ExtractFileAction::class,
'options' => array(
// Tmp dir to store cached resized images
'cache_dir' => Yii::getPathOfAlias('webroot') . '/assets/',
'cache_dir' => Yii::getAlias('@webroot') . '/assets/',
// Web root dir to search images from
'base_dir' => Yii::getPathOfAlias('webroot') . '/',
'base_dir' => Yii::getAlias('@webroot') . '/',
)
)
);
......
......@@ -26,7 +26,7 @@ class DefaultController extends CommunecterController {
{
//echo "hello there"; exit ;
// if(Yii::$app->request->isAjax)
// if(Yii::$container->get('request')->isAjax)
// echo $this->renderPartial("index");
// else
// {
......@@ -34,7 +34,7 @@ class DefaultController extends CommunecterController {
// $this->render("index");
// }
if(Yii::$app->request->isAjax)
if(Yii::$container->get('request')->isAjax)
return $this->renderPartial("index");
else{
$this->layout = "//layouts/directory";
......
......@@ -11,12 +11,12 @@ class DeleteAction extends \PixelHumain\PixelHumain\components\Action {
public function run($id= null) {
//Check if connected
$controller=$this->getController();
$controller=$this->controller;
if( ! Person::logguedAndValid()) {
$res = array("result"=>false, "msg"=>"You must be loggued to delete a comment");
return Rest::json( $res );
} else {
$res = News::delete($id, Yii::$app->session["userId"], true);
$res = News::delete($id, Yii::$container->get('session')["userId"], true);
if(@$res["newsUp"] && $_POST["isLive"]){
$params=array(
"news"=>array( $id=>$res["newsUp"]),
......
......@@ -24,7 +24,7 @@ use Yii;
class GetAction extends \PixelHumain\PixelHumain\components\Action
{
public function run($type=null, $id= null, $date = null, $isLive = null, $source = null){
$controller = $this->getController();
$controller = $this->controller;
$controller->layout = "//layouts/empty";
$costum = CacheHelper::getCostum();
......@@ -40,10 +40,10 @@ class GetAction extends \PixelHumain\PixelHumain\components\Action
//Define condition of each wall generated datas
if($type == Person::COLLECTION) {
$parent = Element::getElementSimpleById( $id,$type,null, array("links"));
if (isset(Yii::$app->session["userId"])){
$params["canManageNews"]=($id == Yii::$app->session["userId"] && $isLive!=true) ? true : false;
if (isset(Yii::$container->get('session')["userId"])){
$params["canManageNews"]=($id == Yii::$container->get('session')["userId"] && $isLive!=true) ? true : false;
}
if(!empty($isLive) && $isLive !== "false" && (@Yii::$app->session["userId"] && $id == Yii::$app->session["userId"])){
if(!empty($isLive) && $isLive !== "false" && (@Yii::$container->get('session')["userId"] && $id == Yii::$container->get('session')["userId"])){
$authorFollowedAndMe=[];
$arrayIds=[$id];
$followsArrayIds=[];
......@@ -118,9 +118,9 @@ class GetAction extends \PixelHumain\PixelHumain\components\Action
array("sharedBy.id"=>array('$in'=>array($id)),"verb"=> "share"))
);
}
if((!@$params["canManageNews"] || $params["canManageNews"] == false ) && @Yii::$app->session["userId"]){
if((!@$params["canManageNews"] || $params["canManageNews"] == false ) && @Yii::$container->get('session')["userId"]){
array_push($orRequest,
array("author"=> Yii::$app->session["userId"],
array("author"=> Yii::$container->get('session')["userId"],
"target.id"=> $id)
);
}
......@@ -129,13 +129,13 @@ class GetAction extends \PixelHumain\PixelHumain\components\Action
}
else if(in_array($type, [Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION])){
$parent = Element::getElementSimpleById($id,$type,null, array("links"));
if(@Yii::$app->session["userId"]){
if($type!= Event::COLLECTION && @$parent["links"][Element::$connectTypes[$type]][Yii::$app->session["userId"]]
&& !@$parent["links"][Element::$connectTypes[$type]][Yii::$app->session["userId"]][Link::TO_BE_VALIDATED])
if(@Yii::$container->get('session')["userId"]){
if($type!= Event::COLLECTION && @$parent["links"][Element::$connectTypes[$type]][Yii::$container->get('session')["userId"]]
&& !@$parent["links"][Element::$connectTypes[$type]][Yii::$container->get('session')["userId"]][Link::TO_BE_VALIDATED])
$params["canManageNews"]=true;
else if($type==Event::COLLECTION &&
((@$parent["links"]["attendees"][Yii::$app->session["userId"]] && @$parent["links"]["attendees"][Yii::$app->session["userId"]]["isAdmin"]) ||
@$parent["links"]["organizer"][Yii::$app->session["userId"]]) )
((@$parent["links"]["attendees"][Yii::$container->get('session')["userId"]] && @$parent["links"]["attendees"][Yii::$container->get('session')["userId"]]["isAdmin"]) ||
@$parent["links"]["organizer"][Yii::$container->get('session')["userId"]]) )
$params["canManageNews"]=true;
}
$scope=["public","restricted"];
......@@ -181,7 +181,7 @@ class GetAction extends \PixelHumain\PixelHumain\components\Action
array("target.id"=>$id,
'$or'=> array(
array("scope.type"=>array('$in'=>$scope)),
array("author"=>Yii::$app->session["userId"])
array("author"=>Yii::$container->get('session')["userId"])
)
)
);
......@@ -346,7 +346,7 @@ class GetAction extends \PixelHumain\PixelHumain\components\Action
$params["removeNews"]=$removeNewsArray;
}
if(@$parent){
$params["edit"] = Authorisation::canEditItem(Yii::$app->session["userId"], $type, $parent["_id"]);
$params["edit"] = Authorisation::canEditItem(Yii::$container->get('session')["userId"], $type, $parent["_id"]);
$params["openEdition"] = Authorisation::isOpenEdition($parent["_id"], $type, @$parent["preferences"]);
}else{
$params["edit"] = false;
......
......@@ -16,7 +16,7 @@ use Yii;
class IndexAction extends \PixelHumain\PixelHumain\components\Action
{
public function run($type=null, $id= null, $date = null, $isLive = null, $source=null,$streamType="news", $textSearch=null, $nbCol=null, $inline=null){
$ctrl = $this->getController();
$ctrl = $this->controller;
$ctrl->layout = "//layouts/empty";
$news = array();
$params=array(
......@@ -38,19 +38,19 @@ class IndexAction extends \PixelHumain\PixelHumain\components\Action
"clickEvent"=>false
);
if(@$parent){
$params["edit"] = Authorisation::canEditItem(Yii::$app->session["userId"], $type, $parent["_id"]);
$params["edit"] = Authorisation::canEditItem(Yii::$container->get('session')["userId"], $type, $parent["_id"]);
$params["openEdition"] = Authorisation::isOpenEdition($parent["_id"], $type, @$parent["preferences"]);
}
if(@Yii::$app->session["userId"]){
if(@Yii::$container->get('session')["userId"]){
$params["canPostNews"]=true;
if(in_array($type, [Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION])){
$parent = Element::getElementSimpleById($id,$type,null, array("links", "name", "profilThumbImageUrl"));
if($type!= Event::COLLECTION && @$parent["links"][Element::$connectTypes[$type]][Yii::$app->session["userId"]]
&& !@$parent["links"][Element::$connectTypes[$type]][Yii::$app->session["userId"]][Link::TO_BE_VALIDATED])
if($type!= Event::COLLECTION && @$parent["links"][Element::$connectTypes[$type]][Yii::$container->get('session')["userId"]]
&& !@$parent["links"][Element::$connectTypes[$type]][Yii::$container->get('session')["userId"]][Link::TO_BE_VALIDATED])
$params["canManageNews"]=true;
else if($type==Event::COLLECTION && ((@$parent["links"]["attendees"][Yii::$app->session["userId"]] && @$parent["links"]["attendees"][Yii::$app->session["userId"]]["isAdmin"]) || @$parent["links"]["organizer"][Yii::$app->session["userId"]]) )
else if($type==Event::COLLECTION && ((@$parent["links"]["attendees"][Yii::$container->get('session')["userId"]] && @$parent["links"]["attendees"][Yii::$container->get('session')["userId"]]["isAdmin"]) || @$parent["links"]["organizer"][Yii::$container->get('session')["userId"]]) )
$params["canManageNews"]=true;
}else if($type == Person::COLLECTION && Yii::$app->session["userId"]==$id && $isLive!=true)
}else if($type == Person::COLLECTION && Yii::$container->get('session')["userId"]==$id && $isLive!=true)
$params["canManageNews"]=true;
}
......@@ -93,7 +93,7 @@ class IndexAction extends \PixelHumain\PixelHumain\components\Action
$params["inline"]=$inline;
if (in_array($type,[Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION, Person::COLLECTION]))
$params["deletePending"] = Element::isElementStatusDeletePending($type, $id);
if(Yii::$app->request->isAjax)
if(Yii::$container->get('request')->isAjax)
return $ctrl->renderPartial("news.views.co.index", $params);
else
return $ctrl->render("news.views.co.index", $params);
......
......@@ -16,7 +16,7 @@ class ModerateAction extends \PixelHumain\PixelHumain\components\Action
{
public function run()
{
$controller=$this->getController();
$controller=$this->controller;
//Detail moderate one news
if(isset($_REQUEST['subAction']) && $_REQUEST['subAction'] == "consolidateModerateNews"){
......@@ -64,7 +64,7 @@ class ModerateAction extends \PixelHumain\PixelHumain\components\Action
'isAnAbuse' => $_REQUEST['isAnAbuse']
);
$resAction = Action::addAction(Yii::$app->session["userId"] , $_REQUEST['id'], "news", Action::ACTION_MODERATE, false, false, $details);
$resAction = Action::addAction(Yii::$container->get('session')["userId"] , $_REQUEST['id'], "news", Action::ACTION_MODERATE, false, false, $details);
//Save => OK
if($resAction['userActionSaved']){
......
......@@ -11,7 +11,7 @@ class SaveAction extends \PixelHumain\PixelHumain\components\Action
{
public function run($type=null, $id=null)
{
$controller=$this->getController();
$controller=$this->controller;
$result=array("result"=>false, "msg"=>Yii::t("common","You must be logged in to add a news entry !"));
if(Person::logguedAndValid()){
$result=News::save($_POST);
......
......@@ -9,7 +9,7 @@ class UpdateAction extends \PixelHumain\PixelHumain\components\Action
{
public function run()
{
$controller=$this->getController();
$controller=$this->controller;
$result=News::update($_POST);
if(@$_GET["tpl"]=="co2"){
$params=array(
......
......@@ -15,9 +15,9 @@ class News {
"collection" => self::COLLECTION,
"controller" => self::CONTROLLER,
"module" => self::MODULE,
"assets" => Yii::$app->getModule( self::MODULE )->assetsUrl,
"init" => Yii::$app->getModule( self::MODULE )->assetsUrl."/js/init.js" ,
"form" => Yii::$app->getModule( self::MODULE )->assetsUrl."/js/dynForm.js" ,
"assets" => Yii::$container->get('yii\base\Module')->getModule( self::MODULE )->assetsUrl,
"init" => Yii::$container->get('yii\base\Module')->getModule( self::MODULE )->assetsUrl."/js/init.js" ,
"form" => Yii::$container->get('yii\base\Module')->getModule( self::MODULE )->assetsUrl."/js/dynForm.js" ,
//"categories" => CO2::getModuleContextList(self::MODULE,"categories"),
"lbhp" => true
);
......@@ -159,7 +159,7 @@ class News {
public static function save($params)
{
//check a user is loggued
$user = Person::getById(Yii::$app->session["userId"]);
$user = Person::getById(Yii::$container->get('session')["userId"]);
//TODO : if type is Organization check the connected user isAdmin
if(empty($user))
......@@ -173,7 +173,7 @@ class News {
|| (isset($_POST["mediaFile"]) && !empty($_POST["mediaFile"])))
{
$news=self::prepData($params);
//Yii::app()->mongodb->selectCollection(self::COLLECTION)->insert($news);
//Yii::$container->get('mongodb')->selectCollection(self::COLLECTION)->insert($news);
$news = PHDB::insert(self::COLLECTION, $news);
//NOTIFICATION MENTIONS
......@@ -183,7 +183,7 @@ class News {
$authorName=Element::getElementSimpleById($news["parentId"], $news["parentType"]);
$author=array("id"=>$news["parentId"], "type"=>$news["parentType"],"name"=>$authorName["name"]);
}else{
$author=array("id" => Yii::$app->session["userId"],"type"=>Person::COLLECTION, "name" => Yii::$app->session["user"]["name"]);
$author=array("id" => Yii::$container->get('session')["userId"],"type"=>Person::COLLECTION, "name" => Yii::$container->get('session')["user"]["name"]);
}
Notification::notifyMentionOn($author , $target, $news["mentions"], null, $news["scope"]);
}
......@@ -192,13 +192,13 @@ class News {
$target=$news["target"];//array("id"=>$news["parentId"],"type"=>$news["parentType"]);
if(@$news["targetIsAuthor"])
$target["targetIsAuthor"]=true;
else if($params["parentType"]==Person::COLLECTION && $params["parentId"] != Yii::$app->session["userId"])
else if($params["parentType"]==Person::COLLECTION && $params["parentId"] != Yii::$container->get('session')["userId"])
$target["userWall"]=true;
if($params["parentType"] != Person::COLLECTION || $params["parentId"] != Yii::$app->session["userId"]){
Notification::constructNotification(ActStr::VERB_POST, array("id" => Yii::$app->session["userId"],"name" => Yii::$app->session["user"]["name"]) , $target, null, null, null, $news["text"]);
if($params["parentType"] != Person::COLLECTION || $params["parentId"] != Yii::$container->get('session')["userId"]){
Notification::constructNotification(ActStr::VERB_POST, array("id" => Yii::$container->get('session')["userId"],"name" => Yii::$container->get('session')["user"]["name"]) , $target, null, null, null, $news["text"]);
}
$news=NewsTranslator::convertParamsForNews($news);
$news["author"] = Person::getSimpleUserById(Yii::$app->session["userId"]);
$news["author"] = Person::getSimpleUserById(Yii::$container->get('session')["userId"]);
/* Send email alert to contact@pixelhumain.com */
//if(@$type && $type=="pixels"){
......@@ -213,11 +213,11 @@ class News {
$typeNews=@$params["type"] ? $params["type"] : "news";
$news = array("type" => $typeNews, //"news",
"text" => $params["text"],
"author" => Yii::$app->session["userId"],
"author" => Yii::$container->get('session')["userId"],
"date"=>PHDB::MongoDate(time()),
"collection"=>self::COLLECTION,
"sharedBy"=> array(
array("id"=>Yii::$app->session["userId"],
array("id"=>Yii::$container->get('session')["userId"],
"type"=>Person::COLLECTION,
"updated"=>PHDB::MongoDate(time())
)
......@@ -241,8 +241,8 @@ class News {
if (isset($params["media"])){
$news["media"] = $params["media"];
if(isset($params["media"]["content"]) && isset($params["media"]["content"]["image"]) && !isset($params["media"]["content"]["imageId"])){
$urlImage = self::uploadNewsImage($params["media"]["content"]["image"],$params["media"]["content"]["imageSize"],Yii::$app->session["userId"]);
$news["media"]["content"]["image"]= Yii::app()->baseUrl."/".$urlImage;
$urlImage = self::uploadNewsImage($params["media"]["content"]["image"],$params["media"]["content"]["imageSize"],Yii::$container->get('session')["userId"]);
$news["media"]["content"]["image"]= Yii::$container->get('Url')::base()."/".$urlImage;
}
}
if (isset($params["mediaImg"]))
......@@ -341,12 +341,12 @@ class News {
if($authorization===true || (@$countShare && $countShare==1)){
//Delete image
if(isset($news["media"]) && isset($news["media"]["content"]) && isset($news["media"]["content"]["image"]) && !isset($news["media"]["content"]["imageId"])){
$endPath=explode(Yii::$app->params['uploadUrl'],$news["media"]["content"]["image"]);
$pathFileDelete= Yii::$app->params['uploadDir'].$endPath[1];
$endPath=explode(Yii::$container->get('yii\base\Module')->params['uploadUrl'],$news["media"]["content"]["image"]);
$pathFileDelete= Yii::$container->get('yii\base\Module')->params['uploadDir'].$endPath[1];
/*if(file_exists ( $pathFileDelete ))
unlink($pathFileDelete);*/
if(Yii::$app->fs->has ( $pathFileDelete )) {
Yii::$app->fs->delete($pathFileDelete);
if(Yii::$container->get('fs')->has ( $pathFileDelete )) {
Yii::$container->get('fs')->delete($pathFileDelete);
}
}
......@@ -401,7 +401,7 @@ class News {
);
if(@$shareUpdate){
$followsArrayIds=[];
$parent=Element::getElementSimpleById(Yii::$app->session["userId"],Person::COLLECTION,null, array("links"));
$parent=Element::getElementSimpleById(Yii::$container->get('session')["userId"],Person::COLLECTION,null, array("links"));
if(@$parent["links"]["follows"] && !empty($parent["links"]["follows"])){
foreach ($parent["links"]["follows"] as $key => $data){
array_push($followsArrayIds,$key);
......@@ -467,14 +467,14 @@ class News {
$allShare = array();
//regarde tous les sharedBy
foreach ($share["sharedBy"] as $key => $value) {
if($value["id"] != Yii::$app->session["userId"]){ //si ce n'est pas moi je garde ce partage
if($value["id"] != Yii::$container->get('session')["userId"]){ //si ce n'est pas moi je garde ce partage
$allShare[] = $value;
}
}
//je me rajoute à la liste des allShare
$share["sharedBy"] = array_merge($allShare,
array(array( "id" => Yii::$app->session["userId"],
array(array( "id" => Yii::$container->get('session')["userId"],
"type"=> Person::COLLECTION,
"comment"=>@$comment,
"updated" => PHDB::MongoDate(time())),
......@@ -491,11 +491,11 @@ class News {
"verb" => $verb,
"target" => array("id" => $targetId,
"type"=> $targetType),
"author" => Yii::$app->session["userId"],
"author" => Yii::$container->get('session')["userId"],
"object" => $activityValue,
"scope" => array("type"=>"restricted"),
"created" => PHDB::MongoDate(time()),
"sharedBy" => array(array( "id" => Yii::$app->session["userId"],
"sharedBy" => array(array( "id" => Yii::$container->get('session')["userId"],
"type"=> Person::COLLECTION,
"comment"=>@$comment,
"updated" => PHDB::MongoDate(time()))),
......@@ -568,10 +568,10 @@ class News {
}else{
$set["media"] = $params["media"];
if(isset($params["media"]["content"]) && isset($params["media"]["content"]["image"]) && !isset($params["media"]["content"]["imageId"])){
$endPath=explode(Yii::$app->params['uploadUrl'],$params["media"]["content"]["image"]);
if(isset($endPath[1]) && !empty($endPath[1]) && !file_exists ( Yii::$app->params['uploadDir'].$endPath[1])){
$urlImage = self::uploadNewsImage($params["media"]["content"]["image"],$params["media"]["content"]["imageSize"],Yii::$app->session["userId"]);
$set["media"]["content"]["image"]= Yii::app()->baseUrl."/".$urlImage;
$endPath=explode(Yii::$container->get('yii\base\Module')->params['uploadUrl'],$params["media"]["content"]["image"]);
if(isset($endPath[1]) && !empty($endPath[1]) && !file_exists ( Yii::$container->get('yii\base\Module')->params['uploadDir'].$endPath[1])){
$urlImage = self::uploadNewsImage($params["media"]["content"]["image"],$params["media"]["content"]["imageSize"],Yii::$container->get('session')["userId"]);
$set["media"]["content"]["image"]= Yii::$container->get('Url')::base()."/".$urlImage;
}
}
}
......@@ -647,7 +647,7 @@ class News {
//One news has to be moderated X times
,"reportAbuseCount" => array('$gt' => 0)
//One moderator can't moderate 2 times a news
,"moderate.".Yii::$app->session["userId"] => array('$exists'=>0)
,"moderate.".Yii::$container->get('session')["userId"] => array('$exists'=>0)
);
if(count($whereAdditional)){
$where = array_merge($where,$whereAdditional);
......@@ -676,11 +676,11 @@ class News {
$upload_dir = $dir.'/'.$folder;
$upload_dir_tmp = $dir.'/tmp';
$returnUrl= Yii::$app->params['uploadUrl'].$dir.'/'.$folder;
$returnUrl_tmp= Yii::$app->params['uploadUrl'].$dir.'/tmp';
$returnUrl= Yii::$container->get('yii\base\Module')->params['uploadUrl'].$dir.'/'.$folder;
$returnUrl_tmp= Yii::$container->get('yii\base\Module')->params['uploadUrl'].$dir.'/tmp';
if(!Yii::$app->fs->has($upload_dir )) {
Yii::$app->fs->createDir($upload_dir );
if(!Yii::$container->get('fs')->has($upload_dir )) {
Yii::$container->get('fs')->createDir($upload_dir );
}
$name=time()."_".$authorId.".".$ext;
......@@ -703,8 +703,8 @@ class News {
//$tmpfname = tempnam("/tmp", "UL_IMAGE");
if(!Yii::$app->fs->has($upload_dir_tmp)) {
Yii::$app->fs->createDir($upload_dir_tmp);
if(!Yii::$container->get('fs')->has($upload_dir_tmp)) {
Yii::$container->get('fs')->createDir($upload_dir_tmp);
}
$context = stream_context_create(
......@@ -718,7 +718,7 @@ class News {
// file_put_contents($tmpfname, $img);
Yii::$app->fs->put($upload_dir_tmp."/".$name, $img, ['visibility' => 'public']);
Yii::$container->get('fs')->put($upload_dir_tmp."/".$name, $img, ['visibility' => 'public']);
$imageUtils = new ImagesUtils($upload_dir_tmp."/".$name);
......@@ -726,8 +726,8 @@ class News {
$returnUrl=$returnUrl."/".$name;
$imageUtils->resizePropertionalyImage($maxWidth,$maxHeight)->save($destPathThumb,$quality);
if(Yii::$app->fs->has($upload_dir_tmp."/".$name)) {
Yii::$app->fs->delete($upload_dir_tmp."/".$name);
if(Yii::$container->get('fs')->has($upload_dir_tmp."/".$name)) {
Yii::$container->get('fs')->delete($upload_dir_tmp."/".$name);
}
return $returnUrl;
......
......@@ -209,13 +209,13 @@ class NewsTranslator {
//et que l'id du sharedBy est dans la liste des follows
//ou que l'id du sharedBy est mon id
if( in_array(@$value["id"], $followsArrayIds) ||
@$value["id"] == Yii::$app->session["userId"]){
@$value["id"] == Yii::$container->get('session')["userId"]){
$dateUpdated = $value["updated"]; //memorise la date du share
$lastComment = @$value["comment"]; //memorise la date du share
$lastAuthorShare = $clearShare; //memorise l'auteur du share
$lastKey = count($sharedBy);
}
}else if(@$value["id"] == Yii::$app->session["userId"]){//si j'ai pas la liste des follows de l'element => journal
}else if(@$value["id"] == Yii::$container->get('session')["userId"]){//si j'ai pas la liste des follows de l'element => journal
$dateUpdated = $value["updated"]; //memorise la date du share
$lastComment = @$value["comment"]; //memorise la date du share
$lastKey = count($sharedBy);
......
......@@ -105,11 +105,11 @@
//<!-- <div id="newLiveFeedForm" class="col-xs-12 no-padding margin-bottom-10"></div> -->
//top page Title
if( isset( Yii::$app->session[ "costum" ][ "app" ][ "#live" ]["title"] ) ) { ?>
<h3 class="title-section col-sm-8"><?php echo Yii::$app->session[ "costum" ][ "app" ][ "#live" ]["title"] ?></h3>
if( isset( Yii::$container->get('session')[ "costum" ][ "app" ][ "#live" ]["title"] ) ) { ?>
<h3 class="title-section col-sm-8"><?php echo Yii::$container->get('session')[ "costum" ][ "app" ][ "#live" ]["title"] ?></h3>
<?php }
if(isset(Yii::$app->session['userId'])){ ?>
if(isset(Yii::$container->get('session')['userId'])){ ?>
<div id="formCreateNewsTemp" style="float: none;" class="center-block hidden">
<div class='no-padding form-create-news-container <?php echo $sizeForm ?>'>
......@@ -166,7 +166,7 @@ if(isset(Yii::$app->session['userId'])){ ?>
<div id='form-news' class="col-xs-12 no-padding">
<input type="hidden" id="parentId" name="parentId"
value="<?php if($contextParentType != "city") echo $contextParentId; else echo Yii::$app->session["userId"]; ?>"/>
value="<?php if($contextParentType != "city") echo $contextParentId; else echo Yii::$container->get('session')["userId"]; ?>"/>
<input type="hidden" id="parentType" name="parentType"
value="<?php if($contextParentType != "city") echo $contextParentType; else echo Person::COLLECTION; ?>"/>
......@@ -205,9 +205,9 @@ if(isset(Yii::$app->session['userId'])){ ?>
<?php if((@$canManageNews && $canManageNews==true)
|| (@Yii::$app->session["userId"]
|| (@Yii::$container->get('session')["userId"]
&& $contextParentType==Person::COLLECTION
&& Yii::$app->session["userId"]==$contextParentId)){ ?>
&& Yii::$container->get('session')["userId"]==$contextParentId)){ ?>
<div class="dropdown col-md-6 no-padding">
<a data-toggle="dropdown" class="btn btn-default" id="btn-toogle-dropdown-scope" href="#"><i class="fa fa-<?php echo @$contextScopeNews[$contextParentType][$contextScopeNews[$contextParentType]["init"]["admin"]]["icon"] ?>"></i> <?php echo @$contextScopeNews[$contextParentType][$contextScopeNews[$contextParentType]["init"]["admin"]]["label"] ?> <i class="fa fa-caret-down" style="font-size:inherit;"></i></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
......@@ -229,8 +229,8 @@ if(isset(Yii::$app->session['userId'])){ ?>
<?php if($contextParentType == Organization::COLLECTION || $contextParentType == Project::COLLECTION || $contextParentType == Event::COLLECTION){ ?>
<div class="dropdown no-padding pull-right">
<a data-toggle="dropdown" class="btn btn-default" id="btn-toogle-dropdown-targetIsAuthor" href="#">
<?php if(@Yii::$app->session["user"]["profilThumbImageUrl"]){ ?>
<img height=20 width=20 src='<?php echo Yii::$app->request->getBaseUrl(true).Yii::$app->session["user"]["profilThumbImageUrl"]; ?>'>
<?php if(@Yii::$container->get('session')["user"]["profilThumbImageUrl"]){ ?>
<img height=20 width=20 src='<?php echo Yii::$container->get('Url')::base(true).Yii::$container->get('session')["user"]["profilThumbImageUrl"]; ?>'>
<?php } else { ?>
<img height=20 width=20 src='<?php echo $this->module->assetsUrl.'/images/thumb/default_citoyens.png' ?>'>
<?php } ?>
......@@ -241,7 +241,7 @@ if(isset(Yii::$app->session['userId'])){ ?>
<a href="javascript:;" class="targetIsAuthor" data-value="1">
<h4 class="list-group-item-heading">
<?php if(@$parent["profilThumbImageUrl"]){ ?>
<img height=20 width=20 src='<?php echo Yii::$app->request->getBaseUrl