コード例 #1
0
ファイル: image.php プロジェクト: MBerguer/wp-demo
 static function render($slider, $id, $params)
 {
     $html = '';
     $play = $params->get(self::$key . 'play-image');
     $playColor = $params->get(self::$key . 'play-color');
     if (empty($play)) {
         $play = $params->get(self::$key . 'play');
         if ($play == -1) {
             $play = null;
         } elseif ($play[0] != '$') {
             $play = N2Uri::pathToUri(dirname(__FILE__) . '/image/play/' . $play);
         }
     }
     if ($params->get(self::$key . 'mirror')) {
         $pause = str_replace('image/play/', 'image/pause/', $play);
         $pauseColor = $playColor;
     } else {
         $pause = $params->get(self::$key . 'pause-image');
         $pauseColor = $params->get(self::$key . 'pause-color');
         if (empty($pause)) {
             $pause = $params->get(self::$key . 'pause');
             if ($pause == -1) {
                 $pause = null;
             } elseif ($pause[0] != '$') {
                 $pause = N2Uri::pathToUri(dirname(__FILE__) . '/image/pause/' . $pause);
             }
         }
     }
     $ext = pathinfo($play, PATHINFO_EXTENSION);
     if (substr($play, 0, 1) == '$' && $ext == 'svg') {
         list($color, $opacity) = N2Color::colorToSVG($playColor);
         $play = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), N2Filesystem::readFile(N2ImageHelper::fixed($play, true))));
     } else {
         $play = N2ImageHelper::fixed($play);
     }
     $ext = pathinfo($pause, PATHINFO_EXTENSION);
     if (substr($pause, 0, 1) == '$' && $ext == 'svg') {
         list($color, $opacity) = N2Color::colorToSVG($pauseColor);
         $pause = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), N2Filesystem::readFile(N2ImageHelper::fixed($pause, true))));
     } else {
         $pause = N2ImageHelper::fixed($pause);
     }
     if ($play && $pause) {
         N2CSS::addFile(N2Filesystem::translate(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'image' . DIRECTORY_SEPARATOR . 'style.css'), $id);
         N2JS::addFile(N2Filesystem::translate(dirname(__FILE__) . '/image/autoplay.js'), $id);
         list($displayClass, $displayAttributes) = self::getDisplayAttributes($params, self::$key);
         $styleClass = N2StyleRenderer::render($params->get(self::$key . 'style'), 'heading', $slider->elementId, 'div#' . $slider->elementId . ' ');
         list($style, $attributes) = self::getPosition($params, self::$key);
         N2JS::addInline('new NextendSmartSliderWidgetAutoplayImage("' . $id . '", ' . floatval($params->get(self::$key . 'responsive-desktop')) . ', ' . floatval($params->get(self::$key . 'responsive-tablet')) . ', ' . floatval($params->get(self::$key . 'responsive-mobile')) . ');');
         $html = N2Html::tag('div', $displayAttributes + $attributes + array('class' => $displayClass . $styleClass . 'nextend-autoplay nextend-autoplay-image', 'style' => $style), N2Html::image($play, '', array('class' => 'nextend-autoplay-play n2-ow')) . N2Html::image($pause, '', array('class' => 'nextend-autoplay-pause n2-ow')));
     }
     return $html;
 }
コード例 #2
0
 private static function getHTML($id, &$params, $animation, $side, $image, $displayClass, $displayAttributes, $styleClass, $color = 'ffffffcc', $hover = 0, $hoverColor = 'ffffffcc')
 {
     list($style, $attributes) = self::getPosition($params, self::$key . $side . '-');
     $imageHover = null;
     $ext = pathinfo($image, PATHINFO_EXTENSION);
     if (substr($image, 0, 1) == '$' && $ext == 'svg') {
         list($color, $opacity) = N2Color::colorToSVG($color);
         $content = N2Filesystem::readFile(N2ImageHelper::fixed($image, true));
         $image = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), $content));
         if ($hover) {
             list($color, $opacity) = N2Color::colorToSVG($hoverColor);
             $imageHover = 'data:image/svg+xml;base64,' . base64_encode(str_replace(array('fill="#FFF"', 'opacity="1"'), array('fill="#' . $color . '"', 'opacity="' . $opacity . '"'), $content));
         }
     } else {
         $image = N2ImageHelper::fixed($image);
     }
     if ($imageHover === null) {
         $image = N2Html::image($image, 'arrow');
     } else {
         $image = N2Html::image($image, 'arrow', array('class' => 'n2-arrow-normal-img')) . N2Html::image($imageHover, 'arrow', array('class' => 'n2-arrow-hover-img'));
     }
     if ($animation == 'none' || $animation == 'fade') {
         return N2Html::tag('div', $displayAttributes + $attributes + array('id' => $id . '-arrow-' . $side, 'class' => $displayClass . $styleClass . 'nextend-arrow n2-ib nextend-arrow-' . $side . '  nextend-arrow-animated-' . $animation, 'style' => $style), $image);
     }
     return N2Html::tag('div', $displayAttributes + $attributes + array('id' => $id . '-arrow-' . $side, 'class' => $displayClass . 'nextend-arrow n2-ib nextend-arrow-animated nextend-arrow-animated-' . $animation . ' nextend-arrow-' . $side, 'style' => $style), N2Html::tag('div', array('class' => $styleClass . ' n2-resize'), $image) . N2Html::tag('div', array('class' => $styleClass . ' n2-active n2-resize'), $image));
 }