Commit 3612511c authored by Raph El's avatar Raph El
Browse files

ModifMerge branch 'master' of https://github.com/pixelhumain/places

parents 1c1953ee ccdecd7c
<?php
/**
<<<<<<< HEAD
* CO Tools Module
=======
* Places Module
>>>>>>> ccdecd7c57ce3beca98f77c77a4baea0c43fd8b7
*
* @author Tibor Katelbach <oceatoon@mail.com>
* @version 0.1
......@@ -12,9 +16,9 @@ class PlacesModule extends CWebModule {
private $_assetsUrl;
private $_version = "v0.1.0";
private $_versionDate = "07/01/2018";
private $_keywords = "places, tiers-lieux, lieux, géographie, module, opensource,CO,communecter";
private $_description = "Places use module for CO";
private $_versionDate = "22/01/2018";
private $_keywords = "places, locations, module,opensource,CO,communecter";
private $_description = "Place module for CO";
private $_pageTitle = "Places modules & CO Systems";
public function getVersion(){return $this->_version;}
......@@ -31,6 +35,11 @@ class PlacesModule extends CWebModule {
return $this->_assetsUrl;
}
public function getParentAssetsUrl()
{
return ( @Yii::app()->params["module"]["parent"] ) ? Yii::app()->getModule( Yii::app()->params["module"]["parent"] )->getAssetsUrl() : $this->module->assetsUrl;
}
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action))
......@@ -66,8 +75,9 @@ class PlacesModule extends CWebModule {
Yii::app()->language = (isset(Yii::app()->session["lang"])) ? Yii::app()->session["lang"] : 'fr';
Yii::app()->params["module"] = array(
"name" => self::getPageTitle(),
"parent" => "co2",
"overwriteList" => array(
"overwrite" => array(
"views" => array(),
"assets" => array(),
"controllers" => array(),
......
{
"sections" : {
"all": { "label":"Tous", "key" : "all", "icon" : "cloud","excludeFromForm" : true},
"common": { "label":"Commun","key" : "common", "icon" : "circle-o"},
"public": { "label":"Public","key" : "public", "icon" : "users"},
"private": { "label":"Privée", "key" : "private", "icon" : "lock"},
"urban": { "label":"Urbain", "key" : "urban", "icon" : "building-o"},
"rural": { "label":"Rural", "key" : "rural", "icon" : "tree"},
"travel": { "label":"Travel", "key" : "travel", "icon" : "car"}
},
"filters":{
"thirdplaces" :
{ "icon" : "home",
"subcat" :
[ "Fablab",
"Repaire Café",
"Coworking",
"Salle reunion",
"Jardin Partagé",
"Urbaine",
"Rurale"
]
},
"home" : {
"icon" : "home",
"subcat" :
[ "Electroménager",
"Mobilier",
"Équipement bébé",
"Animaux",
"Divers"
]
}
}
}
\ No newline at end of file
dynForm = {
jsonSchema : {
title : "Formulaire d'un Lieu",
icon : "map-marker",
type : "object",
onLoads : {
//pour creer un subevnt depuis un event existant
sub : function(){
if(contextData.type && contextData.id )
{
$('#ajaxFormModal #parentId').val(contextData.id);
$("#ajaxFormModal #parentType").val( contextData.type );
}
},
onload : function(){
if(typeof data != "undefined" && data.section && data.type && data.subtype ){
$("#ajaxFormModal #id").val(data.id);
$(".breadcrumbcustom").html( "<h4><a href='javascript:;'' class='btn btn-xs btn-danger' onclick='dyFObj.elementObj.dynForm.jsonSchema.actions.clear()'><i class='fa fa-times'></i></a> "+data.section+" > "+data.type+" > "+data.subtype+"</h4>" );
$(".sectionBtntagList").hide();
$(".typeBtntagList").hide();
} else
$(".typeBtntagList, .nametext, .descriptiontextarea, .pricetext, .contactInfotext, .locationlocation, .imageuploader, .formshowerscustom, .tagstags, #btn-submit-form").hide();
},
},
beforeSave : function(){
var tagAndTypes = ( $("#ajaxFormModal #tags").val() != "" ) ? $("#ajaxFormModal #tags").val()+"," : "" ;
if( $("#ajaxFormModal #section").val() )
tagAndTypes += $("#ajaxFormModal #section").val();
if( $("#ajaxFormModal #type").val() )
tagAndTypes += ","+$("#ajaxFormModal #type").val();
if( $("#ajaxFormModal #subtype").val() )
tagAndTypes += ","+$("#ajaxFormModal #subtype").val();
$("#ajaxFormModal #tags").val( tagAndTypes );
if( typeof $("#ajaxFormModal #description").code === 'function' )
$("#ajaxFormModal #description").val( $("#ajaxFormModal #description").code() );
if($('#ajaxFormModal #parentId').val() == "" && $('#ajaxFormModal #parentType').val() ){
$('#ajaxFormModal #parentId').val( userId );
$("#ajaxFormModal #parentType").val( "citoyens" );
}
},
beforeBuild : function(){
dyFObj.setMongoId('place',function(){
uploadObj.gotoUrl = '#page.type.places.id.'+uploadObj.id;
});
},
afterSave : function(){
if( $('.fine-uploader-manual-trigger').fineUploader('getUploads').length > 0 )
$('.fine-uploader-manual-trigger').fineUploader('uploadStoredFiles');
else {
dyFObj.closeForm();
urlCtrl.loadByHash( uploadObj.gotoUrl );
}
},
actions : {
clear : function() {
$("#ajaxFormModal #section, #ajaxFormModal #type, #ajaxFormModal #subtype").val("");
$(".breadcrumbcustom").html( "");
$(".sectionBtntagList").show();
$(".typeBtntagList").hide();
$(".subtypeSection").html("");
$(".subtypeSectioncustom").show();
$(".typeBtntagList, .nametext, .descriptiontextarea, .pricetext, .contactInfotext, .locationlocation, .imageuploader, .formshowerscustom, .tagstags").hide();
}
},
properties : {
info : {
inputType : "custom",
html:"<p><i class='fa fa-info-circle'></i> Un Point d'interet est un élément assez libre qui peut etre géolocalisé ou pas, qui peut etre rataché à une organisation, un projet ou un évènement.</p>",
},
breadcrumb : {
inputType : "custom",
html:"",
},
sectionBtn :{
label : "De quel type de Lieu s'agit-il ? ",
inputType : "tagList",
placeholder : "Choisir un type",
list : place.sections,
trad : tradCategory,
init : function(){
$(".sectionBtn").off().on("click",function()
{
$(".typeBtntagList").show();
$(".sectionBtn").removeClass("active btn-dark-blue text-white");
$( "."+$(this).data('key')+"Btn" ).toggleClass("active btn-dark-blue text-white");
$("#ajaxFormModal #section").val( ( $(this).hasClass('active') ) ? $(this).data('tag') : "" );
//$(".sectionBtn:not(.active)").hide();
$(".breadcrumbcustom").html( "<h4><a href='javascript:;'' class='btn btn-xs btn-danger' onclick='dyFObj.elementObj.dynForm.jsonSchema.actions.clear()'><i class='fa fa-times'></i></a> "+$(this).data('tag')+"</h4>");
$(".sectionBtntagList").hide();
});
}
},
section : dyFInputs.inputHidden(),
typeBtn :{
label : "Type de lieu ? ",
inputType : "tagList",
placeholder : "Choisir une catégorie",
list : place.filters,
trad : tradCategory,
init : function(){
$(".typeBtn").off().on("click",function()
{
$(".typeBtn").removeClass("active btn-dark-blue text-white");
$( "."+$(this).data('key')+"Btn" ).toggleClass("active btn-dark-blue text-white");
$("#ajaxFormModal #type").val( ( $(this).hasClass('active') ) ? $(this).data('tag') : "" );
$(".breadcrumbcustom").html( "<h4><a href='javascript:;'' class='btn btn-xs btn-danger' onclick='dyFObj.elementObj.dynForm.jsonSchema.actions.clear()'><i class='fa fa-times'></i></a> "+$(".sectionBtn.active").data('tag')+" > "+$(".typeBtn.active").data('tag')+"</h4>" );
$(".typeBtntagList").hide();
//$(".typeBtn:not(.active)").hide();
$("#ajaxFormModal #subtype").val("");
fieldHTML = "";
$.each(place.filters[ $(this).data('key') ]["subcat"], function(k,v) {
fieldHTML += '<div class="col-md-6 padding-5">'+
'<a class="btn tagListEl subtypeBtn '+k+'Btn " data-tag="'+v+'" href="javascript:;">'+v+'</a>' +
"</div>";
});
$(".subtypeSection").html('<hr class="col-md-12 no-padding">'+
'<label class="col-md-12 text-left control-label no-padding" for="typeBtn">'+
'<i class="fa fa-chevron-down"></i> Sous-catégorie'+
'</label>' +
fieldHTML );
$(".subtypeBtn").off().on("click",function()
{
$( ".subtypeBtn" ).removeClass("active");
$(this).addClass("active");
$("#ajaxFormModal #subtype").val( ( $(this).hasClass('active') ) ? $(this).data('tag') : "" );
$(".nametext, .descriptiontextarea, .pricetext, .contactInfotext, .locationlocation, .imageuploader, .formshowerscustom, .tagstags").show();
//$(".subtypeBtn:not(.active)").hide();
$(".breadcrumbcustom").html( "<h4><a href='javascript:;'' class='btn btn-xs btn-danger' onclick='dyFObj.elementObj.dynForm.jsonSchema.actions.clear()'><i class='fa fa-times'></i></a> "+$(".sectionBtn.active").data('tag')+" > "+$(".typeBtn.active").data('tag')+" > "+$(".subtypeBtn.active").data('tag')+"</h4>" );
$(".subtypeSectioncustom").hide();
});
});
}
},
type : dyFInputs.inputHidden(),
subtypeSection : {
inputType : "custom",
html:"<div class='subtypeSection'></div>"
},
subtype : dyFInputs.inputHidden(),
name : dyFInputs.name("place"),
image : dyFInputs.image( ),
//description : dyFInputs.description,
description : dyFInputs.textarea("Description", "..."),
location : dyFInputs.location,
tags :dyFInputs.tags(),
formshowers : {
label : "En détails",
inputType : "custom",
html: "<a class='btn btn-default text-dark w100p' href='javascript:;' onclick='$(\".urlsarray\").slideToggle()'><i class='fa fa-plus'></i> options (urls)</a>",
},
urls : dyFInputs.urlsOptionnel,
parentId : dyFInputs.inputHidden(),
parentType : dyFInputs.inputHidden()
}
}
};
\ No newline at end of file
/* ******************
CO.js
********************* */
//var/www/dev/modules/co2/config/CO2/params.json:
urlCtrl.loadableUrls[ "#place" ] = {
inMenu : true,
useHeader : true,
open : true,
subdomain : "place",
subdomainName : "Lieux",
hash : "#places.co.search",
icon : "map-marker",
mainTitle : "Moteur de Lieux <span class='text-red'>territoriales</span>",
placeholderMainSearch : "Rechercher un lieu ...",
lblBtnCreate : "Ajouter un lieu",
colorBtnCreate : "green",
module:"places"
};
//co.js object types
typeObj.place={ col:"places",ctrl:"place",color:"green",icon:"map-marker"};
typeObj.places = { sameAs:"place" };
typeObj.TiersLieux = {sameAs:"place",color: "azure",icon: "home"};
typeObj.Maison = {sameAs:"place", color: "azure",icon: "home"};
//CO LANG
co.place = {
form : function() { dyFObj.openForm("place") },
i : function () { co.ctrl.lbh("#"+userConnected.username+".view.directory.dir.places");},
};
......@@ -18,7 +18,17 @@ class CoController extends CommunecterController {
public function actions()
{
return array(
'sample' => 'citizenToolKit.controllers.co.SampleAction'
'test' => 'places.controllers.actions.TestAction',
'search' => 'places.controllers.actions.SearchAction'
);
}
public function actionIndex()
{
if(Yii::app()->request->isAjaxRequest)
echo $this->renderPartial("../default/index");
else
$this->render("../default/index");
//$this->redirect(Yii::app()->createUrl( "/".Yii::app()->params["module"]["parent"] ));
}
}
......@@ -18,8 +18,12 @@ class DefaultController extends CommunecterController {
public function actionIndex()
{
/*if( @Yii::app()->params["module"]["parent"] && !@Yii::app()->params["module"]["overwrite"][Yii::app()->controller->id][ Yii::app()->controller->action->id ] ){
$this->redirect(Yii::app()->createUrl( "/".Yii::app()->params["module"]["parent"]."/".Yii::app()->controller->id."/".Yii::app()->controller->action->id ));
}*/
if(Yii::app()->request->isAjaxRequest)
echo $controller->renderPartial("index");
echo $this->renderPartial("index");
else
{
$this->layout = "//layouts/empty";
......
<?php
class SearchAction extends CAction
{
public function run()
{
echo $this->getController()->renderPartial("co2.views.app.search",array("type"=>"place"));
}
}
<?php
class TestAction extends CAction
{
public function run()
{
$this->getController()->render("index");
}
}
\ No newline at end of file
<?php
class Place {
const COLLECTION = "places";
const CONTROLLER = "place";
const MODULE = "places";
//TODO Translate
public static $types = array (
"tierslieux" => "Tiers Lieux",
"fabLab" => "Fab Lab",
"restaurant" => "Restaurant",
"epicerieCollborative" => "Épicerie Collborative",
);
//From Post/Form name to database field name
public static $dataBinding = array (
"section" => array("name" => "section"),
"type" => array("name" => "type"),
"subtype" => array("name" => "placeType"),
"name" => array("name" => "name", "rules" => array("required")),
"address" => array("name" => "address", "rules" => array("addressValid")),
"addresses" => array("name" => "addresses"),
"streetAddress" => array("name" => "address.streetAddress"),
"postalCode" => array("name" => "address.postalCode"),
"city" => array("name" => "address.codeInsee"),
"addressLocality" => array("name" => "address.addressLocality"),
"addressCountry" => array("name" => "address.addressCountry"),
"geo" => array("name" => "geo"),
"geoPosition" => array("name" => "geoPosition"),
"description" => array("name" => "description"),
"addresses" => array("name" => "addresses"),
"parent" => array("name" => "parent"),
"parentId" => array("name" => "parentId"),
"parentType" => array("name" => "parentType"),
"media" => array("name" => "media"),
"urls" => array("name" => "urls"),
"medias" => array("name" => "medias"),
"tags" => array("name" => "tags"),
"modified" => array("name" => "modified"),
"updated" => array("name" => "updated"),
"creator" => array("name" => "creator"),
"created" => array("name" => "created"),
);
//used in initJs.php for the modules definition
public static function getConfig(){
return array(
"collection" => self::COLLECTION,
"controller" => self::CONTROLLER,
"module" => self::MODULE,
"init" => Yii::app()->getModule( self::MODULE )->assetsUrl."/js/init.js" ,
"form" => Yii::app()->getModule( self::MODULE )->assetsUrl."/js/dynForm.js" ,
"categories" => CO2::getModuleContextList(self::MODULE,"categories"),
);
}
/**
* get all Place details of an element
* @param type $id : is the mongoId (String) of the parent
* @param type $type : is the type of the parent
* @return list of Places
*/
public static function getPlaceByIdAndTypeOfParent($id, $type){
return PHDB::find(self::COLLECTION,array("parentId"=>$id,"parentType"=>$type));
}
/**
* get Place with limit $limMin and $limMax
* @return list of Places
*/
public static function getPlaceByTagsAndLimit($limitMin=0, $indexStep=15, $searchByTags=""){
$where = array("name"=>array('$exists'=>1));
if(@$searchByTags && !empty($searchByTags)){
$queryTag = array();
foreach ($searchByTags as $key => $tag) {
if($tag != "")
$queryTag[] = new MongoRegex("/".$tag."/i");
}
if(!empty($queryTag))
$where["tags"] = array('$in' => $queryTag);
}
return PHDB::findAndSort( self::COLLECTION, $where, array("updated" => -1));
}
/**
* get a Place By Id
* @param String $id : is the mongoId of the Place
* @return Place
*/
public static function getById($id) {
$elem = PHDB::findOneById( self::COLLECTION ,$id );
// Use case notragora
if(@$elem["type"])
$elem["typeSig"] = self::COLLECTION.".".$elem["type"];
else
$elem["typeSig"] = self::COLLECTION;
if(@$elem["type"])
$elem = array_merge($elem, Document::retrieveAllImagesUrl($id, self::COLLECTION, $elem["type"], $elem));
return $elem;
}
public static function getDataBinding() {
return self::$dataBinding;
}
}
?>
\ No newline at end of file
<?php
HtmlHelper::registerCssAndScriptsFiles( array('/css/timeline2.css','/css/news/index.css',
) , Yii::app()->theme->baseUrl. '/assets');
$cssAnsScriptFilesModule = array(
'/js/news/index.js',
'/js/news/autosize.js',
'/js/news/newsHtml.js',
);
HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesModule, $this->module->assetsUrl);
$layoutPath = 'webroot.themes.'.Yii::app()->theme->name.'.views.layouts.';
$page = "annonces";
if($params["title"] == "Kgougle") $page = "freedom";
//header + menu
$this->renderPartial($layoutPath.'header',
array( "layoutPath"=>$layoutPath ,
"type" => @$type,
"page" => page) );
?>
<style>
.btn-create-news{
margin-top:0px;
z-index: 10;
border-radius: 0 50%;
-ms-transform: rotate(7deg);
-webkit-transform: rotate(7deg);
transform: rotate(-45deg);
}
.btn-create-news:hover{
background-color: white!important;
color:#34a853!important;
border: 2px solid #34a853!important;
}
.main-btn-scopes {
margin-top: -57px;
}
#formCreateNewsTemp{
display: none!important;
}
#modal-create-anc #formCreateNewsTemp{
display: block!important;
}
#formCreateNewsTemp .form-create-news-container, #formActivity{
max-width: 60%;
/*margin-left:20%;*/
}
#sub-menu-left{
margin-top:1px;
/*text-align: left;*/
}
#sub-menu-left .btn{
/*background-color: #4285f4;
border-color: #4285f4;*/
/*color:white;*/
/*border-radius:80px;*/
font-weight: 700;
}
#sub-menu-left .btn.active{
/*background-color: #fff;
color: #4285f4;*/
}
/*#sub-menu-left .btn:hover{
background-color: #1c6df5;
border-color: #4285f4;
}*/
/*#sub-menu-left .btn.active:hover{
background-color: #fff;
color: #4285f4;
}
#sub-menu-left .btn.bg-yellow{
border-color: transparent;
}*/
<?php
$btnAnc = array("blue" =>array("color1"=>"#4285f4",
"color2"=>"#1c6df5"),
"green" =>array("color1"=>"#34a853",
"color2"=>"#2b8f45"),
"red" =>array("color1"=>"#ea4335",
"color2"=>"#cc392d"),
"yellow" =>array("color1"=>"#fbbc05",
"color2"=>"#e3a800"),
);
?>
<?php foreach($btnAnc as $color => $params){ ?>
.btn-anc-color-<?php echo $color; ?>{
background-color: <?php echo $params["color1"]; ?>;
border-color: <?php echo $params["color1"]; ?>!important;
color: #fff!important;
}
.btn-anc-color-<?php echo $color; ?>:hover{
background-color: <?php echo $params["color2"]; ?>!important;
border-color: <?php echo $params["color1"]; ?>!important;
}
.btn-anc-color-<?php echo $color; ?>.active{
background-color:#fff!important;
color:<?php echo $params["color1"]; ?>!important;
}
.btn-anc-color-<?php echo $color; ?>.active:hover{
background-color: #fff;
color: <?php echo $params["color1"]; ?>;
}
<?php } ?>
.keycat:hover,
.keycat.active,
.btn-select-category-1:hover,
.btn-select-category-1.active{
background-color: #2C3E50!important;
color: #fff!important;
border-color:transparent!important;
}
#sub-menu-left.subsub .btn{
width:95%;
text-align: left;
background-color: white;
border-color: white;
color:#4285f4;
}
#sub-menu-left.subsub{
min-width: 180px;
}
.btn-menu-left-add{
background-color: transparent !important;
border-color: transparent !important;
}
#photoAddNews{
text-align: left;
}
.tagstags, .form-actions{
/*display: none!important;*/
}