index.php 14.4 KB
Newer Older
1
<?php
Tibor Katelbach's avatar
Tibor Katelbach committed
2 3 4 5
$cssJS = array(
    '/plugins/jQuery-Knob/js/jquery.knob.js',
    '/plugins/jQuery-Smart-Wizard/js/jquery.smartWizard.js',
    //'/plugins/jQuery-Smart-Wizard/styles/smart_wizard.css',
6 7 8 9
    // SHOWDOWN
    '/plugins/showdown/showdown.min.js',
    // MARKDOWN
    '/plugins/to-markdown/to-markdown.js',
Tibor Katelbach's avatar
Tibor Katelbach committed
10
);
11
HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->request->baseUrl);
Tibor Katelbach's avatar
Tibor Katelbach committed
12

Tibor Katelbach's avatar
Tibor Katelbach committed
13
$cssJS = array('/js/docs/docs.js');
14 15
HtmlHelper::registerCssAndScriptsFiles($cssJS, Yii::app()->getModule(Yii::app()->params["module"]["parent"])->getAssetsUrl());
?>
Tibor Katelbach's avatar
tweaks  
Tibor Katelbach committed
16 17


18 19 20 21 22 23
<?php
if (@Yii::app()->session["costum"] && @Yii::app()->session["costum"]["docTpl"]) {
	$this->renderPartial(Yii::app()->session["costum"]["docTpl"], true);
} else { 
	$curl = curl_init();
	/////////////////!!!!!!!!!!!!!!!attention ici il faudrat changerl'url
Laurent Després's avatar
merge  
Laurent Després committed
24
	curl_setopt($curl, CURLOPT_URL, "http://192.168.0.15:5080/interop/gitlab/tree?url=https://gitlab.adullact.net/&repo=pixelhumain/codoc");
25 26 27 28 29 30
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($curl, CURLOPT_HEADER, 0);
	$ret = curl_exec($curl);
	$dataDecode = json_decode($ret, true);
	curl_close($curl);
	//var_dump($dataDecode);exit;?>
Tibor Katelbach's avatar
tweaks  
Tibor Katelbach committed
31

Tibor Katelbach's avatar
Tibor Katelbach committed
32
<style type="text/css">
33 34 35 36 37 38 39 40
#docs-main-container{
	position: absolute;
	bottom: 0;
	top: 0px;
	left: 0;
	right: 0;
	z-index: 1000000
}
Clément Damiens's avatar
 
Clément Damiens committed
41 42 43 44 45 46 47 48
	#menu-left{
		position: fixed;
    	z-index: 100000;
	    bottom: 0;
	    top: 60px;
	    left: 0;
	    padding: 0;
	    overflow-y: scroll;
Clément Damiens's avatar
Clément Damiens committed
49
	    	background-color: white;
Clément Damiens's avatar
 
Clément Damiens committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
	}
	#header-doc{
		position: fixed;
		z-index: 100000;
		top: 0px;
		left: 0px;
		height: 60px;
		right: 0px;
		padding-top: 10px;
		background-color: white;
	}
	#header-doc h2{
		float: left;
	    color: #354C57;
	    font-size: 20px;
	    font-variant: small-caps;
	    line-height: 41px;
	    padding: 0px 10px;
	}
	#menu-left ul li{
		list-style: none;
	}
Clément Damiens's avatar
 
Clément Damiens committed
72 73 74 75 76 77 78 79
	#menu-left > ul > li > a{
		font-size: 20px;
	}
	ul.subMenu > li > a{
		font-size:16px;
	}
	#menu-left > ul > li > a, ul.subMenu > li > a{
		color: #354C57;
Clément Damiens's avatar
 
Clément Damiens committed
80 81 82 83 84
		width: 100%;
	    float: left;
	    padding: 5px 20px;
	    text-align: left;
	}
Clément Damiens's avatar
 
