Source for file GroupPrinter.class.php

Documentation is available at GroupPrinter.class.php

  1. <?php
  2. /**
  3. * @package polyphony.HierarchyPrinter
  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: GroupPrinter.class.php,v 1.15 2007/09/19 14:04:46 adamfranco Exp $
  9. */
  10.  
  11. /**
  12. * This class will print an expandable view of Groups.
  13. *
  14. *
  15. * @package polyphony.HierarchyPrinter
  16. *
  17. * @copyright Copyright &copy; 2005, Middlebury College
  18. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  19. *
  20. * @version $Id: GroupPrinter.class.php,v 1.15 2007/09/19 14:04:46 adamfranco Exp $
  21. * @since 11/11/04
  22. */
  23.  
  24. class GroupPrinter {
  25. /**
  26. * Print a group and the expanded children (other groups or members)
  27. *
  28. * @param object $group
  29. * @param string $printGroupFunction Prints current group in group format.
  30. * @param string $printMemberFunction Prints current group in member format.
  31. * @return void
  32. * @access public
  33. * @since 11/8/04
  34. */
  35. function printGroup ($group, $harmoni,
  36. $startingPathInfoKey,
  37. $printGroupFunction,
  38. $printMemberFunction )
  39. {
  40. // Get a string of our groupIds
  41. $groupId =$group->getId();
  42. $groupIdString = urlencode($groupId->getIdString());
  43. // Break the path info into parts for the enviroment and parts that
  44. // designate which groups to expand.
  45. $environmentInfo = array();
  46. $expandedGroups = array();
  47. if ($tmp = $harmoni->request->get("expandedGroups")) {
  48. $expandedGroups = explode(",", $tmp);
  49. }
  50. print "\n\n<table>\n\t<tr><td valign='top'>";
  51. // Print The Group
  52. print <<<END
  53.  
  54. <div style='
  55. border: 1px solid #000;
  56. width: 15px;
  57. height: 15px;
  58. text-align: center;
  59. text-decoration: none;
  60. font-weight: bold;
  61. '>
  62.  
  63. END;
  64.  
  65. // The child groups are already expanded for this group.
  66. // Show option to collapse the list.
  67. if (in_array($groupIdString, $expandedGroups)) {
  68. $groupsToRemove = array($groupIdString);
  69. $newGroups = array_diff($expandedGroups, $groupsToRemove);
  70. $url =$harmoni->request->mkURL();
  71. $url->setValue("expandedGroups", implode(",",$newGroups));
  72. print "<a style='text-decoration: none;' href='";
  73. print $url->write();
  74. print "'>-</a>";
  75. // The group is not already expanded. Show option to expand.
  76. } else {
  77. $newGroups = $expandedGroups;
  78. $newGroups[] = $groupIdString;
  79. print "<a style='text-decoration: none;' href='";
  80. $url =$harmoni->request->mkURL();
  81. $url->setValue("expandedGroups", implode(",", $newGroups));
  82. print $url->write();
  83. print "'>+</a>";
  84. }
  85. print "\n\t\t</div>";
  86. print "\n\t</td><td valign='top'>\n\t\t";
  87. eval($printGroupFunction.'($group);');
  88. print "\n\t</td></tr>\n</table>";
  89. // If the group was expanded, we need to recursively print its children.
  90. if (in_array($groupIdString, $expandedGroups)) {
  91. print <<<END
  92.  
  93. <div style='
  94. margin-left: 13px;
  95. margin-right: 0px;
  96. margin-top:0px;
  97. padding-left: 10px;
  98. border-left: 1px solid #000;
  99. '>
  100.  
  101. END;
  102. $childGroups =$group->getGroups(false);
  103. $childMembers =$group->getMembers(false);
  104. while ($childGroups->hasNext()) {
  105. $childGroup =$childGroups->next();
  106. GroupPrinter::printGroup( $childGroup,
  107. $harmoni,
  108. $startingPathInfoKey,
  109. $printGroupFunction,
  110. $printMemberFunction);
  111. }
  112. // And finally print all the members for the group
  113. while ($childMembers->hasNext()) {
  114. $childMember =$childMembers->next();
  115. print "\n\n<table>\n\t<tr><td valign='top'>";
  116. print "\n\t\t<div style='width: 15px;'>&nbsp;</div>";
  117. print "\n\t</td><td valign='top'>\n\t\t";
  118. eval($printMemberFunction.'($childMember);');
  119. print "\n\t</td></tr>\n</table>";
  120. }
  121. print "\n</div>";
  122.  
  123. }
  124. }
  125. }
  126.  
  127. ?>

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