Beispiel #1
0
    public function __construct(BASE_CLASS_WidgetParameter $objParams)
    {
        parent::__construct();
        $uniqName = $objParams->widgetDetails->uniqName;
        $this->assign('uniqName', $uniqName);
        $service = SLIDESHOW_BOL_Service::getInstance();
        $slides = $service->getSlideList($uniqName);
        $this->assign('slides', $slides);
        if ($slides) {
            $url = OW::getPluginManager()->getPlugin('slideshow')->getStaticJsUrl() . 'slides.min.jquery.js';
            OW::getDocument()->addScript($url);
            $settings = $objParams->customParamList;
            $params = array('sizes' => $service->getSizes($slides), 'pagination' => $settings['navigation'] ? "true" : "false", 'interval' => $settings['interval'], 'uniqname' => $uniqName, 'effect' => $settings['effect'], 'preloadImage' => OW::getThemeManager()->getThemeImagesUrl() . '/ajax_preloader_content.gif');
            $url = OW::getPluginManager()->getPlugin('slideshow')->getStaticJsUrl() . 'slideshow.js';
            OW::getDocument()->addScript($url);
            $id = uniqid();
            $script = 'var slideshow' . $id . ' = new slideshow(' . json_encode($params) . '); slideshow' . $id . '.init();';
            if ($objParams->customizeMode) {
                $script .= 'OW.WidgetPanel.bind("move", function(e) {
		            if ( e.widgetName == "' . $uniqName . '" ) {
		               OW.WidgetPanel.reloadWidget("' . $uniqName . '", function(markup, data){});
		            }
		        });';
            }
            OW::getDocument()->addOnloadScript($script);
        }
    }
Beispiel #2
0
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Beispiel #3
0
 public function beforeWidgetPlaceDelete(OW_Event $event)
 {
     $params = $event->getParams();
     $class = $params['class'];
     if ($class != 'SLIDESHOW_CMP_SlideshowWidget') {
         return;
     }
     $uniqName = $params['uniqName'];
     $service = SLIDESHOW_BOL_Service::getInstance();
     $list = $service->getAllSlideList($uniqName);
     if ($list) {
         foreach ($list as $slide) {
             $service->addSlideToDeleteQueue($slide->id);
         }
     }
 }
Beispiel #4
0
 public function updateFile($params)
 {
     if (!OW::getUser()->isAdmin()) {
         throw new AuthenticationException();
         exit;
     }
     $slideId = isset($params['slideId']) ? trim($params['slideId']) : null;
     $service = SLIDESHOW_BOL_Service::getInstance();
     $slide = $service->findSlideById($slideId);
     $result = array('error' => true, 'message' => '');
     if ($slide) {
         $formElementId = 'file_' . $slide->widgetId;
         $language = OW::getLanguage();
         if (empty($_FILES['slide'])) {
             $result['message'] = "File not selected";
         } else {
             $file = $_FILES['slide'];
             if (is_uploaded_file($file['tmp_name'])) {
                 $iniValue = floatval(ini_get('upload_max_filesize'));
                 $maxSize = 1024 * 1024 * ($iniValue ? $iniValue : 4);
                 if (!UTIL_File::validateImage($file['name'])) {
                     $result['message'] = $language->text('slideshow', 'upload_file_extension_not_allowed');
                 } else {
                     if ($file['size'] > $maxSize) {
                         $result['message'] = $language->text('slideshow', 'upload_file_max_filesize_error');
                     } else {
                         if ($service->updateSlideImage($slide->id, $file)) {
                             $result['slide_id'] = $slideId;
                             $result['error'] = false;
                             $result['input_id'] = $formElementId;
                         } else {
                             $result['message'] = $language->text('slideshow', 'upload_file_error');
                         }
                     }
                 }
             }
         }
     }
     exit("<script>parent.window.OW.trigger('slideshow.upload_file_complete', [" . json_encode($result) . "]);</script>");
 }
Beispiel #5
0
 public function uninstall()
 {
     if (isset($_POST['action']) && $_POST['action'] == 'delete_content') {
         $service = SLIDESHOW_BOL_Service::getInstance();
         $list = $service->getAllSlideList();
         if ($list) {
             foreach ($list as $slide) {
                 $service->addSlideToDeleteQueue($slide->id);
             }
         }
         OW::getConfig()->saveConfig('slideshow', 'uninstall_inprogress', 1);
         BOL_ComponentAdminService::getInstance()->deleteWidget('SLIDESHOW_CMP_SlideshowWidget');
         OW::getFeedback()->info(OW::getLanguage()->text('slideshow', 'plugin_set_for_uninstall'));
         $this->redirect();
     }
     $this->setPageHeading(OW::getLanguage()->text('slideshow', 'page_title_uninstall'));
     $this->setPageHeadingIconClass('ow_ic_delete');
     $this->assign('inprogress', (bool) OW::getConfig()->getValue('slideshow', 'uninstall_inprogress'));
     $js = new UTIL_JsGenerator();
     $js->jQueryEvent('#btn-delete-content', 'click', 'if ( !confirm("' . OW::getLanguage()->text('slideshow', 'confirm_delete_plugin') . '") ) return false;');
     OW::getDocument()->addOnloadScript($js);
 }
