Changeset 3787


Ignore:
Timestamp:
Aug 23, 2009, 5:21:15 PM (11 years ago)
Author:
nikrou
Message:

fonctionnement sans javascript

Location:
extensions/akBookStyle/trunk
Files:
3 edited

Legend:

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

    r3770 r3787  
    2525}
    2626
     27include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
     28
    2729class akContent
    2830{
    2931  public function __construct($config) {
    3032    $this->plugin_config = $config;
     33    $this->current_picture = 0;
    3134  }
    3235
    33   public function loc_begin_index_thumbnails($pictures) {
     36  public function loc_begin_index_thumbnails($images) {
    3437    global $template;
    3538
     39    $this->category_url = make_index_url(array('section' => 'category',
     40                                               'category' => $GLOBALS['page']['category'],
     41                                               'start' => $GLOBALS['page']['start']
     42                                               )
     43                                         );
     44    $this->current_picture = $this->getPictureId($images);
     45
    3646    $template->set_filenames(array('index_thumbnails'=> AK_PLUGIN_TEMPLATE . '/ak_thumbnails.tpl'));
    37    
    38     $template->assign('AK_BY_LINE', 2);
     47    $template->assign('AK_PIC_SRC', get_image_url($images[$this->current_picture]));
     48    $template->assign('AK_BY_LINE', 3);
    3949    $template->assign('AK_RELOADED_IMAGE_TPL', AK_PLUGIN_TEMPLATE. '/ak_reloaded_image.tpl');
    4050    $template->assign('AK_PLUGIN_CSS', AK_PLUGIN_CSS);
    4151  }
     52
     53
     54  public function loc_end_index_thumbnails($tpl_vars, $images) {
     55    foreach ($tpl_vars as &$tpl_var) {
     56
     57      $tpl_var['AK_URL'] = $this->makeAkUrl($tpl_var);
     58    }
     59
     60    return $tpl_vars;
     61  }
     62
     63  /*** privates methods ***/
     64  private function makeAkUrl($image) {
     65    return sprintf('%s/picture/%d', $this->category_url, $image['ID']);
     66
     67  }
     68
     69  private function getPictureId($images) {
     70    if ($GLOBALS['conf']['question_mark_in_urls']==false and
     71        isset($_SERVER["PATH_INFO"]) and !empty($_SERVER["PATH_INFO"]) ) {
     72      $rewritten = $_SERVER["PATH_INFO"];
     73      $rewritten = str_replace('//', '/', $rewritten);
     74    } else {
     75      $rewritten = '';
     76      foreach (array_keys($_GET) as $keynum => $key) {
     77        $rewritten = $key;
     78        break;
     79      }
     80    }
     81    $rewritten = make_index_url().$rewritten;
     82    $pattern = sprintf('`^%s/(?:start\-\d+/)?picture/(\d+)$`',
     83                       str_replace('?', '\?', $this->category_url)
     84                       );
     85
     86    if (preg_match($pattern, $rewritten, $matches)) {
     87      foreach ($images as $index => $image) {
     88        if ($image['id']==$matches[1]) {
     89          return $index;
     90        }
     91      }
     92      return false;
     93    } else {
     94      return false;
     95    }
     96  }
    4297}
    4398?>
  • extensions/akBookStyle/trunk/init.php

    r3782 r3787  
    2929define('AK_PLUGIN_LANG', AK_PLUGIN_ROOT . '/');
    3030define('AK_PLUGIN_TEMPLATE', AK_PLUGIN_ROOT . '/template');
    31 define('AK_PLUGIN_CSS', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)). '/css');
    32 define('AK_PLUGIN_JS', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)). '/js');
    33 define('AK_PLUGIN_IMGS', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)). '/imgs');
     31define('AK_PLUGIN_BASE_URL', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)));
     32define('AK_PLUGIN_CSS', AK_PLUGIN_BASE_URL . '/css');
     33define('AK_PLUGIN_JS', AK_PLUGIN_BASE_URL . '/js');
     34define('AK_PLUGIN_IMGS', AK_PLUGIN_BASE_URL . '/imgs');
     35
    3436
    3537include_once "include/akConfig.class.php";
  • extensions/akBookStyle/trunk/public.php

    r3770 r3787  
    3030
    3131add_event_handler('loc_begin_index_thumbnails',
    32                   array($public_content, 'loc_begin_index_thumbnails'),
     32                  array($public_content, 'loc_begin_index_thumbnails')
     33                  );
     34add_event_handler('loc_end_index_thumbnails',
     35                  array($public_content, 'loc_end_index_thumbnails'),
    3336                  EVENT_HANDLER_PRIORITY_NEUTRAL,
    3437                  2           
Note: See TracChangeset for help on using the changeset viewer.