Commit bdff6417 authored by anon's avatar anon
Browse files

Fixed coding standards

parent 583d4723
......@@ -23,11 +23,11 @@ function linkit_admin_settings() {
'changed' => t('Display node changed time'),
'show_unpublished' => t('Show unpublished nodes in the result'),
);
if (module_exists('book')) {
$node_display_settings_options += array('show_books' => t('Display the book a node belongs to'));
}
$form['linkit_node'] = array(
'#type' => 'fieldset',
'#title' => t('Node settings'),
......@@ -48,7 +48,7 @@ function linkit_admin_settings() {
'#title' => t('Include these content types in the search result'),
'#type' => 'checkboxes',
'#options' => node_get_types('names'),
'#default_value' => $node_settings['content_types'],
'#default_value' => $node_settings['content_types'],
'#description' => t('If none is checked, all content types will be present in the search result.'),
);
}
......@@ -58,7 +58,7 @@ function linkit_admin_settings() {
// Prevent "PHP notice: Undefined variable"
_linkit_taxonomy_get_default_settings($term_settings);
$term_display_settings_options = array(
'show_parent' => t('Display the parent of the term'),
);
......@@ -80,7 +80,7 @@ function linkit_admin_settings() {
);
}
if (!count($form)) {
// No linkit plugins is enabled that uses settings
// Print a message about this
......
......@@ -22,11 +22,11 @@ function linkit_requirements($phase) {
switch ($phase) {
case 'runtime':
if (!module_exists('pathfilter') && !module_exists('pathologic')) {
$severity = REQUIREMENT_ERROR;
$severity = REQUIREMENT_ERROR;
$value = t('Please install pathfilter <strong>OR</strong> pathologic');
}
else {
$severity = REQUIREMENT_OK;
$severity = REQUIREMENT_OK;
$value = t('Ok');
}
$requirements['linkit_dependencies'] = array(
......@@ -51,5 +51,5 @@ function linkit_update_6100() {
$old = variable_get('linkit_node', array());
$new = array('display_settings' => $old);
variable_set('linkit_node', $new);
return $ret;
return $ret;
}
\ No newline at end of file
<?php
<?php
/**
* @file
......@@ -95,7 +95,7 @@ function linkit_textarea($element, $form_state) {
if (isset($element['#process'])) {
if (in_array('bueditor_textarea', $element['#process'])) {
_linkit_add_settings('bueditor');
drupal_add_js(drupal_get_path('module', 'linkit') . '/editors/bueditor/editor_plugin.js');
drupal_add_js(drupal_get_path('module', 'linkit') . '/editors/bueditor/editor_plugin.js');
}
}
return $element;
......@@ -158,21 +158,21 @@ function linkit_dashboard_page($editor) {
module_invoke('admin_menu', 'suppress');
// Add CSS.
drupal_add_css(drupal_get_path('module', 'linkit') . '/css/linkit.css');
// Add JS
static $defualt_settings_added = FALSE;
// Add default settings
if (!$defualt_settings_added) {
$defualt_settings_added = TRUE;
$settings = array(
'linkit' => array('ajaxcall' => url('admin/linkit/geteditresult')),
);
// Check if we have IMCE and access to it.
$imce = module_invoke('imce', 'access');
if($imce) {
if ($imce) {
$settings['linkit']['IMCEurl'] = url('imce', array('query' => array('app' => 'Linkit|url@edit-link')));
}
......@@ -198,13 +198,13 @@ function linkit_dashboard_page($editor) {
// Add JavaScript.
drupal_add_js(drupal_get_path('module', 'linkit') . '/editors/fckeditor/linkit/linkitDialog.js');
break;
case 'bueditor':
// Add JavaScript.
drupal_add_js(drupal_get_path('module', 'linkit') . '/editors/bueditor/linkit.js');
break;
}
print theme('linkit_dashboard', drupal_get_form('_linkit_form'));
exit();
}
......@@ -222,7 +222,7 @@ function linkit_autocomplete($string = NULL) {
if (user_access('create '. $module .' links') || user_access('create all links')) {
$matches = array_merge($matches, $hook_matches[$module]);
}
}
}
else {
$matches = array_merge($matches, $hook_matches[$module]);
}
......@@ -231,13 +231,13 @@ function linkit_autocomplete($string = NULL) {
// hook_linkit_load_plugins_alter() , let other modules change the matches array
drupal_alter('linkit_load_plugins', $matches);
$results = array();
foreach ($matches AS $match) {
// Build the val
$val = check_plain($match['title'] . ' [path:' . $match['path'] . ']');
// Get the extra information text
$information = array();
foreach ($match['information'] AS $extra_info_key => $extra_info_val) {
......@@ -245,7 +245,7 @@ function linkit_autocomplete($string = NULL) {
// But the "$extra_info_key" is hard coded and cant be change by users or administratios so its ok to use t() this way.
$information[] = t(drupal_ucfirst($extra_info_key)) . ':<span>' . $extra_info_val . '</span>';
}
// Build the text
$text = '<div class="clear-block">';
$text .= '<div class="auto-item-title">' . check_plain($match['title']) . '</div>';
......@@ -255,7 +255,7 @@ function linkit_autocomplete($string = NULL) {
$text .= '</div>';
$results[$val] = $text;
}
drupal_json($results);
}
......@@ -266,7 +266,7 @@ function linkit_search_styled_link() {
$string = check_plain($_GET['string']);
$matches = module_invoke_all('linkit_get_search_styled_link', $string);
echo (isset($matches[0]) ? $matches[0] : '');
echo isset($matches[0]) ? $matches[0] : '';
}
}
......@@ -318,7 +318,7 @@ function _linkit_form() {
$form['link']['attributes']['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#maxlength' => 255,
'#maxlength' => 255,
'#size' => 40,
'#default_value' => '',
'#weight' => 0,
......@@ -326,7 +326,7 @@ function _linkit_form() {
$form['link']['attributes']['id'] = array(
'#type' => 'textfield',
'#title' => t('ID'),
'#maxlength' => 255,
'#maxlength' => 255,
'#size' => 40,
'#default_value' => '',
'#weight' => 1,
......@@ -334,7 +334,7 @@ function _linkit_form() {
$form['link']['attributes']['class'] = array(
'#type' => 'textfield',
'#title' => t('Class'),
'#maxlength' => 255,
'#maxlength' => 255,
'#size' => 40,
'#default_value' => '',
'#weight' => 2,
......@@ -342,7 +342,7 @@ function _linkit_form() {
$form['link']['attributes']['rel'] = array(
'#type' => 'textfield',
'#title' => t('Rel'),
'#maxlength' => 255,
'#maxlength' => 255,
'#size' => 40,
'#default_value' => '',
'#weight' => 3,
......@@ -350,7 +350,7 @@ function _linkit_form() {
$form['link']['attributes']['accesskey'] = array(
'#type' => 'textfield',
'#title' => t('Accesskey'),
'#maxlength' => 255,
'#maxlength' => 255,
'#size' => 40,
'#default_value' => '',
'#weight' => 4,
......@@ -358,7 +358,7 @@ function _linkit_form() {
$form['link']['attributes']['anchor'] = array(
'#type' => 'textfield',
'#title' => t('Anchor'),
'#maxlength' => 255,
'#maxlength' => 255,
'#size' => 40,
'#default_value' => '',
'#weight' => 5,
......@@ -384,7 +384,7 @@ function linkit_wysiwyg_plugin($editor, $version) {
_linkit_add_settings('wysiwyg_' . $editor);
switch ($editor) {
case 'tinymce':
case 'tinymce':
$plugins['linkit'] = array(
'path' => drupal_get_path('module', 'linkit') . '/editors/tinymce/',
'filename' => 'editor_plugin.js',
......@@ -393,7 +393,7 @@ function linkit_wysiwyg_plugin($editor, $version) {
'load' => TRUE,
);
break;
case 'ckeditor':
case 'ckeditor':
// notice: Big "L" in the name here! important
$plugins['Linkit'] = array(
'path' => drupal_get_path('module', 'linkit') . '/editors/ckeditor/',
......@@ -402,7 +402,7 @@ function linkit_wysiwyg_plugin($editor, $version) {
'load' => TRUE,
);
break;
case 'fckeditor':
case 'fckeditor':
$plugins['linkit'] = array(
'path' => drupal_get_path('module', 'linkit') . '/editors/fckeditor/',
'buttons' => array('linkit' => t('Linkit')),
......@@ -421,7 +421,7 @@ function _linkit_add_settings($editor) {
if (!isset($editor_settings_added[$editor])) {
$editor_settings_added[$editor] = TRUE;
// Add popup url
$settings = array(
'linkit' => array(
......@@ -441,6 +441,6 @@ function _linkit_add_settings($editor) {
),
);
drupal_add_js($settings, 'setting');
}
}
\ No newline at end of file
<?php
<?php
/**
* @file
* Extend Linkit with files.
......@@ -11,13 +10,13 @@
*/
function linkit_file_linkit_load_plugins($string) {
$matches = array();
// Get files.
$result = db_query("SELECT f.fid, f.filename, f.filepath FROM {files} f WHERE f.filename LIKE LOWER('%%%s%%%') AND f.status = 1", $string);
while ($file = db_fetch_object($result)) {
$matches['file'][] = array(
'title' => $file->filename,
'path' => base_path().$file->filepath,
'path' => base_path() . $file->filepath,
'information' => array(
'type' => 'File',
),
......@@ -36,7 +35,7 @@ function linkit_file_linkit_get_search_styled_link($string) {
/**
* Implementation of hook_linkit_info_plugins().
*
*
* This is used by linkit_permissions
*/
function linkit_file_linkit_info_plugins() {
......
<?php
<?php
/**
* @file
* Extend Linkit with node links.
*/
/**
* Implementation of hook_linkit_load_plugins().
*/
function linkit_node_linkit_load_plugins($string) {
$matches = array();
$settings = variable_get('linkit_node', array());
// Prevent "PHP notice: Undefined variable"
_linkit_node_get_default_settings($settings);
$fields = array('n.nid', 'n.title'); // default fields
$from = array('{node} n'); // default from
$where = array(); // default where
if ($settings['display_settings']['content_type']) {
$from[] = 'INNER JOIN {node_type} nt ON nt.type = n.type';
$fields[] = 'nt.name AS content_type';
......@@ -30,7 +28,7 @@ function linkit_node_linkit_load_plugins($string) {
}
if ($settings['display_settings']['language']) {
$fields[] = 'n.language';
}
}
if ($settings['display_settings']['created']) {
$fields[] = 'n.created';
}
......@@ -56,7 +54,7 @@ function linkit_node_linkit_load_plugins($string) {
$allowed_content_types = implode("', '", $allowed_content_types);
// Special treatment!!
// If we push this to the $where array, the single-quotes will be
// escaped and result in a SQL error.
// escaped and result in a SQL error.
// I asked chx if its ok to use the content type machine name
// "as it is" in this query and he said ok and I trust him.
$sql[] = " AND n.type IN ('" . $allowed_content_types . "')";
......@@ -77,11 +75,11 @@ function linkit_node_linkit_load_plugins($string) {
// Add the node nid
if ($settings['display_settings']['nid']) {
$matches['node'][$i]['information']['nid'] = $node->nid;
}
}
// Add the node content type
if ($settings['display_settings']['content_type']) {
$matches['node'][$i]['information']['content type'] = $node->content_type;
}
}
// Add the node status
if ($settings['display_settings']['status']) {
$matches['node'][$i]['information']['status'] = $node->status ? t('published') : t('unpublished');
......@@ -89,25 +87,25 @@ function linkit_node_linkit_load_plugins($string) {
// Add the node language
if ($settings['display_settings']['language']) {
$matches['node'][$i]['information']['language'] = $node->language ? $node->language : '-';
}
}
// Add the node created time
if ($settings['display_settings']['created']) {
$matches['node'][$i]['information']['created'] = $node->created ? format_date($node->created, 'small') : '-';
}
}
// Add the node changed time
if ($settings['display_settings']['changed']) {
$matches['node'][$i]['information']['changed'] = $node->changed ? format_date($node->changed, 'small') : '-';
}
}
// Add Title of the book a node belong to
if ($settings['display_settings']['show_books'] && $node->bid) {
$book_node = node_load($node->bid);
$matches['node'][$i]['information']['book'] = $book_node->title;
}
}
$i++;
}
return $matches;
}
......@@ -126,10 +124,10 @@ function linkit_node_linkit_get_search_styled_link($string) {
return;
}
// This is a node link created with Linkit, try to grab the title and path now.
// This is a node link created with Linkit, try to grab the title and path now.
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.nid = %d"), $splitted_string[1]);
$node = db_fetch_object($result);
// No reault or no node was found
if (!$result || !$node) {
return;
......@@ -140,7 +138,7 @@ function linkit_node_linkit_get_search_styled_link($string) {
/**
* Implementation of hook_linkit_info_plugins().
*
*
* This is used by linkit_permissions
*/
function linkit_node_linkit_info_plugins() {
......@@ -151,13 +149,13 @@ function linkit_node_linkit_info_plugins() {
}
/**
* Prevent "PHP notice: Undefined variable" by merging the settings
* Prevent "PHP notice: Undefined variable" by merging the settings
* with the defule values
*/
function _linkit_node_get_default_settings(&$settings) {
// Merge settings with the default settings
$settings += array(
'display_settings' => array(),
'display_settings' => array(),
'content_types' => array(),
);
......
<?php
<?php
/**
* @file
* Extend Linkit with permissions.
......
<?php
<?php
/**
* @file
* Extend Linkit with taxonomy links.
......@@ -46,12 +45,12 @@ function linkit_taxonomy_linkit_load_plugins($string) {
// The API says "Find all parents of a given term ID." but thats not true
// It is only returning the very next parent
$parents = taxonomy_get_parents($term->tid);
if (count($parents)) {
$current = current($parents);
$matches['taxonomy'][$i]['information']['parent'] = $current->name;
}
}
}
$i++;
}
return $matches;
......@@ -71,26 +70,26 @@ function linkit_taxonomy_linkit_get_search_styled_link($string) {
if (!is_numeric($splitted_string[count($splitted_string)-1])) {
return ;
}
// Try to get a term object
$term = taxonomy_get_term($splitted_string[count($splitted_string)-1]);
// taxonomy_get_term is returns an object
if (!is_object($term)) {
return ;
}
// Ok, this looks like a term, get the path
$path = taxonomy_term_path($term);
// If $path is the same as the provided $string, we have a match.
if ($path == str_replace('internal:', '', $string)) {
return check_plain($term->name) . ' [path:internal:' . taxonomy_term_path($term) . ']';
}
}
}
/**
* Implementation of hook_linkit_info_plugins().
*
*
* This is used by linkit_permissions
*/
function linkit_taxonomy_linkit_info_plugins() {
......@@ -101,7 +100,7 @@ function linkit_taxonomy_linkit_info_plugins() {
}
/**
* Prevent "PHP notice: Undefined variable" by merging the settings
* Prevent "PHP notice: Undefined variable" by merging the settings
* with the defule values
*/
function _linkit_taxonomy_get_default_settings(&$settings) {
......@@ -109,6 +108,6 @@ function _linkit_taxonomy_get_default_settings(&$settings) {
$settings += array(
'display_settings' => array(
'show_parent' => 0,
),
),
);
}
\ No newline at end of file
<?php
<?php
/**
* @file
* Extend Linkit with user links.
......@@ -43,7 +42,7 @@ function linkit_user_linkit_get_search_styled_link($string) {
return;
}
// This is a node link created with Linkit, try to grab the title and path now.
// This is a node link created with Linkit, try to grab the title and path now.
$result = db_query(db_rewrite_sql("SELECT u.uid, u.name FROM {users} u WHERE u.uid = %d"), $splitted_string[1]);
$user = db_fetch_object($result);
......@@ -57,7 +56,7 @@ function linkit_user_linkit_get_search_styled_link($string) {
/**
* Implementation of hook_linkit_info_plugins().
*
*
* This is used by linkit_permissions
*/
function linkit_user_linkit_info_plugins() {
......
<?php
<?php
/**
* @file
* Extend Linkit with views links.
......@@ -11,7 +10,7 @@
*/
function linkit_views_linkit_load_plugins($string) {
$matches = array();
// Get all page displays in view, and create temporary table
$temp_table = 'CREATE TEMPORARY TABLE {linkit_tmp_view_table} (title VARCHAR(128) NOT NULL, path VARCHAR(128) NOT NULL)';
db_query($temp_table);
......@@ -21,8 +20,8 @@ function linkit_views_linkit_load_plugins($string) {
while ($node = db_fetch_object($result)) {
$optinos = unserialize($node->display_options);
db_query("INSERT INTO {linkit_tmp_view_table} (title, path) VALUES ('%s', '%s')", $node->name, $optinos['path']);
}
}
$result = db_query("SELECT * FROM {linkit_tmp_view_table} WHERE LOWER(path) LIKE LOWER('%%%s%%')", $string);
while ($node = db_fetch_object($result)) {
$matches['view'][] = array(
......@@ -32,14 +31,14 @@ function linkit_views_linkit_load_plugins($string) {
'type' => 'Views',
),
);
}
}
return $matches;
}
/**
* Implementation of hook_linkit_info_plugins().
*
*
* This is used by linkit_permissions
*/
function linkit_views_linkit_info_plugins() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment