Пример #1
0
function static_url($arr)
{
    if ($arr) {
        return \Clips\static_url($arr[0]);
    }
    return false;
}
Пример #2
0
 public function filter_after($chain, $controller, $method, $args, $request, $controller_ret)
 {
     $scsses = \Clips\context('scss');
     if ($scsses) {
         $cache = $this->filecache->cacheDir();
         $forward_method = \Clips\context('forward_method');
         if ($forward_method) {
             $method = $forward_method;
         }
         $full_name = \Clips\to_flat(get_class($controller)) . '_' . $method;
         $uri = \Clips\path_join(\Clips\path_join($cache, 'css'), $full_name);
         $cache_filename = \Clips\path_join($cache, 'css', \Clips\to_flat(get_class($controller) . '_' . $method) . '.css');
         if (file_exists($cache_filename) && !\Clips\config('debug_sass')) {
             \Clips\add_css(\Clips\static_url($uri));
             return;
         }
         if (\Clips\config('debug_sass')) {
             $this->sass->source_map_file = $cache_filename . '.map';
             $this->sass->source_comments = true;
             $this->sass->source_map_embed = true;
             $this->sass->source_map_contents = true;
         }
         // Add the sass_dir into include pathes
         $result = $this->sass->compile($scsses);
         if ($result) {
             $this->filecache->save(\Clips\to_flat(get_class($controller) . '_' . $method) . '.css', $result, \Clips\path_join($cache, 'css'), true);
             \Clips\add_css(\Clips\static_url($uri));
         }
     }
 }
Пример #3
0
function smarty_function_img($params, $template)
{
    $uri = Clips\get_default($params, 'uri');
    if ($uri) {
        unset($params['uri']);
        $params['src'] = Clips\static_url($uri);
    }
    return Clips\create_tag('img', $params);
}
Пример #4
0
function smarty_block_figure($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        Clips\clips_context('indent_level', 1, true);
        return;
    }
    $src = Clips\get_default($params, 'src');
    $path = Clips\get_default($params, 'path', 'responsive/size');
    $resolutions = Clips\get_default($params, 'resolutions');
    $img_path = Clips\find_image($src);
    if (!$img_path) {
        Clips\error('figure', array('Can\'t find image ' . $src . '!'));
        return '';
    }
    $size = Clips\image_size($img_path);
    $size = $size['width'];
    if ($resolutions) {
        // If we are using auto resizing, skip the resolutions
        foreach ($resolutions as $res) {
            $attr['data-media' . $res] = Clips\site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src);
        }
    } else {
        $attr = array('path' => Clips\site_url($path));
    }
    foreach ($params as $key => $value) {
        if ($key == 'path') {
            continue;
        }
        if (strpos($key, 'media') !== false) {
            $attr['data-' . $key] = Clips\site_url('responsive/size/' . $value . '/' . $src);
        } else {
            $attr[$key] = $value;
        }
    }
    $caption = Clips\create_tag_with_content('figcaption', $content);
    $image_dir = Clips\config('image_dir');
    if ($image_dir) {
        $image_dir = $image_dir[0];
    } else {
        $image_dir = 'application/static/img/';
    }
    $img = Clips\create_tag('img', array('src' => Clips\static_url(Clips\path_join($image_dir, $src))));
    $noscript = Clips\create_tag_with_content('noscript', $img);
    $level = Clips\context('indent_level');
    if ($level === null) {
        $level = 0;
    } else {
        $level = count($level);
    }
    $indent = '';
    for ($i = 0; $i < $level; $i++) {
        $indent .= "\t";
    }
    Clips\context_pop('indent_level');
    return Clips\create_tag_with_content('figure', $noscript . "\n{$indent}" . $caption, $attr);
}
Пример #5
0
function smarty_block_uri($params, $content = '', $template, &$repeat)
{
    if ($repeat) {
        return;
    }
    if (Clips\get_default($params, 'static')) {
        return Clips\static_url($content);
    }
    return Clips\base_url($content);
}
 /**
  * @Clips\Model("user")
  * @Clips\Form('admin/login')
  */
 public function index_form()
 {
     $result = $this->user->testPassword($this->post('username'), $this->post('password'));
     if (is_numeric($result)) {
         $this->request->session('user_id', $result);
         return $this->redirect(\Clips\static_url('admin/user/coupon'));
     } else {
         //TODO add alert info
         return $this->redirect(\Clips\static_url('admin/home'));
     }
 }
 /**
  * @Clips\Widget({"game", "home"})
  * @Clips\Scss("welcome/home")
  */
 public function home()
 {
     $args = ['set_dl' => true];
     $this->context('ds_names', ['lastMonthName', 'lastMonthList', 'latestList', 'randList', 'hottestList', 'page_tab', 'dl']);
     $args['latestList'] = $this->app->getLatestAppsF();
     $args['lastMonthList'] = $this->app->getMonthAppsF(new \DateTime());
     $args['randList'] = $this->app->getRandAppsF();
     $args['hottestList'] = $this->app->getTopAppsF();
     $args['lastMonthName'] = $this->app->getLastMonthName() . '精选游戏';
     $args['page_tab'] = 'tab_recommend';
     $args['dl'] = \Clips\static_url('app/download');
     return $this->render('welcome/home', $args);
 }
 public function getGameCategories()
 {
     $categories = $this->select('categories.id, categories.name, categories.config')->from('categories')->where(['categories.status' => self::ACTIVE, 'categories.path like ?' => $this->getGamePath() . '%', 'categories.path <> ?' => $this->getGamePath()])->orderBy('categories.id')->result();
     return array_map(function ($category) {
         $category->config = json_decode($category->config);
         if (isset($category->config->icon)) {
             $category->icon = $category->config->icon;
         }
         $category->href = \Clips\static_url('app/lists/' . $category->id);
         unset($category->config);
         return $category;
     }, $categories);
 }
