Skip to content

Commit

Permalink
Fixed login and some environment bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
gubi committed Aug 1, 2014
1 parent e365d8d commit e9ab3a2
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 112 deletions.
12 changes: 11 additions & 1 deletion API/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@
if(isset($_GET["definitions"]) && trim($_GET["definitions"]) !== "") {
$api->set_content_type("text");

$api->get_definitions($_GET["definitions"], (($_GET["keep_update"] == "true") ? true : false));
$api->get_definitions(
$_GET["definitions"],
((isset($_GET["keep_update"]) && $_GET["keep_update"] == "true") ? true : false),
((isset($_GET["type"]) && trim($_GET["type"]) !== "") ? $_GET["type"] : "string"),
((isset($_GET["condensed"]) && $_GET["condensed"] == "true") ? true : false)
);
}
if(isset($_GET["local"]) && trim($_GET["local"]) !== "") {
$api->set_content_type("text");

$api->get_local_json($_GET["local"]);
}
if(isset($_GET["download"]) && trim($_GET["download"]) !== "") {
$api->force_download("../common/media/" . base64_decode($_GET["download"]));
Expand Down
10 changes: 5 additions & 5 deletions common/css/bootstrap/bootstrap.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 48 additions & 8 deletions common/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ footer ul li + li:before {
@media (min-width: 868px) {
#nav .navbar-collapse.collapse {
float: right;
margin-top: -21px;
margin-top: -23px;
}
}
@media only screen and (max-width:420px) {
Expand All @@ -273,9 +273,9 @@ footer ul li + li:before {
}
.navbar .divider-vertical, .navbar .vertical-divider {
height: 29px;
border-left: 1px solid #e0e0e0;
border-right: 1px solid #ffffff;
margin: 0 5px !important;
background-color: #e0e0e0;
width: 1px;
margin: 0 !important;
}
@media (max-width: 868px) {
.navbar .divider-vertical, .navbar .vertical-divider {
Expand Down Expand Up @@ -352,7 +352,9 @@ section.container {
}

.panel_content {
background-color: #fff;
display: none;
height: 100%;
width: 100%;
}

Expand Down Expand Up @@ -531,14 +533,48 @@ panel span.info, .modal a.text-info, .modal span.text-info, .modal span.info {
user-select: none;
cursor: default;
}
#loader_bg {
bottom: 0;
display: block;
left: 0;
position: fixed;
right: 0;
text-align: center;
top: 0;
width: 100%;
z-index: -1;
}
#se h1[unselectable] {
color: #666;
font-size: 3em;
margin-top: -2em !important;
margin-bottom: 1em;
text-indent: 0;
}
#se h1[unselectable] + h2 {
#se_p h1[unselectable], #loader_bg h1[unselectable] {
opacity: 0.2;
text-align: center;
font-family: 'HelveticaNeueW01-45Ligh';
font-size: 3em;
margin-bottom: 1em;
margin-top: 3em;
text-indent: 0;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;

/* Rules below not implemented in browsers yet */
-o-user-select: none;
user-select: none;
cursor: default;
}
#loader_bg h1[unselectable] {
margin: 25% 0;
opacity: 0.15;
padding-left: 300px;
}

#se h1[unselectable] + h2, {
margin: 0;
border: 0px none;
color: #aaa;
Expand Down Expand Up @@ -678,19 +714,19 @@ section #se_p #se_results {
section #se_p #se_results .panel_content-head, section #se_p #se_results .panel_content-footer{
margin: 0;
}
section #se_p form .input-group {
section #se_p form .input-group, section #se_p #statistics {
width: 50%;
}
@media only screen and (max-width:1024px) {
section #se_p form .input-group {
section #se_p form .input-group, section #se_p #statistics {
width: 80%;
}
}
@media only screen and (max-width:420px) {
section #se_p {
padding: 20px 0 0 0;
}
section #se_p form .input-group {
section #se_p form .input-group, section #se_p #statistics {
width: 100%;
}
}
Expand Down Expand Up @@ -1854,3 +1890,7 @@ label.checkbox {
line-height: 3em;
}
}

#apprise.ask_service {
z-index: 9999;
}
52 changes: 43 additions & 9 deletions common/include/classes/frontend_api.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private function get_definition_file($type) {
}
return $def_file;
}

/* PUBLIC FUNCTIONS */
/* ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */

Expand All @@ -145,7 +146,23 @@ public function get_github_service_definitions($type) {
return $this->browse($definitions_url);
}

