Example #1
0
 /**
  * Prints HTML for the elements from the given item in the given element set
  * and optionally specific element names.
  * If no element names are specified, all the elements in the set will be
  * output.
  *
  * @param Item $item The item whose metadata to output
  * @param string $setName The name of the set to output metadata for
  * @param array $elementNames Array of element names to be output
  */
 private function _outputSetElements($item, $setName, $elementNames = null)
 {
     $outputTexts = array();
     if (!$elementNames) {
         $elements = $item->getElementsBySetName($setName);
         foreach ($elements as $element) {
             foreach ($item->getElementTexts($setName, $element->name) as $text) {
                 $outputTexts[] = array('element' => $element->name, 'text' => $text->text);
             }
         }
     } else {
         if (is_array($elementNames)) {
             foreach ($elementNames as $elementName) {
                 $texts = $item->getElementTexts($setName, $elementName);
                 foreach ($texts as $text) {
                     $outputTexts[] = array('element' => $elementName, 'text' => $text->text);
                 }
             }
         }
     }
     if (count($outputTexts)) {
         echo "<h3>{$setName}</h3>";
         echo '<table class="element-texts" cellpadding="0" cellspacing="0">';
         foreach ($outputTexts as $outputText) {
             echo '<tr class="element">' . '<th scope="row" class="element-name">' . $outputText['element'] . '</th>' . '<td class="element-value">' . $outputText['text'] . '</td>' . '</tr>';
         }
         echo '</table>';
     }
 }
Example #2
0
 /**
  * Draw one label section for one item on the PDF document.
  *
  * @param int $column Horizontal index on the current page
  * @param int $row Vertical index on the current page
  * @param Item $item The item to report on
  */
 private function _drawItemLabel(Zend_Pdf_Page $page, $column, $row, $item)
 {
     // Start at the bottom left corner and count over for columns and down
     // for rows.
     $originX = self::MARGIN_LEFT + $column * (self::LABEL_WIDTH + self::HORIZONTAL_SPACING);
     $originY = self::PAGE_HEIGHT - self::MARGIN_TOP - ($row + 1) * (self::LABEL_HEIGHT + self::VERTICAL_SPACING);
     $page->saveGS();
     // Clip on label boundaries to stop text from running over.
     $page->clipRectangle($originX, $originY, $originX + self::LABEL_WIDTH, $originY + self::LABEL_HEIGHT);
     $image = $this->_getQrCode($this->_baseUrl . '/items/show/' . $item->id);
     $page->drawImage($image, $originX, $originY, $originX + self::LABEL_HEIGHT, $originY + self::LABEL_HEIGHT);
     $titles = $item->getElementTexts('Dublin Core', 'Title');
     if (count($titles) > 0) {
         $textOriginX = $originX + self::LABEL_HEIGHT;
         $textOriginY = $originY + 0.8 * self::LABEL_HEIGHT;
         $cleanTitle = strip_tags(htmlspecialchars_decode($titles[0]->text));
         $this->_drawWrappedText($page, $cleanTitle, $textOriginX, $textOriginY, self::LABEL_WIDTH - (self::LABEL_HEIGHT + 4));
     }
     // Remove clipping rectangle
     $page->restoreGS();
     // Release objects after use to keep memory usage down
     release_object($item);
 }