Skip to content

Commit 6177484

Browse files
author
Jason Smith
committed
Latest changes with code cleanup
1 parent 6e6058c commit 6177484

File tree

4 files changed

+522
-308
lines changed

4 files changed

+522
-308
lines changed

pkplugins/pkplugins.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ name="Patternkit plugin - Red Hat Base"
22
description="Adds patternkit patterns to panels as content types."
33
package="Presentation Framework"
44
core=7.x
5-
version=7.x-1.0
5+
version=7.x-1.1

pkplugins/pkplugins.install

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @file
45
* Install file for ct_article module.
@@ -13,60 +14,5 @@ function pkplugins_schema() {
1314
// Add the redhat_pkplugins caching table.
1415
$schema['cache_pkplugins'] = drupal_get_schema_unprocessed('system', 'cache');
1516

16-
// // Add the redhat_pkplugins module html artifact table.
17-
// $schema['pkplugins_artifacts'] = array(
18-
// 'description' => 'The artifact table for pkplugins. Provides a failover for origin unavailability.',
19-
// 'fields' => array(
20-
// 'uuid' => array(
21-
// 'type' => 'char',
22-
// 'length' => 36,
23-
// 'not null' => TRUE,
24-
// 'default' => '',
25-
// 'description' => 'The Universally Unique Identifier.',
26-
// ),
27-
// 'content' => array(
28-
// 'description' => 'The artifact of interest.',
29-
// 'type' => 'longtext',
30-
// 'default' => '',
31-
// ),
32-
// 'type' => array(
33-
// 'description' => 'The {node_type} of this node.',
34-
// 'type' => 'varchar',
35-
// 'length' => 32,
36-
// 'not null' => TRUE,
37-
// 'default' => '',
38-
// ),
39-
// 'title' => array(
40-
// 'description' => 'The title of this node, always treated a non-markup plain text.',
41-
// 'type' => 'varchar',
42-
// 'length' => 255,
43-
// 'not null' => TRUE,
44-
// 'default' => '',
45-
// ),
46-
// 'created' => array(
47-
// 'description' => 'The Unix timestamp when the node was created.',
48-
// 'type' => 'int',
49-
// 'not null' => TRUE,
50-
// 'default' => 0,
51-
// ),
52-
// 'changed' => array(
53-
// 'description' => 'The Unix timestamp when the node was most recently saved.',
54-
// 'type' => 'int',
55-
// 'not null' => TRUE,
56-
// 'default' => 0,
57-
// ),
58-
// ),
59-
// 'indexes' => array(
60-
// 'node_changed' => array('changed'),
61-
// 'node_created' => array('created'),
62-
// ),
63-
// 'unique keys' => array(
64-
// 'nid_vid' => array('nid', 'vid'),
65-
// 'vid' => array('vid'),
66-
// ),
67-
// 'primary key' => array('nid'),
68-
// );
69-
7017
return $schema;
7118
}
72-

pkplugins/pkplugins.module

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @file
45
* Patternkit wrapper/abstraction for panels.
@@ -53,12 +54,12 @@ function pkplugins_flush_metadata_cache() {
5354
/**
5455
* Utility function to get all Patternkit module metadata.
5556
*
56-
* @param null $subtype
57+
* @param string|null $subtype
5758
* If specified, return only metadata for this subtype.
5859
* @param bool $reset
5960
* Optionally force the meta data to be reloaded.
6061
*
61-
* @return array|stdClass
62+
* @return array|object
6263
* Array of metadata objects found or object if specific module requested.
6364
*/
6465
function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
@@ -78,23 +79,24 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
7879
$patternkit_host . '/api/patterns',
7980
array(
8081
'headers' => array('Content-Type' => 'application/json'),
81-
'timeout' => 10
82+
'timeout' => 10,
8283
)
8384
);
8485
if (!empty($patterns) && empty($patterns->error) && $patterns->code == 200) {
85-
$cached_metadata = (array)json_decode($patterns->data);
86+
$cached_metadata = (array) json_decode($patterns->data);
8687

8788
// Cache the data so that we don't have to build it again.
8889
// (if cache enabled, otherwise just a slow, redundant memcache set).
8990
if ($pkplugins_cache_enabled == TRUE) {
9091
cache_set('pkplugins_pk_metadata', $cached_metadata, 'cache', CACHE_PERMANENT);
9192
}
92-
} else {
93+
}
94+
else {
9395
_pkplugins_show_error(
9496
'Patternkit failed to load metadata from service (%service_uri): %error',
9597
array(
9698
'%service_uri' => $patternkit_host . '/api/patterns',
97-
'%error' => !empty($patterns->error) ? $patterns->error : $patterns->code
99+
'%error' => !empty($patterns->error) ? $patterns->error : $patterns->code,
98100
)
99101
);
100102
return NULL;
@@ -129,18 +131,16 @@ function _pkplugins_get_metadata($subtype = NULL, $reset = FALSE) {
129131
*
130132
* @param string $msg
131133
* The message to display (with t vars as appropriate).
132-
* @param array $vars
134+
* @param array $vars
133135
* Optional array of replacement text appropriate for use in t function.
134136
* @param string $status
135137
* Status for the error message. Passed to drupal_set_message.
136138
*/
137-
function _pkplugins_show_error($msg, $vars = array(), $status = 'error') {
139+
function _pkplugins_show_error($msg, array $vars = array(), $status = 'error') {
138140
if (variable_get('pkplugins_show_errors', FALSE) && user_is_logged_in()) {
139-
drupal_set_message(t($msg, $vars), $status);
141+
drupal_set_message(format_string($msg, $vars), $status);
140142
}
141143
if (variable_get('pkplugins_log_errors', FALSE)) {
142144
watchdog('pkplugins', $msg, $vars, WATCHDOG_ERROR);
143145
}
144146
}
145-
146-

0 commit comments

Comments
 (0)