Created
January 13, 2015 09:48
-
-
Save cmnstmntmn/ae3be0ab28ee2fbd588a to your computer and use it in GitHub Desktop.
This file contains hidden or 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); | |
$result->setAttribute("email", "http://www.gravatar.com/avatar/" . md5(strtolower($email)) . "?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
$result->setAttribute ads email attribute to the parent .. no ideea how to target child nodes