コード例 #1
0
ファイル: Pagination.php プロジェクト: Killerfun/galette
 /**
  * Creates pagination links and assign some usefull variables to the
  * Smarty template
  *
  * @param Smarty  $tpl        Smarty template
  * @param boolean $restricted Do not permit to display all
  *
  * @return void
  */
 public function setSmartyPagination($tpl, $restricted = true)
 {
     $paginate = null;
     $tabs = "\t\t\t\t\t\t";
     //Create pagination links
     if ($this->current_page < 11) {
         $idepart = 1;
     } else {
         $idepart = $this->current_page - 10;
     }
     if ($this->current_page + 10 < $this->pages) {
         $ifin = $this->current_page + 10;
     } else {
         $ifin = $this->pages;
     }
     $next = $this->current_page + 1;
     $previous = $this->current_page - 1;
     if ($this->current_page != 1) {
         $paginate .= "\n" . $tabs . "<li><a href=\"?page=1\" title=\"" . _T("First page") . "\">&lt;&lt;</a></li>\n";
         $paginate .= $tabs . "<li><a href=\"?page=" . $previous . "\" title=\"" . preg_replace("(%i)", $previous, _T("Previous page (%i)")) . "\">&lt;</a></li>\n";
     }
     for ($i = $idepart; $i <= $ifin; $i++) {
         if ($i == $this->current_page) {
             $paginate .= $tabs . "<li class=\"current\"><a href=\"#\" title=\"" . preg_replace("(%i)", $this->current_page, _T("Current page (%i)")) . "\">-&nbsp;{$i}&nbsp;-</a></li>\n";
         } else {
             $paginate .= $tabs . "<li><a href=\"?page=" . $i . "\" title=\"" . preg_replace("(%i)", $i, _T("Page %i")) . "\">" . $i . "</a></li>\n";
         }
     }
     if ($this->current_page != $this->pages) {
         $paginate .= $tabs . "<li><a href=\"?page=" . $next . "\" title=\"" . preg_replace("(%i)", $next, _T("Next page (%i)")) . "\">&gt;</a></li>\n";
         $paginate .= $tabs . "<li><a href=\"?page=" . $this->pages . "\" title=\"" . preg_replace("(%i)", $this->pages, _T("Last page (%i)")) . "\">&gt;&gt;</a></li>\n";
     }
     //Now, we assign common variables to Smarty template
     $tpl->assign('nb_pages', $this->pages);
     $tpl->assign('page', $this->current_page);
     $tpl->assign('numrows', $this->show);
     $tpl->assign('pagination', $paginate);
     $options = array(10 => "10", 20 => "20", 50 => "50", 100 => "100");
     if ($restricted === false) {
         $options[0] = _T("All");
     }
     $tpl->assign('nbshow_options', $options);
 }
コード例 #2
0
ファイル: Plugins.php プロジェクト: Killerfun/galette
 /**
  * Search and load public menu templates from plugins.
  * Also sets the web path to the plugin with the var "galette_[plugin-name]_path"
  *
  * @param Smarty      $tpl         Smarty template
  * @param Preferences $preferences Galette's preferences
  * @param boolean     $public_page Called from a public page
  *
  * @return void
  */
 public function getPublicMenus($tpl, $preferences, $public_page = false)
 {
     $modules = $this->getModules();
     foreach (array_keys($this->getModules()) as $r) {
         $menu_path = $this->getTemplatesPath($r) . '/public_menu.tpl';
         if ($tpl->template_exists($menu_path)) {
             $name2path = strtolower(str_replace(' ', '_', $modules[$r]['name']));
             $tpl->assign('galette_' . $name2path . '_path', 'plugins/' . $r . '/');
             $tpl->assign('public_page', $public_page);
             $tpl->display($menu_path);
         }
     }
 }