Clément Damiens committed
85 86 87
	#menu-left ul li .subMenu, #menu-left > ul > li > a{
		border-bottom: 1px solid #ccc;
	}
88
	#menu-left > ul > li > a.active {
Clément Damiens's avatar
 
Clément Damiens committed
89
		text-decoration: none;
Tibor Katelbach's avatar
Tibor Katelbach committed
90
		background-color:#65BA91;
Clément Damiens's avatar
 
Clément Damiens committed
91
		color: white;
Clément Damiens's avatar
 
Clément Damiens committed
92 93 94
		font-size: 22px;
	}
	ul.subMenu > li > a.active, ul.subMenu > li > a:hover{
Tibor Katelbach's avatar
Tibor Katelbach committed
95
		border-left: 4px solid #65BA91;
96 97 98
		/*color: #65BA91;*/
		background-color:#65BA91;
		color: white;
Clément Damiens's avatar
 
Clément Damiens committed
99 100 101 102 103
		font-size:18px;
		text-decoration: none;
	}
	#menu-left ul li a.active span.text-red, #menu-left ul li a:hover span.text-red{
		color:#354C57 !important;
Clément Damiens's avatar
 
Clément Damiens committed
104 105 106 107 108 109 110 111 112 113
	}
	.close-modal{
		top: 10px !important;
    	right: 10px !important;
     	z-index: 100000000000000 !important;
    	position: fixed !important;
	}
	.close-modal .lr, .close-modal .rl{
		height: 40px !important;
	}
114 115
	/* ul.subMenu{
		display:none;
Clément Damiens's avatar
 
Clément Damiens committed
116

117
	} */
Clément Damiens's avatar
 
Clément Damiens committed
118 119
	ul.subMenu{
		padding-left: 30px
Clément Damiens's avatar
doc up  
Clément Damiens committed
120
	}
Clément Damiens's avatar
Clément Damiens committed
121
#show-menu-xs, #close-docs{
122 123 124
	    padding: 7px 15px;
    font-size: 20px;
}
125 126 127 128 129 130
.head-content-title {
	border-radius: 6px;
	background-color:#65BA91;
	color: white;
	text-align:center;
}
Clément Damiens's avatar
 
Clément Damiens committed
131
#header-docs .panel-title, .subtitleDocs .panel-title {
132 133
	font-size: 40px;
}
Clément Damiens's avatar
 
Clément Damiens committed
134
#header-docs .panel-title .sub-title, .subtitleDocs .panel-title .sub-title{
135
	font-size: 20px !important;
136
	font-style: italic;
137
}
Clément Damiens's avatar
 
Clément Damiens committed
138
#container-docs{
Clément Damiens's avatar
Clément Damiens committed
139 140
	background-color: white;
	z-index: 10000;
141
	top: 60px;
Clément Damiens's avatar
 
Clément Damiens committed
142
}
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
@media (max-width: 991px) {
 /* .open-type-filter{
        display: block;
    position: absolute;
    right: -33px;
    height: 50px;
    width: 50px;
    border: 1px solid #dadada;
    border-radius: 100%;
    text-align: right;
    padding-right: 8px;
    z-index: -1;
    font-size: 20px;
  }*/
  #menu-left{
    width: 56%;
    left: -56%;
Clément Damiens's avatar
Clément Damiens committed
160
	bottom: 0px;
161
	}
162

163 164 165 166 167 168 169
}

@media (min-width: 991px) {
  #menu-left {
    left:0 !important;
  }
}
170
</style>
171 172 173 174
<div id="docs-main-container">
	<div id="header-doc" class="shadow2">
		<a href='javascript:;' id="show-menu-xs" class="visible-xs visible-sm pull-left" data-placement="bottom" data-title="Menu"><i class="fa fa-bars"></i></a>
		<h2 class="elipsis no-margin"><i class="fa fa-book hidden-xs"></i> <?php echo Yii::t("docs", "All <span class='hidden-xs'>you need to know</span> about") ?></h2>
175
		<img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/img/LOGOS/CO2/logo-head-search.png"
176
	                     class="logo-menutop main pull-left" height=30>
177
	    <a href='javascript:;' class="lbh pull-right" id="close-docs"><span><i class="fa fa-sign-out"></i> <?php echo Yii::t("common", "Back") ?></span></a>
178
	</div>
Tibor Katelbach's avatar
Tibor Katelbach committed
179

180 181 182
	<div id="menu-left" class="col-md-3 col-sm-2 col-xs-12 shadow2">
	  	<ul class="col-md-12 col-sm-12 col-xs-12 no-padding">
			<li class="col-xs-12 no-padding">
183 184
				<a href="javascript:" class="link-docs-menu down-menu gitlab" data-path="README.md"data-type="welcome" data-dir="<?php echo Yii::app()->language ?>">
					<i class="fa fa-angle-right"></i> <?php echo Yii::t("docs", "WEL<span class='text-red'>CO</span>ME"); ?>
185 186
				</a>
			</li>
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
<?php
///////// function pour construire menu-left
    function makeSubLi($key, $value)
    {
        if ($key == 'noPath') {
            $name = $path = $value;
        } else {
            $name = $value;
            $path = $key . "/" . $value;
        }
        echo '	<li class="col-xs-12 no-padding">
					<a href="javascript:" class="link-docs-menu gitlab" data-path="' . $path . '" data-dir="' . Yii::app()->language . '" >
					' . substr($name, 0, -3) . '</a>
				</li>';
    };

    function makeSubMenu($data, $parentK)
    {
        foreach ($data as $k => $v) {
            if (!is_int($k)) {
                echo '<li class="col-xs-12 no-padding">
						<a href="javascript:" class="link-docs-menu down-menu" data-type="' . $parentK . '" data-dir="' . Yii::app()->language . '">
						<i class="fa fa-angle-right"></i> ' . $parentK . ' > ' . $k . '</a>
						<ul class="subMenu col-xs-12 no-padding">';
            } else {
                echo '<li class="col-xs-12 no-padding">';
            }
            if (is_array($v)) {
                foreach ($v as $subK => $subV) {
                    if (is_array($subV)) {
                        makeSubMenu([$subK => $subV], $parentK . "/" . $k);
                    } else {
                        makeSubLi($parentK . "/" . $k, $subV);
                    }
                }
            } else {
                if (!is_int($k)) {
                    makeSubLi($parentK . "/" . $k, $v);
                } else {
                    makeSubLi($parentK, $v);
                }
            }
            if (!is_int($k)) {
                echo '	</ul>';
            }
            echo '	  </li>';

        }
    }
//////////////////////////////////////
    //unset($dataDecode['Images'], $dataDecode['readme']); ///attention ici spécifique a la doc communecter
    foreach ($dataDecode as $k => $v) {
        if ($k != 'Images' && $k != 'readme' && !is_int($k)) {
            echo '<li class="col-xs-12 no-padding">
			<a href="javascript:" class="link-docs-menu down-menu" data-type="' . $k . '" data-dir="' . Yii::app()->language . '">
			<i class="fa fa-angle-right"></i> ' . $k . '</a>';
            if (is_array($v)) {
                echo '<ul class="subMenu step1 col-xs-12 no-padding">';
                makeSubMenu($v, $k);
                echo '	</ul>
			</li>';
            } else {
                makeSubLi($k, $v);
                echo '</li>';
            }
        } else if (is_int($k)) {
            makeSubLi('noPath', $v);
        }
    }
    ?>
257 258
		</ul>
	</div>
Tibor Katelbach's avatar
Tibor Katelbach committed
259

260 261
	<div id="container-docs" class="col-md-offset-3 col-md-9 col-sm-12 col-xs-12 no-padding">
	<?=$dataDecode["readme"]?>
262
	</div>
