1+ <?php
2+ /**
3+ * This file contains the material template
4+ *
5+ * @package PHPDraft\HTML
6+ * @author Sean Molenaar<[email protected] > 7+ */
8+ use PHPDraft \Out \Minifier ;
9+ ?>
10+ <!DOCTYPE html>
11+ <html lang="en">
12+ <head>
13+ <title><?= $ this ->base_data ['TITLE ' ]; ?> </title>
14+ <meta name="viewport" content="width=device-width, initial-scale=1">
15+ <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
16+ <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
17+ <script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
18+ <?php foreach ($ this ->css as $ style ): ?>
19+ <link rel="stylesheet" href="<?= $ style ?> ">
20+ <?php endforeach ; ?>
21+ <style>
22+ <?= Minifier::minify_css (file_get_contents ($ this ->find_include_file ($ this ->template , 'css ' ), true ));?>
23+ </style>
24+ </head>
25+ <body>
26+ <div class="demo-layout-waterfall mdl-layout mdl-js-layout">
27+ <header class="mdl-layout__header mdl-layout__header--waterfall">
28+ <div class="mdl-layout__header-row">
29+ <!-- Title -->
30+ <span class="mdl-layout-title"><?= $ this ->base_data ['TITLE ' ]; ?> </span>
31+ <div class="mdl-layout-spacer"></div>
32+ <div class="mdl-textfield mdl-js-textfield mdl-textfield--expandable
33+ mdl-textfield--floating-label mdl-textfield--align-right">
34+ <label class="mdl-button mdl-js-button mdl-button--icon"
35+ for="waterfall-exp">
36+ <i class="material-icons">search</i>
37+ </label>
38+ <div class="mdl-textfield__expandable-holder">
39+ <input class="mdl-textfield__input" type="text" name="sample"
40+ id="waterfall-exp">
41+ </div>
42+ </div>
43+ </div>
44+ </header>
45+ <div class="mdl-layout__drawer">
46+ <span class="mdl-layout-title"><?= $ this ->base_data ['TITLE ' ]; ?> </span>
47+ <nav class="mdl-navigation">
48+ <a class="mdl-navigation__link" href="#"><b>Webservices</b></a>
49+ <?php foreach ($ this ->categories as $ category ): ?>
50+ <a class="mdl-navigation__link" href="#<?= $ category ->get_href (); ?> "><?= $ category ->title ; ?> </a>
51+ <?php if ($ category ->children !== []): ?>
52+ <?php foreach ($ category ->children as $ resource ): ?>
53+ <a class="mdl-navigation__link" href="#<?= str_replace ('- ' , '/ ' , $ resource ->get_href ()); ?> ">
54+ - <?= $ resource ->title ; ?>
55+ </a>
56+ <?php foreach ($ resource ->children as $ transition ): ?>
57+ <a class="mdl-navigation__link" href="#<?= str_replace ('- ' , '/ ' , $ transition ->get_href ()); ?> ">
58+ -- <?= $ transition ->title ; ?>
59+ <span class="pull-right <?= $ this ->get_method_icon ($ transition ->get_method ()); ?> "></span>
60+ </a>
61+ <?php endforeach ; ?>
62+ <?php endforeach ; ?>
63+ <?php endif ; ?>
64+ <?php endforeach ; ?>
65+ <?php if (!empty ($ this ->base_structures )): ?>
66+ <a class="mdl-navigation__link" href="#"><b>Objects</b></a>
67+ <?php foreach ($ this ->base_structures as $ key => $ structure ): ?>
68+ <a class="mdl-navigation__link" href="#<?= $ this ->strip_link_spaces ($ key ); ?> "><?= $ key ; ?> </a>
69+ <?php endforeach ; ?>
70+ <?php endif ; ?>
71+ </nav>
72+ </div>
73+ <main class="mdl-layout__content">
74+ <div class="page-content">
75+ <?php foreach ($ this ->categories as $ category ): ?>
76+ <?php if (!empty ($ category ->title )): ?>
77+ <h3><a id="<?= $ category ->get_href (); ?> "><?= $ category ->title ; ?> </a></h3>
78+ <?php endif ; ?>
79+ <?php if (!empty ($ category ->description )): ?>
80+ <p><?= $ category ->description ; ?> </p>
81+ <?php endif ; ?>
82+ <?php foreach ($ category ->children as $ resource ): ?>
83+ <h4>
84+ <a id="<?= str_replace ('- ' , '/ ' , $ resource ->get_href ()); ?> "><?= $ resource ->title ; ?> </a>
85+ <small><?= $ resource ->href ; ?> </small>
86+ </h4>
87+ <p><?php $ resource ->description ; ?> </p>
88+ <?php foreach ($ resource ->children as $ transition ): ?>
89+ <div class="demo-card-wide mdl-card mdl-shadow--2dp <?= $ transition ->get_method (); ?> ">
90+ <div class="mdl-card__title">
91+ <h2 class="mdl-card__title-text"><var><?= $ transition ->get_method (); ?> </var>
92+ <code><?= $ transition ->href ; ?> </code>
93+ <a class="pull-right transition-title"
94+ id="<?= str_replace ('- ' , '/ ' ,
95+ $ transition ->get_href ()); ?> "><?= $ transition ->title ; ?> </a></h2>
96+ </div>
97+ <div class="mdl-card__supporting-text">
98+ <?= $ transition ->description ; ?>
99+ <?php if (!empty ($ transition ->requests ) || !empty ($ transition ->responses )): ?>
100+ <div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect">
101+ <div class="mdl-tabs__tab-bar">
102+ <?php if (!empty ($ transition ->requests )): ?>
103+ <a href="#<?= $ transition ->get_href (); ?> -request-panel" class="mdl-tabs__tab is-active">Request</a>
104+ <?php endif ;?>
105+ <?php if (!empty ($ transition ->responses )): ?>
106+ <?php foreach ($ transition ->responses as $ key => $ response ): ?>
107+ <a href="#<?= $ transition ->get_href () . '- ' . $ response ->statuscode ; ?> -panel"
108+ class="mdl-tabs__tab <?= $ this ->get_response_status ($ response ->statuscode ) ?> "><?= $ response ->statuscode ; ?> </a>
109+ <?php endforeach ;?>
110+ <?php endif ;?>
111+ </div>
112+ <?php if (!empty ($ transition ->requests )): ?>
113+ <?php foreach ($ transition ->requests as $ key => $ request ): ?>
114+ <div class="mdl-tabs__panel is-active" id="<?= $ transition ->get_href (); ?> -request-panel">
115+ <?= $ request ->description ; ?>
116+ <?php if ($ transition ->url_variables !== []): ?>
117+ <h5>Example URI</h5>
118+ <span class="base-url"><?= $ this ->base_data ['HOST ' ]; ?> </span><em><?= $ transition ->build_url (); ?> </em>
119+ <?php endif ; ?>
120+ <?php if ($ request ->headers !== []): ?>
121+ <h5>Headers</h5>
122+ <ul class="headers mdl-list">
123+ <?php foreach ($ request ->headers as $ name => $ value ): ?>
124+ <li class="mdl-list__item">
125+ <code>
126+ <span class="attr"><?= $ name ; ?> </span>: <span class="value"><?= $ value ; ?> </span>
127+ </code>
128+ </li>
129+ <?php endforeach ; ?>
130+ </ul>
131+ <?php endif ; ?>
132+ <?php if (!empty ($ request ->body )): ?>
133+ <h5>Body</h5>
134+ <?php foreach ($ request ->body as $ value ): ?>
135+ <?php if (is_string ($ value )): ?>
136+ <code class="request-body"><?= $ value ; ?> </code>
137+ <?php else : ?>
138+ <?php $ type = (isset ($ request ->headers ['Content-Type ' ])) ? $ request ->headers ['Content-Type ' ] : null ; ?>
139+ <?= $ value ->print_request ($ type ); ?>
140+ <?= $ value ?>
141+ <?php endif ; ?>
142+ <?php endforeach ; ?>
143+ <?php endif ; ?>
144+ <?php if (!empty ($ request ->struct )): ?>
145+ <h5>Structure</h5>
146+ <?= $ request ->struct ?>
147+ <?php endif ; ?>
148+ <?php if ($ transition ->url_variables !== null ): ?>
149+ <h5>URI Parameters</h5>
150+ <?= $ transition ->url_variables ; ?>
151+ <?php endif ; ?>
152+ <?php if ($ transition ->data_variables !== null ): ?>
153+ <h5>Data object</h5>
154+ <?= $ transition ->data_variables ?>
155+ <?php endif ; ?>
156+ </div>
157+ <?php endforeach ; ?>
158+ <?php endif ; ?>
159+ <?php if (!empty ($ transition ->responses )): ?>
160+ <?php foreach ($ transition ->responses as $ key => $ response ): ?>
161+ <div class="mdl-tabs__panel" id="<?= $ transition ->get_href () . '- ' . $ response ->statuscode ; ?> -panel">
162+ <?= $ response ->description ; ?>
163+ <?php if ($ response ->headers !== []): ?>
164+ <h5>Headers</h5>
165+ <ul class="headers mdl-list">
166+ <?php foreach ($ response ->headers as $ name => $ value ): ?>
167+ <li class="mdl-list__item">
168+ <code>
169+ <span class="attr"><?= $ name ; ?> </span>: <span class="value"><?= $ value ; ?> </span>
170+ </code>
171+ </li>
172+ <?php endforeach ; ?>
173+ </ul>
174+ <?php endif ; ?>
175+ <?php if ($ response ->structure !== []): ?>
176+ <h5>Data Structure</h5>
177+ <div class="row">
178+ <?php foreach ($ response ->structure as $ value ): ?>
179+ <?= $ value ; ?>
180+ <?php endforeach ; ?>
181+ </div>
182+ <?php endif ; ?>
183+ <?php foreach ($ response ->content as $ key => $ value ): ?>
184+ <div>
185+ <?php $ href =
186+ $ transition ->get_href () . '- ' . $ response ->statuscode . '- ' . str_replace ([
187+ '/ ' ,
188+ '+ ' ,
189+ ], '- ' , $ key ); ?>
190+ <h5 class="response-body"
191+ data-toggle="collapse"
192+ data-target="#request-<?= $ href ?> ">
193+ <span class="glyphicon indicator glyphicon-menu-up"></span>
194+ <?= $ key ; ?>
195+
196+ </h5>
197+ <pre class="collapse collapsed response-body"
198+ id="request-<?= $ href ?> "><?= $ value ; ?> </pre>
199+ </div>
200+ <?php endforeach ; ?>
201+ </div>
202+ </div>
203+ <?php endforeach ; ?>
204+ <?php endif ; ?>
205+ <?php endif ;?>
206+ </div>
207+ <div class="mdl-card__menu">
208+ <button id="<?= $ transition ->get_href ();?> " class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect">
209+ <i class="material-icons">bug_report</i>
210+ </button>
211+ <div class="mdl-tooltip" for="<?= $ transition ->get_href ();?> ">
212+ <?= $ transition ->get_curl_command ($ this ->base_data ['HOST ' ], []); ?>
213+ </div>
214+ </div>
215+ </div>
216+ <?php endforeach ;?>
217+ <?php endforeach ;?>
218+ <?php endforeach ;?>
219+ <?php if (count ($ this ->base_structures ) > 0 ): ?>
220+ <h3><a id="datastructures">Data structures</a></h3>
221+ <?php foreach ($ this ->base_structures as $ key => $ structure ): ?>
222+ <div class="demo-card-wide mdl-card mdl-shadow--2dp">
223+ <div class="mdl-card__title">
224+ <h2 class="mdl-card__title-text"><a id="object-<?= $ this ->strip_link_spaces ($ key ); ?> "><?= $ key ; ?> </a></h2>
225+ </div>
226+ <div class="mdl-card__supporting-text">
227+ <?= $ structure ; ?>
228+ </div>
229+ </div>
230+ <?php endforeach ; ?>
231+ <?php endif ; ?>
232+ </div>
233+ </main>
234+ </div>
235+ <?php $ extras = array_filter ($ this ->base_data , function ($ value ) {
236+ return !in_array ($ value , ['HOST ' , 'TITLE ' , 'ALT_HOST ' , 'FORMAT ' , 'DESC ' ]);
237+ }, ARRAY_FILTER_USE_KEY );
238+ if (!empty ($ extras )):
239+ $ extras ['host ' ] = $ this ->base_data ['HOST ' ]; ?>
240+ <button
241+ type="button"
242+ class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored"
243+ data-toggle="popover"
244+ title="Extra info"
245+ data-placement="top"
246+ data-html="true"
247+ data-content="<?php foreach ($ extras as $ key => $ value ): ?> <p><?= $ key ; ?> : <?= $ value ; ?> </p><?php endforeach ; ?> ">
248+ <i class="material-icons">help outline</i>
249+ </button>
250+ <?php endif ; ?>
251+ <?php foreach ($ this ->js as $ js ): ?>
252+ <script src="<?= $ js ?> "></script>
253+ <?php endforeach ; ?>
254+ <script src="https://code.jquery.com/jquery-2.2.4.min.js"
255+ integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
256+ crossorigin="anonymous"></script>
257+ <script><?= Minifier::minify_js (file_get_contents ($ this ->find_include_file ($ this ->template , 'js ' ), true )); ?> </script>
258+ </body>
259+ </html>
0 commit comments