Commit c6ab97d0 authored by Okhin's avatar Okhin

Merge branch 'qcc4_sunday' into qcc4

Conflicts:
	templates/thankyou.html
parents 747827ab 5a1135aa
/tmp
app/config.php
tests/tmp
*~
......@@ -5,13 +5,19 @@ RewriteEngine On
# In such cases, it should be the path (relative to the document root)
# containing this .htaccess file
#
# RewriteBase /
#RewriteBase
RewriteCond %{REQUEST_URI} \.ini$
RewriteRule \.ini$ - [R=404]
RewriteCond %{REQUEST_FILENAME} !-l
#RewriteBase /piphone/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#RewriteCond %{REQUEST_URI} \.ini$
#RewriteRule \.ini$ - [R=404]
#RewriteCond %{REQUEST_FILENAME} !-l
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .* index.php [L,QSA]
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
......@@ -7,8 +7,9 @@ class Api {
// Generic get function for REST API
static function get($url) {
$curl = curl_init();
$url = API_BASE . $url;
$url = API_BASE . $url . "/?format=json";
curl_setopt($curl, CURLOPT_URL, $url);
//curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
......@@ -30,41 +31,31 @@ class Api {
// Asking for campaign informations
static function get_campaign() {
$json = Api::get("campaign/" . CAMPAIGN_ID);
return json_decode($json, true);
}
// Searching a random or specific contact
static function get_contact($contact_id='') {
if ($contact_id!='') {
$json = Api::get("campaign/" . CAMPAIGN_ID . "/contact/" . $contact_id);
} else {
$json = Api::get("campaign/" . CAMPAIGN_ID . "/contact");
}
$json = Api::get("campaigns/" . CAMPAIGN_ID);
return json_decode($json, true);
}
// Asking for complete list of contacts
static function get_contacts() {
$json = Api::get("campaign/" . CAMPAIGN_ID . "/contacts");
$json = Api::get("campaigns/" . CAMPAIGN_ID . "/contacts");
return json_decode($json, true);
}
// Asking for complete list of groups
static function get_groups() {
$json = Api::get("campaign/" . CAMPAIGN_ID . "/groups");
$json = Api::get("campaigns/" . CAMPAIGN_ID . "/groups");
return json_decode($json, true);
}
// Asking for complete list of feedback categories
static function get_feedback_categories() {
$json = Api::get("campaign/" . CAMPAIGN_ID . "/feedback/categories");
$json = Api::get("campaigns/" . CAMPAIGN_ID . "/feedback/categories");
return json_decode($json, true);
}
// Asking for arguments by language
static function get_arguments($language='en') {
$json = Api::get("campaign/" . CAMPAIGN_ID . "/arguments/" . $language);
$json = Api::get("campaigns/" . CAMPAIGN_ID . "/arguments/" . $language);
return json_decode($json, true);
}
......@@ -75,7 +66,7 @@ class Api {
"comment"=>$comment,
"feedback_category"=>$feedback_category
);
$json = Api::post("campaign/" . CAMPAIGN_ID . "/feedback/add", $data);
$json = Api::post("campaigns/" . CAMPAIGN_ID . "/feedback/add", $data);
return json_decode($json, true);
}
......
......@@ -16,6 +16,16 @@ class Controller {
array("iso" => "en", "name"=>"English"),
);
$f3->set('languages', $languages);
// Init campaign informations
$f3->set('campaign', Api::get_campaign());
// Init contacts list if needed
if (!$f3->exists('contacts')) {
$f3->set('contacts', Api::get_contacts(), API_TIMEOUT);
}
// Workaround for caching variables
$f3->set('contacts', $f3->get('contacts'));
}
// Function called after routing
......
......@@ -6,8 +6,9 @@ class Main extends Controller {
* Presents campaign information and a random Contact
*/
function home($f3,$args) {
$f3->set('campaign', Api::get_campaign());
$f3->set('contact', Api::get_contact());
// Select a random contact
$rand_id = rand(0, count($f3->get('contacts'))-1);
$f3->set('contact', $f3->get('contacts')[$rand_id]);
$f3->set('block_content','home.html');
}
......@@ -76,5 +77,9 @@ class Main extends Controller {
$f3->set('block_content', 'contactslist.html');
}
};
function salespitch($f3, $args) {
$f3->set('block_content', 'salespitch.html');
}
};
<?php
// Fake REST API from Campaign module
/*
* Fake REST API from Campaign module
*
* Uses datas folder to retrieve informations
*/
class RestApi {
function campaign($f3,$args) {
echo '{
"title": "Piphone Demo\'s campaign",
"description": "This is a demo campaign used to illustrate how the piphone works. This campaign does not grants you the possibility to contact anyone, it\'s just an ilustration of how it works.",
"start_date": "2014-01-01",
"end_date": "2014-12-31",
"default_language": "en"
}';
}
function contacts($f3,$args) {
// List of contacts
echo '{"contacts":[{
"id": "4123",
"last_name": "ANDERSDOTTER",
"first_name": "Amelia",
"tel": "+322 28 45922",
"groups": [{"type": "Political group","name": "Greens/EFA","media": ""},{"type": "National party","name": "Piratpartiet","media": ""},
{"type": "Country","name": "SE","media": ""},{"type": "Committee","name": "ITRE","media": ""},{"type": "Committee","name": "INTA","media": ""},
{"type": "Committee","name": "CONT","media": ""}
]},{
"id": "4123",
"last_name": "ANDERSDOTTER",
"first_name": "Amelia",
"tel": "+322 28 45922",
"groups": [{"type": "Political group","name": "Greens/EFA","media": ""},{"type": "National party","name": "Piratpartiet","media": ""},
{"type": "Country","name": "SE","media": ""},{"type": "Committee","name": "ITRE","media": ""},{"type": "Committee","name": "INTA","media": ""},
{"type": "Committee","name": "CONT","media": ""}
]},{
"id": "4123",
"last_name": "ANDERSDOTTER",
"first_name": "Amelia",
"tel": "+322 28 45922",
"groups": [{"type": "Political group","name": "Greens/EFA","media": ""},{"type": "National party","name": "Piratpartiet","media": ""},
{"type": "Country","name": "SE","media": ""},{"type": "Committee","name": "ITRE","media": ""},{"type": "Committee","name": "INTA","media": ""},
{"type": "Committee","name": "CONT","media": ""}
]}
]}';
function return_datas($filename) {
$f = fopen($filename, 'r');
$result = fread($f, filesize($filename));
fclose($f);
return $result;
}
function contact($f3,$args) {
if ($f3->exists('PARAMS.contact')) {
// Specified contact
} else {
// Random contact
echo '{
"id": "4123",
"last_name": "ANDERSDOTTER",
"first_name": "Amelia",
"tel": "+322 28 45922",
"groups": [
{
"type": "Political group",
"name": "Greens/EFA",
"media": ""
},
{
"type": "National party",
"name": "Piratpartiet",
"media": ""
},
{
"type": "Country",
"name": "SE",
"media": ""
},
{
"type": "Committee",
"name": "ITRE",
"media": ""
},
{
"type": "Committee",
"name": "INTA",
"media": ""
},
{
"type": "Committee",
"name": "CONT",
"media": ""
}
]
}';
}
function campaign($f3,$args) {
echo $this->return_datas('app/datas/campaign.json');
}
function groups($f3,$args) {
// List of groups available
function contacts($f3,$args) {
echo $this->return_datas('app/datas/contacts.json');
}
function categories($f3,$args) {
......
......@@ -5,6 +5,9 @@ AUTOLOAD=app/
; Folder containing templates
UI=templates/
; Cache
CACHE = true
; Debug level
DEBUG=3
......
<?php
/* Configuration file for Campaign manager */
define("CAMPAIGN_ID","1");
define("API_BASE","http://localhost/restapi/");
/* TODO : remove this in production ;) */
error_reporting(E_ALL|E_WARNING);
......
This folder contains only datas for the fake REST API (for tests and dev).
{
"title": "Piphone Demo's campaign",
"description": "This is a demo campaign used to illustrate how the piphone works. This campaign does not grants you the possibility to contact anyone, it's just an ilustration of how it works.",
"start_date": "2014-01-01",
"end_date": "2014-12-31",
"default_language": "en"
}
{
"contacts":[
{
"id": "75426",
"last_name": "ANDERSDOTTER",
"first_name": "Amelia",
"tel": "+322 28 45922",
"external_id": "108570",
"groups": [
{
"type": "Political group",
"name": "Greens/EFA",
"media": ""
},
{
"type": "National party",
"name": "Piratpartiet",
"media": ""
},
{
"type": "Country",
"name": "SE",
"media": ""
},
{
"type": "Committee",
"name": "ITRE",
"media": ""
},
{
"type": "Committee",
"name": "INTA",
"media": ""
},
{
"type": "Committee",
"name": "CONT",
"media": ""
}
]
},
{
"id": "1245",
"last_name": "BLINKEVIČIŪTĖ",
"first_name": "Vilija",
"tel": "+322 28 45435",
"external_id": "96681",
"groups": [
{
"type": "Political group",
"name": "S&D",
"media": ""
},
{
"type": "National party",
"name": "LSDP",
"media": ""
},
{
"type": "Country",
"name": "LI",
"media": ""
},
{
"type": "Committee",
"name": "LIBE",
"media": ""
},
{
"type": "Committee",
"name": "FEMM",
"media": ""
},
{
"type": "Committee",
"name": "EMPL",
"media": ""
}
]
},
{
"id": "2324",
"last_name": "ANDRIEU",
"first_name": "Eric",
"tel": "+322 28 45170",
"external_id": "113892",
"groups": [
{
"type": "Political group",
"name": "S&D",
"media": ""
},
{
"type": "National party",
"name": "Parti socialiste",
"media": ""
},
{
"type": "Country",
"name": "FR",
"media": ""
},
{
"type": "Committee",
"name": "INTA",
"media": ""
},
{
"type": "Committee",
"name": "AGRI",
"media": ""
}
]
}
]
}
[routes]
; Main site
GET @home:/=Main->home
GET @home:/=Main->home
GET|POST @feedback:/feedback=Main->feedbackform
GET|POST @call:/call/@id=Main->call
GET @contactslist:/contactslist=Main->contactslist
POST @feedbacksip:/feedbacksip=Main->feedbacksip
GET @salespitch:/salespitch=Main->salespitch
; Fake REST API
GET /restapi/campaign/@id=RestApi->campaign
GET /restapi/campaign/@id/contacts=RestApi->contacts
GET /restapi/campaign/@id/contact=RestApi->contact
GET /restapi/campaign/@id/contact/@contact=RestApi->contact
GET /restapi/campaign/@id/groups=RestApi->groups
GET /restapi/campaign/@id/feedback/categories=RestApi->categories
POST /restapi/campaign/@id/feedback/add=RestApi->feedback_add
GET /restapi/campaign/@id/arguments/@lang=RestApi->arguments
GET /restapi/campaigns/@id=RestApi->campaign
GET /restapi/campaigns/@id/contacts=RestApi->contacts
GET /restapi/campaigns/@id/feedback/categories=RestApi->categories
POST /restapi/campaigns/@id/feedback/add=RestApi->feedback_add
GET /restapi/campaigns/@id/arguments/@lang=RestApi->arguments
GET|POST @feedback:/feedback=Main->feedbackform
GET|POST @call:/call/@id=Main->call
GET @contactslist:/contactslist=Main->contactslist
POST @feedbacksip:/feedbacksip=Main->feedbacksip
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
<!DOCTYPE html>
<!-- saved from url=(0048)file:///home/ag3m/Bureau/Code/PiPhone/index.html -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="file:///home/ag3m/Bureau/Code/PiPhone/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom css -->
<style>
// .tropgros {display: none;}
// p,div,span {margin:0!important; padding:0!important; text-align: center;}
.riquiqui {display: none;}
.panel {margin:0.5em !important; padding: 0.5em !important;}
form {margin:0.5em;}
.form-group + button {padding:0!important; }
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body style="background:black;">
<div class="container-fluid panel panel-default">
<div class="row">
<div class="col-sm-12">
<!-- contact page -->
<div class="col-sm-2 tropgros"><!-- image à gauche -->
<img class="img-responsive img-circle" src="./Bootstrap 101 Template_files/108570.jpg" alt="mep">
</div><!-- /image à gauche -->
<div class="col-sm-10"><!-- pas image -->
<div class="row">
<div class="col-sm-8"><!-- gauche -->
<div><!-- titre -->
<h2 class="tropgros" id="name">{{ @contact.first_name }} <br class="visible-xs-block">{{ @contact.last_name }}</h2>
<h3 class="riquiqui" id="name">{{ @contact.first_name }} <br>{{ @contact.last_name }}</h3>
</div><!-- /titre -->
<div class="visible-xs-block"><!-- infos -->
<address style="margin-top:1em;" class="tropgros">
<strong>Informations</strong><br>
Blablabla<br>
</address>
<p class="lead text-center"><abbr title="Numéro de téléphone">Tel:</abbr> <a href="tel: {{ @contact.tel }}">{{ @contact.tel }}</a></p>
</div><!-- /infos -->
<div><!-- groupes -->
<repeat group="{{ @contact.groups }}" value="{{ @group }}">
<check if="{{ @group.type!=&#39;Committee&#39; }}">
<dl class="dl-horizontal tropgros" id="resume">
<dt>{{ @group.type }}:</dt>
<dd><a href="https://memopol.lqdn.fr/europe/parliament/group/Greens/EFA/"><img src="./Bootstrap 101 Template_files/GreensEFA.png" height="24" alt="Greens/EFA"></a> - {{ @group.name }}</dd>
<dt>{{ @group.type }}:</dt>
<dd><a href="https://memopol.lqdn.fr/europe/parliament/group/Greens/EFA/"><img src="./Bootstrap 101 Template_files/GreensEFA.png" height="24" alt="Greens/EFA"></a> - {{ @group.name }}</dd>
</dl>
<ul class="list-inline riquiqui" id="committee">
<li><img src="./Bootstrap 101 Template_files/GreensEFA.png" height="24" alt="Greens/EFA"></li>
<li><img src="./Bootstrap 101 Template_files/GreensEFA.png" height="24" alt="Greens/EFA"></li>
</ul>
</check>
</repeat>
</div><!-- /groupes -->
<div><!-- committee -->
<repeat group="{{ @contact.groups }}" value="{{ @group }}">
<check if="{{ @group.type==&#39;Committee&#39; }}">
<ul class="list-inline" id="committee">
<li><abbr title="Committee on Industry, Research and Energy" class="initialism"><ahref="https: memopol.lqdn.fr="" europe="" parliament="" committee="" itre="" "=""><div class="well well-sm">{{ @group.name }}</div></ahref="https:></abbr></li>
<li><abbr title="Committee on Industry, Research and Energy" class="initialism"><ahref="https: memopol.lqdn.fr="" europe="" parliament="" committee="" itre="" "=""><div class="well well-sm">{{ @group.name }}</div></ahref="https:></abbr></li>
</ul>
</check>
</repeat>
</div><!-- /committee -->
</div><!-- /-- gauche -->
<div class="col-sm-4"><!-- droite -->
<div class="hidden-xs text-right"><!-- infos -->
<address style="margin-top:1em;">
<strong>Informations</strong><br>
Blablabla<br>
<p class="lead text-center"><abbr title="Numéro de téléphone">Tel:</abbr> <a href="tel: {{ @contact.tel }}">{{ @contact.tel }}</a></p>
</address>
</div><!-- /infos -->
<div class="text-center"><!-- actions -->
<button type="button" class="btn btn-primary" title="Appeler maintenant"><span class="glyphicon glyphicon-earphone"></span></button>
<button type="button" class="btn btn-default" title="Plus d&#39;informations"><a href="https://memopol.lqdn.fr/europe/parliament/deputy/AmeliaAndersdotter/"><span class="glyphicon glyphicon-info-sign"></span></a></button>
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="country">Choisissez un pays : </label>
<select name="country" id="country" onchange="$(&#39;#selcountry&#39;).submit()"><option value="">-- Toute l'Europe -- </option></select>
</div><!-- /form-group -->
<button type="submit" class="btn btn-default" title="Choisir un autre député"><span class="glyphicon glyphicon-refresh"></span></button>
</form>
</div><!-- /actions -->
</div><!-- /droite -->
</div><!-- /row-->
</div><!--/.col-sm-6--><!-- /pas image -->
<!-- contact page -->
</div>
</div>
</div><!-- /container-fluid -->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="./Bootstrap 101 Template_files/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="./Bootstrap 101 Template_files/bootstrap.min.js"></script>
</body></html>
\ No newline at end of file
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /static/img/groups/eu/GreensEFA.png was not found on this server.</p>
<hr>
<address>Apache/2.2.16 (Debian) Phusion_Passenger/2.2.11 PHP/5.3.3-7+squeeze22 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8o mod_wsgi/3.3 Python/2.6.6 Server at memopol.lqdn.fr Port 443</address>
</body></html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.