263 264
<?php }?>

Tibor Katelbach's avatar
tweaks  
Tibor Katelbach committed
265

Tibor Katelbach's avatar
Tibor Katelbach committed
266 267
</div>
<script type="text/javascript">
Tibor Katelbach's avatar
Tibor Katelbach committed
268

Clément Damiens's avatar
Clément Damiens committed
269
var page="<?php echo @$page ?>";
270 271 272
var dir="<?php echo @$dir ?>";
var urlGit = 'https://gitlab.adullact.net';
var repoGit= '/pixelhumain/codoc';
Tibor Katelbach's avatar
Tibor Katelbach committed
273

Tibor Katelbach's avatar
Tibor Katelbach committed
274
jQuery(document).ready(function() {
Tibor Katelbach's avatar
Tibor Katelbach committed
275
	mylog.log("render","co2.views.docs.index");
276 277 278 279 280
	var dataMenu = "";
	$(".subMenu").hide();
	var readme = " "+
	$("#container-docs").text();
	$('#container-docs').html(gitlabMdToHtml(readme));
281
	dir=(dir=="") ? mainLanguage : dir;
282
	
Tibor Katelbach's avatar
Tibor Katelbach committed
283 284
	if(costum == null){
		if(page != "")
285 286 287
		initDocs(page, dir);
		else
		initDocs("welcome", mainLanguage);
Tibor Katelbach's avatar
Tibor Katelbach committed
288
	}
Tibor Katelbach's avatar
Tibor Katelbach committed
289 290
	bindLinkDocs()

291
	
Tibor Katelbach's avatar
Tibor Katelbach committed
292
	$("#show-menu-xs").click(function(){
293 294
		if(!$(this).hasClass("show-dir")){
      $(this).addClass("show-dir").data("title", "<?php echo Yii::t("common", "Close") ?>").find("i").removeClass("fa-chevron-right").addClass("fa-times");
Tibor Katelbach's avatar
Tibor Katelbach committed
295 296
      $("#menu-left").animate({ left : "0%" }, 400 );
    }else{
297 298 299
		$(this).removeClass("show-dir").data("title", "<?php echo Yii::t("common", "Open filtering by type") ?>").find("i").removeClass("fa-times").addClass("fa-chevron-right");
		$("#menu-left").animate({ left : "-56%" }, 400 );

Tibor Katelbach's avatar
Tibor Katelbach committed
300 301
    }
});
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
});

function initDocs(page, dir){
	if(urlBackHistory.indexOf("#docs") >= 0){
		if(userId!="")
			$("#close-docs").attr("href","#page.type.citoyens.id."+userId);
		else
			$("#close-docs").attr("href","#search");
	}else
	$("#close-docs").attr("href",urlBackHistory);
	$(".link-docs-menu[data-type='"+page+"'][data-dir='"+dir+"']").addClass("active");
	if(!$(".link-docs-menu[data-type='"+page+"'][data-dir='"+dir+"']").hasClass("down-menu"))
		$(".link-docs-menu[data-type='"+page+"'][data-dir='"+dir+"']").parents().eq(2).find(".down-menu").addClass("active").find("i").removeClass("fa-angle-right").addClass("fa-angle-down");
	else
		$(".link-docs-menu[data-type='"+page+"'][data-dir='"+dir+"']").find("i").removeClass("fa-angle-right").addClass("fa-angle-down");
}
function bindLinkDocs() {

Clément Damiens's avatar
Clément Damiens committed
320
	$(".link-docs-menu").off().on("click",function(){
321 322 323 324

		if($(this).hasClass("down-menu") && !$(this).hasClass("active")){
			$(this).parent().siblings().children("a").removeClass("active").find("i").removeClass("fa-angle-down").addClass("fa-angle-right");
			$(this).parent().siblings().children("ul").hide();
Clément Damiens's avatar
 
Clément Damiens committed
325
			$(this).addClass("active").find("i").removeClass("fa-angle-right").addClass("fa-angle-down");
326 327 328 329
			$(this).next().show();
		} else {
			$(this).parentsUntil('.step1').siblings().find("ul").hide();
			//$(this).parentsUntil('.step1').siblings().find("a").hide();
Clément Damiens's avatar
 
Clément Damiens committed
330 331 332 333 334 335 336
			$(".subMenu .link-docs-menu").removeClass("active");
			$(this).addClass("active");
			if(!$(this).parents().eq(2).find(".link-docs-menu:first").hasClass("active")){
				$("#menu-left > ul > li > a").removeClass("active").find("i").removeClass("fa-angle-down").addClass("fa-angle-right");
				$(this).parents().eq(2).find(".link-docs-menu:first").addClass("active").find("i").removeClass("fa-angle-right").addClass("fa-angle-down");
			}
		}
337

338 339 340 341
		if($("#show-menu-xs").is(":visible")){
			$("#show-menu-xs").removeClass("show-dir");
			$("#menu-left").animate({ left : "-56%" }, 400 );
		}
Clément Damiens's avatar
Clément Damiens committed
342
		onchangeClick=false;
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
		if ($(this).hasClass("gitlab")) {
			$(".gitlab").removeClass('active');
			$(this).addClass('active');
			showLoader('#container-docs');
			var titleH = $(this).data("path");
			var headContent = "<span><h1 class='head-content-title'>"+titleH.slice(0,-3)+
			"<a href='"+urlGit+repoGit+"/-/blob/master/"+$(this).data("path")+"' class='lbh pull-right' target='_blank' id='edit'>"+
			"<span><i class='fa fa-edit'></i></span></a></h1></span>";
			var urlInterop = baseUrl+"/interop/gitlab/page?url="+urlGit+repoGit+"/-/blob/master/"+$(this).data('path');
			getAjax('', urlInterop, function (data) {
						descHtml = gitlabMdToHtml(data.content);
						$("#container-docs").html(headContent+descHtml).removeClass("text-center").attr("style", "margin-left: 27%; max-width: 72%");
					bindLinkDocs();
					}
						, "html");
		}
		// hashDocs="#docs.page."+$(this).data("type");
		// if(notNull($(this).data("dir")) && $(this).data("dir") != "")
		// 	hashDocs+= ".dir."+$(this).data("dir");
		// location.hash=hashDocs;
363 364
		//if(moduleId == activeModuleId)
		//	moduleInDocs($(this).data("type"), $(this).data("dir"), $(this).data("get"));
365 366 367
		//else
		//}
		//navInDocs($(this).data("type"), $(this).data("dir"), $(this).data("get"));
Clément Damiens's avatar
 
Clément Damiens committed
368
	});
Tibor Katelbach's avatar
Tibor Katelbach committed
369
 }
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
 function gitlabMdToHtml(str) {
	descHtml = dataHelper.convertMardownToHtml(str);
	if(str.indexOf("/gitlab\.adullact\.net\/pixelhumain\/codoc") > 0) {
		descHtml = descHtml.replace(/href="https:\/\/gitlab\.adullact\.net\/pixelhumain\/codoc\/-\/blob\/master\//gm,'href="javascript:" data-path="');
		descHtml = descHtml.replace(/.md"/gm,'.md" class="gitlab link-docs-menu in-md"' );
	}
	if(str.indexOf("!@") > 0) {
		descHtml = descHtml.replace(/!(@[^\s\)]+)/gm,
			'<a href="'+baseUrl+'/#$1" target="_blank">$1</a>');
	}
	descHtml = descHtml.replace(/<a href="([^j][^\s"]+)">/gm,
			'<a href="$1" target="_blank">');
	return descHtml;

 }
Clément Damiens's avatar
 
