@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $etag = trim($parser->data['headers']['etag']); |
| 105 | 105 | |
| 106 | 106 | $feed_etag = $this->_feed->get_parameter('net.nemein.rss', 'etag'); |
| 107 | - if ( !empty($feed_etag) |
|
| 107 | + if (!empty($feed_etag) |
|
| 108 | 108 | && $feed_etag == $etag) |
| 109 | 109 | { |
| 110 | 110 | // Feed hasn't changed, skip updating |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $guid = $item->get_id(); |
| 199 | 199 | $title = $item->get_title(); |
| 200 | 200 | |
| 201 | - if ( ( empty($title) |
|
| 201 | + if ((empty($title) |
|
| 202 | 202 | || trim($title) == '...') |
| 203 | 203 | && empty($guid)) |
| 204 | 204 | { |
@@ -216,8 +216,7 @@ discard block |
||
| 216 | 216 | $article->_activitystream_verb = 'http://community-equity.org/schema/1.0/clone'; |
| 217 | 217 | $article->_rcs_message = sprintf(midcom::get()->i18n->get_string('%s was imported from %s', 'net.nemein.rss'), $title, $this->_feed->title); |
| 218 | 218 | |
| 219 | - $values = array |
|
| 220 | - ( |
|
| 219 | + $values = array( |
|
| 221 | 220 | 'title' => $title, |
| 222 | 221 | $this->_guid_property => $guid, // FIXME: This breaks with URLs longer than 255 chars |
| 223 | 222 | 'content' => $item->get_content(), |
@@ -277,7 +276,7 @@ discard block |
||
| 277 | 276 | $meta_values['published'] = $article_date; |
| 278 | 277 | } |
| 279 | 278 | |
| 280 | - if ( $this->apply_values($article, $values, $meta_values) |
|
| 279 | + if ($this->apply_values($article, $values, $meta_values) |
|
| 281 | 280 | && !$article->update()) |
| 282 | 281 | { |
| 283 | 282 | return false; |
@@ -312,7 +311,7 @@ discard block |
||
| 312 | 311 | private function find_author(net_nemein_rss_parser_item $item) |
| 313 | 312 | { |
| 314 | 313 | // Try to figure out item author |
| 315 | - if ( $this->_feed->forceauthor |
|
| 314 | + if ($this->_feed->forceauthor |
|
| 316 | 315 | && $this->_feed->defaultauthor) |
| 317 | 316 | { |
| 318 | 317 | // Feed has a "default author" set, use it |
@@ -320,7 +319,7 @@ discard block |
||
| 320 | 319 | } |
| 321 | 320 | $author = $this->match_item_author($item); |
| 322 | 321 | $fallback_person_id = 1; |
| 323 | - if ( !$author |
|
| 322 | + if (!$author |
|
| 324 | 323 | || $author->id == $fallback_person_id) |
| 325 | 324 | { |
| 326 | 325 | if ($this->_feed->defaultauthor) |
@@ -441,7 +440,7 @@ discard block |
||
| 441 | 440 | $purge_guids = array(); |
| 442 | 441 | foreach ($local_items as $item) |
| 443 | 442 | { |
| 444 | - if ( midcom::get()->componentloader->is_installed('net.nemein.favourites') |
|
| 443 | + if (midcom::get()->componentloader->is_installed('net.nemein.favourites') |
|
| 445 | 444 | && midcom::get()->componentloader->load_graceful('net.nemein.favourites')) |
| 446 | 445 | { |
| 447 | 446 | // If it has been favorited keep it |
@@ -150,8 +150,7 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | $item->set_local_guid($guid); |
| 152 | 152 | debug_add("Imported item " . $item->get_id() . ' as ' . $guid, MIDCOM_LOG_INFO); |
| 153 | - } |
|
| 154 | - else |
|
| 153 | + } else |
|
| 155 | 154 | { |
| 156 | 155 | debug_add("Failed to import item " . $item->get_id() . ': ' . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR); |
| 157 | 156 | } |
@@ -282,8 +281,7 @@ discard block |
||
| 282 | 281 | { |
| 283 | 282 | return false; |
| 284 | 283 | } |
| 285 | - } |
|
| 286 | - else |
|
| 284 | + } else |
|
| 287 | 285 | { |
| 288 | 286 | $this->apply_values($article, $values, $meta_values); |
| 289 | 287 | if (!$article->create()) |
@@ -327,8 +325,7 @@ discard block |
||
| 327 | 325 | { |
| 328 | 326 | // Feed has a "default author" set, use it |
| 329 | 327 | $author = new midcom_db_person($this->_feed->defaultauthor); |
| 330 | - } |
|
| 331 | - else |
|
| 328 | + } else |
|
| 332 | 329 | { |
| 333 | 330 | // Fall back to "Midgard Admin" just in case |
| 334 | 331 | $author = new midcom_db_person($fallback_person_id); |
@@ -373,8 +370,7 @@ discard block |
||
| 373 | 370 | { |
| 374 | 371 | $symlink_topic = new midcom_db_topic($symlink); |
| 375 | 372 | $article->topic = $symlink_topic->id; |
| 376 | - } |
|
| 377 | - catch (midcom_error $e) |
|
| 373 | + } catch (midcom_error $e) |
|
| 378 | 374 | { |
| 379 | 375 | $e->log(); |
| 380 | 376 | } |
@@ -484,8 +480,7 @@ discard block |
||
| 484 | 480 | $name = html_entity_decode($name, ENT_QUOTES, midcom::get()->i18n->get_current_charset()); |
| 485 | 481 | // Atom feed, the value can be either full name or username |
| 486 | 482 | $author_info['user_or_full'] = $name; |
| 487 | - } |
|
| 488 | - else |
|
| 483 | + } else |
|
| 489 | 484 | { |
| 490 | 485 | $name = html_entity_decode($email, ENT_QUOTES, midcom::get()->i18n->get_current_charset()); |
| 491 | 486 | } |
@@ -493,15 +488,13 @@ discard block |
||
| 493 | 488 | if (!preg_match('/(<|\()/', $name)) |
| 494 | 489 | { |
| 495 | 490 | $author_info['user_or_full'] = $name; |
| 496 | - } |
|
| 497 | - else |
|
| 491 | + } else |
|
| 498 | 492 | { |
| 499 | 493 | if (strstr($name, '<')) |
| 500 | 494 | { |
| 501 | 495 | // The classic "Full Name <email>" format |
| 502 | 496 | $regex = '/(?<fullname>.+) <?(?<email>[a-zA-Z0-9_.-]+?@[a-zA-Z0-9_.-]+)>?[ ,]?/'; |
| 503 | - } |
|
| 504 | - else |
|
| 497 | + } else |
|
| 505 | 498 | { |
| 506 | 499 | // The classic "email (Full Name)" format |
| 507 | 500 | $regex = '/^(?<email>[a-zA-Z0-9_.-]+?@[a-zA-Z0-9_.-]+) \((?<fullname>.+)\)$/'; |
@@ -520,8 +513,7 @@ discard block |
||
| 520 | 513 | { |
| 521 | 514 | // This value has a space in it, assuming full name |
| 522 | 515 | $author_info['full_name'] = $author_info['user_or_full']; |
| 523 | - } |
|
| 524 | - else |
|
| 516 | + } else |
|
| 525 | 517 | { |
| 526 | 518 | $author_info['username'] = $author_info['user_or_full']; |
| 527 | 519 | } |