function segment($index)
{
    // získame segmenty
    $segments = get_segments();
    // ak segment s daným indexom existuje, vrátime ho, inak vrátime false
    return isset($segments[$index - 1]) ? $segments[$index - 1] : false;
}
示例#2
0
 public function get_links()
 {
     // Set Current Page
     if (is_numeric(get_segments($this->uri_segment))) {
         $this->current_page = get_segments($this->uri_segment);
     } else {
         $this->current_page = 1;
     }
     // Page numbers
     if ($this->total_pages > 1) {
         $links = $this->main_tag_open;
         if ($this->current_page > 1) {
             // First Page Link
             if ($this->first_link !== false) {
                 $links .= $this->first_tag_open . '<a href="' . $this->base_url . '/1">' . $this->first_link . '</a>' . $this->first_tag_close;
             }
             // Previous Page Link
             $links .= $this->prev_tag_open . '<a href="' . $this->base_url . '/' . ($this->current_page - 1) . '">' . $this->prev_link . '</a>' . $this->prev_tag_close;
         }
         if ($this->total_pages > 4 && $this->current_page > 4) {
             for ($i = $this->current_page - 3; $i < $this->current_page; $i++) {
                 $links .= $this->num_tag_open . '<a href="' . $this->base_url . '/' . $i . '">' . $i . '</a>' . $this->num_tag_close;
             }
             $links .= $this->cur_tag_open . $i . $this->cur_tag_close;
             if ($this->current_page != $this->total_pages) {
                 if ($this->current_page + 4 > $this->total_pages) {
                     $last_page = $this->current_page + ($this->total_pages - $this->current_page);
                 } else {
                     $last_page = $this->current_page + 3;
                 }
                 for ($i = $this->current_page + 1; $i <= $last_page; $i++) {
                     $links .= $this->num_tag_open . '<a href="' . $this->base_url . '/' . $i . '">' . $i . '</a>' . $this->num_tag_close;
                 }
             }
         } elseif ($this->total_pages > 4 && $this->current_page < 5) {
             if ($this->current_page + 4 > $this->total_pages) {
                 $last_page = $this->current_page + ($this->total_pages - $this->current_page);
             } else {
                 $last_page = $this->current_page + 3;
             }
             for ($i = 1; $i <= $last_page; $i++) {
                 if ($i == $this->current_page) {
                     $links .= $this->cur_tag_open . $i . $this->cur_tag_close;
                 } else {
                     $links .= $this->num_tag_open . '<a href="' . $this->base_url . '/' . $i . '">' . $i . '</a>' . $this->num_tag_close;
                 }
             }
         } else {
             for ($i = 1; $i <= $this->total_pages; $i++) {
                 if ($i == $this->current_page) {
                     $links .= $this->cur_tag_open . $i . $this->cur_tag_close;
                 } else {
                     $links .= $this->num_tag_open . '<a href="' . $this->base_url . '/' . $i . '">' . $i . '</a>' . $this->num_tag_close;
                 }
             }
         }
         if ($this->current_page < $this->total_pages) {
             // Next Page Link
             $links .= $this->next_tag_open . '<a href="' . $this->base_url . '/' . ($this->current_page + 1) . '">' . $this->next_link . '</a>' . $this->next_tag_close;
             // Last Page Link
             if ($this->last_link !== false) {
                 $links .= $this->last_tag_open . '<a href="' . $this->base_url . '/' . $this->total_pages . '">' . $this->last_link . '</a>' . $this->last_tag_close;
             }
         }
         $links .= $this->main_tag_close;
         return $links;
     }
 }
示例#3
0
 function current_segment()
 {
     return get_segments(count(get_segments()) - 1);
 }
示例#4
0
function get_all_segments($binding)
{
    return get_segments($binding, null);
}
示例#5
0
function get_abstract_id($dbc, $article_id)
{
    $segments = get_segments($dbc, $article_id);
    return $segments[0];
}
示例#6
0
    $id = $_GET['id'];
    $has_right_to_edit = isset($_GET['view']) ? false : has_right_to_edit($dbc, $_SESSION['id'], $id);
    if (isset($_GET['delete_image'])) {
        delete_image_from_segment($dbc, $_GET['segment_id'], $_GET['delete_image']);
    }
    if (isset($_GET['deleted_segment_id'])) {
        delete_segment_from_article($dbc, $id, $_GET['deleted_segment_id']);
    }
    if (isset($_GET['insert'])) {
        insert_segment_into_article($dbc, $id, $_GET['insert'], $_GET['prev']);
    }
    if (isset($_GET['copy'])) {
        copy_and_insert_segment($dbc, $id, $_GET['copy'], $_GET['prev']);
    }
    $article_info = get_article_info($dbc, $id);
    $segments = get_segments($dbc, $id);
    $images = set_image_no($dbc, $segments);
    ?>
    <script type ="text/javascript">
        function jump(link) {
            window.location = "#" + link;
        }
    </script>
    <div class="container">
        <div class="row">
            <div class="span3  bs-docs-sidebar">
                <ul class="nav nav-list bs-docs-sidenav">

    <?php 
    $is_first_segment = true;
    //print_r($segments);