public function get_definitions($type, $keep_update, $response_type = "string") {
/**
* Extract Service definitions print as javascript variables
*
* Example: Get all definition of types from Github repo and print condensed
* `.../API/?definitions=types&keep_update=true&type=all&condensed=true`
*
* Example: Get all definition of api directly from service and print in json (not condensed)
* `?definitions=api&type=json&condensed=false`
*
*
* @param {string} $type The Service define (also listed in @get_definition_file())
* @param {bool} $keep_update If true take the definition from Github repo
* @param {string} $response_type (string|array|json|obj|object|all) The type of the response. Default: "string"
* @param {bool} $condensed If true displayed results will be condensed (without spaces and break returns)
* @return {string|obj}
*/
public function get_definitions($type, $keep_update, $response_type = "string", $condensed = false) {
$def_file = $this->get_definition_file($type);
$global_constants = $this->getUserDefinedConstants();
if($keep_update) {
Expand All @@ -164,26 +181,37 @@ public function get_definitions($type, $keep_update, $response_type = "string")

$script_constants = array_diff_assoc($after_include_constants, $global_constants);
}
foreach($script_constants as $define => $value) {
$k[$define] = $value;
$d[] = $define . (($condensed) ? '="' : ' = "') . $value . '"';
}
$js = "";
if($response_type == "string" || $response_type == "all") {
foreach($script_constants as $define => $value) {
$js .= "var " . $define . ' = "' . $value . '";' . "\n";
$k[$define] = $value;
if($condensed) {
$js .= "var " . implode(",", $d) . ";";
} else {
$js .= "var " . implode(",\n", $d) . ";";
}
}
if($response_type == "all") { $js .= "\n"; }
if($response_type == "array" || $response_type == "all") {
$js .= "var __ = {};\n";
foreach($script_constants as $define => $value) {
$js .= '__["' . $define . '"] = "' . $value . '";' . "\n";
if($response_type == "json" || $response_type == "array" || $response_type == "all") {
if($condensed) {
$jsj .= "{" . implode(",", preg_replace("/^(\w+)\=/", '"$1":', $d)) . "}";
} else {
$jsj .= "{\n " . implode(",\n ", preg_replace("/^(\w+)\ \=\ /", '"$1": ', $d)) . "\n}";
}
if($response_type == "all") { $js .= (($condensed) ? "\n" : "\n\n"); }
$jsa = ($response_type != "json") ? "var k = " . $jsj . ";" : $jsj;
$js .= $jsa;
}

if($response_type == "obj" || $response_type == "object") {
return $script_constants;
} else {
print $js;
exit();
}
}

public function set_content_type($content_type) {
switch($content_type) {
case "json":
Expand All @@ -196,6 +224,12 @@ public function set_content_type($content_type) {
}
}

public function get_local_json($path){
$f = file_get_contents("../common/include/" . rawurldecode($path));
print "var roles = " . trim($f) . ";";
exit();
}

public function debug() {
$this->set_content_type("text");
$this->debug = true;
Expand Down
17 changes: 11 additions & 6 deletions common/include/conf/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
),
"attributes" => array(
"href" => "/",
"title" => "Go to Main Page"
"title" => "Go to Main Page",
"class" => "btn btn-link"
)
),
/*
Expand All @@ -44,7 +45,8 @@
"text" => "About us"
),
"attributes" => array(
"href" => "javascript: void(0);"
"href" => "javascript: void(0);",
"class" => "btn btn-link"
),
"childs" => array(
"About us" => array(
Expand Down Expand Up @@ -82,7 +84,8 @@
"text" => "National Inventories"
),
"attributes" => array(
"href" => "javascript: void(0);"
"href" => "javascript: void(0);",
"class" => "btn btn-link"
),
"childs" => array(
"National Inventories" => array(
Expand Down Expand Up @@ -120,7 +123,8 @@
"text" => "Search"
),
"attributes" => array(
"href" => "/Search"
"href" => "/Search",
"class" => "btn btn-link"
),
"divider" => "vertical-divider"
),
Expand Down Expand Up @@ -154,7 +158,6 @@
),
"divider" => "vertical-divider"
),
*/
"Sign in" => array(
"content" => array(
"icon" => "fa fa-sign-in",
Expand All @@ -164,9 +167,11 @@
"href" => "javascript:void(0);",
"data-toggle" => "modal",
"data-target" => "#login",
"id" => "login_menu_btn"
"id" => "login_menu_btn",
"class" => "btn btn-link disabled"
)
)
*/
);
$menu["menu"]["map_toolbox"] = array(
"Find_location" => array(
Expand Down
8 changes: 4 additions & 4 deletions common/js/_main/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,6 @@
};

var form_data = {};
if($("#breadcrumb").css("display") == "none") {
$("#breadcrumb").fadeIn(200);
}
$.ask_to_service(kAPI, function(response) {
if (jQuery.type(callback) == "function") {
if(response[kAPI_RESPONSE_PAGING][kAPI_PAGING_AFFECTED] > 0) {
Expand All @@ -694,6 +691,9 @@
$("#forms-head .btn-group").append('<a href="javascript: void(0);" class="btn btn-orange save_btn disabled" style="display: none;">Search <span class="fa fa-chevron-right"></span></a>');
$("#forms-footer .btn-group").append('<a href="javascript: void(0);" class="btn btn-orange save_btn disabled" style="display: none;">Search <span class="fa fa-chevron-right"></span></a>');
}
if($("#breadcrumb").css("display") == "none") {
$("#breadcrumb").fadeIn(200);
}
$("#forms").fadeIn(300);

// Fires when user clicks on "Save" button
Expand Down Expand Up @@ -818,7 +818,7 @@
$("#forms-head #right_btn, #forms-head .save_btn, #forms-footer #right_btn, #forms-footer .save_btn").fadeOut(300, function() {
$("#forms-head .content-title, #forms-footer .content-title").text("");
$("#forms-body .content-body").html("");
$("section.container").animate({"padding-top": "39px"}, 300, function(){
$("section.container").animate({"padding-top": "75px"}, 300, function(){
// Reset breadcrumb and panels
$.reset_breadcrumb();
$.reset_contents("forms", true);
Expand Down
Loading

0 comments on commit e9ab3a2

Please sign in to comment.