Skip to content

Commit

Permalink
- add Pixelio parser
Browse files Browse the repository at this point in the history
  • Loading branch information
R.Brown committed Feb 6, 2014
1 parent 1f6f4d7 commit 10cd3e8
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
1 change: 1 addition & 0 deletions credit-tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
require_once(plugin_dir_path(__FILE__) . '/php/parser/parser.php');
require_once(plugin_dir_path(__FILE__) . '/php/parser/fotolia.php');
require_once(plugin_dir_path(__FILE__) . '/php/parser/istockphoto.php');
require_once(plugin_dir_path(__FILE__) . '/php/parser/pixelio.php');

// Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively.
register_activation_hook(__FILE__, array('Credit_Tracker', 'activate'));
Expand Down
22 changes: 22 additions & 0 deletions options.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ function ct_get_sources_array()
'caption' => 'Getty Images',
'copyright' => 'get_getty_images_copyright',
'retriever' => 'get_getty_images_metadata'
),
'pixelio' => array(
'caption' => 'Pixelio',
'copyright' => 'get_pixelio_copyright',
'retriever' => 'get_pixelio_metadata'
)
);
return $sources;
Expand Down Expand Up @@ -615,4 +620,21 @@ function get_getty_images_metadata($number)
return $item;
}

/**
* Pixelio: copyright
*/
function get_pixelio_copyright()
{
return Pixelio::COPYRIGHT;
}

/**
* Pixelio: metadata
*/
function get_pixelio_metadata($number)
{
$parser = new Pixelio();
return $parser->execute($number);
}

?>
43 changes: 43 additions & 0 deletions php/parser/pixelio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* Pixelio parser
*
* @package parser
* @author Labs64 <[email protected]>
**/
class Pixelio extends Parser
{

const COPYRIGHT = '&copy; %author% / <a href="http://www.pixelio.de" target="_blank">PIXELIO</a>';

const BASE_URL = 'http://www.pixelio.de/media/';

function __construct()
{
parent::__construct();
}

protected function parse($number)
{
$item = parent::parse($number);
$item['source'] = 'Pixelio';
$item['publisher'] = 'Pixelio';
$item['license'] = 'Royalty-free';

$url = self::BASE_URL . $number;
$doc = new DOMDocument();
$html = @$doc->loadHTMLFile($url);
if ($html) {
$xpath = new DOMXPath($doc);

$tags = $xpath->query("//tr/td[contains(., 'Fotograf:')]/following::td[1]/a");
if (!is_null($tags) && $tags->length > 0) {
$item['author'] = $tags->item(0)->textContent;
}
}

return $item;
}

}
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ Yes you can! Join in on our [GitHub repository](https://github.com/Labs64/credit
== Changelog ==

= 0.9.9 =
* *TODO*
* Enable Pixelio

= 0.9.8 =
* Change default fields set at Media Library to Ident-Nr., Source, Author
* Enable Fotolia parser
* Enable Fotolia

= 0.9.7 =
* Test and approve plugin for WordPress 3.8
Expand Down

0 comments on commit 10cd3e8

Please sign in to comment.