Example #1
0
 public static function dispatch()
 {
     static::$_uri = $uri = trim($_SERVER['REQUEST_URI'], static::URI_DELIMITER);
     $containerRoute = static::containerRoute();
     if (null !== $containerRoute) {
         return;
     }
     $defaultRoute = static::defaultRoute();
     if (null !== $defaultRoute) {
         return;
     }
     $entities = container()->getEntities();
     /* Pages non routées */
     if (true === container()->getMultiSite() && !empty($entities) && null === container()->getMapRoutes()) {
         $url = substr($_SERVER['REQUEST_URI'], 1);
         $db = new Querydata('page');
         $res = $db->where('is_home = ' . getBool('true')->getId())->get();
         $home = $db->first($res);
         $_homeUrl = Cms::__($home->getUrl());
         $homeUrl = null !== $_homeUrl ? $_homeUrl : 'home';
         $url = !strlen($url) ? $homeUrl : $url;
         $pages = Cms::getPages();
         $cmsRoutes = array();
         $lngs = explode(',', cms_option('page_languages'));
         if (count($pages)) {
             foreach ($pages as $pageTmp) {
                 if (1 < count($lngs)) {
                     $urlTab = $pageTmp->getUrl();
                     foreach ($lngs as $lng) {
                         if (ake($lng, $urlTab)) {
                             $cmsRoutes[$urlTab[$lng]] = $pageTmp;
                         }
                     }
                 } else {
                     $cmsRoutes[Cms::__($pageTmp->getUrl())] = $pageTmp;
                 }
             }
         }
         $found = Arrays::exists($url, $cmsRoutes);
         if (false === $found) {
             $found = Cms::match($cmsRoutes);
         }
         if (true === $found && ake($url, $cmsRoutes)) {
             $page = $cmsRoutes[$url];
             $status = Inflector::lower($page->getStatuspage()->getName());
             $dateDepub = $page->getDateOut();
             $now = time();
             $continue = true;
             if (strlen($dateDepub)) {
                 list($d, $m, $y) = explode('-', $dateDepub, 3);
                 $dateDepub = "{$y}-{$m}-{$d}";
                 $dateDepub = new Date($dateDepub);
             }
             if ($dateDepub instanceof Date) {
                 $ts = $dateDepub->getTimestamp();
                 if ($ts < $now) {
                     $page = $cmsRoutes['home'];
                 }
             }
             if ('offline' == $status) {
                 $continue = false;
             } else {
                 if ('online' != $status) {
                     $page = ake($status, $cmsRoutes) ? $cmsRoutes[$status] : $cmsRoutes['home'];
                 }
             }
             if (true === $continue) {
                 return static::isCms($page);
             }
         }
     }
     if (true === container()->getMultiSite()) {
         $file = APPLICATION_PATH . DS . 'config' . DS . SITE_NAME . DS . 'routes.php';
     } else {
         $file = APPLICATION_PATH . DS . 'config' . DS . 'routes.php';
     }
     if (File::exists($file)) {
         $configRoutes = (include $file);
         $routes = $configRoutes['collection'];
         $routes += null !== container()->getRoutes() ? container()->getRoutes() : array();
         foreach ($routes as $route) {
             if (!$route instanceof Container) {
                 continue;
             }
             $path = $route->getPath();
             if ($path == $uri) {
                 return static::make($route);
             }
         }
         foreach ($routes as $route) {
             if (!$route instanceof Container) {
                 continue;
             }
             if (!strlen($route->getPath())) {
                 continue;
             }
             $matched = static::match($route->getPath());
             if (false === $matched) {
                 continue;
             } else {
                 return static::make($route);
             }
         }
     } else {
         static::make(container()->getNotFoundRoute());
         return;
     }
     if (null === container()->getMapRoutes()) {
         static::is404();
     } else {
         static::make(container()->getNotFoundRoute());
         return;
     }
 }
Example #2
0
    function cms_slideshow($name, $echo = true)
    {
        $html = '';
        Data::getAll('slideshow');
        Data::getAll('slideshowmedia');
        $db = dm('slideshow');
        $res = $db->where('name = ' . $name)->get();
        $slideshowHeight = cms_option('slideshow_height');
        $slideshowBg = cms_option('slideshow_background');
        if (count($res)) {
            $slideshow = $db->first($res);
            $dbMedia = dm('slideshowmedia');
            $rows = $dbMedia->where('slideshow = ' . $slideshow->getId())->order('position')->get();
            if (count($rows)) {
                $html .= '<style>


.slideSize {
    font-size: 24px;
    position: relative;
    top: -15px;
}
.tales {
  width:auto !important;
  margin:auto !important;
  max-height: ' . $slideshowHeight . ' !important;
}
.carousel-inner {
  width:auto !important;
  max-height: ' . $slideshowHeight . ' !important;
  background: ' . $slideshowBg . ';
}
.carousel .item {-webkit-transition: opacity 3s; -moz-transition: opacity 3s; -ms-transition: opacity 3s; -o-transition: opacity 3s; transition: opacity 3s;}
.carousel .active.left {left:0;opacity:0;z-index:2;}
.carousel .next {left:0;opacity:1;z-index:1;}
</style>
<script>
$(document).ready(function() {
    $(\'.carousel\').carousel({
        interval: 2000
    })
});
</script>
                    <div class="row"><div id="slideshow_' . $slideshow->getId() . '" class="carousel slide">';
                $html .= '<ol class="carousel-indicators">';
                for ($i = 0; $i < count($rows); $i++) {
                    $ac = $i < 1 ? 'active' : '';
                    $html .= '<li data-target="#slideshow_' . $slideshow->getId() . '" data-slide-to="' . $i . '" class="' . $ac . '"></li>';
                }
                $html .= '</ol><div class="carousel-inner">';
                $first = true;
                foreach ($rows as $media) {
                    $active = $first ? ' active' : '';
                    $html .= '<div class="item' . $active . '">';
                    $html .= '<a href="' . Cms::__($media->getLink()) . '">';
                    $html .= '<img class="tales" src="' . $media->getImage() . '" alt="' . $slideshow->getName() . ' ' . $media->getPosition() . '" title ="' . $slideshow->getName() . ' ' . $media->getPosition() . '" />';
                    $html .= '</a>';
                    $html .= '<div class="carousel-caption">';
                    $html .= '<p>' . Cms::__($media->getText()) . '</p>';
                    $html .= '</div>';
                    $html .= '</div>';
                    $first = false;
                }
                $html .= '</div>
                    <a class="left carousel-control" href="#slideshow_' . $slideshow->getId() . '" data-slide="prev"><i class="fa fa-arrow-left slideSize"></i></a>
                        <a class="right carousel-control" href="#slideshow_' . $slideshow->getId() . '" data-slide="next"><i class="fa fa-arrow-right slideSize"></i></a>
                    </div></div>';
            }
        }
        if (true === $echo) {
            echo $html;
        } else {
            return $html;
        }
    }