/** * * Render html block 'stack-navigation-panel' with json-data for RIA UI * * @param array $stack. Array of photos * @param array $current_photo. Array represented current photo * * @return string $html rendered html with 'photo-stream-cache' json data for RIA UI */ public function getStackNavigationPanel($stack, $current_photo) { $theme_url = $this->theme->getUrl(); $current = 0; $count = count($stack); $prev_in_stack = null; $next_in_stack = null; foreach ($stack as $photo) { if ($photo['id'] == $current_photo['id']) { if ($current > 0) { $prev_in_stack = $stack[$current - 1]; //$prev_in_stack['url'] = str_replace('%url%', $prev_in_stack['url'], $url_template); } if ($current < $count - 1) { $next_in_stack = $stack[$current + 1]; //$next_in_stack['url'] = str_replace('%url%', $next_in_stack['url'], $url_template); } break; } $current++; } $offset = $current + 1; $html = "<div class='stack-nav' data-photo-id='{$current_photo['id']}'>"; $html .= ' <a href="' . ($prev_in_stack ? isset($prev_in_stack['full_url']) ? $prev_in_stack['full_url'] : $prev_in_stack['url'] : 'javascript:void(0);') . '" class="rewind"><img src="' . $theme_url . 'img/stack-rewind.png"></a>'; $html .= " <strong class='offset'>{$offset}</strong> / {$count}"; $html .= ' <a href="' . ($next_in_stack ? isset($next_in_stack['full_url']) ? $next_in_stack['full_url'] : $next_in_stack['url'] : 'javascript:void(0);') . '" class="ff"><img src="' . $theme_url . 'img/stack-ff.png"></a>'; // hidden stack-stream with class thumb need for rich gradual loading photo effect when go next/prev photo in stack $html .= ' <ul class="photostream" style="display:none;">'; for ($i = 0; $i < $count; ++$i) { $html .= " <li data-photo-id='{$stack[$i]['id']}' " . ($i == $current ? 'class="selected"' : '') . ">"; $html .= " <a href='{$stack[$i]['url']}'><img class='thumb' src='{$stack[$i]['thumb']['url']}" . (!is_null($stack[$i]['edit_datetime']) ? '?' . strtotime($stack[$i]['edit_datetime']) : '') . "'></a>"; $html .= " </li>"; } $html .= ' </ul>'; $html .= '</div>'; $html .= '<script>'; $html .= ' var __photo_stack_data = __photo_stack_data || {};'; $html .= " __photo_stack_data['{$current_photo['id']}'] = " . json_encode($stack); $html .= '</script>'; return $html; }
/** * @param string $theme_id * @return string */ public function themeUrl($theme_id) { $app_id = $this->wa->getConfig()->getApplication(); $theme = new waTheme($theme_id, $app_id); return $theme->path ? $theme->getUrl() : null; }