Example #1
0
 /**
  *
  */
 public function selectLanguage($name, $value, $attribs = null)
 {
     //select version
     $config = Zend_Registry::get('config');
     $siteVersions = $config->language->translations;
     foreach ($siteVersions as $locale => $label) {
         $data[$locale] = $this->view->getTranslation($label);
     }
     return $this->view->formSelect($name, $value, $attribs, $data);
 }
Example #2
0
 /**
  *  this helper renders a language selector
  *  it also processes the selected language
  *  it must be rendered above the content in order for the current
  *  content to reflect the language selection
  */
 public function languageForm()
 {
     //process form if this is a post back
     if (Digitalus_Filter_Post::has('setLang')) {
         Digitalus_Language::setLanguage($_POST['language']);
         // @todo: this needs to redirect so it loads the whole page in the new language
     }
     $currentLanguage = Digitalus_Language::getLanguage();
     $languageSelector = $this->view->selectLanguage('language', $currentLanguage);
     $xhtml = '<form action="' . $this->view->ModuleAction() . '" method="post">';
     $xhtml .= '<p>' . $languageSelector . '</p>';
     $xhtml .= '<p>' . $this->view->formSubmit('setLang', $this->view->getTranslation('Set Language')) . '</p>';
     $xhtml .= '</form>';
     return $xhtml;
 }
Example #3
0
 /**
  *
  */
 public function selectBlog($name, $value)
 {
     $mdlBlog = new Blog_Blog();
     $blogs = $mdlBlog->getBlogs();
     if ($blogs == null) {
         return $this->view->getTranslation('There are no blogs to view!');
     } else {
         $options[] = $this->view->getTranslation('Select One');
         foreach ($blogs as $blog) {
             $options[$blog->id] = $blog->name;
         }
         $form = new Digitalus_Form();
         $select = $form->createElement('select', $name, array('multiOptions' => $options, 'belongsTo' => 'module'));
         return $select;
     }
 }
Example #4
0
 /**
  *
  */
 public function selectLayout($name, $value = null, $attr = null, $defaut = null)
 {
     $config = Zend_Registry::get('config');
     $pathToPublicLayouts = $config->design->pathToPublicLayouts;
     $layouts = Digitalus_Filesystem_File::getFilesByType($pathToPublicLayouts, 'phtml');
     if ($defaut == NULL) {
         $defaut = $this->view->getTranslation('Select One');
     }
     $options[0] = $defaut;
     if (is_array($layouts)) {
         foreach ($layouts as $layout) {
             $options[$layout] = $layout;
         }
         return $this->view->formSelect($name, $value, $attr, $options);
     } else {
         return null;
     }
 }
Example #5
0
 /**
  *
  */
 public function selectSkin($name, $value = null, $attr = null, $defaut = null)
 {
     $config = Zend_Registry::get('config');
     $pathToPublicSkins = $config->design->pathToSkins;
     $skins = Digitalus_Filesystem_Dir::getDirectories($pathToPublicSkins);
     if ($defaut == NULL) {
         $defaut = $this->view->getTranslation('Select One');
     }
     $options[0] = $defaut;
     if (is_array($skins)) {
         foreach ($skins as $skin) {
             $options[$skin] = $skin;
         }
         return $this->view->formSelect($name, $value, $attr, $options);
     } else {
         return null;
     }
 }
Example #6
0
 /**
  *
  */
 public function listLanguageLinks()
 {
     $page = Digitalus_Builder::getPage();
     $currentLanguage = $page->getLanguage();
     $availableLanguages = $page->getAvailableLanguages();
     $xhtml = $this->view->getTranslation('You are reading this page in') . ' ' . $this->view->getTranslation(Digitalus_Language::getFullName($currentLanguage)) . '.';
     if (is_array($availableLanguages)) {
         $languageLinks = array();
         $uri = new Digitalus_Uri();
         $base = $uri->toString();
         foreach ($availableLanguages as $locale => $name) {
             if (!empty($locale) && $locale != $currentLanguage) {
                 $url = $base . '/p/language/' . $locale;
                 $languageLinks[] = '<a href="' . $url . '">' . $this->view->getTranslation($name) . '</a>';
             }
         }
         if (is_array($languageLinks) && count($languageLinks) > 0) {
             foreach ($languageLinks as $language) {
                 $languageLinksTranslated[] = $this->view->getTranslation($language);
             }
             $xhtml .= ' ' . $this->view->getTranslation('This page is also translated into') . ' ' . implode(', ', $languageLinks);
         }
     }
     return '<p>' . $xhtml . '</p>';
 }
Example #7
0
 /**
  *
  */
 public function link($label, $link, $icon = null, $class = 'link', $target = null)
 {
     $this->link = Digitalus_Toolbox_String::stripLeading('/', $link);
     $this->baseUrl = Digitalus_Toolbox_String::stripLeading('/', $this->view->getBaseUrl());
     // clean the link
     if ($this->isRemoteLink($link) || $this->isAnchorLink($link)) {
         $cleanLink = $link;
     } else {
         $cleanLink = '/' . $this->addBaseUrl($this->link);
     }
     if ($target != null) {
         $target = "target='{$target}'";
     }
     $linkParts[] = "<a href='{$cleanLink}' class='{$class}' {$target}>";
     if (null !== $icon) {
         $linkParts[] = $this->getIcon($icon, $label);
     }
     if (!empty($label)) {
         $linkParts[] = $this->view->getTranslation((string) $label);
     }
     $linkParts[] = '</a>';
     return implode(null, $linkParts);
 }