Clément Damiens committed
385
function navInDocs(page, dir, get){
Clément Damiens's avatar
 
Clément Damiens committed
386
	coInterface.simpleScroll(0);
Clément Damiens's avatar
 
Clément Damiens committed
387
	showLoader('#container-docs');
Clément Damiens's avatar
Clément Damiens committed
388
	urlToSend="docs/index/";
Clément Damiens's avatar
 
Clément Damiens committed
389
	if(notNull(dir) && dir !="")
Clément Damiens's avatar
Clément Damiens committed
390 391 392
		urlToSend+="dir/"+dir+"/";
	urlToSend+="page/"+page;
	ajaxPost('#container-docs' ,baseUrl+'/'+moduleId+"/"+urlToSend,
393
			 null,function(){},"html");
Clément Damiens's avatar
 
Clément Damiens committed
394
}
Clément Damiens's avatar
 
Clément Damiens committed
395
function getConceptList(list, dom, type){
396
	str="";
Clément Damiens's avatar
 
Clément Damiens committed
397 398
	classContainer = (notNull(type) && type=="list") ? "col-md-12 col-sm-12 col-xs-12" : "col-md-4 col-sm-6 col-xs-12";
	classKeypan = (notNull(type) && type=="list") ? "keypanList" : "keypan";
399
	$.each(list,function(i,obj) {
Clément Damiens's avatar
 
Clément Damiens committed
400
		//icon = (obj.icon) ? obj.icon : "fa-tag" ;
401 402
		color = (obj.color) ? obj.color : "#E33551" ;
		size = (obj.size) ? obj.size : "20" ;
Clément Damiens's avatar
 
Clément Damiens committed
403 404
		str+='<div class="'+classContainer+'"><div class="'+classKeypan+' panel panel-white">';
				if(typeof obj.url != "undefined")
405
		str+=		'<a href="'+obj.url+'" targte="_blank">';
Clément Damiens's avatar
 
Clément Damiens committed
406
		str+=	'<div class="panel-heading border-light ">'+
407
					'<span class="panel-title">';
Clément Damiens's avatar
 
Clément Damiens committed
408 409
						if(typeof obj.image != "undefined")
		str+=				'<img class="img-responsive" src="'+obj.image+'"/> ';
Clément Damiens's avatar
 
Clément Damiens committed
410 411 412 413 414 415
						if(typeof obj.icon != "undefined")
		str+=				'<i class="fa '+obj.icon+' faa-pulse animated-hover fa-2x"></i>';
						if(!notNull(type) || type!="list")
		str+=				'<br/>';
		str+=			'<span style="font-size: '+size+'px; color:'+color+';">'+obj.title.toUpperCase()+'</span>';
						if(typeof obj.subtitle != "undefined")
Clément Damiens's avatar
 
Clément Damiens committed
416 417
		str+=				'<span style="font-size: 16px;font-style:italic"> <br/>'+obj.subtitle+'</span>';
		str+=		'</span>'+
Clément Damiens's avatar
 
Clément Damiens committed
418 419 420 421 422 423 424 425 426 427 428 429 430 431
				'</div>';
				if(!notNull(type) || type!="list")
		str+=		'<hr/>';
		str+=	'<div class="panel-body">';
					if(typeof obj.date != "undefined")
		str+=			obj.date+"<br>";
					if(typeof obj.body != "undefined")
		str+=			obj.body+"<br>";
					if(typeof obj.link != "undefined"){
		str+=			"<a class='btn btn-danger btn-sm margin-top-10' href='"+obj.link.url+"'";
						if(typeof obj.link.blank != "undefined" && obj.link.blank)
		str+=				" target='_blank'"
		str+=			">"+obj.link.label+"</a>";
					}
Clément Damiens's avatar
 
Clément Damiens committed
432 433 434 435
		str+=	'</div>';
			if(typeof obj.url != "undefined")
		str+=	'</a>';
		str+="</div></div>";
436 437 438
	 });
	$(dom).html(str);
}
439
</script>