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
This commit is contained in:
79
workflow/engine/classes/class.dashletRssReader.php
Normal file
79
workflow/engine/classes/class.dashletRssReader.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-->
|
||||
<!--<html xmlns="http://www.w3.org/1999/xhtml">-->
|
||||
<head>
|
||||
<title></title>
|
||||
<meta http-equiv="refresh" content="30;url="$url>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
background: #FFFFFF;
|
||||
font: 100% arial, verdana, helvetica, sans-serif;
|
||||
color: #000000;
|
||||
}
|
||||
#container{
|
||||
margin: 0 auto;
|
||||
}
|
||||
.clearf{
|
||||
clear: both;
|
||||
height: 0;
|
||||
line-height: 0;
|
||||
font-size: 0;
|
||||
}
|
||||
.icon{
|
||||
float:left;
|
||||
margin-left: 5%;
|
||||
width: 13%;
|
||||
}
|
||||
.description{
|
||||
float: right;
|
||||
margin-right: 1%;
|
||||
width: 90%;
|
||||
font-size: 64%;
|
||||
text-align : justify;
|
||||
}
|
||||
|
||||
.icon img{
|
||||
width: 35px;
|
||||
}
|
||||
|
||||
.description strong{
|
||||
color: #2C2C2C;
|
||||
}
|
||||
|
||||
.description a{
|
||||
color: #1A4897;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.icon, .description{
|
||||
margin-top: 0.20em;
|
||||
}
|
||||
error{
|
||||
font-family:verdana;
|
||||
font-size:14px;
|
||||
color:red;
|
||||
/*background-color:maroon;*/
|
||||
}
|
||||
/*TD{font-family: arial,verdana,helvetica,sans-serif; font-size: 8pt;*/
|
||||
/*}*/
|
||||
{/literal}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table cellspacing="0" cellpadding="0" border="0" width="99%">
|
||||
|
||||
{if $status eq "Error"}
|
||||
<br/><br/><br/>
|
||||
<tr>
|
||||
<td style=" font-family:verdana; font-size:22px; color:Red;" align="center">{$render[0].link}</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td style=" font-family:verdana; font-size:19px; color:Red;" align="center">{$render[0].description}</td>
|
||||
</tr>
|
||||
{else}
|
||||
{section name=index loop=$render}
|
||||
<tr >
|
||||
<td class="description a">{$render[index].link}</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td class="description">{$render[index].description}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
{/if}
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
</body>
|
||||
|
||||
<!--</html>-->
|
||||
Reference in New Issue
Block a user