Пример #9
0
 public function filter_after($chain, $controller, $method, $args, $request, $controller_ret)
 {
     $js = \Clips\context('js');
     if ($js) {
         if (!is_array($js)) {
             $js = array($js);
         }
         $js = array_map(function ($item) {
             if (is_array($item)) {
                 $js = explode("\n", $item['script']);
                 $ret = array('<script type="text/javascript">');
                 foreach ($js as $line) {
                     $ret[] = "\t" . $line;
                 }
                 $ret[] = '</script>';
                 return implode("\n\t\t", $ret);
             }
             if (is_object($item)) {
                 $js = explode("\n", $item->script);
                 $ret = array('<script type="text/javascript">');
                 foreach ($js as $line) {
                     $ret[] = "\t" . trim($line);
                 }
                 $ret[] = '</script>';
                 return implode("\n\t\t", $ret);
             } else {
                 $path = \Clips\safe_add_extension($item, 'js');
                 if (strpos($path, 'http:') === false) {
                     $path = \Clips\static_url($path);
                 }
                 return '<script type="text/javascript" src="' . $path . '"></script>';
             }
         }, $js);
         // Added the jsx support for ReactJs
         $jsx = \Clips\context('jsx');
         if ($jsx) {
             foreach ($jsx as $item) {
                 $js[] = '<script type="text/jsx" src="' . \Clips\static_url(\Clips\safe_add_extension($item, 'jsx')) . '"></script>';
             }
         }
         \Clips\context('js', implode("\n\t\t", $js), false);
     } else {
         \Clips\context('js', '');
     }
 }
 private function buildApps($apps)
 {
     return array_map(function ($app) {
         $app->config = json_decode($app->config);
         $app->href = \Clips\static_url('app/detail/' . $app->id);
         if (isset($app->config->icon)) {
             $app->icon = $app->config->icon;
         }
         if (isset($app->config->poster)) {
             $app->poster = $app->config->poster;
         }
         if (isset($app->config->content)) {
             $app->content = $app->config->content;
         }
         if (isset($app->config->size)) {
             $app->size = $app->config->size;
         }
         if (isset($app->config->company)) {
             $app->company = $app->config->company;
         }
         if (isset($app->config->filename)) {
             $app->filename = $app->config->filename;
         }
         if (isset($app->config->online_time)) {
             $app->online_time = $app->config->online_time;
         } else {
             $app->online_time = 30;
         }
         $app->online_time_action = round($app->online_time / 60, 2) . '小时';
         unset($app->config);
         if (isset($app->number)) {
             $app->number = $this->formatDownloadNumber($app->number);
         }
         return $app;
     }, $apps);
 }
