-
-
Save jonmifsud/0e27371266e50cd037ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once TOOLKIT . '/class.datasource.php'; | |
class datasourcerecent_comments extends SectionDatasource | |
{ | |
public $dsParamROOTELEMENT = 'recent-comments'; | |
public $dsParamORDER = 'desc'; | |
public $dsParamPAGINATERESULTS = 'no'; | |
public $dsParamLIMIT = '20'; | |
public $dsParamSTARTPAGE = '1'; | |
public $dsParamREDIRECTONEMPTY = 'no'; | |
public $dsParamREDIRECTONFORBIDDEN = 'no'; | |
public $dsParamREDIRECTONREQUIRED = 'no'; | |
public $dsParamSORT = 'system:creation-date'; | |
public $dsParamHTMLENCODE = 'no'; | |
public $dsParamASSOCIATEDENTRYCOUNTS = 'yes'; | |
public $dsParamINCLUDEDELEMENTS = array( | |
'system:date', | |
'articol', | |
'nume: formatted', | |
'excerpt', | |
'e-mail: formatted', | |
); | |
public function __construct($env = null, $process_params = true) | |
{ | |
parent::__construct($env, $process_params); | |
$this->_dependencies = array(); | |
} | |
public function getSource() | |
{ | |
return '16'; | |
} | |
public function allowEditorToParse() | |
{ | |
return true; | |
} | |
public function execute(array &$param_pool = null) | |
{ | |
$result = new XMLElement($this->dsParamROOTELEMENT); | |
try{ | |
$result = parent::execute($param_pool); | |
$entries = $result->getChildrenByName('entry'); | |
foreach($entries as $entry){ | |
$emails = $entry->getChildrenByName('email'); | |
$email = $emails[0]; | |
$emailValue = $email->getValue(); | |
$email->setAttribute("email", "http://www.gravatar.com/avatar/" . md5(strtolower($emailValue)) . "?s=" . $size . $this->size . "&d=" . $this->_env["param"]["root"] . "/extensions/gravatar/assets/default.gif"); | |
} | |
} catch (FrontendPageNotFoundException $e) { | |
// Work around. This ensures the 404 page is displayed and | |
// is not picked up by the default catch() statement below | |
FrontendPageNotFoundExceptionHandler::render($e); | |
} catch (Exception $e) { | |
$result->appendChild(new XMLElement('error', $e->getMessage() . ' on ' . $e->getLine() . ' of file ' . $e->getFile())); | |
return $result; | |
} | |
if ($this->_force_empty_result) { | |
$result = $this->emptyXMLSet(); | |
} | |
if ($this->_negate_result) { | |
$result = $this->negateXMLSet(); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment