Skip to content

Commit 98fd082

Browse files
committed
Added new page
1 parent 0e6cafb commit 98fd082

File tree

4 files changed

+84
-10
lines changed

4 files changed

+84
-10
lines changed

controllers/front/graphql.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
* @version 0.1.0
1111
*/
1212

13-
error_reporting(E_ALL);
14-
ini_set('display_errors', 1);
15-
1613
require_once dirname(__FILE__) . '/../../system/startup.php';
1714

1815
/**
@@ -24,9 +21,31 @@ class VuefrontGraphqlModuleFrontController extends ModuleFrontController
2421
private $codename = "vuefront";
2522
private $route = "vuefront";
2623

24+
public function setMedia()
25+
{
26+
parent::setMedia();
27+
$this->context->controller->registerStylesheet(
28+
'modules-vuefront-front-css',
29+
'modules/vuefront/views/css/front.css',
30+
array('media' => 'all', 'priority' => 200)
31+
);
32+
}
33+
2734
public function initContent()
2835
{
2936
parent::initContent();
37+
if ($_SERVER['HTTP_ACCEPT']) {
38+
$accepts = explode(',', $_SERVER['HTTP_ACCEPT']);
39+
if (in_array('text/html', $accepts)) {
40+
$this->context->smarty->assign(array(
41+
'hello' => 'Hello World!!!'
42+
));
43+
44+
$this->setTemplate('module:vuefront/views/templates/front/d_vuefront.tpl');
45+
return;
46+
}
47+
}
48+
3049
start($this->context);
3150
}
3251
}

resolver/startup/startup.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,32 @@ class ResolverStartupStartup extends Resolver
1717
{
1818
public function index()
1919
{
20+
2021
if (Tools::getValue('cors')) {
21-
if (! empty($_SERVER['HTTP_ORIGIN'])) {
22+
if (!empty($_SERVER['HTTP_ORIGIN'])) {
2223
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
2324
} else {
2425
header('Access-Control-Allow-Origin: *');
2526
}
2627
header('Access-Control-Allow-Methods: POST, OPTIONS');
2728
header('Access-Control-Allow-Credentials: true');
28-
header('Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With, '.
29-
'If-Modified-Since,Cache-Control,Content-Type,Range,Token,token,Cookie,cookie,content-type');
29+
header('Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With, ' .
30+
'If-Modified-Since,Cache-Control,Content-Type,Range,Token,token,Cookie,cookie,content-type');
3031
}
3132

3233
$this->load->model('startup/startup');
33-
34+
3435
try {
3536
$resolvers = $this->model_startup_startup->getResolvers();
36-
$schema = BuildSchema::build(Tools::file_get_contents(DIR_PLUGIN.'schema.graphql'));
37+
$schema = BuildSchema::build(Tools::file_get_contents(DIR_PLUGIN . 'schema.graphql'));
3738
$rawInput = Tools::file_get_contents('php://input');
3839
$input = json_decode($rawInput, true);
3940
$query = $input['query'];
4041

42+
if(empty($query)) {
43+
die('Query missing.');
44+
}
45+
4146
$variableValues = isset($input['variables']) ? $input['variables'] : null;
4247
$result = GraphQL::executeQuery($schema, $query, $resolvers, null, $variableValues);
4348
} catch (\Exception $e) {
@@ -47,7 +52,7 @@ public function index()
4752
]
4853
];
4954
}
50-
55+
5156
die(json_encode($result));
5257
}
5358
}

views/css/front.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.module-content {
2+
padding: 60px 0;
3+
text-align: center;
4+
margin: auto 0;
5+
}
6+
.module-container {
7+
height: 100%;
8+
display: -webkit-box;
9+
display: -ms-flexbox;
10+
display: flex;
11+
-webkit-box-align: center;
12+
-ms-flex-align: center;
13+
align-items: center;
14+
-webkit-box-pack: center;
15+
-ms-flex-pack: center;
16+
justify-content: center;
17+
}
18+
19+
.mb-1 {
20+
margin-bottom: 15px;
21+
}
22+
23+
.mb-2 {
24+
margin-bottom: 25px;
25+
}
26+
27+
.module-content__title {
28+
}
29+
30+
.module-content__image img {
31+
width: 300px;
32+
}

views/templates/front/d_vuefront.tpl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,23 @@
88
* @license MIT
99
* @version 0.1.0
1010
*}
11+
<!doctype html>
12+
<html lang="{$language.iso_code}">
13+
<head>
14+
{block name='head'}
15+
{include file='_partials/head.tpl'}
16+
{/block}
17+
</head>
18+
<body id="{$page.page_name}" class="{$page.body_classes|classnames}">
19+
<div class="container module-container">
20+
<div class="module-content">
21+
<div class="text-center module-content__image">
22+
<img src="modules/vuefront/views/img/logo.png"/>
23+
</div>
24+
<div class="module-content__title mb-2">{l s='You have Succefully installed Vuefront on Prestashop ' mod='vuefront'}</div>
1125

12-
{$vuefront|escape:'htmlall':'UTF-8'}
26+
<a href="https://vuefront.com/guide/setup.html" target="blank" class="btn btn-primary">Continue</a>
27+
</div>
28+
</div>
29+
</body>
30+
</html>

0 commit comments

Comments
 (0)