Ignore:
Timestamp:
Sep 9, 2009, 9:28:56 AM (15 years ago)
Author:
nikrou
Message:

navigation between picture (AK_NEXT, AK_PREVIOUS)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/akBookStyle/trunk/include/akContent.class.php

    r3830 r3838  
    3232    $this->plugin_config = $config;
    3333    $this->current_picture = 0;
     34    $this->next_picture = null;
     35    $this->previous_picture = null;
    3436  }
    3537
     
    5052    $template->assign('AK_DIR_THUMBNAIL', isset($GLOBALS['conf']['dir_thumbnail'])?$GLOBALS['conf']['dir_thumbnail']:'thumbnail');
    5153    $template->assign('AK_PREFIX_THUMBNAIL', $GLOBALS['conf']['prefix_thumbnail']);
    52     $template->assign('AK_PIC_SRC', get_image_url($images[$this->current_picture]));
    5354    $template->assign('AK_BY_LINE', $this->plugin_config->ak_by_line);
    5455    $template->assign('AK_MOUSE_EVENT', $this->plugin_config->ak_mouse_event);
     
    5859    $template->assign('AK_HORIZONTAL_TPL', AK_PLUGIN_TEMPLATE. '/ak_horizontal.tpl');
    5960    $template->assign('AK_THUMBNAILS_LOC', $this->plugin_config->ak_thumbnails_loc);
    60                 /* Thumbnail Nav */
    61                 if (!empty($page['navigation_bar'])) {
    62                         $nav = explode('|', $page['navigation_bar']);
    63                         if (substr($nav[1],1,2)=='<a') {
    64                                 $this->navbar['URL_PREV'] = substr($nav[1],10,stripos($nav[1],'" rel="'));
    65                         }
    66                         if (substr($nav[3],1,2)=='<a') {
    67                                 $this->navbar['URL_NEXT'] = substr($nav[3],10,stripos($nav[3],'" rel="'));
    68                         }
    69                         $template->assign('navbar', $this->navbar);
    70                 }
    71 }
     61    $template->assign('AK_PIC_SRC', get_image_url($images[$this->current_picture]));
     62
     63    $template->assign('AK_NEXT', $this->getNextPicture($this->current_picture, $images));
     64    $template->assign('AK_PREVIOUS', $this->getPreviousPicture($this->current_picture, $images));
     65  }
    7266
    7367  public function loc_end_index_thumbnails($tpl_vars, $images) {
     
    121115    }
    122116  }
     117
     118  private function getPreviousPicture($current, $images) {
     119    $previous = $current--;
     120    if ($previous>0) {
     121      return $this->makeAkUrl(array('ID' => $images[$previous]['id']));
     122    } else {
     123      return null;
     124    }
     125  }
     126
     127  private function getNextPicture($current, $images) {
     128    $index_current = null;
     129    foreach ($images as $index => $image) {
     130      if ($image['id']==$current) {
     131        $index_current = $index;
     132        break;
     133      }
     134    }
     135
     136    $next = $index_current+1;
     137    if ($next<count($images)) {
     138      return $this->makeAkUrl(array('ID' => $images[$next]['id']));
     139    } else {
     140      return null;
     141    }
     142  }
    123143}
    124144?>
Note: See TracChangeset for help on using the changeset viewer.