You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2007/02/22 15:16:27 UTC
svn commit: r510526 [1/2] - in
/incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs:
./ AlertDisplay.php Alerter.xsd Cached_Alerts.xml
Author: slaws
Date: Thu Feb 22 06:16:26 2007
New Revision: 510526
URL: http://svn.apache.org/viewvc?view=rev&rev=510526
Log:
Add PHP display component to Alert Aggregator
Added:
incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/
incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/AlertDisplay.php
incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/Alerter.xsd
incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/Cached_Alerts.xml
Added: incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/AlertDisplay.php
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/AlertDisplay.php?view=auto&rev=510526
==============================================================================
--- incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/AlertDisplay.php (added)
+++ incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/AlertDisplay.php Thu Feb 22 06:16:26 2007
@@ -0,0 +1,186 @@
+<?php
+include 'SCA/SCA.php';
+
+/**
+ * @service
+ * @binding.rest.rpc
+ * @types http://tuscany.apache.org/samples/alerter ./Alerter.xsd
+ */
+class AlertDisplay
+{
+ /**
+ * @reference
+ * @binding.rest.rpc http://localhost:9090/rest/sample.alerter.AlerterComponent/AlerterService
+ * @types http://tuscany.apache.org/samples/alerter ./Alerter.xsd
+ */
+ public $alert_service;
+
+ /**
+ * @return string
+ */
+ public function getAlertsHTMLTable()
+ {
+ $xmldas = SDO_DAS_XML::create("./Alerter.xsd");
+ $doc = $xmldas->loadFile("./Cached_Alerts.xml");
+ $cached_alerts = $doc->getRootDataObject();
+
+ // Use the alertService reference
+ $new_alerts = $this->alert_service->getAllNewAlerts();
+
+ foreach($new_alerts->alert as $alert){
+ $new_alert = $cached_alerts->createDataObject('alert');
+ $new_alert->title = $alert->title;
+ $new_alert->summary = $alert->summary;
+ $new_alert->address = $alert->address;
+ $new_alert->date = $alert->date;
+ $new_alert->sourceid = $alert->sourceid;
+ $new_alert->unread = true;
+ }
+
+ $return_table = "<TABLE border=\'0\'>";
+ $alert_id_number = 0;
+ foreach($cached_alerts->alert as $alert){
+ $alert->id = "alert_" . $alert_id_number;
+ $title = substr($alert->title,0,80);
+ $summary = substr($alert->summary,0,40);
+ $unread_string = $alert->unread ? "unread_title" : "read_title";
+ $return_row = <<<ALERTROW
+<TR class="source_$alert->sourceid clickable" onclick="displayAlert('$alert->address', '')">
+ <TD>
+ <SPAN id="$alert->id" class="$unread_string">$title</SPAN>
+ <SPAN class="summary"> - $summary ...</SPAN>
+ </TD>
+ <TD>
+ $alert->date
+ </TD>
+</TR>
+ALERTROW;
+ $return_table = $return_table . $return_row;
+ $alert_id_number += 1;
+ }
+ $return_table = $return_table . "</TABLE>";
+
+ // as php is one shot we have to save away the alerts we want to cache
+ $xmldas->saveFile($doc, "./Cached_Alerts.xml");
+
+ return $return_table;
+ }
+
+ /**
+ * @param string $alert_id
+ * @return string
+ */
+ public function readAlert($alert_id)
+ {
+ $xmldas = SDO_DAS_XML::create("./Alerter.xsd");
+ $doc = $xmldas->loadFile("./Cached_Alerts.xml");
+ $cached_alerts = $doc->getRootDataObject();
+
+ $return_summary = "";
+
+ foreach($cached_alerts->alert as $alert){
+SCA::$logger->log($alert->id . " vs " . $alert_id );
+ if (strcmp($alert->id,$alert_id) == 0){
+ SCA::$logger->log("Match");
+ $alert->unread = false;
+ $return_summary = "<PRE>" . $alert->summary . "</PRE>";
+ }
+ }
+
+ // as php is one shot we have to save away the alerts we want to cache
+ $xmldas->saveFile($doc, "./Cached_Alerts.xml");
+
+ return $return_summary;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAlertSourcesHTMLTable()
+ {
+ # Use the alertService reference
+ $alert_sources = $this->alert_service->getAlertSources();
+
+// some debug
+//ob_start();
+//print_r( $alert_sources );
+//$debug = ob_get_contents();
+//ob_end_clean();
+//SCA::$logger->log($debug);
+
+ $return_table = "<TABLE border='0'>\n";
+
+ foreach ($alert_sources->source as $alert_source){
+ $source_id = $alert_source->id;
+ $return_row = <<<SOURCEROW
+<TR CLASS="source_$source_id" >
+ <TD CLASS="clickable" ONCLICK="displayAlert('$alert_source->address', '')">
+ <IMG SRC="rss.png"/> $alert_source->name
+ </TD>
+ <TD CLASS="clickable link" ONCLICK="showEditSource('$source_id')">Edit</TD>
+ <TD CLASS="clickable link" ONCLICK="deleteSource('$source_id')">Delete</TD>
+</TR>
+<TR ID="edit_source_$source_id" CLASS="hidden source_$source_id">
+ <TD COLSPAN="3">
+ <TABLE CLASS="sourceDetailsTable">
+ <TR>
+ <TD>Source name:</TD>
+ <TD>
+ <INPUT ID="source_{$source_id}_name" TYPE="TEXT" SIZE="50" VALUE="$alert_source->name"/>
+ </TD>
+ </TR>
+ <TR>
+ <TD>Source address:</TD>
+ <TD>
+ <INPUT ID="source_{$source_id}_address" TYPE="TEXT" SIZE="50" VALUE="$alert_source->address"/>
+ </TD>
+ </TR>
+ <TR>
+ <TD>
+ <INPUT ID="source_{$source_id}_type" TYPE="HIDDEN" VALUE="$source_id"/>
+ <INPUT TYPE="BUTTON" VALUE="Update" ONCLICK="updateSource('$source_id')"/>
+ <INPUT TYPE="BUTTON" VALUE="Cancel" ONCLICK="hideEditSource('$source_id')"/>
+ </TD>
+ </TR>
+ </TABLE>
+ </TD>
+</TR>
+SOURCEROW;
+ $return_table = $return_table . $return_row;
+ }
+
+ $return_table = $return_table . "</TABLE>\n";
+ return $return_table;
+ }
+
+ /**
+ * @param integer $source_id
+ * @return string
+ */
+ public function deleteAlertSource($source_id){
+ # Use the alertService reference
+ $this->alertService->removeAlertSource($source_id);
+
+ //TODO
+ }
+
+ /**
+ * @param source $alert_source http://tuscany.apache.org/samples/alerter
+ */
+ public function addAlertSource($alert_source){
+ # Use the alertService reference
+ $this->alertService->addAlertSource($alert_source);
+ }
+
+ /**
+ * @param source $alert_source http://tuscany.apache.org/samples/alerter
+ */
+ public function updateAlertSource($alert_source){
+ # Use the alertService reference
+ $this->alertService->updateAlertSource($alert_source);
+ }
+}
+?>
+
+
+
Added: incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/Alerter.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/Alerter.xsd?view=auto&rev=510526
==============================================================================
--- incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/Alerter.xsd (added)
+++ incubator/tuscany/cpp/sca/samples/AlertAggregator/httpserver.php/htdocs/Alerter.xsd Thu Feb 22 06:16:26 2007
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema targetNamespace="http://tuscany.apache.org/samples/alerter"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://tuscany.apache.org/samples/alerter">
+ <element name="alerts" type="ns:alerts"/>
+
+ <complexType name="alert">
+ <sequence>
+ <element name="title" type="string"/>
+ <element name="summary" type="string"/>
+ <element name="address" type="anyURI" maxOccurs="1" minOccurs="1"/>
+ <element name="date" type="string" maxOccurs="1" minOccurs="1"/>
+ </sequence>
+ <attribute name="sourceid" type="string" use="optional"/>
+ <attribute name="unread" type="boolean" use="optional"/>
+ <attribute name="id" type="string" use="optional"/>
+ </complexType>
+
+ <complexType name="alerts">
+ <sequence>
+ <element name="alert" type="ns:alert" maxOccurs="unbounded" minOccurs="0" />
+ </sequence>
+ </complexType>
+
+ <element name="config" type="ns:config"/>
+ <element name="source" type="ns:source"/>
+
+ <complexType name="source">
+ <sequence>
+ <element name="name" type="string" maxOccurs="1" minOccurs="1"/>
+ <element name="address" type="anyURI" maxOccurs="1" minOccurs="1"/>
+ <element name="lastChecked" type="string" maxOccurs="1" minOccurs="0"/>
+ <element name="feedAddress" type="string" maxOccurs="1" minOccurs="0"/>
+ <element name="popServer" type="string" maxOccurs="1" minOccurs="0"/>
+ <element name="popUsername" type="string" maxOccurs="1" minOccurs="0"/>
+ <element name="popPassword" type="string" maxOccurs="1" minOccurs="0"/>
+ <any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="optional"/>
+ <attribute name="type" use="required">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="rss"/>
+ <enumeration value="pop"/>
+ <enumeration value="nntp"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ </complexType>
+
+ <complexType name="config">
+ <sequence>
+ <element name="source" type="ns:source" maxOccurs="unbounded" minOccurs="0"/>
+ </sequence>
+ </complexType>
+</schema>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org