예제 #1
0
 public static function extractShortCode(&$content, $beginShortCode, $endShortCode)
 {
     // Find the opening tag
     $begin = TpsMisc::mb_strpos($content, $beginShortCode);
     if ($begin === false) {
         return null;
     }
     // Find the closing tag
     $end = TpsMisc::mb_strpos($content, $endShortCode, $begin);
     if ($end === false) {
         return null;
     }
     // Cache some string lengths
     $lenBegin = TpsMisc::mb_strlen($beginShortCode);
     $lenEnd = TpsMisc::mb_strlen($endShortCode);
     // If the shortcodes are surrounded by header tags, then extract them too. This is a frequent user error due to the way the text editor inserts shortcodes.
     $beginHeadingTag = $endHeadingTag = '';
     if (preg_match('(<h([1-6])>)', TpsMisc::mb_substr($content, $begin - 4, 4), $beginMatches) && preg_match('(</h([1-6])>)', TpsMisc::mb_substr($content, $end + $lenEnd, 5), $endMatches) && $beginMatches[1] === $endMatches[1]) {
         $beginHeadingTag = $beginMatches[0];
         $endHeadingTag = $endMatches[0];
     }
     $shortCode = $beginHeadingTag . trim(TpsMisc::mb_substr($content, $begin + $lenBegin, $end - $begin - $lenBegin)) . $endHeadingTag;
     $content = TpsMisc::mb_substr($content, 0, $begin - TpsMisc::mb_strlen($beginHeadingTag)) . TpsMisc::mb_substr($content, $end + $lenEnd + TpsMisc::mb_strlen($endHeadingTag));
     return $shortCode;
 }
예제 #2
0
    public static function do_page()
    {
        $tabs = array('general' => array('title' => __("General", 'theia-post-slider'), 'class' => 'General'), 'navigationBar' => array('title' => __("Navigation Bar", 'theia-post-slider'), 'class' => 'NavigationBar'));
        if (array_key_exists('tab', $_GET) && array_key_exists($_GET['tab'], $tabs)) {
            $currentTab = $_GET['tab'];
        } else {
            $currentTab = 'general';
        }
        ?>

		<div class="wrap" xmlns="http://www.w3.org/1999/html">
			<div id="icon-options-general" class="icon32"><br></div>
			<h2>Theia Post Slider</h2>
			<?php 
        settings_errors();
        ?>
			<h2 class="nav-tab-wrapper">
				<?php 
        foreach ($tabs as $id => $tab) {
            $class = 'nav-tab';
            if ($id == $currentTab) {
                $class .= ' nav-tab-active';
            }
            ?>
				    <a href="?page=tps&tab=<?php 
            echo $id;
            ?>
" class="<?php 
            echo $class;
            ?>
"><?php 
            echo $tab['title'];
            ?>
</a>
				    <?php 
        }
        ?>
			</h2>
			<?php 
        $class = 'TpsAdmin_' . $tabs[$currentTab]['class'];
        require $class . '.php';
        $page = new $class();
        $page->echoPage();
        ?>

			<h3><?php 
        _e("Live Preview", 'theia-post-slider');
        ?>
</h3>
			<div class="theiaPostSlider_adminPreview">
				<?php 
        echo TpsMisc::getNavigationBar(array('currentSlide' => 1, 'totalSlides' => 3, 'id' => 'tps_nav_upper', 'class' => '_upper', 'style' => in_array(TpsOptions::get('nav_vertical_position'), array('top_and_bottom', 'top')) ? '' : 'display: none'));
        ?>
				<div id="tps_dest" class="theiaPostSlider_slides"></div>
				<div id="tps_src" class="theiaPostSlider_slides">
					<?php 
        include dirname(__FILE__) . '/preview-slider.php';
        ?>
				</div>
				<?php 
        echo TpsMisc::getNavigationBar(array('currentSlide' => 1, 'totalSlides' => 3, 'id' => 'tps_nav_lower', 'class' => '_lower', 'style' => in_array(TpsOptions::get('nav_vertical_position'), array('top_and_bottom', 'bottom')) ? '' : 'display: none'));
        $sliderOptions = array('src' => '#tps_src > div', 'dest' => '#tps_dest', 'nav' => array('#tps_nav_upper', '#tps_nav_lower'), 'navText' => TpsOptions::get('navigation_text'), 'helperText' => TpsOptions::get('helper_text'), 'transitionEffect' => TpsOptions::get('transition_effect'), 'transitionSpeed' => TpsOptions::get('transition_speed'), 'keyboardShortcuts' => true, 'prevText' => TpsOptions::get('prev_text'), 'nextText' => TpsOptions::get('next_text'), 'buttonWidth' => TpsOptions::get('button_width'));
        ?>
				<script type='text/javascript'>
					var slider, theme;
					jQuery(document).ready(function() {
						slider = new tps.createSlideshow(<?php 
        echo json_encode($sliderOptions);
        ?>
);
					});
				</script>
			</div>
		</div>
		<?php 
    }
예제 #3
0
 public static function getNavigationBar($options)
 {
     $defaults = array('currentSlide' => null, 'totalSlides' => null, 'prevPostId' => null, 'nextPostId' => null, 'prevPostUrl' => null, 'nextPostUrl' => null, 'id' => null, 'class' => null, 'style' => null);
     $options = array_merge($defaults, $options);
     // Get text
     $text = TpsOptions::get('navigation_text');
     $text = str_replace('%{currentSlide}', $options['currentSlide'], $text);
     $text = str_replace('%{totalSlides}', $options['totalSlides'], $text);
     // Get button URLs
     $prev = TpsMisc::getNavigationBarButton($options, false);
     $next = TpsMisc::getNavigationBarButton($options, true);
     // Title
     global $pages, $page;
     $title = TpsShortCodes::extractShortCode($pages[$page - 1], TpsMisc::$beginTitleShortCode, TpsMisc::$endTitleShortCode);
     if (!$title) {
         $title = '<span class="_helper">' . TpsOptions::get('helper_text') . '</span>';
     }
     // Final HTML
     $class = array('theiaPostSlider_nav');
     $class[] = '_' . TpsOptions::get('nav_horizontal_position');
     if ($options['class'] != null) {
         $class[] = $options['class'];
     }
     $html = '<div' . ($options['id'] !== null ? ' id="' . $options['id'] . '"' : '') . ($options['style'] !== null ? ' style="' . $options['style'] . '"' : '') . ' class="' . implode($class, ' ') . '">' . '<div class="_buttons">' . $prev . '<span class="_text">' . $text . '</span>' . $next . '</div>' . '<div class="_title">' . $title . '</div>' . '</div>';
     return $html;
 }