Skip to content
Snippets Groups Projects
Commit b91cea86 authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Coder review fixes.

parent 91884d37
No related branches found
No related tags found
No related merge requests found
...@@ -228,7 +228,8 @@ function feeds_unlock_tab_form($form, &$form_state, $importer_id, $node = NULL) ...@@ -228,7 +228,8 @@ function feeds_unlock_tab_form($form, &$form_state, $importer_id, $node = NULL)
); );
$form['actions']['submit']['#disabled'] = TRUE; $form['actions']['submit']['#disabled'] = TRUE;
$form['actions']['submit']['#value'] = t('Unlock (disabled)'); $form['actions']['submit']['#value'] = t('Unlock (disabled)');
} else { }
else {
$form['actions']['submit']['#value'] = t('Unlock'); $form['actions']['submit']['#value'] = t('Unlock');
} }
return $form; return $form;
...@@ -238,17 +239,17 @@ function feeds_unlock_tab_form($form, &$form_state, $importer_id, $node = NULL) ...@@ -238,17 +239,17 @@ function feeds_unlock_tab_form($form, &$form_state, $importer_id, $node = NULL)
* Form submit handler. Resets all feeds state. * Form submit handler. Resets all feeds state.
*/ */
function feeds_unlock_tab_form_submit($form, &$form_state) { function feeds_unlock_tab_form_submit($form, &$form_state) {
drupal_set_message('Import Unlocked'); drupal_set_message(t('Import Unlocked'));
$form_state['redirect'] = $form['#redirect']; $form_state['redirect'] = $form['#redirect'];
$feed_nid = empty($form['#feed_nid']) ? 0 : $form['#feed_nid']; $feed_nid = empty($form['#feed_nid']) ? 0 : $form['#feed_nid'];
$importer_id = $form['#importer_id']; $importer_id = $form['#importer_id'];
//Is there a more API-friendly way to set the state? //Is there a more API-friendly way to set the state?
db_update('feeds_source') db_update('feeds_source')
->condition('id', $importer_id) ->condition('id', $importer_id)
->condition('feed_nid', $feed_nid) ->condition('feed_nid', $feed_nid)
->fields(array('state' => FALSE)) ->fields(array('state' => FALSE))
->execute(); ->execute();
} }
/** /**
......
...@@ -15,16 +15,16 @@ function feeds_rules_event_info() { ...@@ -15,16 +15,16 @@ function feeds_rules_event_info() {
foreach (feeds_importer_load_all() as $importer) { foreach (feeds_importer_load_all() as $importer) {
$config = $importer->getConfig(); $config = $importer->getConfig();
$processor = feeds_plugin($config['processor']['plugin_key'], $importer->id); $processor = feeds_plugin($config['processor']['plugin_key'], $importer->id);
// It's possible to get FeedsMissingPlugin here which will break things // It's possible to get FeedsMissingPlugin here which will break things
// since it doesn't implement FeedsProcessor::entityType(). // since it doesn't implement FeedsProcessor::entityType().
if (!$processor instanceof FeedsProcessor) { if (!$processor instanceof FeedsProcessor) {
continue; continue;
} }
$entity_type = $processor->entityType(); $entity_type = $processor->entityType();
$label = isset($entity_info[$entity_type]['label']) ? $entity_info[$entity_type]['label'] : $entity_type; $label = isset($entity_info[$entity_type]['label']) ? $entity_info[$entity_type]['label'] : $entity_type;
$info['feeds_import_'. $importer->id] = array( $info['feeds_import_'. $importer->id] = array(
'label' => t('Before saving an item imported via @name.', array('@name' => $importer->config['name'])), 'label' => t('Before saving an item imported via @name.', array('@name' => $importer->config['name'])),
'group' => t('Feeds'), 'group' => t('Feeds'),
...@@ -69,8 +69,8 @@ function feeds_rules_action_info() { ...@@ -69,8 +69,8 @@ function feeds_rules_action_info() {
*/ */
function feeds_action_skip_item($entity_wrapper) { function feeds_action_skip_item($entity_wrapper) {
$entity = $entity_wrapper->value(); $entity = $entity_wrapper->value();
if(isset($entity->feeds_item)) { if (isset($entity->feeds_item)) {
$entity->feeds_item->skip = TRUE; $entity->feeds_item->skip = TRUE;
} }
} }
......
<?php <?php
/**
* @file
* Empty module file.
*/
include_once('feeds_import.features.inc'); include_once('feeds_import.features.inc');
<?php <?php
/**
* @file
* Empty module file.
*/
include_once('feeds_news.features.inc'); include_once('feeds_news.features.inc');
<?php <?php
/** /**
* @file
* Contains CSV Parser. * Contains CSV Parser.
*
* Functions in this file are independent of the Feeds specific implementation. * Functions in this file are independent of the Feeds specific implementation.
* Thanks to jpetso http://drupal.org/user/56020 for most of the code in this * Thanks to jpetso http://drupal.org/user/56020 for most of the code in this
* file. * file.
...@@ -155,7 +157,7 @@ class ParserCSV { ...@@ -155,7 +157,7 @@ class ParserCSV {
* reached the timeout set with setTimeout() or the line limit set with * reached the timeout set with setTimeout() or the line limit set with
* setLineLimit(). * setLineLimit().
* *
* @see ParserCSV::setStartByte($start); * @see ParserCSV::setStartByte()
*/ */
public function lastLinePos() { public function lastLinePos() {
return $this->lastLinePos; return $this->lastLinePos;
......
<?php <?php
/**
* @file
* Contains the FeedsCSVParser class.
*/
/** /**
* Parses a given file as a CSV file. * Parses a given file as a CSV file.
*/ */
......
<?php <?php
/**
* @file
* Contains the FeedsFetcher and related classes.
*/
/** /**
* Base class for all fetcher results. * Base class for all fetcher results.
*/ */
......
<?php <?php
/**
* @file
* Contains FeedsParser and related classes.
*/
/** /**
* A result of a parsing stage. * A result of a parsing stage.
*/ */
...@@ -121,7 +126,7 @@ abstract class FeedsParser extends FeedsPlugin { ...@@ -121,7 +126,7 @@ abstract class FeedsParser extends FeedsPlugin {
* The source element from $item identified by $element_key. * The source element from $item identified by $element_key.
* *
* @see FeedsProcessor::map() * @see FeedsProcessor::map()
* @see FeedsCSVParser::getSourceElement(). * @see FeedsCSVParser::getSourceElement()
*/ */
public function getSourceElement(FeedsSource $source, FeedsParserResult $result, $element_key) { public function getSourceElement(FeedsSource $source, FeedsParserResult $result, $element_key) {
if ($element_key == 'parent:uid' && if ($element_key == 'parent:uid' &&
...@@ -523,7 +528,7 @@ class FeedsDateTimeElement extends FeedsElement { ...@@ -523,7 +528,7 @@ class FeedsDateTimeElement extends FeedsElement {
* This class is a Drupal independent extension of the >= PHP 5.2 DateTime * This class is a Drupal independent extension of the >= PHP 5.2 DateTime
* class. * class.
* *
* @see FeedsDateTimeElement class * @see FeedsDateTimeElement
*/ */
class FeedsDateTime extends DateTime { class FeedsDateTime extends DateTime {
public $granularity = array(); public $granularity = array();
......
<?php <?php
/**
* @file
* Contains FeedsProcessor and related classes.
*/
// Update mode for existing items. // Update mode for existing items.
define('FEEDS_SKIP_EXISTING', 0); define('FEEDS_SKIP_EXISTING', 0);
......
<?php <?php
/**
* @file
* Contains FeedsSimplePieParser and related classes.
*/
/** /**
* Adapter to present SimplePie_Enclosure as FeedsEnclosure object. * Adapter to present SimplePie_Enclosure as FeedsEnclosure object.
*/ */
...@@ -30,8 +35,8 @@ class FeedsSimplePieEnclosure extends FeedsEnclosure { ...@@ -30,8 +35,8 @@ class FeedsSimplePieEnclosure extends FeedsEnclosure {
* Ensure that the simplepie class definitions are loaded for the enclosure when unserializing. * Ensure that the simplepie class definitions are loaded for the enclosure when unserializing.
*/ */
public function __wakeup() { public function __wakeup() {
feeds_include_library('simplepie.inc', 'simplepie'); feeds_include_library('simplepie.inc', 'simplepie');
$this->simplepie_enclosure = unserialize($this->_serialized_simplepie_enclosure); $this->simplepie_enclosure = unserialize($this->_serialized_simplepie_enclosure);
} }
/** /**
...@@ -211,7 +216,7 @@ class FeedsSimplePieParser extends FeedsParser { ...@@ -211,7 +216,7 @@ class FeedsSimplePieParser extends FeedsParser {
'name' => t('Enclosures'), 'name' => t('Enclosures'),
'description' => t('An array of enclosures attached to the feed item.'), 'description' => t('An array of enclosures attached to the feed item.'),
), ),
) + parent::getMappingSources(); ) + parent::getMappingSources();
} }
/** /**
......
<?php <?php
/**
* @file
* Contains FeedsSitemapParser and related classes.
*/
/** /**
* A parser for the Sitemap specification http://www.sitemaps.org/protocol.php * A parser for the Sitemap specification http://www.sitemaps.org/protocol.php
*/ */
......
<?php <?php
/**
* @file
* Contains FeedsSyndicationParser and related classes.
*/
/** /**
* Class definition for Common Syndication Parser. * Class definition for Common Syndication Parser.
* *
...@@ -71,6 +76,6 @@ class FeedsSyndicationParser extends FeedsParser { ...@@ -71,6 +76,6 @@ class FeedsSyndicationParser extends FeedsParser {
'name' => t('Geo Locations'), 'name' => t('Geo Locations'),
'description' => t('An array of geographic locations with a name and a position.'), 'description' => t('An array of geographic locations with a name and a position.'),
), ),
) + parent::getMappingSources(); ) + parent::getMappingSources();
} }
} }
...@@ -198,7 +198,7 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -198,7 +198,7 @@ class FeedsTermProcessor extends FeedsProcessor {
'name' => t('Term name'), 'name' => t('Term name'),
'description' => t('Name of the taxonomy term.'), 'description' => t('Name of the taxonomy term.'),
'optional_unique' => TRUE, 'optional_unique' => TRUE,
), ),
'parent' => array( 'parent' => array(
'name' => t('Parent: Term name'), 'name' => t('Parent: Term name'),
'description' => t('The name of the parent taxonomy term.'), 'description' => t('The name of the parent taxonomy term.'),
...@@ -217,7 +217,7 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -217,7 +217,7 @@ class FeedsTermProcessor extends FeedsProcessor {
'description' => array( 'description' => array(
'name' => t('Term description'), 'name' => t('Term description'),
'description' => t('Description of the taxonomy term.'), 'description' => t('Description of the taxonomy term.'),
), ),
); );
// If path is enabled expose path alias. // If path is enabled expose path alias.
...@@ -254,7 +254,8 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -254,7 +254,8 @@ class FeedsTermProcessor extends FeedsProcessor {
if ($tid = db_query("SELECT tid FROM {taxonomy_term_data} WHERE name = :name AND vid = :vid", array(':name' => $value, ':vid' => $vocabulary->vid))->fetchField()) { if ($tid = db_query("SELECT tid FROM {taxonomy_term_data} WHERE name = :name AND vid = :vid", array(':name' => $value, ':vid' => $vocabulary->vid))->fetchField()) {
return $tid; return $tid;
} }
} else if($target == 'guid') { }
elseif ($target == 'guid') {
$query = db_select('feeds_item') $query = db_select('feeds_item')
->fields('feeds_item', array('entity_id')) ->fields('feeds_item', array('entity_id'))
->condition('entity_type', 'taxonomy_term'); ->condition('entity_type', 'taxonomy_term');
...@@ -283,9 +284,10 @@ class FeedsTermProcessor extends FeedsProcessor { ...@@ -283,9 +284,10 @@ class FeedsTermProcessor extends FeedsProcessor {
* @return string * @return string
*/ */
protected function getHash($entity_id) { protected function getHash($entity_id) {
if($this->config['force_update']) { if ($this->config['force_update']) {
return ''; // dummy to always update return ''; // dummy to always update
} else { }
else {
return parent::getHash($entity_id); return parent::getHash($entity_id);
} }
} }
......
<?php <?php
/**
* @file
* Tests for the common syndication parser.
*/
/** /**
* Test cases for common syndication parser library. * Test cases for common syndication parser library.
* *
......
...@@ -91,11 +91,10 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { ...@@ -91,11 +91,10 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$this->assertEqual($count, 10, 'Accurate number of items in database.'); $this->assertEqual($count, 10, 'Accurate number of items in database.');
// Assert default input format on first imported feed node. // Assert default input format on first imported feed node.
/*
// NEEDS update. // NEEDS update.
$format = db_query_range("SELECT nr.format FROM {feeds_node_item} fi JOIN {node} n ON fi.nid = n.nid JOIN {node_revision} nr ON n.vid = nr.vid", 0, 1)->fetchField(); // $format = db_query_range("SELECT nr.format FROM {feeds_node_item} fi JOIN {node} n ON fi.nid = n.nid JOIN {node_revision} nr ON n.vid = nr.vid", 0, 1)->fetchField();
$this->assertEqual($format, filter_fallback_format(), 'Using default Input format.'); // $this->assertEqual($format, filter_fallback_format(), 'Using default Input format.');
*/
// Import again. // Import again.
$this->drupalPost("node/$nid/import", array(), 'Import'); $this->drupalPost("node/$nid/import", array(), 'Import');
...@@ -165,11 +164,10 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { ...@@ -165,11 +164,10 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$this->assertEqual($count, 10, 'Accurate number of items in database.'); $this->assertEqual($count, 10, 'Accurate number of items in database.');
// Assert input format. // Assert input format.
/*
// NEEDS update. // NEEDS update.
$format = db_query_range("SELECT nr.format FROM {feeds_node_item} fi JOIN {node} n ON fi.nid = n.nid JOIN {node_revision} nr ON n.vid = nr.vid", 0, 1)->fetchField(); // $format = db_query_range("SELECT nr.format FROM {feeds_node_item} fi JOIN {node} n ON fi.nid = n.nid JOIN {node_revision} nr ON n.vid = nr.vid", 0, 1)->fetchField();
$this->assertEqual($format, filter_fallback_format() + 1, 'Set non-default Input format.'); // $this->assertEqual($format, filter_fallback_format() + 1, 'Set non-default Input format.');
*/
// Set to update existing, remove authorship of above nodes and import again. // Set to update existing, remove authorship of above nodes and import again.
$this->setSettings('syndication', 'FeedsNodeProcessor', array('update_existing' => 2)); $this->setSettings('syndication', 'FeedsNodeProcessor', array('update_existing' => 2));
......
<?php <?php
/**
* @file
* Helper module for Feeds tests.
*/
/** /**
* Implements hook_menu(). * Implements hook_menu().
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment