Commit 3eec5b33 authored by Nicolas Nambinintsoa's avatar Nicolas Nambinintsoa
Browse files

Merge branch 'development' into pompe

parents 71f8fb66 0404e157
<?php
class D3Action extends CAction
{
public function run($id=null, $type=null,$view=null,$slug=null)
public function run($id=null, $type=null,$view=null,$slug=null,$ctx=null)
{
if(!@$id && isset(Yii::app()->session["userId"])){
$id = Yii::app()->session["userId"];
......@@ -33,13 +33,15 @@ class D3Action extends CAction
$links = array();
$tags = array();
$strength = 0.095;
$hasOrga = false;
$hasKnows = false;
$hasEvents = false;
$hasProjects = false;
$hasMembersO = false;
$hasMembersP = false;
$hasTags = false;
$has = [];
$lbls = [
Link::person2organization => "ORGANIZATIONS",
Link::person2personknows => "KNOWS",
Link::person2events => "EVENTS",
Link::person2projects => ucwords(Link::person2projects),
Link::organization2person => "MEMBERS org",
Person::COLLECTION => "MEMBERS people"
];
$link = "#page.type.".$itemType.".id.".(string)$item["_id"];
......@@ -60,71 +62,87 @@ class D3Action extends CAction
array_push($data, array( "id" => $item["parentId"], "group" => $grp, "label" => @$parent["name"], "level" => 2,"type"=>$item["parentType"],"tags" => @$parent["tags"], "linkSize" => count(@$parent["links"], COUNT_RECURSIVE),"img"=>@$parent["profilThumbImageUrl"] ) );
array_push($links, array( "target" => $item["parentId"], "source" => "parent", "strength" => $strength ) );
}
foreach ($item["links"] as $key => $value){
foreach ($item["links"] as $linkType => $value){
foreach ($value as $k => $v) {
if(strcmp($key, "memberOf") == 0 || strcmp($key, "organizer") == 0){
if(strcmp($linkType, Link::person2organization) == 0 ||
strcmp($linkType, Link::organization2personOrga ) == 0){
$obj = Organization::getById($k);
if(!@$obj["_id"] || !@$obj["name"])continue;
if(!$hasOrga){
array_push($data, array( "id" => "orgas", "group" => 1, "label" => "ORGANIZATIONS", "level" => 1 ) );
if(!isset($has[$linkType])){
array_push($data, array( "id" => "orgas",
"group" => 1,
"label" => $lbls[Link::person2organization],
"level" => 1 ) );
array_push($links, array( "target" => "orgas", "source" => $root["id"], "strength" => $strength ) );
$hasOrga = true;
$has[$linkType] = true;
}
array_push($data, array( "id" => (string)@$obj["_id"], "group" => 2, "label" => @$obj["name"], "level" => 2,"type"=>Organization::CONTROLLER,"tags" => @$obj["tags"], "linkSize" => count(@$obj["links"], COUNT_RECURSIVE),"img"=>@$obj["profilThumbImageUrl"] ) );
array_push($links, array( "target" => (string)@$obj["_id"], "source" => "orgas", "strength" => $strength ) );
}
else if (strcmp($key, "knows") == 0 ||
strcmp($key, "attendees") == 0 ||
strcmp($key, "contributors") == 0 ){
else if (strcmp($linkType, Link::person2personknows) == 0 ||
strcmp($linkType, Link::event2person) == 0 ){
$obj = Person::getById($k);
if(!@$obj["_id"] || !@$obj["name"])continue;
$obj["type"] = "person";
if(!$hasKnows){
array_push($data, array( "id" => "knows", "group" => 1, "label" => "KNOWS", "level" => 1) );
if(!isset($has[$linkType])){
array_push($data, array( "id" => "knows",
"group" => 1,
"label" => $lbls[Link::person2personknows],
"level" => 1) );
array_push($links, array( "target" => "knows", "source" => $root["id"], "strength" => $strength ) );
$hasKnows = true;
$has[$linkType] = true;
}
array_push($data, array( "id" => (string)@$obj["_id"], "group" => 1, "label" => @$obj["name"], "level" => 2,"tags" => @$obj["tags"],"type"=>Person::COLLECTION, "linkSize" => count(@$obj["links"], COUNT_RECURSIVE),"img"=>@$obj["profilThumbImageUrl"] ) );
array_push($links, array( "target" => (string)@$obj["_id"], "source" => "knows", "strength" => $strength ,"tags" => @$obj["tags"]) );
}
else if (strcmp($key, "events") == 0){
else if (strcmp($linkType, Link::person2events ) == 0){
$obj = Event::getById($k);
if(!@$obj["_id"] || !@$obj["name"])continue;
if(!$hasEvents){
array_push($data, array( "id" => "events", "group" => 1, "label" => "EVENTS", "level" => 1 ) );
if(!isset($has[$linkType])){
array_push($data, array( "id" => "events",
"group" => 1,
"label" => $lbls[Link::person2events],
"level" => 1 ) );
array_push($links, array( "target" => "events", "source" => $root["id"], "strength" => $strength ) );
$hasEvents = true;
$has[$linkType] = true;
}
array_push($data, array( "id" => (string)@$obj["_id"], "group" => 4, "label" => @$obj["name"], "level" => 2,"type"=>Event::CONTROLLER,"tags" => @$obj["tags"], "linkSize" => count(@$obj["links"], COUNT_RECURSIVE),"img"=>@$obj["profilThumbImageUrl"] ));
array_push($links, array( "target" => (string)@$obj["_id"], "source" => "events", "strength" => $strength ) );
}
else if (strcmp($key, "projects") == 0){
else if (strcmp($linkType, Link::person2projects ) == 0){
$obj = Project::getById($k);
if(!@$obj["_id"] || !@$obj["name"])continue;
$obj["type"] = "projects";
if(!$hasProjects){
array_push($data, array( "id" => "projects", "group" => 1, "label" => "PROJECTS", "level" => 1 ) );
array_push($links, array( "target" => "projects", "source" => $root["id"], "strength" => $strength ) );
$hasProjects = true;
if(!isset($has[$linkType])){
array_push($data, array( "id" => $linkType,
"group" => 1,
"label" => $lbls[Link::person2projects],
"level" => 1 ) );
array_push($links, array( "target" => $linkType, "source" => $root["id"], "strength" => $strength ) );
$has[$linkType] = true;
}
array_push($data, array( "id" => (string)@$obj["_id"], "group" => 3, "label" => @$obj["name"], "level" => 2,"type"=>Project::CONTROLLER,"tags" => @$obj["tags"], "linkSize" => count(@$obj["links"], COUNT_RECURSIVE),"img"=>@$obj["profilThumbImageUrl"] ));
array_push($links, array( "target" => (string)@$obj["_id"], "source" => "projects", "strength" => $strength ) );
array_push($links, array( "target" => (string)@$obj["_id"], "source" => $linkType, "strength" => $strength ) );
}
else if(strcmp($key, "members")== 0){
else if(strcmp($linkType, Link::organization2person )== 0 ||
strcmp($linkType, Link::project2person )== 0 ){
if(isset($v["type"])){
if(strcmp($v["type"], Organization::COLLECTION) == 0){
$obj = Organization::getById($k);
if(!@$obj["_id"] || !@$obj["name"])continue;
if(!$hasMembersO){
array_push($data, array( "id" => "memberso", "group" => 1, "label" => "MEMBERS org", "level" => 1 ) );
if(!isset($has["memberso"])){
array_push($data, array( "id" => "memberso",
"group" => 1,
"label" => $lbls[Link::organization2person],
"level" => 1 ) );
array_push($links, array( "target" => "memberso", "source" => $root["id"], "strength" => $strength ) );
$hasMembersO = true;
$has["memberso"] = true;
}
array_push($data, array( "id" => (string)@$obj["_id"], "group" => 2, "label" => @$obj["name"], "level" => 2,"type"=>Organization::COLLECTION,"tags" => @$obj["tags"], "linkSize" => count(@$obj["links"], COUNT_RECURSIVE),"img"=>@$obj["profilThumbImageUrl"] ));
array_push($links, array( "target" => (string)@$obj["_id"], "source" => "memberso", "strength" => $strength ) );
......@@ -135,10 +153,13 @@ class D3Action extends CAction
$obj = Person::getById($k);
if(!@$obj["_id"] || !@$obj["name"])continue;
$obj["type"] = "person";
if(!$hasMembersP){
array_push($data, array( "id" => "membersp", "group" => 1, "label" => "MEMBERS people", "level" => 1 ) );
if(!isset($has["membersp"])){
array_push($data, array( "id" => "membersp",
"group" => 1,
"label" => $lbls[Person::COLLECTION],
"level" => 1 ) );
array_push($links, array( "target" => "membersp", "source" => $root["id"], "strength" => $strength ) );
$hasMembersP = true;
$has["membersp"] = true;
}
array_push($data, array( "id" => (string)@$obj["_id"], "group" => 1, "label" => @$obj["name"], "level" => 2,"type"=>Person::COLLECTION,"tags" => @$obj["tags"], "linkSize" => count(@$obj["links"], COUNT_RECURSIVE) ));
array_push($links, array( "target" => (string)@$obj["_id"], "source" => "membersp", "strength" => $strength ) );
......@@ -151,10 +172,10 @@ class D3Action extends CAction
foreach (@$obj["tags"] as $ix => $tag) {
if(!in_array($tag, $tags)){
$tags[] = $tag;
if(!$hasTags){
if(!isset($has["tags"])){
array_push($data, array( "id" => "tags", "group" => 1, "label" => "TAGS", "level" => 1 ) );
array_push($links, array( "target" => "tags", "source" => $root["id"], "strength" => $strength ) );
$hasTags = true;
$has["tags"] = true;
}
array_push($data, array( "id" => "tag".(count($tags)), "group" => 1, "label" => $tag, "level" => 2,"type"=>"tag" ));
array_push($links, array( "target" => "tag".(count($tags)), "source" => "tags", "strength" => $strength ) );
......@@ -177,6 +198,7 @@ class D3Action extends CAction
);
Yii::app()->theme = "empty";
Yii::app()->layout = "empty";
Yii::app()->session["theme"] = "empty";
if($view)
......
......@@ -31,15 +31,16 @@ class LisearchAction extends CAction
$hasMembersP = false;
$searchCrit = array(
"searchType"=> array(Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION, Person::COLLECTION)
"searchType"=> array(Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION, Person::COLLECTION),
"indexMin"=>0,
"indexStep"=>300
);
$crit = "";
$icon = "";
$link = "";
if(@$tag){
$searchCrit["searchTag"]= array($tag);
$searchCrit["searchTags"]= array($tag);
$crit = "TAG : ".$tag;
$icon = "<i class='fa fa-tag'></i> ";
$link = "";
......@@ -75,7 +76,7 @@ class LisearchAction extends CAction
var_dump($list);
} else
*/
$list = Search::globalAutoComplete( $searchCrit );
$list = SearchNew::globalAutoComplete( $searchCrit );
if(isset($list) && @$list["results"]){
foreach ($list["results"] as $key => $value){
......@@ -90,9 +91,9 @@ class LisearchAction extends CAction
Event::COLLECTION,
Person::COLLECTION);
if( @$value['type'] && in_array( $value['type'], $types) ) {
if( @$value['collection'] && in_array( $value['collection'], $types) ) {
if( in_array($value['type'], array( Organization::COLLECTION,Organization::TYPE_BUSINESS , Organization::TYPE_NGO, Organization::TYPE_GROUP, Organization::TYPE_GOV, Organization::TYPE_COOP)) ){
if( in_array($value['collection'], array( Organization::COLLECTION,Organization::TYPE_BUSINESS , Organization::TYPE_NGO, Organization::TYPE_GROUP, Organization::TYPE_GOV, Organization::TYPE_COOP)) ){
// if(!$hasOrga){
// array_push($data, array( "id" => "orgas", "group" => 1, "label" => "ORGANIZATIONS", "level" => 1 ) );
// array_push($links, array( "target" => "orgas", "source" => "search", "strength" => $strength ) );
......@@ -103,7 +104,7 @@ class LisearchAction extends CAction
}
else if ($value['type'] == Event::COLLECTION ){
else if ($value['collection'] == Event::COLLECTION ){
// if(!$hasEvents){
// array_push($data, array( "id" => "events", "group" => 1, "label" => "EVENTS", "level" => 1 ) );
// array_push($links, array( "target" => "events", "source" => "search", "strength" => $strength ) );
......@@ -124,7 +125,7 @@ class LisearchAction extends CAction
// }
else if ($value['type'] == Project::COLLECTION ){
else if ($value['collection'] == Project::COLLECTION ){
// if(!$hasProjects){
// array_push($data, array( "id" => "projects", "group" => 1, "label" => "PROJECTS", "level" => 1 ) );
// array_push($links, array( "target" => "projects", "source" => "search", "strength" => $strength ) );
......
......@@ -21,13 +21,17 @@ class SearchAction extends CAction
$hasMembersP = false;
$searchCrit = array(
"searchType"=> array(Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION, Person::COLLECTION)
"searchType"=> array(Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION, Person::COLLECTION),
"countType"=> array(Organization::COLLECTION, Project::COLLECTION, Event::COLLECTION, Person::COLLECTION),
"indexMin"=>0,
"indexStep"=>300,
"count"=>true
);
$crit = "";
$icon = "";
$link = "";
if(@$tag){
$searchCrit["searchTag"]= array($tag);
$searchCrit["searchTags"]= array($tag);
$crit = "TAG : ".$tag;
$icon = "<i class='fa fa-tag'></i> ";
$link = "";
......@@ -40,7 +44,6 @@ class SearchAction extends CAction
}
else if(@$geo){
$searchCrit["locality"] = array(array( "type"=>"country", "countryCode" => $geo));
//echo "<script> alert( '".var_dump($searchCrit)."' ); </script>";
$crit = "GEO : ".$geo."";
$icon = "<i class='fa fa-map-marker'></i> ";
$link = "";
......@@ -63,8 +66,7 @@ class SearchAction extends CAction
var_dump($list);
} else
*/
$list = Search::globalAutoComplete( $searchCrit );
$list = SearchNew::globalAutoComplete( $searchCrit );
if(isset($list) && @$list["results"]){
foreach ($list["results"] as $key => $value){
$types = array(
......@@ -78,9 +80,9 @@ class SearchAction extends CAction
Event::COLLECTION,
Person::COLLECTION);
if( @$value['type'] && in_array( $value['type'], $types) ) {
if( @$value['collection'] && in_array( $value['collection'], $types) ) {
if( in_array($value['type'], array( Organization::COLLECTION,Organization::TYPE_BUSINESS , Organization::TYPE_NGO, Organization::TYPE_GROUP, Organization::TYPE_GOV, Organization::TYPE_COOP)) ){
if( in_array($value['collection'], array( Organization::COLLECTION,Organization::TYPE_BUSINESS , Organization::TYPE_NGO, Organization::TYPE_GROUP, Organization::TYPE_GOV, Organization::TYPE_COOP)) ){
if(!$hasOrga){
array_push($data, array( "id" => "orgas", "group" => 1, "label" => "ORGANIZATIONS", "level" => 1 ) );
array_push($links, array( "target" => "orgas", "source" => "search", "strength" => $strength ) );
......@@ -91,7 +93,7 @@ class SearchAction extends CAction
}
else if ($value['type'] == Person::COLLECTION ){
else if ($value['collection'] == Person::COLLECTION ){
if(!$hasKnows){
array_push($data, array( "id" => "people", "group" => 1, "label" => "PEOPLE", "level" => 1) );
array_push($links, array( "target" => "people", "source" => "search", "strength" => $strength ) );
......@@ -101,7 +103,7 @@ class SearchAction extends CAction
array_push($links, array( "target" => $key, "source" => "people", "strength" => $strength ,"tags" => @$value["tags"]) );
}
else if ($value['type'] == Event::COLLECTION ){
else if ($value['collection'] == Event::COLLECTION ){
if(!$hasEvents){
array_push($data, array( "id" => "events", "group" => 1, "label" => "EVENTS", "level" => 1 ) );
array_push($links, array( "target" => "events", "source" => "search", "strength" => $strength ) );
......@@ -111,7 +113,7 @@ class SearchAction extends CAction
array_push($links, array( "target" => $key, "source" => "events", "strength" => $strength ) );
}
else if ($value['type'] == Project::COLLECTION ){
else if ($value['collection'] == Project::COLLECTION ){
if(!$hasProjects){
array_push($data, array( "id" => "projects", "group" => 1, "label" => "PROJECTS", "level" => 1 ) );
array_push($links, array( "target" => "projects", "source" => "search", "strength" => $strength ) );
......@@ -132,7 +134,14 @@ class SearchAction extends CAction
}
}
}
$crit .= " (".count($data).")";
if(isset($list["count"])){
$countRes=0;
foreach($list["count"] as $v){
$countRes+=$v;
}
}else
$countRes=count($data);
$crit .= " (".$countRes.")";
$params = array(
'data' => $data,
'links' => $links,
......
<?php
$cssAnsScriptFilesTheme = array(
"/plugins/Chart-2.8.0/Chart.min.js",
); HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesTheme, Yii::app()->request->baseUrl);
?>
<script type="text/javascript">
window.chartColors = {
red: 'rgb(255, 99, 132)',
orange: 'rgb(255, 159, 64)',
yellow: 'rgb(255, 205, 86)',
green: 'rgb(75, 192, 192)',
blue: 'rgb(54, 162, 235)',
purple: 'rgb(153, 102, 255)',
grey: 'rgb(201, 203, 207)'
};
var materialcolor = [
window.chartColors.red , window.chartColors.orange , window.chartColors.yellow, window.chartColors.green, window.chartColors.blue, window.chartColors.purple, window.chartColors.grey
]
var COLORS = [
"#0A2F62",
"#0B2D66",
"#064191",
"#2C97D0",
"#16A9B1",
"#0AA178",
"#74B976",
"#0AA178",
"#16A9B1",
"#2A99D1",
"#064191",
"#0B2E68"
];
</script>
<div id="container" style="margin:0px auto;width:100%">
<canvas id="canvas-bar<?php echo $id?>"></canvas>
</div>
<script>
var randomScalingFactor = function() {
return Math.round(Math.random() * 100);
};
jQuery(document).ready(function() {
if(typeof <?php echo $id?>Data == "undefined"){
mylog.log("render","/modules/graph/views/co/bar.php");
var barChartData = {
labels: ["Developpement",
"Chef de projet",
"Formation",
"Commercial",
"Graphiste",
"Designer",
"Créatif"],
datasets: [{
label : "Tibor",
backgroundColor: window.chartColors.red,
borderColor: window.chartColors.red,
borderWidth: 1,
data: [78,43,40,29,40,59,103]
},
{
label : "Rapha",
backgroundColor: window.chartColors.blue,
borderColor: window.chartColors.blue,
borderWidth: 1,
data: [28,23,20,9,20,29,203]
},
{
label : "Bouboule",
backgroundColor: window.chartColors.orange,
borderColor: window.chartColors.orange,
borderWidth: 1,
data: [8,5,2,98,200,299,3]
}]
};
} else {
var barChartData<?php echo $id?> = {
labels : <?php echo $id?>Data.label,
datasets: [
{
backgroundColor: materialcolor,
borderColor: materialcolor,
borderWidth: 1,
data: <?php echo $id?>Data.dataset
}
]
}
}
var ctx = document.getElementById('canvas-bar<?php echo $id?>').getContext('2d');
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData<?php echo $id?>,
options: {
title: {
display: true,
text: 'Chart.js Bar Chart - Stacked'
},
tooltips: {
mode: 'index',
intersect: false
},
responsive: true,
scales: {
xAxes: [{
stacked: true,
}],
yAxes: [{
stacked: true
}]
}
}
});
});
</script>
<?php
$cssAnsScriptFilesTheme = array(
"/plugins/Chart-2.8.0/Chart.min.js",
); HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesTheme, Yii::app()->request->baseUrl);
?>
<script type="text/javascript">
window.chartColors = {
red: 'rgb(255, 99, 132)',
orange: 'rgb(255, 159, 64)',
yellow: 'rgb(255, 205, 86)',
green: 'rgb(75, 192, 192)',
blue: 'rgb(54, 162, 235)',
purple: 'rgb(153, 102, 255)',
grey: 'rgb(201, 203, 207)'
};
var materialcolor = [
window.chartColors.red , window.chartColors.orange , window.chartColors.yellow, window.chartColors.green, window.chartColors.blue, window.chartColors.purple, window.chartColors.grey
]
var COLORS = [
"#0A2F62",
"#0B2D66",
"#064191",
"#2C97D0",
"#16A9B1",
"#0AA178",
"#74B976",
"#0AA178",
"#16A9B1",
"#2A99D1",
"#064191",
"#0B2E68"
];
</script>
<div id="container" style="margin:0px auto;width:100%">
<canvas id="canvas-bar<?php echo $id?>"></canvas>
</div>
<script>
var randomScalingFactor = function() {
return Math.round(Math.random() * 100);
};
jQuery(document).ready(function() {
if(typeof <?php echo $id?>Datachart == "undefined" || <?php echo $id?>Datachart.label.length == 0){
mylog.log("render","/modules/graph/views/co/bar.php");
var barChartData = {
labels: ["Developpement",
"Chef de projet",
"Formation",
"Commercial",
"Graphiste",
"Designer",
"Créatif"],
datasets: [{
label : "Tibor",
backgroundColor: window.chartColors.red,
borderColor: window.chartColors.red,
borderWidth: 1,
data: [78,43,40,29,40,59,103]
},
{
label : "Rapha",
backgroundColor: window.chartColors.blue,
borderColor: window.chartColors.blue,
borderWidth: 1,
data: [28,23,20,9,20,29,203]
},
{
label : "Bouboule",
backgroundColor: window.chartColors.orange,
borderColor: window.chartColors.orange,
borderWidth: 1,
data: [8,5,2,98,200,299,3]
}]
};
} else {
var dtasets = [];
for (var i = <?php echo $id?>Datachart.labels.length - 1; i >= 0; i--) {
dtasets.push({
label : <?php echo $id?>Datachart.labels[i] ,
backgroundColor: materialcolor[i],
borderColor: materialcolor[i],
borderWidth: 1,
data : <?php echo $id?>Datachart.datasets[i]
})
}
var barChartData<?php echo $id?> = {
labels : <?php echo $id?>Datachart.label,
datasets: dtasets
}
}
var ctx = document.getElementById('canvas-bar<?php echo $id?>').getContext('2d');
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData<?php echo $id?>,
options: {
title: {
display: true,