/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-logs"); $harmoni->request->passthrough('log', 'priority', 'startYear', 'startMonth', 'startDay', 'startHour', 'endYear', 'endMonth', 'endDay', 'endHour', 'agent_id', 'node_id', 'category'); $agentManager = Services::getService("Agent"); $idManager = Services::getService("Id"); $hierarchyManager = Services::getService("Hierarchy"); /********************************************************* * the log search form *********************************************************/ // Log header $actionRows->add(new Heading(_("Logs"), 2), "100%", null, LEFT, CENTER); $loggingManager = Services::getService("Logging"); $log = $loggingManager->getLogForWriting("test_log"); $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified."); $priorityType = new Type("logging", "edu.middlebury", "normal", "An action which involves reading."); // Links to other logs $logNames = $loggingManager->getLogNamesForReading(); ob_start(); if (RequestContext::value("log")) { $currentLogName = RequestContext::value("log"); } while ($logNames->hasNext()) { $logName = $logNames->next(); if (!isset($currentLogName)) { $currentLogName = $logName; } if ($logName != $currentLogName) { print "\n<a href='"; print $harmoni->request->quickURL("logs", "browse", array("log" => $logName)); print "'>" . $logName . "</a>"; } else { print $logName; } if ($logNames->hasNext()) { print " | "; } } print " \n\t<table border='0'>\n\t\t<tr>\n\t\t\t<th valign='top'>" . _("Date Range: ") . "</th>\n\t\t\t<td>\n\n"; $startDate = $this->getStartDate(); $endDate = $this->getEndDate(); $this->printDateRangeForm($startDate, $endDate); print "\n\n\t\t\t</td>\n\t\t</tr>\n"; print "\n\t\t<tr>\n\t\t\t<th>" . _("Filters:") . "</th>\n\t\t\t<td>\n"; if (RequestContext::value('agent_id')) { print "\n\t\t\t"; $id = $idManager->getId(RequestContext::value('agent_id')); $url = $harmoni->request->mkURL("logs", "browse"); $url->setValue('agent_id', null); $agent = $agentManager->getAgent($id); print $agent->getDisplayName(); print "\n\t\t\t\t<input type='button' onclick='window.location=\""; print str_replace('&', '&', $url->write()); print "\"' value='X'/>"; } if (RequestContext::value('agent_id') && RequestContext::value('node_id')) { print "\n\t\t\t "; } if (RequestContext::value('node_id')) { print "\n\t\t\t"; $id = $idManager->getId(RequestContext::value('node_id')); $url = $harmoni->request->mkURL("logs", "browse"); $url->setValue('node_id', null); try { $node = $hierarchyManager->getNode($id); if ($node->getDisplayName()) { print $node->getDisplayName(); } else { print _("Id: ") . $nodeId->getIdString(); } } catch (UnknownIdException $e) { print $id->getIdString(); } catch (UnimplementedException $e) { print $id->getIdString(); } print "\n\t\t\t\t<input type='button' onclick='window.location=\""; print str_replace('&', '&', $url->write()); print "\"' value='X'/>"; } if ((RequestContext::value('agent_id') || RequestContext::value('node_id')) && RequestContext::value('category')) { print "\n\t\t\t "; } if (RequestContext::value('category')) { print "\n\t\t\t"; $url = $harmoni->request->mkURL("logs", "browse"); $url->setValue('category', null); print urldecode(RequestContext::value('category')); print "\n\t\t\t\t<input type='button' onclick='window.location=\""; print str_replace('&', '&', $url->write()); print "\"' value='X'/>"; } print "\n<br/><br/>"; if (isset($currentLogName)) { $log = $loggingManager->getLogForReading($currentLogName); if (method_exists($log, 'getCategories')) { print "\n\t\t\t\t<form action='"; $url = $harmoni->request->mkURL('logs', 'browse'); $url->setValue('category', null); print $url->write(); print "' method='post'>"; print "\n\t\t\t\t\t<input type='submit' value='" . _('Set Category Filter:') . "'/>"; print "\n\t\t\t\t\t<select name='" . RequestContext::name('category') . "'>"; foreach ($log->getCategories() as $category) { print "\n\t\t\t\t\t\t<option value='{$category}'>{$category}</option>"; } print "\n\t\t\t\t\t</select>"; print "\n\t\t\t\t</form>"; } } print "\n\t\t\t\t<form action='"; $url = $harmoni->request->mkURL('logs', 'browse'); $url->setValue('node_id', null); print $url->write(); print "' method='post'>"; print "\n\t\t\t\t\t<input type='submit' value='" . _('Set Node Id Filter:') . "'/>"; print "\n\t\t\t\t\t<input name='" . RequestContext::name('node_id') . "' type='text'/>"; print "\n\t\t\t\t</form>"; print "\n\t\t\t\t<form action='"; $url = $harmoni->request->mkURL('logs', 'browse'); $url->setValue('agent_id', null); print $url->write(); print "' method='post'>"; print "\n\t\t\t\t\t<input type='submit' value='" . _('Set Agent Id Filter:') . "'/>"; print "\n\t\t\t\t\t<input name='" . RequestContext::name('agent_id') . "' type='text'/>"; print "\n\t\t\t\t</form>"; print "\n\t\t\t</td></tr>"; print "\n\t</table>"; $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); // --- The Current log --- if (isset($currentLogName)) { $log = $loggingManager->getLogForReading($currentLogName); $actionRows->add(new Heading($log->getDisplayName(), 3), "100%", null, LEFT, CENTER); ob_start(); // Links to other priorities print "<strong>" . _("Priority: ") . "</strong>"; if (RequestContext::value("priority")) { $currentPriorityType = HarmoniType::fromString(RequestContext::value("priority")); $entries = $log->getEntries($formatType, $currentPriorityType); if (!$entries->hasNext()) { unset($currentPriorityType, $entries); } } $priorityTypes = $loggingManager->getPriorityTypes(); $priorityLinks = array(); while ($priorityTypes->hasNext()) { $priorityType = $priorityTypes->next(); // Only print priority types with entries $entries = $log->getEntries($formatType, $priorityType); if ($entries->hasNext()) { if (!isset($currentPriorityType)) { $currentPriorityType = $priorityType; } if (!$priorityType->isEqual($currentPriorityType)) { $string = "\n<a href='"; $string .= $harmoni->request->quickURL("logs", "browse", array("log" => RequestContext::value("log"), "priority" => $priorityType->asString())); $string .= "'>" . $priorityType->getKeyword() . "</a>"; } else { $string = $priorityType->getKeyword(); } $priorityLinks[] = $string; } unset($entries); } print implode(" | ", $priorityLinks); if (isset($currentPriorityType)) { // Entries print <<<END \t\t \t\t<script type='text/javascript'> \t\t\t/* <![CDATA[ */ \t\t \t\t\tfunction showTrace(buttonElement) { \t\t\t\tnewWindow = window.open("", "traceWindow", 'toolbar=no,width=600,height=500,resizable=yes,scrollbars=yes,status=no') \t\t\t\t// the next sibling is text, the one after that is our hidden div \t\t\t\tnewWindow.document.write(buttonElement.nextSibling.nextSibling.innerHTML) \t\t\t\tnewWindow.document.bgColor="lightpink" \t\t\t\tnewWindow.document.close() \t\t\t} \t\t \t\t\t/* ]]> */ \t\t</script> \t\t END; // Do a search if needed if (!$startDate->isEqualTo($this->minDate()) || !$endDate->isEqualTo(DateAndTime::tomorrow()) || RequestContext::value('agent_id') || RequestContext::value('node_id') || RequestContext::value('category')) { $criteria = array(); $criteria['start'] = $startDate; $criteria['end'] = $endDate; if (RequestContext::value('agent_id')) { $criteria['agent_id'] = $idManager->getId(RequestContext::value('agent_id')); } if (RequestContext::value('node_id')) { $criteria['node_id'] = $idManager->getId(RequestContext::value('node_id')); } if (RequestContext::value('category')) { $criteria['category'] = urldecode(RequestContext::value('category')); } $searchType = new Type("logging_search", "edu.middlebury", "Date-Range/Agent/Node"); $entries = $log->getEntriesBySearch($criteria, $searchType, $formatType, $currentPriorityType); } else { $entries = $log->getEntries($formatType, $currentPriorityType); } $headRow = "\n\t\t<tr>\n\t\t\t<th>timestamp</th>\n\t\t\t<th>category</th>\n\t\t\t<th>description</th>\n\t\t\t<th>trace</th>\n\t\t\t<th>agents</th>\n\t\t\t<th>nodes</th>\n\t\t</tr>"; $resultPrinter = new TableIteratorResultPrinter($entries, $headRow, 20, "printLogRow", 1); print $resultPrinter->getTable(); } if (isset($currentLogName) && isset($currentPriorityType)) { $url = $harmoni->request->quickURL('logs', 'browse_rss', array("log" => $currentLogName, "priority" => $currentPriorityType->asString())); $title = $currentLogName . " " . $currentPriorityType->getKeyword() . " " . _("Logs"); $outputHandler = $harmoni->getOutputHandler(); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<div style='text-align: right'>"; print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='RSS Icon'/>"; print "\n\t\t\t" . _("Subscribe to the RSS feed of this log"); print "\n\t\t</a>"; print "\n\t\t</div>"; } $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); } textdomain($defaultTextDomain); $harmoni->request->endNamespace(); }
/** * Answer a component containing either all slots or the search results. * * @return object Component * @access private * @since 12/4/07 */ private function getSlotList() { $slotMgr = SlotManager::instance(); if ($this->getSearchTerm()) { $slots = $this->getSlotsBySearch($this->getSearchTerm()); } else { $slots = $slotMgr->getAllSlots(); } $headRow = "\n\t<tr>\n\t\t<th>" . _("Placeholder Name") . "</th>\n\t\t<th>" . _("Type") . "</th>\n\t\t<th>" . _("Category") . "</th>\n\t\t<th>" . _("Media Quota") . "</th>\n\t\t<th>" . _("Site Exists") . "</th>\n\t\t<th>" . _("Owners") . "</th>\n\t\t<th>" . _("Actions") . "</th>\n\t</tr>"; $printer = new TableIteratorResultPrinter($slots, $headRow, 50, array($this, 'getSlotComponent')); return new Block($printer->getTable(), STANDARD_BLOCK); }