Пример #1
0
 function actionEditshow($params = '')
 {
     $objSlideshow = new SlideshowModel();
     $show_id = !empty($params['show_id']) ? intval($params['show_id']) : false;
     if (!empty($params['dosave'])) {
         $saveData = array();
         $saveData['id'] = $show_id;
         $saveData['title'] = !empty($params['show_title']) ? $params['show_title'] : 'Unnamed';
         $saveData['keyName'] = !empty($params['show_keyname']) ? $params['show_keyname'] : false;
         $saveData['delay'] = !empty($params['show_delay']) ? $params['show_delay'] : 1;
         $saveData['transition'] = !empty($params['show_transition']) ? $params['show_transition'] : 'fade';
         $saveData['width'] = !empty($params['show_width']) ? $params['show_width'] : 320;
         $saveData['height'] = !empty($params['show_height']) ? $params['show_height'] : 240;
         $show_id = $objSlideshow->saveShow($saveData);
         //upload slides
         if (!empty($params['uploads']['newslide']['name'])) {
             foreach ($params['uploads']['newslide']['name'] as $pointer => $ignore) {
                 if (!empty($params['uploads']['newslide']['tmp_name'][$pointer])) {
                     $newSlide = array();
                     $newSlide['name'] = $params['uploads']['newslide']['name'][$pointer];
                     $newSlide['tmp_name'] = $params['uploads']['newslide']['tmp_name'][$pointer];
                     $uploadedSlide = $objSlideshow->uploadSlide($newSlide);
                     if ($uploadedSlide) {
                         $params['show_slides'][] = $uploadedSlide;
                     } else {
                         $this->messages[] = array('type' => 'error', 'message' => 'Unable to upload slide.');
                     }
                 }
             }
         }
         //save slide to show
         if (!empty($params['show_slides'])) {
             foreach ($params['show_slides'] as $slide) {
                 $saveData = array();
                 $saveData['id'] = !empty($slide['id']) ? $slide['id'] : false;
                 $saveData['show_id'] = $show_id;
                 $saveData['title'] = $slide['title'];
                 $saveData['description'] = $slide['description'];
                 $saveData['image'] = $slide['image'];
                 $saveData['link'] = $slide['link'];
                 $saveData['windowaction'] = !empty($slide['windowaction']) ? '_blank' : '_self';
                 $objSlideshow->saveSlide($saveData);
             }
         }
         $this->messages[] = array('type' => 'success', 'message' => 'Slideshow has been saved.');
         if ($params['submit'] == 'Save and Close') {
             $this->actionIndex();
             return;
         }
     }
     if (!empty($show_id)) {
         $showInfo = $objSlideshow->loadShow($show_id);
         $slideList = $objSlideshow->getSlides($show_id);
         $this->view->assign('slideList', $slideList);
         $this->view->assign('showInfo', $showInfo);
     }
     $this->view->assign('content', $this->view->fetch('tpl/slideshows/show.tpl'));
     $this->view->assign('messages', $this->messages);
     $this->finish();
 }
Пример #2
0
/**
 * Smarty {slideshow_adv} block plugin
 *
 * Type:     block<br>
 * Name:     slideshow_adv<br>
 * Purpose:  Loads in a slideshow from the database<br>
 * Useage:
 * 
 * 
 * @author Nathan Gardner <*****@*****.**>
 */
function smarty_block_slideshow_adv($params, $content, &$smarty, $firstRun)
{
    if ($firstRun) {
        if (!empty($params['identifier']) && !empty($params['varname'])) {
            $objSlideshow = new SlideshowModel();
            $showId = $objSlideshow->getShowId($params['identifier']);
            if (!empty($showId)) {
                $showInfo = $objSlideshow->loadShow($showId);
                $showInfo['slides'] = $objSlideshow->getSlides($showId);
                $smarty->assign($params['varname'], $showInfo);
            } else {
                return 'ERROR: Unknown identifier';
            }
        } else {
            return 'ERROR: Must pass an identifier and a name';
        }
    } else {
        return $content;
    }
}
Пример #3
0
/**
 * Smarty {slideshow} function plugin
 *
 * Type:     function<br>
 * Name:     slideshow<br>
 * Purpose:  Loads in a slideshow from the database<br>
 * @author Nathan Gardner <*****@*****.**>
 * @param array
 * @param Smarty
 */
function smarty_function_slideshow($params, &$smarty)
{
    if (!empty($params['identifier'])) {
        $objSlideshow = new SlideshowModel();
        $showId = $objSlideshow->getShowId($params['identifier']);
        if (!empty($showId)) {
            $showInfo = $objSlideshow->loadShow($showId);
            $showInfo['slides'] = $objSlideshow->getSlides($showId);
            $jsOutput = '
            <script type="text/javascript">
            $(document).ready(function() {
                $(\'#slideshow_' . $showId . '\').cycle({
                   fx: \'' . $showInfo['transition'] . '\',
                   timeout: ' . $showInfo['delay'] * 1000 . ',
                   pager: \'#navi_' . $showId . '\',
                   pagerAnchorBuilder: function(idx, slide) { 
                   		return \'<a href="#"><img src="/bento/img/x.gif"/></a>\'; 
					} 
                });
            });
            </script>
            ';
            $output = $jsOutput . "\r\n";
            $output .= '
            <div class="slideshow" style="width:' . $showInfo['width'] . 'px; height:' . $showInfo['height'] . 'px;">
                
                <div class="navi" id="navi_' . $showId . '"></div>
                
                <div class="slideshow-slides" id="slideshow_' . $showId . '">
                
            ';
            foreach ($showInfo['slides'] as $slide) {
                $output .= '
                <div class="slide">
                    <div class="slide-box">
                        <p class="slide-title">' . $slide['title'] . '</p>
                        <p class="slide-info">' . $slide['description'] . '</p>
                    </div>
                    ';
                if (!empty($slide['link'])) {
                    $output .= '<a href="' . $slide['link'] . '" target="' . $slide['windowaction'] . '">';
                }
                $output .= '<img src="/image.php?f=' . $slide['image'] . '&amp;w=' . $showInfo['width'] . '&amp;h=' . $showInfo['height'] . '&amp;" alt="' . $slide['title'] . '"/>';
                if (!empty($slide['link'])) {
                    $output .= '</a>';
                }
                $output .= '
                </div>
                ';
            }
            $output .= '
                
                </div>
                
            </div>
            ';
            return $output;
        } else {
            return 'ERROR: Unknown slideshow';
        }
    } else {
        return 'ERROR: Must pass identifier';
    }
}