Beispiel #6
0
 public function __construct($slideId)
 {
     parent::__construct();
     $slide = SLIDESHOW_BOL_Service::getInstance()->findSlideById($slideId);
     $form = new SLIDESHOW_CLASS_EditSlideForm($slide);
     $this->addForm($form);
     $script = '$("#btn-edit-slide").click(function(){
         var file = $("#file_' . $slide->widgetId . '");
         
         if ( file.val() != "" ) {
             OW.inProgressNode($(this));
             window.uploadSlideFields["' . $slide->widgetId . '"].startUpload();
         }
         else {
             window.owForms["edit-slide-form"].submitForm();
         }
     });
     
     document.editSlideFloatbox.bind("close", function(){
         OW.unbind("slideshow.upload_file");
         OW.unbind("slideshow.upload_file_complete");
     });
     
     window.owForms["edit-slide-form"].bind("success", function(data){
         $.ajax({
             type: "post",
             url: ' . json_encode(OW::getRouter()->urlForRoute('slideshow.ajax-redraw-list', array('uniqName' => $slide->widgetId))) . ',
             data: {},
             dataType: "json",
             success: function(data){
                 markup = data.markup;
                 document.editSlideFloatbox.close();
                 $("#slides-tbl tbody").html(data.markup);
             }
         });
     });';
     OW::getDocument()->addOnloadScript($script);
 }
Beispiel #7
0
 public function slideshowUninstallProcess()
 {
     $config = OW::getConfig();
     // check if uninstall is in progress
     if (!$config->getValue('slideshow', 'uninstall_inprogress')) {
         return;
     }
     // check if cron queue is not busy
     if ($config->getValue('slideshow', 'uninstall_cron_busy')) {
         return;
     }
     $config->saveConfig('slideshow', 'uninstall_cron_busy', 1);
     $service = SLIDESHOW_BOL_Service::getInstance();
     $list = $service->getDeleteQueueList(self::SLIDE_DELETE_LIMIT);
     if ($list) {
         foreach ($list as $slide) {
             $service->deleteSlideById($slide->id);
         }
         $config->saveConfig('slideshow', 'uninstall_cron_busy', 0);
     } else {
         $config->saveConfig('slideshow', 'uninstall_inprogress', 0);
         BOL_PluginService::getInstance()->uninstall('slideshow');
     }
 }
Beispiel #8
0
 public function reorderList($params)
 {
     if (!OW::getUser()->isAdmin()) {
         throw new AuthenticationException();
         exit;
     }
     $service = SLIDESHOW_BOL_Service::getInstance();
     if (!empty($_POST['slide-list'])) {
         foreach ($_POST['slide-list'] as $order => $id) {
             $slide = $service->findSlideById($id);
             if (empty($slide)) {
                 continue;
             }
             $slide->order = $order + 1;
             $service->updateSlide($slide);
         }
     }
     exit;
 }
Beispiel #9
0
    public function __construct($uniqName)
    {
        parent::__construct();
        $service = SLIDESHOW_BOL_Service::getInstance();
        $slides = $service->getSlideList($uniqName);
        $markup = '';
        if ($slides) {
            foreach ($slides as $slide) {
                $cmp = new SLIDESHOW_CMP_Slide($slide);
                $markup .= $cmp->render();
            }
        }
        $this->assign('markup', $markup);
        $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl();
        OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js");
        $script = '$("#btn-add-image").click(function(){
            document.addSlideFloatbox = OW.ajaxFloatBox(
        		"SLIDESHOW_CMP_AddSlide", 
        		{uniqName: ' . json_encode($uniqName) . '}, 
        		{width:422, iconClass: "ow_ic_add", title: ' . json_encode(OW::getLanguage()->text('slideshow', 'add_image')) . '}
        	);
        });';
        $script .= '$("#slides-tbl").on("mouseover", "tr", function(){ 
            $(this).find(".ow_slider_actions a").show(); 
        });
        
        $("#slides-tbl").on("mouseout", "tr", function(){
            $(this).find(".ow_slider_actions a").hide(); 
        });
        
        $("#slides-tbl").on("click", "a", function(){
            if ( $(this).hasClass("action_delete_slide") )
            {
                var url = ' . json_encode(OW::getRouter()->urlForRoute('slideshow.ajax-delete-slide')) . ';
                
                if ( confirm(' . json_encode(OW::getLanguage()->text('slideshow', 'delete_slide_confirm')) . ') ){
                    $.ajax({
		                type: "post",
		                url: url,
		                data: { slideId: $(this).attr("rel") },
		                dataType: "json",
		                success: function(data){
		                    markup = data.markup;
		                    $("#slides-tbl tbody").html(data.markup);
		                }
		            });
                }
            }
            else if ( $(this).hasClass("action_edit_slide") )
            {
                var slideId = $(this).attr("rel");
                
                document.editSlideFloatbox = OW.ajaxFloatBox(
                    "SLIDESHOW_CMP_EditSlide", 
                    {slideId: slideId}, 
                    {width:422, iconClass: "ow_ic_edit", title: ' . json_encode(OW::getLanguage()->text('slideshow', 'edit_slide')) . '}
                );
            }
        });';
        $script .= '$("#slides-tbl tbody").sortable({
            cursor: "move",
            update: function(event, ui){
                if ( ui.sender ) { return; }

                var set = {};

                $("tr", "#slides-tbl tbody").each(function(i){
                    set["slide-list["+i+"]"] = $(this).attr("rel");
                });

                var url = ' . json_encode(OW::getRouter()->urlForRoute('slideshow.ajax-reorder-list')) . ';
                $.post(url, set);
            }
        }).disableSelection();';
        OW::getDocument()->addOnloadScript($script);
    }
Beispiel #10
0
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2011, Oxwall Foundation
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
$service = SLIDESHOW_BOL_Service::getInstance();
$list = $service->getAllSlideList();
if ($list) {
    foreach ($list as $slide) {
        $service->addSlideToDeleteQueue($slide->id);
    }
}
BOL_ComponentAdminService::getInstance()->deleteWidget('SLIDESHOW_CMP_SlideshowWidget');