CODE STYLE class.dashletProcessMakerCommunity.php class.dashletProcessMakerEnterprise.php class.dashletRssReader.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 12:38:43 -04:00
parent 9a683be6ae
commit 4a9180e95f
3 changed files with 141 additions and 127 deletions

View File

@@ -2,25 +2,30 @@
require_once 'classes/interfaces/dashletInterface.php'; require_once 'classes/interfaces/dashletInterface.php';
class dashletProcessMakerCommunity implements DashletInterface { class dashletProcessMakerCommunity implements DashletInterface
{
const version = '1.0'; const version = '1.0';
public static function getAdditionalFields($className) { public static function getAdditionalFields ($className)
$additionalFields = array(); {
$additionalFields = array ();
return $additionalFields; return $additionalFields;
} }
public static function getXTemplate($className) { public static function getXTemplate ($className)
{
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>"; return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
} }
public function setup($config) { public function setup ($config)
{
return true; return true;
} }
public function render ($width = 300) { public function render ($width = 300)
{
$html = " $html = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">

View File

@@ -2,25 +2,30 @@
require_once 'classes/interfaces/dashletInterface.php'; require_once 'classes/interfaces/dashletInterface.php';
class dashletProcessMakerEnterprise implements DashletInterface { class dashletProcessMakerEnterprise implements DashletInterface
{
const version = '1.0'; const version = '1.0';
public static function getAdditionalFields($className) { public static function getAdditionalFields ($className)
$additionalFields = array(); {
$additionalFields = array ();
return $additionalFields; return $additionalFields;
} }
public static function getXTemplate($className) { public static function getXTemplate ($className)
{
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>"; return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
} }
public function setup($config) { public function setup ($config)
{
return true; return true;
} }
public function render ($width = 300) { public function render ($width = 300)
{
$html = " $html = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">

View File

@@ -2,12 +2,14 @@
require_once 'classes/interfaces/dashletInterface.php'; require_once 'classes/interfaces/dashletInterface.php';
class dashletRssReader implements DashletInterface { class dashletRssReader implements DashletInterface
{
const version = '1.0'; const version = '1.0';
public static function getAdditionalFields($className) { public static function getAdditionalFields ($className)
$additionalFields = array(); {
$additionalFields = array ();
$urlFrom = new stdclass(); $urlFrom = new stdclass();
$urlFrom->xtype = 'textfield'; $urlFrom->xtype = 'textfield';
@@ -22,86 +24,88 @@ class dashletRssReader implements DashletInterface {
return $additionalFields; return $additionalFields;
} }
public static function getXTemplate($className) { public static function getXTemplate ($className)
{
return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>"; return "<iframe src=\"{page}?DAS_INS_UID={id}\" width=\"{width}\" height=\"207\" frameborder=\"0\"></iframe>";
} }
public function setup($config) { public function setup ($config)
$this->urlFrom = isset($config['DAS_URL']) ? $config['DAS_URL'] : "http://license.processmaker.com/syspmLicenseSrv/en/green/services/rssAP"; {
$this->urlFrom = isset( $config['DAS_URL'] ) ? $config['DAS_URL'] : "http://license.processmaker.com/syspmLicenseSrv/en/green/services/rssAP";
return true; return true;
} }
public function render ($width = 300) { public function render ($width = 300)
{
$pCurl = curl_init(); $pCurl = curl_init();
curl_setopt($pCurl, CURLOPT_URL, $this->urlFrom); curl_setopt( $pCurl, CURLOPT_URL, $this->urlFrom );
curl_setopt($pCurl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $pCurl, CURLOPT_RETURNTRANSFER, true );
curl_setopt($pCurl, CURLOPT_FOLLOWLOCATION, false); curl_setopt( $pCurl, CURLOPT_FOLLOWLOCATION, false );
curl_setopt($pCurl, CURLOPT_AUTOREFERER, true); curl_setopt( $pCurl, CURLOPT_AUTOREFERER, true );
//To avoid SSL error //To avoid SSL error
curl_setopt($pCurl, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt( $pCurl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt($pCurl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt( $pCurl, CURLOPT_SSL_VERIFYPEER, 0 );
//To avoid timeouts //To avoid timeouts
curl_setopt($pCurl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt( $pCurl, CURLOPT_CONNECTTIMEOUT, 10 );
curl_setopt($pCurl, CURLOPT_TIMEOUT, 20); curl_setopt( $pCurl, CURLOPT_TIMEOUT, 20 );
curl_setopt($pCurl, CURLOPT_NOPROGRESS, false); curl_setopt( $pCurl, CURLOPT_NOPROGRESS, false );
curl_setopt($pCurl, CURLOPT_VERBOSE, true); curl_setopt( $pCurl, CURLOPT_VERBOSE, true );
//Apply proxy settings //Apply proxy settings
$sysConf = System::getSystemConfiguration(); $sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') { if ($sysConf['proxy_host'] != '') {
curl_setopt($pCurl, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '')); curl_setopt( $pCurl, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '') );
if ($sysConf['proxy_port'] != '') { if ($sysConf['proxy_port'] != '') {
curl_setopt($pCurl, CURLOPT_PROXYPORT, $sysConf['proxy_port']); curl_setopt( $pCurl, CURLOPT_PROXYPORT, $sysConf['proxy_port'] );
} }
if ($sysConf['proxy_user'] != '') { if ($sysConf['proxy_user'] != '') {
curl_setopt($pCurl, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '')); curl_setopt( $pCurl, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : '') );
} }
curl_setopt($pCurl, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt( $pCurl, CURLOPT_HTTPHEADER, array ('Expect:'
) );
} }
$self->rss = @simplexml_load_string(curl_exec($pCurl)); $self->rss = @simplexml_load_string( curl_exec( $pCurl ) );
if($self->rss) if ($self->rss) {
{ $index = 0;
$index= 0;
$render = ''; $render = '';
$self->items = $self->rss->channel->item; $self->items = $self->rss->channel->item;
if (count($self->rss->channel)!= 0) { if (count( $self->rss->channel ) != 0) {
$status = 'true'; $status = 'true';
foreach($self->items as $self->item) foreach ($self->items as $self->item) {
{
$self->title = $self->item->title; $self->title = $self->item->title;
$self->link = $self->item->link; $self->link = $self->item->link;
$self->des = $self->item->description; $self->des = $self->item->description;
$render[] = array('link' => '<a href="'.$self->link.'" target="_blank">'.$self->title.'</a><br/>','description' => $self->des.'<br/><hr>'); $render[] = array ('link' => '<a href="' . $self->link . '" target="_blank">' . $self->title . '</a><br/>','description' => $self->des . '<br/><hr>'
$index++; );
$index ++;
} }
} } else {
else {
$status = 'Error'; $status = 'Error';
$render[] =array('link' => 'Error', 'description' =>"Unable to parse XML"); $render[] = array ('link' => 'Error','description' => "Unable to parse XML"
);
} }
} } else {
else {
$status = 'Error'; $status = 'Error';
$render[] =array('link' => 'Error', 'description' =>"Unable to parse XML"); $render[] = array ('link' => 'Error','description' => "Unable to parse XML"
);
} }
G::verifyPath ( PATH_SMARTY_C, true ); G::verifyPath( PATH_SMARTY_C, true );
$smarty = new Smarty(); $smarty = new Smarty();
$smarty->template_dir = PATH_CORE.'templates/dashboard/'; $smarty->template_dir = PATH_CORE . 'templates/dashboard/';
$smarty->compile_dir = PATH_SMARTY_C; $smarty->compile_dir = PATH_SMARTY_C;
try { try {
$smarty->assign('url', $this->urlFrom); $smarty->assign( 'url', $this->urlFrom );
$smarty->assign('render', $render); $smarty->assign( 'render', $render );
$smarty->assign('status', $status); $smarty->assign( 'status', $status );
} } catch (Exception $ex) {
catch (Exception $ex) {
print $item->key; print $item->key;
} }
$smarty->display('dashletRssReaderTemplate.html',null,null); $smarty->display( 'dashletRssReaderTemplate.html', null, null );
} }