Exemple #1
0
 public static function parseTagSlider(&$content, array &$options, &$templateName, &$fallBack, array $rendererStates, $parentClass)
 {
     $xenOptions = XenForo_Application::get('options');
     $visitor = XenForo_Visitor::getInstance();
     $postid = $parentClass->getPostParam('post_id');
     if ($postid) {
         //tagid by post
         if (!$parentClass->getTagExtra('tagid', $postid)) {
             $parentClass->addTagExtra('tagid', array($postid => 1));
         } else {
             $newTagid = $parentClass->getTagExtra('tagid', $postid) + 1;
             $parentClass->addTagExtra('tagid', array($postid => $newTagid));
         }
         $tagid = $parentClass->getTagExtra('tagid', $postid);
     } else {
         //tagid by page (not sure if it will be used)
         if (!$parentClass->getTagExtra('tagid')) {
             $parentClass->addTagExtra('tagid', 1);
         } else {
             $newTagid = $parentClass->getTagExtra('tagid') + 1;
             $parentClass->addTagExtra('tagid', $newTagid);
         }
         $tagid = $parentClass->getTagExtra('tagid');
     }
     $uniqid = $postid ? "adv_slider_{$postid}_{$tagid}" : $parentClass->uniqid('adv_slider_');
     /*Default Master Options*/
     $width = $xenOptions->AdvBBcodeBar_slider_defaultwidth;
     $widthType = $xenOptions->AdvBBcodeBar_slider_defaultwidth_unit;
     $blockAlign = 'bleft';
     $globalHeight = $xenOptions->AdvBBcodeBar_slider_defaultheight;
     $layout = '';
     $cmd = false;
     $autoplay = false;
     $interval = $xenOptions->AdvBBcodeBar_slider_interval_default == 3000 ? false : $xenOptions->AdvBBcodeBar_slider_interval_default;
     $num = false;
     $noclick = false;
     /*Browse Master Options*/
     foreach ($options as $option) {
         $original = $option;
         $option = BBM_Helper_BbCodes::cleanOption($option);
         if (preg_match('#^\\d+(px)?$#', $option)) {
             $width = str_replace(array('px', '%'), '', $option);
             $widthType = 'px';
         } elseif (preg_match('#^\\d+%$#', $option)) {
             $width = str_replace(array('px', '%'), '', $option);
             $widthType = '%';
         } elseif (preg_match('#^(\\d+?(px)?)x(\\d+?)$#', $option, $matches)) {
             $width = str_replace(array('px', '%'), '', $matches[1]);
             $widthType = 'px';
             $globalHeight = str_replace(array('px', '%'), '', $matches[3]);
         } elseif (preg_match('#^(\\d+?%)x(\\d+?)$#', $option, $matches)) {
             $width = str_replace(array('px', '%'), '', $matches[1]);
             $widthType = '%';
             $globalHeight = str_replace(array('px', '%'), '', $matches[2]);
         } elseif ($option == 'bleft') {
             $blockAlign = 'bleft';
         } elseif ($option == 'bcenter') {
             $blockAlign = 'bcenter';
         } elseif ($option == 'bright') {
             $blockAlign = 'bright';
         } elseif ($option == 'fleft') {
             $blockAlign = 'fleft';
         } elseif ($option == 'fright') {
             $blockAlign = 'fright';
         } elseif ($option == 'inside') {
             $layout = 'inside';
         } elseif ($option == 'cmd') {
             $cmd = true;
         } elseif ($option == 'num') {
             $num = true;
         } elseif ($option == 'autoplay' && $xenOptions->AdvBBcodeBar_slider_autoplay_authorise) {
             $autoplay = true;
         } elseif (preg_match('#^\\d+ms$#', $option)) {
             $interval = str_replace('ms', '', $option);
         } elseif ($option == 'noclick') {
             $noclick = true;
         }
     }
     /* Check Options */
     if ($widthType == '%' && $width > 100) {
         $width = 100;
     }
     if (!preg_match('#^\\d{2,3}$#', $width) || $widthType == 'px' && $width > $xenOptions->AdvBBcodeBar_slider_maxwidth) {
         $width = $xenOptions->AdvBBcodeBar_slider_maxwidth;
         $widthType = 'px';
     }
     if ($globalHeight > $xenOptions->AdvBBcodeBar_slider_maxheight) {
         $globalHeight = $xenOptions->AdvBBcodeBar_slider_maxheight;
     }
     $layout = !BBM_Helper_BbCodes::isBadIE(8) ? $layout : '';
     //Prevent IE6&IE7 to use the inside layout
     if ($interval && ($interval > $xenOptions->AdvBBcodeBar_slider_interval_max || $interval < $xenOptions->AdvBBcodeBar_slider_interval_min)) {
         $interval = $xenOptions->AdvBBcodeBar_slider_interval_default;
         $interval = $interval == 3000 ? false : $interval;
     }
     /*Get slides from content*/
     $wip = BBM_Helper_BbCodes::getSpecialTags($content);
     $content = '';
     //Raz content
     $slides = array();
     $requestUri = $parentClass->getRequestPath();
     //needed for noscript
     $hasImage = false;
     foreach ($wip as $k => $slide) {
         $id = $k + 1;
         $content = $slide['content'];
         $slide_attributes = $slide['option'];
         $title = '';
         $hasAlreadyBeenOpened = false;
         $open = false;
         $image = false;
         $align = 'left';
         $attachmentParams = false;
         $absoluteTitle = false;
         $fullClass = '';
         if ($slide_attributes) {
             $slideOptions = explode('|', $slide_attributes);
             /*Browse Slave Options*/
             foreach ($slideOptions as $slideOption) {
                 $original = $slideOption;
                 $slideOption = BBM_Helper_BbCodes::cleanOption($slideOption);
                 if ($slideOption == 'left') {
                     $align = 'left';
                 } elseif ($slideOption == 'center') {
                     $align = 'center';
                 } elseif ($slideOption == 'right') {
                     $align = 'right';
                 } elseif ($slideOption == 'bottom') {
                     $absoluteTitle = 'bottom';
                 } elseif ($slideOption == 'top') {
                     $absoluteTitle = 'top';
                 } elseif ($slideOption == 'open') {
                     if ($hasAlreadyBeenOpened == false) {
                         $hasAlreadyBeenOpened = $open = true;
                     }
                 } elseif (preg_match('#^\\d+$#i', $slideOption)) {
                     $validExtensions = array('gif', 'png', 'jpg', 'jpeg');
                     $permsFallback[] = $xenOptions->AdvBBcodeBar_fallbackperms ? array('group' => 'forum', 'permission' => 'viewAttachment') : null;
                     $attachmentParams = $parentClass->getAttachmentParams($slideOption, $validExtensions, $permsFallback);
                     $image = true;
                     $hasImage = true;
                 } elseif ($slideOption == 'full') {
                     $fullClass = 'full';
                 } elseif (!empty($slideOption)) {
                     $title = $original;
                 }
             }
         }
         $slides[$id] = array('title' => $xenOptions->AdvBBcodeBar_slider_titles_raw ? strip_tags($title) : $title, 'absoluteTitle' => $absoluteTitle, 'align' => $align, 'open' => $open, 'fullClass' => $fullClass, 'image' => $image, 'content' => $content, 'attachParams' => $attachmentParams);
     }
     /* Confirm Options */
     $autodiff = 100;
     $options['uniqid'] = $uniqid;
     $options['width'] = $width;
     $options['widthType'] = $widthType;
     $options['height'] = $globalHeight;
     $options['blockAlign'] = $blockAlign;
     $options['layout'] = $layout;
     $options['slides'] = $slides;
     $options['autodiff'] = $autodiff;
     $options['autowidth'] = $widthType == '%' ? 'advAutoWidth' : '';
     $options['innerwidth'] = $widthType == 'px' && $layout != 'inside' ? $width - $autodiff . 'px' : '100%';
     $options['cmd'] = $cmd;
     $options['num'] = $num;
     $options['autoplay'] = $autoplay;
     $options['interval'] = $interval;
     $options['noclick'] = $noclick;
     /* Responsive Management */
     $useResponsiveMode = BBM_Helper_BbCodes::useResponsiveMode();
     $options['responsiveMode'] = $useResponsiveMode;
     if ($useResponsiveMode) {
         //Make it almost full width, no reason to limit the width for the readers here
         if ($widthType == 'px' && $hasImage) {
             $options['width'] = $xenOptions->sedo_adv_responsive_maxwidth;
             $coeffDelta = $xenOptions->sedo_adv_responsive_maxwidth > $width ? $width / $xenOptions->sedo_adv_responsive_maxwidth : $xenOptions->sedo_adv_responsive_maxwidth / $width;
             $options['height'] = $globalHeight * $coeffDelta;
         } else {
             $options['width'] = '90';
             $options['widthType'] = '%';
             $options['autowidth'] = 'advAutoWidth';
             $options['innerwidth'] = '100%';
         }
         $options['blockAlign'] = $xenOptions->sedo_adv_responsive_blockalign;
         $options['autowidth'] = $options['widthType'] == '%' ? 'advAutoWidth' : '';
         $options['innerwidth'] = $options['widthType'] == 'px' && $layout != 'inside' ? $options['width'] - $autodiff . 'px' : '100%';
     }
 }