/** * Generate a string containing all of the references for an object * * @param mixed object whose references we are going to print out * @return string */ public function referenceString($referenced) { // if the object has no references, just return a blank string if (!isset($referenced->references) || count($referenced->references) <= 0) { return ''; } // new tag builder object $builder = new Tag_Builder(); // go through each reference generating a short reference string foreach ($referenced->references as $reference) { $shortName = $this->view->h($reference['shortName']); $item = $this->view->h($reference['item']); $references[] = "{$shortName} {$item}"; } // return an imploded version of all generated strings return $builder->em(' (' . implode(', ', $references) . ')'); }
/** * Generate a string containing all of the references for an object * * @param mixed object whose references we are going to print out * @param string (optional) prompt string * @return string */ public function referenceString($referenced, $prompt = null) { if (!isset($referenced->references) || count($referenced->references) <= 0) { return; } $builder = new Tag_Builder(); foreach ($referenced->references as $reference) { $shortName = $this->view->h($reference['shortName']); $item = $this->view->h($reference['item']); $references[] = "{$shortName} {$item}"; } $output = ''; if ($prompt !== null) { $output = "<strong>{$prompt}:</strong> "; } $output .= isset($references) ? $builder->em(' (' . implode(', ', $references) . ')') : ''; return $output; }