Skip to content

Instantly share code, notes, and snippets.

@cmnstmntmn
Created January 13, 2015 09:48
Embed
What would you like to do?
<?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);
$result->setAttribute("email", "http://www.gravatar.com/avatar/" . md5(strtolower($email)) . "?s=" . $size . $this->size . "&amp;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;
}
}
@cmnstmntmn
Copy link
Author

$result->setAttribute ads email attribute to the parent .. no ideea how to target child nodes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment