Source for file view.act.php

Documentation is available at view.act.php

  1. <?php
  2. /**
  3. * @package polyphony.basket
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: view.act.php,v 1.15 2007/09/19 14:04:54 adamfranco Exp $
  9. */
  10.  
  11. require_once(POLYPHONY."/main/library/AbstractActions/MainWindowAction.class.php");
  12. require_once(POLYPHONY."/main/library/Basket/Basket.class.php");
  13.  
  14. require_once(HARMONI."GUIManager/StyleProperties/TextAlignSP.class.php");
  15. require_once(HARMONI."GUIManager/StyleProperties/MinHeightSP.class.php");
  16. require_once(HARMONI."/Primitives/Collections-Text/HtmlString.class.php");
  17.  
  18. /**
  19. *
  20. *
  21. * @package polyphony.basket
  22. *
  23. * @copyright Copyright &copy; 2005, Middlebury College
  24. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  25. *
  26. * @version $Id: view.act.php,v 1.15 2007/09/19 14:04:54 adamfranco Exp $
  27. */
  28. class viewAction
  29. extends MainWindowAction
  30. {
  31. /**
  32. * Check Authorizations
  33. *
  34. * @return boolean
  35. * @access public
  36. * @since 4/26/05
  37. */
  38. function isAuthorizedToExecute () {
  39. // Check that the user can access this collection
  40. return TRUE;
  41. }
  42. /**
  43. * Return the heading text for this action, or an empty string.
  44. *
  45. * @return string
  46. * @access public
  47. * @since 4/26/05
  48. */
  49. function getHeadingText () {
  50. return _("View Your Selection");
  51. }
  52. /**
  53. * Build the content for this action
  54. *
  55. * @return boolean
  56. * @access public
  57. * @since 4/26/05
  58. */
  59. function buildContent () {
  60. $actionRows =$this->getActionRows();
  61. $harmoni = Harmoni::instance();
  62. $harmoni->request->startNamespace("basket");
  63. $idManager = Services::getService("Id");
  64. $authZ = Services::getService("AuthZ");
  65. $basket = Basket::instance();
  66. $basket->clean();
  67. $basket->reset();
  68.  
  69. //***********************************
  70. // Things to do with your basket
  71. //***********************************
  72. ob_start();
  73. print _("Basket").": ";
  74. // perhaps there will be enough links sometime for this function
  75. // BasketPrinter::printBasketFunctionLinks($harmoni, $basket);
  76.  
  77. print "<a href=\"".$harmoni->request->quickURL("basket", "export").
  78. "\">"._("Export Selection(<em>Assets</em>)")."</a>";
  79. print " | ";
  80. print "<a href=\"".$harmoni->request->quickURL("basket", "empty").
  81. "\">"._("Empty Selection")."</a>";
  82.  
  83. $layout = new Block(ob_get_contents(), STANDARD_BLOCK);
  84. ob_end_clean();
  85. $actionRows->add($layout, "100%", null, CENTER, CENTER);
  86. //***********************************
  87. // print the results
  88. //***********************************
  89. $resultPrinter = new IteratorResultPrinter($basket, 3, 6, "printAssetShort");
  90. $resultLayout =$resultPrinter->getLayout("viewAction::canView");
  91. $actionRows->add($resultLayout, "100%", null, LEFT, CENTER);
  92. $harmoni->request->endNamespace();
  93. }
  94. // Callback function for checking authorizations
  95. function canView( $assetId ) {
  96. $authZ = Services::getService("AuthZ");
  97. $idManager = Services::getService("Id");
  98.  
  99. if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId))
  100. {
  101. return TRUE;
  102. } else {
  103. $basket = Basket::instance();
  104. $basket->removeItem($assetId);
  105. return FALSE;
  106. }
  107. }
  108. }
  109.  
  110. function printAssetShort($assetId, $num) {
  111. $harmoni = Harmoni::instance();
  112. $repositoryManager = Services::getService("Repository");
  113. $asset =$repositoryManager->getAsset($assetId);
  114. $container = new Container(new YLayout, BLOCK, EMPHASIZED_BLOCK);
  115. $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container.");
  116. $fillContainerSC->addSP(new MinHeightSP("88%"));
  117. $container->addStyle($fillContainerSC);
  118. $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text");
  119. $centered->addSP(new TextAlignSP("center"));
  120. $assetId =$asset->getId();
  121. if ($_SESSION["show_thumbnail"] == 'true') {
  122. $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($asset);
  123. if ($thumbnailURL !== FALSE) {
  124. $xmlStart = $num - 1;
  125. $thumbSize = $_SESSION["thumbnail_size"]."px";
  126. ob_start();
  127. print "\n<div style='height: $thumbSize; width: $thumbSize; margin: auto;'>";
  128. print "\n\t<a style='cursor: pointer;'";
  129. print " onclick='Javascript:window.open(";
  130. print '"'.VIEWER_URL."?&amp;source=";
  131. print urlencode($harmoni->request->quickURL("basket", "browse_xml"));
  132. print '&amp;start='.$xmlStart.'", ';
  133. print '"_blank", ';
  134. print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"';
  135. print ")'>";
  136. print "\n\t\t<img src='$thumbnailURL' class='thumbnail thumbnail_image' alt='Thumbnail Image' style='max-height: $thumbSize; max-width: $thumbSize;' />";
  137. print "\n\t</a>";
  138. print "\n</div>";
  139. $component = new UnstyledBlock(ob_get_contents());
  140. $component->addStyle($centered);
  141. ob_end_clean();
  142. $container->add($component, "100%", null, CENTER, CENTER);
  143. }
  144. }
  145. ob_start();
  146. if ($_SESSION["show_displayName"] == 'true')
  147. print "\n\t<div style='font-weight: bold; height: 50px; overflow: auto;'>".htmlspecialchars($asset->getDisplayName())."</div>";
  148. if ($_SESSION["show_id"] == 'true')
  149. print "\n\t<div>"._("ID#").": ".$assetId->getIdString()."</div>";
  150. if ($_SESSION["show_description"] == 'true') {
  151. $description = HtmlString::withValue($asset->getDescription());
  152. $description->trim(25);
  153. print "\n\t<div style='font-size: smaller; height: 50px; overflow: auto;'>".$description->asString()."</div>";
  154. }
  155. $component = new UnstyledBlock(ob_get_contents());
  156. ob_end_clean();
  157. $container->add($component, "100%", null, LEFT, TOP);
  158. ob_start();
  159. print "\n<a href='";
  160. print $harmoni->request->quickURL("basket", "remove", array('asset_id' => $assetId->getIdString()));
  161. print "' title='"._("Remove from Selection")."'>";
  162. print _('remove');
  163. print "</a>";
  164. print "\n | <a href='";
  165. print $harmoni->request->quickURL("basket", "up", array('asset_id' => $assetId->getIdString()));
  166. print "' title='". _('move up')."'>";
  167. // print "<img src='".POLYPHONY_PATH."/icons/basket/arrowleft.png' width='25px' border='0' alt='"._("Move Up")."' />";
  168. print "&lt;--";
  169. print "</a>";
  170. print "\n | <a href='";
  171. print $harmoni->request->quickURL("basket", "down", array('asset_id' => $assetId->getIdString()));
  172. print "' title='". _('move down')."'>";
  173. // print "<img src='".POLYPHONY_PATH."/icons/basket/arrowright.png' width='25px' border='0' alt='"._("Move Down")."' />";
  174. print "--&gt;";
  175. print "</a>";
  176. $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, RIGHT, BOTTOM);
  177. return $container;
  178. }

Documentation generated on Wed, 19 Sep 2007 10:27:43 -0400 by phpDocumentor 1.3.0RC3