Skip to content

Commit 6cfcab3

Browse files
committed
Coding standards fixes
style(patternkit.module, patternkit.inc)
1 parent 5d1b92c commit 6cfcab3

File tree

4 files changed

+37
-22
lines changed

4 files changed

+37
-22
lines changed

include/api.inc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* API Callbacks for Patternkit endpoints.
6+
*/
7+
8+
/**
9+
* Returns the JSON-encoded Patternkit schema for the provided pattern.
10+
*
11+
* @param string $library
12+
* The name of the pattern library to search.
13+
* @param string $pattern
14+
* The name of the pattern to use for retrieving the schema.
15+
*/
16+
function patternkit_api_pattern_schema($library, $pattern) {
17+
drupal_json_output(_patternkit_get_metadata($pattern));
18+
}

patternkit.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ core=7.x
55
dependencies[] = ctools
66
dependencies[] = panels
77
files[] = src/PatternkitDrupalCachedLib.php
8+
files[] = src/PatternkitDrupalTwigLib.php
89
files[] = src/PatternkitEditorConfig.php
910
files[] = src/PatternkitLibInterface.php
1011
files[] = src/PatternkitPattern.php
1112
files[] = src/PatternkitRESTLib.php
12-
files[] = src/PatternkitDrupalTwigLib.php

patternkit.module

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// Default TTL is 30 * 24 * 60 * 60, 30 minutes.
99
const PATTERNKIT_DEFAULT_TTL = 2592000;
1010

11+
include __DIR__ . '/include/api.inc';
1112
include __DIR__ . '/include/patternkit_config_form.inc';
1213
include __DIR__ . '/include/utility.inc';
1314

plugins/content_types/patternkit.inc

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ require_once __DIR__ . '/../../include/utility.inc';
1818
*
1919
* Plugins are described by creating a $plugin array which will be used
2020
* by the system that includes this file.
21+
*
22+
* The 'all contexts' is NEEDED to be able to use substitution strings.
2123
*/
2224
$plugin = array(
2325
'title' => t('Patternkit Pattern'),
@@ -28,7 +30,7 @@ $plugin = array(
2830
'content type' => 'patternkit_patternkit_content_type_content_type',
2931
'admin info' => 'patternkit_patternkit_content_type_admin_info',
3032
'defaults' => array(),
31-
'all contexts' => TRUE, // This is NEEDED to be able to use substitution strings in your pane.
33+
'all contexts' => TRUE,
3234
);
3335

3436
/**
@@ -49,7 +51,7 @@ function patternkit_patternkit_content_type_content_type($subtype) {
4951
if (!user_is_anonymous()) {
5052
drupal_set_message(
5153
t(
52-
"The patternkit framework module (:module) appears to be missing. Remove from this panel, or replace the missing code and clear caches.",
54+
'The patternkit framework module (:module) appears to be missing. Remove from this panel, or replace the missing code and clear caches.',
5355
array(
5456
':module' => $subtype,
5557
)
@@ -110,7 +112,7 @@ function patternkit_patternkit_content_type_admin_title(
110112
) {
111113
$module = _patternkit_get_metadata($subtype);
112114
if (empty($module->title)) {
113-
$title = "BROKEN/MISSING MODULE";
115+
$title = 'BROKEN/MISSING MODULE';
114116
}
115117
else {
116118
$title = $module->title;
@@ -175,14 +177,12 @@ function patternkit_patternkit_content_type_edit_form($form, &$form_state) {
175177
$form['override_title_text'],
176178
$form['override_title_heading']);
177179

178-
// @TODO: Re-enable the other formats.
180+
// @TODO: Re-enable the other formats like JSON and webcomponent.
179181
$form['presentation_style'] = array(
180182
'#type' => 'select',
181183
'#title' => 'Presentation style',
182184
'#options' => array(
183-
// 'webcomponent' => 'Web component',
184185
'html' => 'HTML inline',
185-
// 'json' => 'JSON (with js/css)',
186186
),
187187
'#default_value' => isset($conf['presentation_style']) ? $conf['presentation_style'] : '',
188188
);
@@ -307,7 +307,7 @@ function patternkit_patternkit_content_type_render(
307307
static $is_processed;
308308

309309
// Initialize our static (if necessary).
310-
if (is_null($is_processed)) {
310+
if ($is_processed === NULL) {
311311
$is_processed = array();
312312
}
313313

@@ -363,17 +363,8 @@ function patternkit_patternkit_content_type_render(
363363
),
364364
)
365365
);
366-
//
367-
// if (!empty($config['pkdata']['attachments'])) {
368-
// $settings = _patternkit_merge_js(
369-
// $config['pkdata']['attachments'],
370-
// $base_dependencies
371-
// );
372-
// dpm($settings, 'settings');
373-
// dpm($base_dependencies, 'bd');
374-
// }
375-
376366

367+
// @todo Merge attachment JS and dependencies.
377368
// Build the response object.
378369
$block = new stdClass();
379370
$block->title = '';
@@ -396,13 +387,19 @@ function patternkit_patternkit_content_type_render(
396387
cache_set($cid, $block, 'cache_patternkit', time() + $ttl);
397388
}
398389

390+
// @todo Re-evaluate use of this flag.
399391
// Set flag to let other modules know content is ngpanes stuff.
400392
$block->ngpane = 1;
401393

402394
return $block;
403395
}
404396

405-
/************* Utility functions below *************/
397+
/**
398+
* Utility functions.
399+
*
400+
* @ingroup utility
401+
* @{
402+
*/
406403

407404
/**
408405
* Render the actual contents of the module.
@@ -432,7 +429,7 @@ function _patternkit_render_block(
432429
return 'MISSING/BROKEN';
433430
}
434431

435-
if ($config['presentation_style'] == 'webcomponent') {
432+
if ($config['presentation_style'] === 'webcomponent') {
436433
$subtype = substr($subtype, 3);
437434
$body = "<$subtype-pattern></$subtype-pattern>";
438435
}
@@ -466,8 +463,7 @@ function _patternkit_admin_info_presentation_render(
466463
) {
467464
$result = patternkit_patternkit_content_type_render($subtype, $conf, array(), array());
468465

469-
$output = $result->content;
470-
return $output;
466+
return $result->content;
471467
}
472468

473469
/**

0 commit comments

Comments
 (0)