Пример #11
0
 /**
  * @Clips\Form({"search"})
  * @Clips\Model({"title","column","movie"})     
  * @Clips\Widget({"epg", "navigation", "image"})
  * @Clips\Scss({"welcome/index"})
  * @Clips\Js({"application/static/js/welcome/index.js"})
  */
 public function index()
 {
     $this->title('Pinet Home Page', true);
     return $this->render('welcome/index', array('actions' => $this->navigation(), 'items' => array((object) array('title' => 'nature1', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/1'), (object) array('title' => 'nature2', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/2'), (object) array('title' => 'nature3', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/3'), (object) array('title' => 'nature4', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/4'), (object) array('title' => 'nature5', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/5'), (object) array('title' => 'nature6', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/6'), (object) array('title' => 'nature7', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/7'), (object) array('title' => 'nature8', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/8'), (object) array('title' => 'nature9', 'res' => 'test/01.png', 'image' => 'http://lorempixel.com/1200/1200/nature/9')), "tab" => array("navs" => array('nav1', 'nav2', 'nav3'), "contents" => array((object) array('title' => 'movie1', 'info' => 'sdsdsdsdsds'), (object) array('episodes' => '1,2,3,4,5'), (object) array('number' => array('sdsds', 'sdsds', 'sdsdsds')))), "videos" => array((object) array('title' => 'movie title1', 'count' => '152万', 'imageSrc' => \Clips\static_url('application/static/img/test/01.png')), (object) array('title' => 'movie title2', 'count' => '152万', 'imageSrc' => \Clips\static_url('application/static/img/test/01.png')), (object) array('title' => 'movie title3', 'count' => '152万', 'imageSrc' => \Clips\static_url('application/static/img/test/01.png')), (object) array('title' => 'movie title4', 'count' => '152万', 'imageSrc' => \Clips\static_url('application/static/img/test/01.png')), (object) array('title' => 'movie title5', 'count' => '152万', 'imageSrc' => \Clips\static_url('application/static/img/test/01.png')), (object) array('title' => 'movie title6', 'count' => '152万', 'imageSrc' => \Clips\static_url('application/static/img/test/01.png')))));
 }
Пример #12
0
 /**
  * @Clips\Form({"search"})
  * @Clips\Widget({"epg", "navigation", "image"})
  * @Clips\Scss({"welcome/list"})
  * @Clips\Js({"application/static/js/welcome/list.js"})
  * @Clips\Model({"column", "movie", "title"})
  */
 public function sift($columnID)
 {
     $this->request->session('column_id', $columnID);
     $sift = $this->request->session('sift') ? $this->request->session('sift') : array();
     if ($this->request->session('search')) {
         $sift['search'] = $this->request->session('search');
     }
     $this->request->session('sift', array_merge($sift, $this->get()));
     $siftTypes = $this->movie->sift($columnID);
     $movies = $this->video->getNewsByColumnID($columnID, $offset = 0, $limit = 10);
     //		$movies = $this->title->siftRecords($movies, $this->request->session('sift'));
     $movies = $this->video->siftRecords($this->request->session('sift'), $columnID);
     return $this->render('movie/list', array('nav' => true, 'slider' => true, 'column_id' => $columnID, 'movies' => $movies, "sifts" => $this->column->getTypeNav(), "tab" => array("navs" => array(array('name' => '最新', 'url' => \Clips\static_url('movie/index/' . $columnID . '/new')), array('name' => '最热', 'url' => \Clips\static_url('movie/index/' . $columnID . '/hot'))), "contents" => array((object) array('title' => 'movie1', 'info' => 'sdsdsdsdsds'), (object) array('episodes' => '1,2,3,4,5'), (object) array('number' => array('sdsds', 'sdsds', 'sdsdsds'))))));
 }
 public function download($app_id, $filename)
 {
     $time = 0;
     if ($this->download->getWithInDay($app_id)) {
         $app = $this->app->getDetail($app_id);
         if (isset($app->online_time)) {
             $time = $app->online_time;
         }
     }
     $id = $this->download->addLog($app_id, $this->request->get('info', ''));
     $uri = \Clips\static_url('/application/static/apps/' . $filename);
     return $this->redirect($uri);
 }
