/** * Build the content for this action * * @return void * @access public * @since 11/07/06 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); // ob_start(); $harmoni = Harmoni::instance(); $harmoni->request->passthrough('collection_id'); $harmoni->request->startNamespace("polyphony-tags"); $harmoni->request->passthrough('repository_id'); $harmoni->request->passthrough('system'); $actionRows->add(new Block(TagAction::getTagMenu(), STANDARD_BLOCK), "100%", null, LEFT, TOP); $items = $this->getItems(); $resultPrinter = new IteratorResultPrinter($items, 1, 5, 'getTaggedItemComponent', $this->getViewAction()); $resultLayout = $resultPrinter->getLayout("canViewItem"); // $resultLayout =$resultPrinter->getLayout(); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); // $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); $harmoni->request->forget('repository_id'); $harmoni->request->forget('system'); $harmoni->request->endNamespace(); textdomain($defaultTextDomain); $harmoni->request->passthrough('collection_id'); }
/** * Build the content for this action * * @return void * @access public * @since 11/07/06 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); // ob_start(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-tags"); $actionRows->add(new Block(TagAction::getTagMenu(), STANDARD_BLOCK), "100%", null, LEFT, TOP); // Related Tags ob_start(); print "<h3 style='margin-top: 0px; margin-bottom: 0px;'>" . _("Related Tags:") . "</h3>"; $tag = $this->getTag(); print TagAction::getTagCloudDiv($tag->getRelatedTags(TAG_SORT_FREQ), 'view', 100); $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); $items = $this->getItems(); $resultPrinter = new IteratorResultPrinter($items, 1, 5, 'getTaggedItemComponent', $this->getViewAction()); $resultLayout = $resultPrinter->getLayout("canViewItem"); // $resultLayout =$resultPrinter->getLayout(); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); // $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); $harmoni->request->endNamespace(); textdomain($defaultTextDomain); }
/** * * @param TagAction $action * @return boolean hook result */ function onStartTagShowContent(TagAction $action) { $user = common_current_user(); if ($user) { $tag = $action->trimmed('tag'); $tagsub = TagSub::pkeyGet(array('tag' => $tag, 'profile_id' => $user->id)); if ($tagsub) { $form = new TagUnsubForm($action, $tag); } else { $form = new TagSubForm($action, $tag); } $action->elementStart('div', 'entity_actions'); $action->elementStart('ul'); $action->elementStart('li', 'entity_subscribe'); $form->show(); $action->elementEnd('li'); $action->elementEnd('ul'); $action->elementEnd('div'); } return true; }
/** * Execute the Action * * @param object Harmoni $harmoni * @return mixed * @access public * @since 4/25/05 */ function execute() { $xLayout = new XLayout(); $yLayout = new YLayout(); $harmoni = Harmoni::instance(); $mainScreen = new Container($yLayout, BLOCK, 1); // :: Top Row :: // The top row for the logo and status bar. $headRow = new Container($xLayout, HEADER, 1); // The logo $logo = new Component("\n<a href='" . MYPATH . "/'> <img src='" . LOGO_URL . "' \n\t\t\t\t\t\t\tstyle='border: 0px;' alt='" . _("Concerto Logo'") . "/> </a>", BLANK, 1); $headRow->add($logo, null, null, LEFT, TOP); // Language Bar $harmoni->history->markReturnURL("polyphony/language/change"); $languageText = "\n<form action='" . $harmoni->request->quickURL("language", "change") . "' method='post'>"; $harmoni->request->startNamespace("polyphony"); $languageText .= "\n\t<div style='text-align: center'>\n\t<select name='" . $harmoni->request->getName("language") . "'>"; $harmoni->request->endNamespace(); $langLoc = Services::getService('Lang'); $currentCode = $langLoc->getLanguage(); $languages = $langLoc->getLanguages(); ksort($languages); foreach ($languages as $code => $language) { $languageText .= "\n\t\t<option value='" . $code . "'" . ($code == $currentCode ? " selected='selected'" : "") . ">"; $languageText .= $language . "</option>"; } $languageText .= "\n\t</select>"; $languageText .= "\n\t<input type='submit' />"; $languageText .= "\n\t</div>\n</form>"; $languageBar = new Component($languageText, BLANK, 1); $headRow->add($languageBar, null, null, LEFT, TOP); // Pretty Login Box $loginRow = new Container($yLayout, OTHER, 1); $headRow->add($loginRow, null, null, RIGHT, TOP); ob_start(); $authN = Services::getService("AuthN"); $agentM = Services::getService("Agent"); $idM = Services::getService("Id"); $authTypes = $authN->getAuthenticationTypes(); $users = ''; while ($authTypes->hasNext()) { $authType = $authTypes->next(); $id = $authN->getUserId($authType); if (!$id->isEqual($idM->getId('edu.middlebury.agents.anonymous'))) { $agent = $agentM->getAgent($id); $exists = false; foreach (explode("+", $users) as $user) { if ($agent->getDisplayName() == $user) { $exists = true; } } if (!$exists) { if ($users == '') { $users .= $agent->getDisplayName(); } else { $users .= " + " . $agent->getDisplayName(); } } } } if ($users != '') { print "\n<div style='text-align: right'><small>"; if (count(explode("+", $users)) == 1) { print _("User: "******"\t"; } else { print _("Users: ") . $users . "\t"; } print "<a href='" . $harmoni->request->quickURL("auth", "logout") . "'>" . _("Log Out") . "</a></small></div>"; } else { // set bookmarks for success and failure $harmoni->history->markReturnURL("polyphony/display_login"); $harmoni->history->markReturnURL("polyphony/login_fail", $harmoni->request->quickURL("user", "main")); $harmoni->request->startNamespace("harmoni-authentication"); $usernameField = $harmoni->request->getName("username"); $passwordField = $harmoni->request->getName("password"); $harmoni->request->endNamespace(); $harmoni->request->startNamespace("polyphony"); print "\n<div style='text-align: right'>" . "\n<form action='" . $harmoni->request->quickURL("auth", "login") . "' align='right' method='post'><small>" . "\n\t" . _("Username:"******" <input type='text' size='8' \n\t\t\t\t\tname='{$usernameField}'/>" . "\n\t" . _("Password:"******" <input type='password' size ='8' \n\t\t\t\t\tname='{$passwordField}'/>" . "\n\t <input type='submit' value='Log In' />" . "\n</small></form></div>\n"; $harmoni->request->endNamespace(); } $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, TOP); // User tools ob_start(); print "<div style='font-size: small; margin-top: 8px;'>"; print "<a href='" . $harmoni->request->quickURL("user", "main") . "'>"; print _("User Tools"); print "</a>"; print " | "; print "<a href='" . $harmoni->request->quickURL("admin", "main") . "'>"; print _("Admin Tools"); print "</a>"; print "</div>"; $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, BOTTOM); //Add the headerRow to the mainScreen $mainScreen->add($headRow, "100%", null, LEFT, TOP); // :: Center Pane :: $centerPane = $mainScreen->add(new Container($xLayout, OTHER, 1), "100%", null, LEFT, TOP); // use the result from previous actions if ($harmoni->printedResult) { $contentDestination = new Container($yLayout, OTHER, 1); $centerPane->add($contentDestination, null, null, LEFT, TOP); $contentDestination->add(new Block($harmoni->printedResult, 1), null, null, TOP, CENTER); $harmoni->printedResult = ''; } else { $contentDestination = $centerPane; } // use the result from previous actions if (is_object($harmoni->result)) { $contentDestination->add($harmoni->result, null, null, CENTER, TOP); } else { if (is_string($harmoni->result)) { $contentDestination->add(new Block($harmoni->result, STANDARD_BLOCK), null, null, CENTER, TOP); } } // Menu Column $menuColumn = $centerPane->add(new Container($yLayout, OTHER, 1), "140px", null, LEFT, TOP); // Main menu $menuGenerator = new ConcertoMenuGenerator(); $menuColumn->add($menuGenerator->generateMainMenu(), "140px", null, LEFT, TOP); // RSS Links $outputHandler = $harmoni->getOutputHandler(); if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction()) && RequestContext::value('collection_id')) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id'))); $title = _("RSS feed of the most recently added Assets"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); 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" . _("RSS: newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id'), 'order' => 'modification')); $title = _("RSS feed of the most recently changed Assets"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); 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" . _("RSS: recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } /* if (preg_match("/^collections\..+$/", $harmoni->getCurrentAction())) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('collection', 'rss_all_latest'); $title = _("RSS feed of the most recently added Assets across all Collections"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); 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"._("RSS: all newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('collections', 'rss_all_latest', array('order' => 'modification')); $title = _("RSS feed of the most recently changed Assets across all Collections"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); 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"._("RSS: all recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } */ if (preg_match("/^exhibitions\\.browse_exhibition\$/", $harmoni->getCurrentAction()) && RequestContext::value('exhibition_id')) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('exhibition_id' => RequestContext::value('exhibition_id'))); $title = _("RSS feed of the most recently added Slideshows in this Exhibition"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); 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" . _("RSS: newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('order' => 'modification', 'exhibition_id' => RequestContext::value('exhibition_id'))); $title = _("RSS feed of the most recently changed Slideshows in this Exhibition"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); 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" . _("RSS: recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } /* if (preg_match("/^exhibitions\.browse$/", $harmoni->getCurrentAction())) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows'); $title = _("RSS feed of the most recently added Slideshows across all Exhibitions"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); 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"._("RSS: all newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('order' => 'modification')); $title = _("RSS feed of the most recently changed Slideshows across all Exhibitions"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); 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"._("RSS: all recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } */ // Basket $basket = Basket::instance(); if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction())) { $menuColumn->add(AssetPrinter::getMultiEditOptionsBlock(), "100%", null, LEFT, TOP); } $menuColumn->add($basket->getSmallBasketBlock(EMPHASIZED_BLOCK), "100%", null, LEFT, TOP); // Collection Tags if (preg_match("/^(collection|asset|tags)\\./", $harmoni->getCurrentAction()) && $this->getCurrentRepository()) { $harmoni->request->passthrough("collection_id"); $harmoni->request->passthrough("asset_id"); $menuColumn->add(new Block("<strong>" . _("Tags in this Collection: ") . "</strong>" . TagAction::getTagCloudForRepository($this->getCurrentRepository(), 'concerto'), EMPHASIZED_BLOCK), "100%", null, LEFT, TOP); $harmoni->request->forget("collection_id"); $harmoni->request->forget("asset_id"); } // :: Footer :: $footer = new Container(new XLayout(), FOOTER, 1); $helpText = "<a target='_blank' href='"; $helpText .= $harmoni->request->quickURL("help", "browse_help"); $helpText .= "'>" . _("Help") . "</a>"; $footer->add(new UnstyledBlock($helpText), "50%", null, LEFT, BOTTOM); if (!isset($_SESSION['ConcertoVersion'])) { $document = new DOMDocument(); // attempt to load (parse) the xml file if ($document->load(MYDIR . "/doc/raw/changelog/changelog.xml")) { $versionElems = $document->getElementsByTagName("version"); $latest = $versionElems->item(0); $_SESSION['ConcertoVersion'] = $latest->getAttribute('number'); if (preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $latest->getAttribute('date'), $matches)) { $_SESSION['ConcertoCopyrightYear'] = $matches[1]; } else { $_SESSION['ConcertoCopyrightYear'] = $latest->getAttribute('date'); } } else { $_SESSION['ConcertoVersion'] = "2.x.x"; $_SESSION['ConcertoCopyrightYear'] = "2006"; } } $footerText = "<a href='" . $harmoni->request->quickURL('window', 'changelog') . "' target='_blank'>Concerto v." . $_SESSION['ConcertoVersion'] . "</a> "; $footerText .= "©" . $_SESSION['ConcertoCopyrightYear'] . " Middlebury College <a href='http://concerto.sourceforge.net'>"; $footerText .= _("about"); $footerText .= "</a>"; $footer->add(new UnstyledBlock($footerText), "50%", null, RIGHT, BOTTOM); $mainScreen->add($footer, "100%", null, RIGHT, BOTTOM); return $mainScreen; }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $asset = $this->getAsset(); $repositoryId = $this->getRepositoryId(); // function links ob_start(); AssetPrinter::printAssetFunctionLinks($harmoni, $asset); $layout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($layout, "100%", null, LEFT, CENTER); // Columns for Description and thumbnail. $xLayout = new XLayout(); $contentCols = new Container($xLayout, OTHER, 1); $actionRows->add($contentCols, "100%", null, LEFT, CENTER); // Description and dates ob_start(); $assetId = $asset->getId(); print "\n\t<dl>"; if ($asset->getDescription()) { $description = HtmlString::withValue($asset->getDescription()); $description->clean(); print "\n\t\t<dt style='font-weight: bold;'>" . _("Description:") . "</dt>"; print "\n\t\t<dd>" . $description->asString() . "</dd>"; } print "\n\t\t<dt style='font-weight: bold;'>"; print _("ID#"); print ":</dt>\n\t\t<dd >"; print $assetId->getIdString(); print "</dd>"; print "\n\t\t<dt style='font-weight: bold;'>"; print _("Type"); print ":</dt>\n\t\t<dd >"; try { print $asset->getAssetType()->asString(); } catch (UnimplementedException $e) { print "unknown"; } print "</dd>"; try { $date = $asset->getModificationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Modification Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } catch (UnimplementedException $e) { } try { $date = $asset->getCreationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Creation Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } catch (UnimplementedException $e) { } try { if (is_object($asset->getEffectiveDate())) { $date = $asset->getEffectiveDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Effective Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } } catch (UnimplementedException $e) { } try { if (is_object($asset->getExpirationDate())) { $date = $asset->getExpirationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Expiration Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } print "\n\t</dl>"; } catch (UnimplementedException $e) { } $contentCols->add(new Block(ob_get_clean(), STANDARD_BLOCK), "60%", null, LEFT, TOP); // Add the tagging manager script to the header $outputHandler = $harmoni->getOutputHandler(); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . POLYPHONY_PATH . "javascript/Tagger.js'></script>" . "\n\t\t<link rel='stylesheet' type='text/css' href='" . POLYPHONY_PATH . "javascript/Tagger.css' />"); // Tags ob_start(); print "\n\t<div style='font-weight: bold; margin-bottom: 10px;'>" . _("Tags given to this Asset: ") . "</div>"; print "\n\t<div style=' text-align: justify;'>"; print TagAction::getTagCloudForItem(TaggedItem::forId($assetId, 'concerto'), 'view'); print "\n\t</div>"; $contentCols->add(new Block(ob_get_clean(), STANDARD_BLOCK), "40%", null, LEFT, TOP); //*********************************** // Info Records //*********************************** ob_start(); $printedRecordIds = array(); // Get the set of RecordStructures so that we can print them in order. $setManager = Services::getService("Sets"); $structSet = $setManager->getPersistentSet($repositoryId); if ($structSet->hasNext()) { // First, lets go through the info structures listed in the set and print out // the info records for those structures in order. while ($structSet->hasNext()) { $structureId = $structSet->next(); $records = $asset->getRecordsByRecordStructure($structureId); while ($records->hasNext()) { $record = $records->next(); $recordId = $record->getId(); $printedRecordIds[] = $recordId->getIdString(); print "<hr />"; printRecord($repositoryId, $assetId, $record); } } } else { $structures = $asset->getRecordStructures(); while ($structures->hasNext()) { $structure = $structures->next(); $structureId = $structure->getId(); $records = $asset->getRecordsByRecordStructure($structureId); while ($records->hasNext()) { $record = $records->next(); $recordId = $record->getId(); $printedRecordIds[] = $recordId->getIdString(); print "<hr />"; printRecord($repositoryId, $assetId, $record); } } } $layout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($layout, "100%", null, LEFT, CENTER); //*********************************** // Content // If we can, we may want to print the content here. // @todo Add some sniffing of content so that we can either put it in if // it is text, image, etc, or do otherwise with it if it is some other form // of data. //*********************************** try { $content = $asset->getContent(); if ($string = $content->asString()) { ob_start(); print "\n<textarea readonly='readonly' rows='30' cols='80'>"; print htmlspecialchars($string); print "</textarea>"; $layout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($layout, "100%", null, LEFT, CENTER); } } catch (UnimplementedException $e) { } }
/** * This just adds an agent list for debugging purposes. * * @return void * @access public * @since 11/07/06 */ function buildContent() { parent::buildContent(); $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); ob_start(); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-tags"); ob_start(); print "\n<select name='" . RequestContext::name('num_tags') . "'"; print " onchange=\""; print "var url='" . $harmoni->request->quickURL(null, null, array('num_tags' => 'XXXXX')) . "'; "; print "window.location = url.replace(/XXXXX/, this.value).urlDecodeAmpersands(); "; print "\">"; $options = array(50, 100, 200, 400, 600, 1000, 0); foreach ($options as $option) { print "\n\t<option value='" . $option . "' " . ($option == $this->getNumTags() ? " selected='selected'" : "") . ">" . ($option ? $option : _('all')) . "</option>"; } print "\n</select>"; print str_replace('%1', ob_get_clean(), _("Showing top %1 tags")); $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, TOP); $harmoni->request->endNamespace(); textdomain($defaultTextDomain); }
/** * Answer the tags for a block * * @param object BlockSiteComponent $block * @return string * @access public * @since 4/3/08 */ function getTags($block) { $harmoni = Harmoni::instance(); ob_start(); // Tags SiteDispatcher::passthroughContext(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $item = TaggedItem::forId($block->getQualifierId(), 'segue'); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $block->getQualifierId())) { print "\n\t<div class='tagging_tags_display'>"; print TagAction::getTagCloudForItem($item, 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); } else { print TagAction::getTagCloud($item->getTags(), 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); } SiteDispatcher::forgetContext(); print "\n\t</div>"; return ob_get_clean(); }
<?php //前台缓存开关 define('IS_CAHCE', true); //模板句柄 global $_tpl, $_cache; if (IS_CAHCE && !$_cache->noCache()) { ob_start(); $_tpl->cache(Tool::tplName() . '.tpl'); } $_nav = new NavAction($_tpl); $_nav->showfront(); //列出主导航 $_cookie = new Cookie('user'); if (IS_CAHCE) { $_tpl->assign('header', '<script type="text/javascript">getHeader();</script>'); } else { if ($_cookie->getCookie()) { $_tpl->assign('header', $_cookie->getCookie() . ',您好! <a href="register.php?action=logout">退出</a> '); } else { $_tpl->assign('header', ' <a href="register.php?action=reg" class="user">注册</a> <a href="register.php?action=login" class="user">登录</a>'); } } $_link = new FriendLinkAction($_tpl); $_link->index(); $_tag = new TagAction($_tpl); $_tag->getFiveTag(); $_tpl->assign('webname', WEBNAME);
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $this->init(); $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $asset = $this->getAsset(); $assetId = $asset->getId(); // function links ob_start(); AssetPrinter::printAssetFunctionLinks($harmoni, $asset); $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), null, null, CENTER, CENTER); ob_start(); print "\n<table width='100%'>\n<tr><td style='text-align: left; vertical-align: top'>"; print "\n\t<dl>"; if ($asset->getDisplayName()) { print "\n\t\t<dt style='font-weight: bold;'>" . _("Title:") . "</dt>"; print "\n\t\t<dd>" . $asset->getDisplayName() . "</dd>"; } if ($asset->getDescription()) { $description = HtmlString::withValue($asset->getDescription()); $description->clean(); print "\n\t\t<dt style='font-weight: bold;'>" . _("Description:") . "</dt>"; print "\n\t\t<dd>" . $description->asString() . "</dd>"; } print "\n\t\t<dt style='font-weight: bold;'>"; print _("ID#"); print ":</dt>\n\t\t<dd >"; print $assetId->getIdString(); print "</dd>"; print "\n\t\t<dt style='font-weight: bold;'>"; print _("Type"); print ":</dt>\n\t\t<dd >"; print $asset->getAssetType()->asString(); print "</dd>"; $date = $asset->getModificationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Modification Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; $date = $asset->getCreationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Creation Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; if (is_object($asset->getEffectiveDate())) { $date = $asset->getEffectiveDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Effective Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } if (is_object($asset->getExpirationDate())) { $date = $asset->getExpirationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Expiration Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } print "\n\t</dl>"; print "\n</td><td style='text-align: right; vertical-align: top'>"; $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($assetId); if ($thumbnailURL !== FALSE) { print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' align='right' class='thumbnail_image' style='margin-bottom: 5px;' />"; } // Add the tagging manager script to the header $outputHandler = $harmoni->getOutputHandler(); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . POLYPHONY_PATH . "javascript/Tagger.js'></script>" . "\n\t\t<link rel='stylesheet' type='text/css' href='" . POLYPHONY_PATH . "javascript/Tagger.css' />"); // Tags print "\n\t<div style='font-weight: bold; margin-bottom: 10px; text-align: left; clear: both;'>" . _("Tags given to this Asset: ") . "</div>"; print "\n\t<div style=' text-align: justify;'>"; print TagAction::getTagCloudForItem(TaggedItem::forId($assetId, 'concerto'), 'view'); print "\n\t</div>"; print "\n</td></tr></table>"; // print "\n\t<hr/>"; $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); $searchBar = new Container(new YLayout(), BLOCK, STANDARD_BLOCK); $actionRows->add($searchBar, "100%", null, CENTER, CENTER); //*********************************** // Get the assets to display //*********************************** $assets = $asset->getAssets(); $tmpAssets = array(); while ($assets->hasNext()) { $asset = $assets->next(); switch ($_SESSION["asset_order"]) { case 'DisplayName': $assetKey = $asset->getDisplayName(); break; case 'Id': $id = $asset->getId(); $assetKey = $id->getIdString(); break; case 'ModificationDate': $date = $asset->getModificationDate(); $assetKey = $date->asString(); break; case 'CreationDate': $date = $asset->getCreationDate(); $assetKey = $date->asString(); break; default: $assetKey = '0'; } $i = 0; while (isset($tmpAssets[$assetKey . "_" . $i])) { $i++; } $tmpAssets[$assetKey . "_" . $i] = $asset; } if ($_SESSION["asset_order_direction"] == 'ASC') { ksort($tmpAssets); } else { krsort($tmpAssets); } //*********************************** // print the results //*********************************** $resultPrinter = new ArrayResultPrinter($tmpAssets, $_SESSION["asset_columns"], $_SESSION["assets_per_page"], array($this, "printAssetShort"), $this->getParams()); $resultPrinter->setStartingNumber($this->_state['startingNumber']); $resultLayout = $resultPrinter->getLayout(array($this, "canView")); $resultLayout->setPreHTML("<form id='AssetMultiEditForm' name='AssetMultiEditForm' action='' method='post'>"); $resultLayout->setPostHTML("</form>"); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); /********************************************************* * Display options *********************************************************/ $currentUrl = $harmoni->request->mkURL(); $searchBar->setPreHTML("\n<form action='" . $currentUrl->write() . "' method='post'>\n\t<input type='hidden' name='" . RequestContext::name('form_submitted') . "' value='true'/>"); $searchBar->setPostHTML("\n</form>"); ob_start(); print "\n\t<strong>" . _("Child Assets") . ":</strong>"; $searchBar->add(new UnstyledBlock(ob_get_clean()), null, null, LEFT, TOP); $searchBar->add($this->getDisplayOptions($resultPrinter), null, null, LEFT, TOP); }
/** * The average function can be use independantly but the deviation function uses * the average function. * * @static */ static function deviation($array) { if (!count($array)) { return 0; } $avg = TagAction::average($array); foreach ($array as $value) { $variance[] = pow($value - $avg, 2); } $deviation = sqrt(TagAction::average($variance)); return $deviation; }
function printAssetShort($asset, $params, $num) { $harmoni = Harmoni::instance(); $container = new Container(new YLayout(), BLOCK, EMPHASIZED_BLOCK); $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container."); $fillContainerSC->addSP(new MinHeightSP("88%")); $container->addStyle($fillContainerSC); $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text"); $centered->addSP(new TextAlignSP("center")); $assetId = $asset->getId(); if ($_SESSION["show_thumbnail"] == 'true') { try { $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($asset); } catch (Exception $e) { $thumbnailURL = false; } if ($thumbnailURL !== FALSE) { if (RepositoryInputOutputModuleManager::hasThumbnailNotIcon($asset)) { $thumbClass = 'thumbnail_image'; } else { $thumbClass = 'thumbnail_icon'; } } else { $thumbnailURL = POLYPHONY_PATH . "/icons/filetypes/unknown.png"; $thumbClass = 'thumbnail_icon'; } $thumbSize = $_SESSION["thumbnail_size"] . "px"; ob_start(); print "\n<div style='height: {$thumbSize}; width: {$thumbSize}; margin: auto;'>"; print "\n\t<a style='cursor: pointer;'"; print " onclick='Javascript:window.open("; print '"' . AssetPrinter::getSlideshowLink($asset, $num) . '", '; // print '"'.preg_replace("/[^a-z0-9]/i", '_', $assetId->getIdString()).'", '; print '"_blank", '; print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"'; print ")'>"; print "\n\t\t<img src='{$thumbnailURL}' class='thumbnail {$thumbClass}' alt='Thumbnail Image' style='max-height: {$thumbSize}; max-width: {$thumbSize};' />"; print "\n\t</a>"; print "\n</div>"; $component = new UnstyledBlock(ob_get_contents()); $component->addStyle($centered); ob_end_clean(); $container->add($component, "100%", null, CENTER, CENTER); } ob_start(); if ($_SESSION["show_displayName"] == 'true') { print "\n\t<div style='font-weight: bold; height: 50px; overflow: auto;'>" . htmlspecialchars($asset->getDisplayName()) . "</div>"; } if ($_SESSION["show_id"] == 'true') { print "\n\t<div>" . _("ID#") . ": " . $assetId->getIdString() . "</div>"; } if ($_SESSION["show_description"] == 'true') { $description = HtmlString::withValue($asset->getDescription()); $description->trim(16); $descriptionShort = preg_replace('/\\.\\.\\.$/', "<a onclick=\"" . "var panel = Panel.run(" . "'" . addslashes(htmlspecialchars($asset->getDisplayName())) . "', " . "100, 400, this.parentNode); " . "if (!panel.contentElement.innerHTML) " . "{panel.contentElement.innerHTML = this.parentNode.nextSibling.innerHTML;}" . "\">...</a>", $description->asString()); print "\n\t<div style='font-size: smaller; height: 50px; overflow: auto;'>"; print $descriptionShort; print "</div>"; if (preg_match('/\\.\\.\\.$/', $description->asString())) { print "<div style='display: none'>" . $asset->getDescription() . "</div>"; } } if ($_SESSION["show_tags"] == 'true') { // Tags print "\n\t<div style='font-size: smaller; height: 50px; overflow: auto; text-align: justify; margin-top: 5px;'>"; print TagAction::getTagCloudForItem(TaggedItem::forId($assetId, 'concerto'), 'view', array('font-size: 90%;', 'font-size: 100%;')); print "\n\t</div>"; } $component = new UnstyledBlock(ob_get_contents()); ob_end_clean(); $container->add($component, "100%", null, LEFT, TOP); // Bottom controls if ($_SESSION["show_controls"] == 'true') { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); ob_start(); print "\n<div style='margin-top: 5px; font-size: small; white-space: nowrap;'>"; AssetPrinter::printAssetFunctionLinks($harmoni, $asset, NULL, $num, false); print " | "; $harmoni->request->startNamespace("AssetMultiEdit"); print "\n<input type='checkbox'"; print " name='" . RequestContext::name("asset") . "'"; print " value='" . $assetId->getIdString() . "'"; print "/>"; print "\n<input type='hidden'"; print " name='" . RequestContext::name("asset_can_modify_" . $assetId->getIdString()) . "'"; try { if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $assetId)) { print " value='true'"; } else { print " value='false'"; } } catch (UnknownIdException $e) { // allow non-harmoni Repositories. print " value='true'"; } print "/>"; print "\n<input type='hidden'"; print " name='" . RequestContext::name("asset_can_delete_" . $assetId->getIdString()) . "'"; try { if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $assetId)) { print " value='true'"; } else { print " value='false'"; } } catch (UnknownIdException $e) { // allow non-harmoni Repositories. print " value='true'"; } print "/>"; $harmoni->request->endNamespace(); print "</div>"; $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, RIGHT, BOTTOM); } return $container; }
/** * Answer the tags for a block * * @param object BlockSiteComponent $block * @return string * @access public * @since 4/3/08 */ function getTags($block) { $harmoni = Harmoni::instance(); ob_start(); // Tags print "\n\t<div class='tagging_tags_display'>"; print "Tags: "; SiteDispatcher::passthroughContext(); $item = TaggedItem::forId($block->getQualifierId(), 'segue'); print TagAction::getTagCloud($item->getTags(), 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); SiteDispatcher::forgetContext(); print "\n\t</div>"; return ob_get_clean(); }
/** * Print out an Item * * @param object $item * @param string $viewAction The action to choose when clicking on a tag. * @return string * @access public * @since 11/8/06 */ function printTaggedItem(TaggedItem $item, $viewAction) { print "\n\t<a href='" . $item->getUrl() . "'>"; if ($item->getThumbnailUrl()) { print "\n\t\t<img src='" . $item->getThumbnailUrl() . "' style=' float: right;' class='thumbnail_image' />"; } if ($item->getDisplayName()) { print "\n\t\t<strong>" . $item->getDisplayName() . "</strong>"; } else { print "\n\t\t<strong>" . _('untitled') . "</strong>"; } print "\n\t</a>"; print "\n\t<p>" . $item->getDescription() . "</p>"; // Tags print "\n\t<p style='text-align: justify;'>"; print "\n\t<strong>" . _('Tags') . ":</strong> "; print TagAction::getTagCloudForItem($item, $viewAction, array('font-size: 90%;', 'font-size: 100%;', 'font-size: 110%;')); print "\n\t</p>"; print "\n\t<p><strong>" . _('System') . ":</strong> "; if ($item->getSystem() == ARBITRARY_URL) { print _("The Internet"); } else { print ucFirst($item->getSystem()); } print "</p>"; }
/** * Print out an Item * * @param object $item * @param string $viewAction The action to choose when clicking on a tag. * @return string * @access public * @since 11/8/06 */ function printTaggedItem(TaggedItem $item, $viewAction) { print "\n\t<a href='" . $item->getUrl() . "'>"; if ($item->getThumbnailUrl()) { print "\n\t\t<img src='" . $item->getThumbnailUrl() . "' style=' float: right;' class='thumbnail_image' />"; } if ($item->getDisplayName()) { print "\n\t\t<strong>" . $item->getDisplayName() . "</strong>"; } else { print "\n\t\t<strong>" . _('untitled') . "</strong>"; } print "\n\t</a>"; print "\n\t<p>" . $item->getDescription() . "</p>"; // Tags // print "\n\t<p style='text-align: justify;'>"; print "\n\t<strong>" . _('Tags') . ":</strong> "; $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $item->getId())) { print TagAction::getTagCloudForItem($item, $viewAction, array('font-size: 90%;', 'font-size: 100%;', 'font-size: 110%;')); } else { print TagAction::getReadOnlyTagCloudForItem($item, $viewAction, array('font-size: 90%;', 'font-size: 100%;', 'font-size: 110%;')); } // print "\n\t</p>"; print "\n\t<p><strong>" . _('System') . ":</strong> "; if ($item->getSystem() == ARBITRARY_URL) { print _("The Internet"); } else { print ucFirst($item->getSystem()); } print "</p>"; }
/** * Return the markup that represents the plugin. * Plugin writers should override this method with their own functionality * as needed. * * @return string * @access public * @since 1/12/06 */ public function getMarkup() { ob_start(); if ($this->getFieldValue('edit') && $this->canModify()) { $director = SiteDispatcher::getSiteDirector(); $node = $director->getSiteComponentById($this->getId()); $currentTarget = $this->getTargetNodeId(); $node = $director->getSiteComponentById($this->getId()); print "\n" . $this->formStartTagWithAction(); $visitor = new UmbrellaVisitor(); $node->acceptVisitor($visitor); print "<div>"; print _('Chose a section or page:'); print "<select name='" . $this->getFieldName('tagNode') . "'>"; $this->writeUmbrellaSelect($visitor->getNodeData(), $currentTarget); print "</select>\n"; print "<div class='tags_display_options'>" . _('Only tags from your selected section or page will be displayed') . "</div><br/>\n"; print "<select name='" . $this->getFieldName('defaultSortMethod') . "'>"; print "\n\t<option value='alpha' "; if ($this->readOption('defaultSortMethod') == 'alpha') { print "selected='selected'"; } print ">" . _('sort tags alphabetically') . "</option>"; print "\n\t<option value='freq' "; if ($this->readOption('defaultSortMethod') == 'freq') { print "selected='selected'"; } print ">" . _('sort tags by frequency') . "</option>"; print "</select>\n"; print "<br/>"; print "<select name='" . $this->getFieldName('defaultDisplayType') . "'>"; print "\n\t<option value='cloud' "; if ($this->readOption('defaultDisplayType') == 'cloud') { print "selected='selected'"; } print ">" . _('display as cloud') . "</option>"; print "\n\t<option value='list' "; if ($this->readOption('defaultDisplayType') == 'list') { print "selected='selected'"; } print ">" . _('display as list') . "</option>"; print "</select>\n"; print "<br/>"; print "<select name='" . $this->getFieldName('defaultListLimit') . "'>"; print "\n\t<option value='0' "; if ($this->readOption('defaultListLimit') == '0') { print "selected='selected'"; } print ">" . _('in list show: all') . "</option>"; for ($i = 5; $i < 25; $i = $i + 5) { print "\n\t<option value='{$i}' "; if (intval($this->readOption('defaultListLimit')) == $i) { print "selected='selected'"; } print ">" . str_replace('%1', $i, _('in list show: %1')) . "</option>"; } for ($i = 25; $i <= 300; $i = $i + 25) { print "\n\t<option value='{$i}' "; if (intval($this->readOption('defaultListLimit')) == $i) { print "selected='selected'"; } print ">" . str_replace('%1', $i, _('in list show: %1')) . "</option>"; } print "</select>\n"; print "<br/>"; print "<br/>"; print "<input type='submit' value='Update' name='" . $this->getFieldName('submit') . "'>\n"; print "\n\t<input type='button' value='" . _('Cancel') . "' onclick=" . $this->locationSendString() . "/>"; print "</div>"; print "</form>"; } else { if ($this->canView()) { $items = array(); $director = SiteDispatcher::getSiteDirector(); $node = $director->getSiteComponentById($this->getTargetNodeId()); $visitor = new TaggableItemVisitor(); $items = $node->acceptVisitor($visitor); print "\n<div class='breadcrumbs' style='height: auto; margin-top: 1px; margin-bottom: 5px; border-bottom: 1px dotted; padding-bottom: 2px;'>"; print str_replace('%1', $node->acceptVisitor(new BreadCrumbsVisitor($node)), _("Tags within: %1")); print "</div>"; print "\n<div style='text-align: justify;' id='tag_cloud_container-" . $this->getId() . "'>"; $tags = TagAction::getTagsFromItems($items); //SiteDispatcher::passthroughContext(); print TagAction::getTagCloudDiv($tags, 'sitetag', TagAction::getDefaultStyles(), array(), array(null => array('node' => $this->getTargetNodeId()))); //SiteDispatcher::forgetContext(); ?> <script type="text/javascript"> // <![CDATA[ var cloudParent = document.get_element_by_id('tag_cloud_container-<?php print $this->getId(); ?> '); var clouds = document.get_elements_by_class('tag_cloud', cloudParent); var cloud = TagCloud.forContainer(clouds[0]); <?php if ($this->readOption('defaultListLimit') != 15) { print "\n\tcloud.tagList.setLimit(" . $this->readOption('defaultListLimit') . ");"; } if ($this->readOption('defaultSortMethod') == 'freq') { print "\n\tcloud.orderFreq();"; } if ($this->readOption('defaultDisplayType') == 'list') { print "\n\tcloud.showList();"; } ?> // ]]> </script> <?php print "</div>"; if ($this->shouldShowControls()) { print "\n<div style='text-align: right; white-space: nowrap;'>"; print "\n\t<a " . $this->href(array('edit' => 'true')) . ">" . _('edit') . "</a>"; print "\n</div>"; } /* $visitor = new UmbrellaVisitor; $node->acceptVisitor($visitor); print "<br/><pre>"; print_r($visitor->getNodeData()); print "</pre><br/>\n"; */ } } return ob_get_clean(); }