1: <?php
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14: 15: 16: 17: 18: 19: 20: 21:
22:
23: $plugin_root = dirname (__FILE__);
24: require_once($plugin_root.'/reports.php');
25:
26:
27:
28:
29: function bright_template_pack_load_bright_customization_scripts() {
30: wp_enqueue_script('jquery-ui-datepicker');
31: wp_enqueue_style('jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
32:
33: wp_enqueue_script('jquery-data-tables',
34:
35: '//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js',
36: array('jquery'));
37: wp_enqueue_script('jquery-data-tables-column-filter',
38: '//jquery-datatables-column-filter.googlecode.com/svn/trunk/media/js/jquery.dataTables.columnFilter.js',
39: array('jquery-data-tables'));
40: wp_enqueue_script('dataTables-tableTools',
41: '//cdn.datatables.net/tabletools/2.2.4/js/dataTables.tableTools.min.js',
42: array('jquery-data-tables'));
43:
44: wp_enqueue_script('bright_template_pack_custom',
45: plugins_url('bright-template-pack.js', __FILE__),
46: array('bright'));
47: wp_enqueue_script('moment',
48: plugins_url('moment.min.js', __FILE__),
49: array('bright'));
50: }
51:
52: add_action('wp_enqueue_scripts', 'bright_template_pack_load_bright_customization_scripts');
53:
54:
55:
56: function bright_template_pack_load_bright_customization_styles() {
57: wp_register_style('bright_template_pack_custom',
58: plugins_url('bright-template-pack/bright-template-pack.css'));
59: wp_enqueue_style('bright_template_pack_custom');
60:
61: wp_register_style('jquery.dataTables.css',
62: '//cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css');
63:
64:
65: wp_enqueue_style('jquery.dataTables.css');
66:
67: wp_register_style('dataTables.tableTools.css',
68: '//cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css');
69:
70: wp_enqueue_style('dataTables.tableTools.css');
71: }
72: add_action('wp_enqueue_scripts', 'bright_template_pack_load_bright_customization_styles');
73:
74:
75: global $bright_embedder_templates;
76:
77:
78:
79: if (empty($bright_embedder_templates)) {
80: $bright_embedder_templates = array();
81: }
82:
83: $bright_embedder_templates['bright_template_debugger'] = <<<EOF
84:
85: <h1>Welcome to the bright template debugger.</h1>
86:
87: <h2>{<span/>{attributes}}</h2>
88:
89: <pre>
90: As passed to the templates the {<span/>{attributes}} variable are:
91:
92: {{#dump attributes}}{{/dump}}
93:
94: So some examples you can use in your template:
95:
96: {<span/>{attributes.template}} will be transformed to "{{attributes.template}}"
97: </pre>
98:
99: <h2>{<span/>{containerId}}</h2>
100:
101: <pre>
102:
103: So some examples you can use in your template:
104:
105: {<span/>{containerId}} : {{containerId}}
106:
107: </pre>
108:
109: {{#if courses}}
110: <h2>{<span/>{courses}}</h2>
111:
112: <pre>
113: As passed to the templates the {<span/>{courses}} variable are:
114:
115: {{#dump2 'courses' courses}}{{/dump2}}
116:
117: TODO:
118: {<span/>{#dump2 'courses.0' courses[0]}}{<span/>{/dump2}}
119:
120: doesn't render. how do I get the first course?
121:
122: So some examples you can use in your template:
123:
124:
125: </pre>
126:
127: {{/if}}
128:
129: <h2>{<span/>{custom}}</h2>
130:
131: <pre>
132: As passed to the templates the {<span/>{custom}} variable are:
133:
134: {{#dump custom}}{{/dump}}
135:
136: So some examples you can use in your template:
137:
138:
139: </pre>
140:
141:
142: <h2>{<span/>{page}}</h2>
143:
144: <pre>
145: As passed to the templates the {<span/>{page}} variable are:
146:
147: {{#dump2 'page' page}}{{/dump2}}
148:
149: {{#dump2 'page.categories' page.categories}}{{/dump2}}
150:
151: {{#dump2 'page.categories.uncategorized' page.categories.uncategorized}}{{/dump2}}
152:
153: So some examples you can use in your template:
154:
155:
156: </pre>
157:
158:
159: <h2>{<span/>{this}}</h2>
160:
161: Note, the this variables contains all the other data available, but without the toplevel syntactic sugar of direct access.
162: But it is useful for writting nested helped functions that requires the entire template context.
163:
164: <br/>
165: <strong>These are always equivalent:</strong><br/>
166: {<span/>{this.title}}<br/>
167: {<span/>{title}}<br/>
168: <strong>So generally speaking, in your template, you can ommit the 'this.' part.</strong><br/>
169:
170: As passed to the templates the {<span/>{this}} variable are:
171:
172: {{#dump2 'this' this}}{{/dump2}}
173:
174: {{#if metadata}}
175: {{#dump2 'metadata' metadata}}{{/dump2}}
176: {{/if}}
177:
178: So some examples you can use in your template:<br/>
179:
180: {{#if title}}
181: {<span/>{title}} : {{title}}
182: {{/if}}
183:
184: </pre>
185:
186: <h2>{<span/>{user}}</h2>
187:
188: <pre>
189: As passed to the templates the {<span/>{user}} variable are:
190:
191: {{#dump2 'user' user}}{{/dump2}}
192: {{#dump2 'user.meta' user.meta}}{{/dump2}}
193: {{#dump2 'user.site_roles' user.site_roles}}{{/dump2}}
194:
195: So some examples you can use in your template:
196:
197: {<span/>{user.email}} : {{user.email}}
198: {<span/>{user.avatar}} : {{user.avatar}}
199: {<span/>{user.meta.first_name}} : {{user.meta.first_name}}
200: {<span/>{user.meta.last_name}} : {{user.meta.last_name}}
201: {<span/>{user.site_roles.administrator}} : {{user.site_roles.administrator}}
202:
203:
204: </pre>
205:
206:
207:
208:
209:
210:
211:
212: EOF;
213:
214:
215:
216: $bright_embedder_templates['bright_course_table'] = <<<EOF
217: {{#if this.attributes.self_register}}
218: <div>Self-registration is enabled!</div>
219: {{/if}}
220: <table class="bright-courselist">
221: <thead>
222: <tr>
223: <th>Course</th>
224: <th>Status</th>
225: <th>Score</th>
226: <th>Take Course</th>
227: </tr>
228: </thead>
229: <tbody>
230: {{#sort this courses sortBy="title"}}
231: <tr>
232: <td>{{title}}</td>
233: <td>{{registration.complete}}, {{registration.success}}</td>
234: <td>{{registration.score}}</td>
235: <td>
236: {{#if registration}}
237: {{#courselist-launchbutton this}}{{/courselist-launchbutton}}
238: {{else}}
239: {{#if this.attributes.self_register}}
240: {{#courselist-launchbutton this}}{{/courselist-launchbutton}}
241: {{/if}}
242: {{/if}}
243: </td>
244: <td>{{#if_course_completed}}
245: <a href="/certificate?bright_course_id={{course_guid}}">Certificate</a>
246: {{/if_course_completed}}
247: </td>
248: </tr>
249: {{/sort}}
250: <tbody>
251: </table>
252: EOF;
253:
254:
255: $stats_table = <<<EOF
256: <table class="stats">
257: <tr>
258: <th class="stats-score">Score</th>
259: <th class="stats-complete">Completion</th>
260: <th class="stats-success">Success</th>
261: <th class="stats-time">Total Time</th>
262: {{#if registration.attempts}}
263: <th class="stats-attempts">Attempts</th>
264: {{/if}}
265: </tr>
266: <tr>
267: <td class="stats-score">{{registration.score}}</td>
268: <td class="stats-complete">{{#bright_localize_scorm this.attributes.locale registration.complete}}{{/bright_localize_scorm}}</td>
269: <td class="stats-success">{{#bright_localize_scorm this.attributes.locale registration.success}}{{/bright_localize_scorm}}</td>
270: <td class="stats-time">{{#bright_localize_scorm this.attributes.locale registration.totaltime}}{{/bright_localize_scorm}}</td>
271: {{#if registration.attempts}}
272: <td class="stats-attempts">{{#bright_localize_scorm this.attributes.locale registration.attempts}}{{/bright_localize_scorm}}</td>
273: {{/if}}
274: </tr>
275: </table>
276: EOF;
277:
278: $course_description = '<div class="course-description">{{#fetch_description this}}{{/fetch_description}}</div>';
279:
280: function btp_create_header_text($course_description) {
281: $ret = <<<EOF
282: <div>
283: <img class="course-image" src="{{#fetch_image this}}{{/fetch_image}}" />
284: <div class="course-category">{{#fetch_category_string this}}{{/fetch_category_string}}</div>
285: <div class="course-title">{{#fetch_title this}}{{/fetch_title}}</div>
286: {$course_description}
287: </div>
288: EOF;
289: return $ret;
290: }
291:
292: $launchbutton = '<div class="bright-launch-buttons">{{{launchbutton}}}</div>';
293: $clear = '<div class="clear"></div>';
294:
295: $header_text = btp_create_header_text($course_description);
296: $bright_embedder_templates['classic'] = <<<EOF
297: {$header_text}
298: {$stats_table}
299: {$clear}
300: {$launchbutton}
301: EOF;
302:
303: $bright_embedder_templates["random_course"] = <<<EOF
304: {{#random_course courses}}
305: <table>
306: <tr>
307: <td>Title:</td>
308: <td>{{title}}</td>
309: </tr>
310: <tr>
311: <td>Description:</td>
312: <td>{{metadata.description}}</td>
313: </tr>
314: <tr>
315: <td>Launch</td>
316: <td>{{#courselist-launchbutton}}{{/courselist-launchbutton}}
317: </td>
318: </tr>
319: </table>
320: {{/random_course}}
321: </br>
322: Last updated: {{#rightnow}}{{/rightnow}}
323: EOF;
324:
325:
326: ?>
327: