Files
luos/workflow/engine/classes/class.dashletRssReader.php
Marco Antonio Nina 19d91e7db7 BUG 0000 dashlet to add new rss url SOLVED
- Added a new class to dashlet and a template, where you only need the url as a parameter to show rss xml
2012-03-28 18:36:37 -04:00

79 lines
2.3 KiB
PHP

<?php
require_once 'classes/interfaces/dashletInterface.php';
class dashletRssReader implements DashletInterface {
public static function getAdditionalFields($className) {
$additionalFields = array();
$urlFrom = new stdclass();
$urlFrom->xtype = 'textfield';
$urlFrom->name = 'DAS_URL';
$urlFrom->fieldLabel = 'Url';
$urlFrom->width = 250;
$urlFrom->maxLength = 150;
$urlFrom->allowBlank = false;
$urlFrom->value = "http://";
$additionalFields[] = $urlFrom;
return $additionalFields;
}
public static function getXTemplate($className) {
//Metodo q funcion bien
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
}
public function setup($config) {
$this->urlFrom = isset($config['DAS_URL']) ? $config['DAS_URL'] : "http://license.processmaker.com/syspmLicenseSrv/en/green/services/rssAP";
return true;
}
public function render ($width = 300) {
$self->url = $this->urlFrom;
$self->rss = @simplexml_load_file($self->url);
if($self->rss)
{
$index= 0;
$render = '';
$self->items = $self->rss->channel->item;
if (count($self->rss->channel)!= 0) {
$status = 'true';
foreach($self->items as $self->item)
{
$self->title = $self->item->title;
$self->link = $self->item->link;
$self->des = $self->item->description;
$render[] = array('link' => '<a href="'.$self->link.'" target="_blank">'.$self->title.'</a><br/>','description' => $self->des.'<br/><hr>');
$index++;
}
}
else {
$status = 'Error';
$render[] =array('link' => 'Error', 'description' =>"Unable to parse XML");
}
}
else {
$status = 'Error';
$render[] =array('link' => 'Error', 'description' =>"Unable to parse XML");
}
G::verifyPath ( PATH_SMARTY_C, true );
$smarty = new Smarty();
$smarty->template_dir = PATH_CORE.'templates/dashboard/';
$smarty->compile_dir = PATH_SMARTY_C;
try {
$smarty->assign('url', $this->urlFrom);
$smarty->assign('render', $render);
$smarty->assign('status', $status);
}
catch (Exception $ex) {
print $item->key;
}
$smarty->display('dashletRssReaderTemplate.html',null,null);
}
}