Пример #14
0
function smarty_function_js($params, $template)
{
    $tool = \Clips\get_clips_tool();
    //Processing jquery init
    $init = \Clips\clips_context('jquery_init');
    if ($init) {
        if (!is_array($init)) {
            $init = array($init);
        }
        $init[] = "if(typeof initialize === 'function') initialize();";
        \Clips\add_init_js("//====================================\n// The jQuery initialize function \n//====================================\n\n" . 'jQuery(function($){' . "\n\t" . implode("\n\t", $init) . "\n" . '});');
    }
    // Processing js
    $scripts = \Clips\context('js');
    if ($scripts) {
        if (!is_array($scripts)) {
            $scripts = array($scripts);
        }
        $output = array();
        $init = array();
        foreach ($scripts as $item) {
            if (is_array($item)) {
                $js = explode("\n", $item['script']);
                $ret = array();
                foreach ($js as $line) {
                    $ret[] = "\t" . $line;
                }
                $init[] = implode("\n\t\t", $ret);
            } else {
                if (is_object($item)) {
                    $js = explode("\n", $item->script);
                    $ret = array();
                    foreach ($js as $line) {
                        $ret[] = "\t" . trim($line);
                    }
                    $init[] = implode("\n\t\t", $ret);
                } else {
                    $path = \Clips\safe_add_extension($item, 'js');
                    if (strpos($path, 'http:') === false) {
                        $path = \Clips\static_url($path);
                    }
                    $output[] = '<script type="text/javascript" src="' . $path . '"></script>';
                }
            }
        }
        $output[] = '<script type="text/javascript">' . "\n\t\t" . implode("\n\t\t", $init) . "\n\t\t" . '</script>';
        // Added the jsx support for ReactJs
        $jsx = \Clips\context('jsx');
        if ($jsx) {
            if (\Clips\config('babel')) {
                // TODO: This is a little bit ugly, needs refactor....
                $babel = $tool->library('babel');
                foreach ($jsx as $item) {
                    $path = Clips\try_path(Clips\safe_add_extension($item, 'jsx'));
                    if ($path) {
                        $output[] = '<script type="text/javascript" src="' . Clips\static_url($babel->compile($path)) . '"></script>';
                    }
                }
            } else {
                foreach ($jsx as $item) {
                    $output[] = '<script type="text/babel" src="' . Clips\static_url(Clips\safe_add_extension($item, 'jsx')) . '"></script>';
                }
            }
        }
        $jsx = \Clips\context('jsx_script');
        if ($jsx) {
            if (\Clips\config('babel')) {
                $babel = $tool->library('babel');
                $cache = $tool->library('fileCache');
                $c = \Clips\context('controller');
                $cm = \Clips\context('controller_method');
                $name = $c . '_' . $cm . '.jsx';
                $cache_file = $cache->cacheDir() . '/js/cache/' . $c . '_' . $cm . '.js';
                if (\Clips\try_path($cache_file) && !\Clips\config('debug_jsx')) {
                    $output[] = '<script type="text/javascript" src="' . Clips\static_url($cache_file) . '"></script>';
                } else {
                    $cache->save($name, $jsx, \Clips\path_join($cache->cacheDir(), 'js'));
                    $output[] = '<script type="text/javascript" src="' . Clips\static_url($babel->compile($cache->cacheDir() . '/js/' . $name)) . '"></script>';
                }
            } else {
                $output[] = '<script type="text/babel">' . implode("\n\t\t", $jsx) . '</script>';
            }
        }
        return implode("\n\t\t", $output);
    } else {
        return '';
    }
}
Пример #15
0
function smarty_function_picture($params, $template)
{
    $src = Clips\get_default($params, 'src');
    if ($src) {
        if (preg_match('/_\\([A-Za-z0-9_]+\\)/', $src)) {
            $is_template = true;
        }
    }
    if (!isset($is_template)) {
        $path = Clips\get_default($params, 'path', 'responsive/size');
        $resolutions = Clips\get_default($params, 'resolutions');
        $medias = Clips\get_default($params, 'medias');
        $img_path = Clips\find_image($src);
        if (!$img_path) {
            Clips\error('picture', array('Can\'t find image ' . $src . '!'));
            return '';
        }
        $size = Clips\image_size($img_path);
        $size = $size['width'];
        $content = array();
        $level = Clips\context('indent_level');
        if ($level === null) {
            $level = 0;
        } else {
            $level = count($level);
        }
        $indent = '';
        for ($i = 0; $i < $level; $i++) {
            $indent .= "\t";
        }
        if ($resolutions || $medias) {
            if ($resolutions) {
                // If we are using auto resizing, skip the resolutions
                unset($params['resolutions']);
                foreach ($resolutions as $res) {
                    $content[] = "\t" . Clips\create_tag('source', array('src' => Clips\site_url('responsive/size/' . (double) $res / 2880 * (double) $size . '/' . $src), 'media' => '(min-width:' . $res . 'px)'));
                }
            }
            if ($medias) {
                unset($params['medias']);
                foreach ($medias as $media => $res) {
                    $content[] = "\t" . Clips\create_tag('source', array('src' => Clips\site_url('responsive/size/' . $res . '/' . $src), 'media' => '(min-width:' . $media . 'px)'));
                }
            }
        } else {
            $params['path'] = Clips\site_url($path);
        }
        $image_dir = Clips\config('image_dir');
        if ($image_dir) {
            $image_dir = $image_dir[0];
        } else {
            $image_dir = 'application/static/img/';
        }
        Clips\clips_context('indent_level', 1, true);
        $img = Clips\create_tag('img', array('src' => Clips\static_url(Clips\path_join($image_dir, $src))));
        $content[] = "\t" . Clips\create_tag_with_content('noscript', $img);
        Clips\context_pop('indent_level');
    } else {
        $params['data-role'] = 'item-picture';
        $params['path'] = Clips\site_url(Clips\get_default($params, 'path', 'responsive/size'));
        $indent = '';
        $content = array();
    }
    return Clips\create_tag_with_content('picture', implode("\n{$indent}", $content), $params);
}