function smarty_function_link($params, &$smarty)
{
    if (empty($params['name'])) {
        throw new Exception('No name parameter provided for the link');
    }
    if (empty($params['href'])) {
        throw new Exception('No href parameter provided for the link');
    }
    $name = $params['name'];
    $href = $params['href'];
    unset($params['name']);
    unset($params['href']);
    $title = $name;
    if (!empty($params['title'])) {
        $title = $params['title'];
        unset($params['title']);
    }
    $translator = I18n::getInstance()->getTranslator();
    $name = $translator->translate($name);
    $title = $translator->translate($title);
    $anchor = new Anchor($name, $href);
    $anchor->setAttribute('title', $title);
    foreach ($params as $key => $value) {
        $anchor->setAttribute($key, $value);
    }
    return $anchor->getHtml();
}
 /**
  * Adds the confirmation message to the anchor
  * @param zibo\library\html\Anchor $anchor Generated anchor for the cell
  * @param mixed $value Value of the cell
  * @return null
  */
 protected function processAnchor(Anchor $anchor, $value)
 {
     $message = $this->processMessage($value);
     if ($message) {
         $anchor->setAttribute('onclick', 'return confirm(\'' . $message . '\');');
     }
 }
 /**
  * Gets the HTML of the dependencies of the module
  * @param string $id CSS id for the dependencies container
  * @param array $dependencies Array with Module instances with version info
  * @return HTML of the dependencies
  */
 protected function getDependenciesHtml($id, $dependencies)
 {
     $dependenciesCount = count($dependencies);
     if (!$dependenciesCount) {
         return '';
     }
     $label = $this->translator->translatePlural($dependenciesCount, self::TRANSLATION_DEPENDS);
     $anchor = new Anchor($label, '#');
     $jQueryEscapedId = str_replace('.', '\\\\.', $id);
     $anchor->setAttribute('onclick', '$("#' . $jQueryEscapedId . '").slideToggle("normal"); return false;');
     $html = '<div class="info">' . PHP_EOL;
     $html .= $anchor->getHtml() . PHP_EOL;
     $html .= '<div id="' . $id . '" style="display:none;"><ul>' . PHP_EOL;
     foreach ($dependencies as $dependency) {
         $html .= '<li>' . $dependency->getNamespace() . '.' . $dependency->getName() . ' ' . $dependency->getVersion() . '</li>' . PHP_EOL;
     }
     $html .= '</ul></div></div>';
     return $html;
 }
 /**
  * Gets the HTML of the provided modules
  * @param array $modules Array with the data of the modules
  * @param string $id Style id for the containing ul
  * @param string $class Style class for the containing div
  * @param string $labelModule The translation key for 1 module
  * @param string $labelModules The translation key for multiple modules
  * @return string The HTML of the provided modules
  */
 private function getModulesHtml($modules, $id, $class, $labelModule, $labelModules)
 {
     $numModules = count($modules);
     if ($numModules == 0) {
         return '';
     }
     if ($numModules == 1) {
         $label = $this->translator->translate($labelModule);
     } else {
         $label = $this->translator->translate($labelModules, array('number' => $numModules));
     }
     $id .= ucfirst($class);
     $anchor = new Anchor($label, '#');
     $anchor->setAttribute('id', $id);
     $html = '<div class="' . $class . '">';
     $html .= $anchor->getHtml() . '<ul id="' . $id . 'List">';
     foreach ($modules as $module) {
         $html .= '<li>' . $this->getNameHtml($module) . '</li>';
     }
     $html .= '</ul></div>';
     return $html;
 }
 /**
  * Create a new page anchor
  * @param string $label label for the anchor
  * @param string $class style class for the anchor
  * @param int $page page number to link to
  * @return zibo\library\html\Anchor
  */
 private function createAnchor($label, $class, $page)
 {
     $anchor = new Anchor($label);
     if ($this->onclick) {
         $anchor->setAttribute('onclick', str_replace('%page%', $page, $this->onclick));
     }
     if ($this->href) {
         $anchor->setAttribute('href', str_replace('%page%', $page, $this->href));
     }
     $anchor->setClass($class);
     return $anchor;
 }
Exemple #6
0
 /**
  * Get the html for an anchor
  * @param string $href the href of the anchor
  * @param string $label the label for the anchor
  * @param boolean $translate true to translate the label
  * @param string $class Style class for the anchor
  * @return string html of the anchor
  */
 private function getAnchorHtml($href, $label, $translate, $class = null, $id = null, $title = null)
 {
     if ($translate) {
         $label = $this->translator->translate($label);
     }
     if ($href != '#') {
         $href = $this->baseUrl . Module::ROUTE_JOPPA . $href;
     }
     if (!$label) {
         $label = 'N/A';
     }
     $anchor = new Anchor($label, $href);
     if ($id) {
         $anchor->setId($id);
     }
     if ($class) {
         $anchor->appendToClass($class);
     }
     if ($title) {
         $anchor->setAttribute('title', $title);
     }
     return $anchor->getHtml();
 }