当前位置: 首页>>代码示例>>PHP>>正文


PHP f::read方法代码示例

本文整理汇总了PHP中f::read方法的典型用法代码示例。如果您正苦于以下问题:PHP f::read方法的具体用法?PHP f::read怎么用?PHP f::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在f的用法示例。


在下文中一共展示了f::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extract

 public static function extract($file, $line)
 {
     $content = f::read($file);
     $lines = preg_split('/\\r\\n|\\n|\\r/', $content);
     $begin = $line - 5;
     if ($begin < 0) {
         $begin = 0;
     }
     $end = 10;
     $lines = array_slice($lines, $begin, $end);
     $html = '';
     $n = $begin + 1;
     foreach ($lines as $l) {
         if (empty($l)) {
             $l = ' ';
         }
         $num = '<span class="code-line-number">' . $n . '</span>';
         if ($n == $line) {
             $html .= '<span class="code-line code-line-highlighted">' . $num . htmlspecialchars($l) . '</span>';
         } else {
             $html .= '<span class="code-line">' . $num . htmlspecialchars($l) . '</span>';
         }
         $n++;
     }
     return $html;
 }
开发者ID:chrishiam,项目名称:LVSL,代码行数:26,代码来源:terror.php

示例2: routes

 private static function routes()
 {
     kirby()->routes(array(array('pattern' => self::$route, 'action' => function () {
         echo SplitviewTool::html();
     }), array('pattern' => self::$route . '/assets/css/tool.css', 'action' => function () {
         $path = self::$assets . 'css' . DS . 'tool.css';
         return new Response(f::read($path), 'css');
     }), array('pattern' => self::$route . '/assets/css/tool.min.css', 'action' => function () {
         $path = self::$assets . 'css' . DS . 'tool.min.css';
         return new Response(f::read($path), 'css');
     }), array('pattern' => self::$route . '/assets/js/dist/tool.js', 'action' => function () {
         $path = self::$assets . 'js' . DS . 'dist/tool.js';
         return new Response(f::read($path), 'js');
     }), array('pattern' => self::$route . '/assets/js/dist/tool.min.js', 'action' => function () {
         $path = self::$assets . 'js' . DS . 'dist/tool.min.js';
         return new Response(f::read($path), 'js');
     }), array('pattern' => self::$route . '/assets/js/src/site.js', 'action' => function () {
         $path = self::$assets . 'js' . DS . 'src/site/site.js';
         return new Response(f::read($path), 'js');
     }), array('pattern' => self::$route . '/assets/js/dist/site.min.js', 'action' => function () {
         $path = self::$assets . 'js' . DS . 'dist/site.min.js';
         return new Response(f::read($path), 'js');
     }), array('pattern' => self::$route . '/assets/fonts/font-awesome.woff', 'action' => function () {
         $path = self::$assets . 'fonts' . DS . 'font-awesome-4.5.0' . DS . 'fontawesome-webfont.woff';
         return new Response(f::read($path), 'woff');
     }), array('pattern' => self::$route . '/assets/fonts/source-sans-pro.woff', 'action' => function () {
         $path = self::$assets . 'fonts' . DS . 'source-sans-pro' . DS . 'SourceSansPro-Regular.otf.woff';
         return new Response(f::read($path), 'woff');
     })));
 }
开发者ID:creichel,项目名称:splitview,代码行数:30,代码来源:routes.php

示例3: assets

 public function assets($type, $root, $files)
 {
     $output = array();
     foreach ($files as $filename) {
         $output[] = f::read(dirname($root) . DS . 'assets' . DS . $type . DS . $filename);
     }
     $this->{$type} .= implode(PHP_EOL . PHP_EOL, $output);
 }
开发者ID:irenehilber,项目名称:kirby-base,代码行数:8,代码来源:plugins.php

示例4: runTests

 public function runTests($result)
 {
     $root = TEST_ROOT_ETC . DS . 'kirbytext';
     $dirs = dir::read($root);
     foreach ($dirs as $dir) {
         $testFile = $root . DS . $dir . DS . 'test.txt';
         $expectedFile = $root . DS . $dir . DS . 'expected.html';
         $this->assertEquals(f::read($expectedFile), $result(f::read($testFile)), 'test: ' . $dir);
     }
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:10,代码来源:KirbytextTest.php

示例5: copy

 protected function copy()
 {
     if ($this->input->getOption('bare')) {
         $blueprint = f::read($this->template());
         $blueprint = str::template($blueprint, ['title' => ucfirst($this->name())]);
         f::write($this->file(), $blueprint);
     } else {
         $this->questions();
     }
 }
开发者ID:getkirby,项目名称:cli,代码行数:10,代码来源:Blueprint.php

示例6: get

 static function get($file, $raw = false)
 {
     if (!c::get('cache')) {
         return false;
     }
     $content = f::read(self::file($file));
     if ($raw == false) {
         $content = @unserialize($content);
     }
     return $content;
 }
开发者ID:robeam,项目名称:kirbycms,代码行数:11,代码来源:cache.php

示例7: read

 public static function read($file, $type = null)
 {
     // type autodetection
     if (is_null($type)) {
         $type = f::extension($file);
     }
     // get the adapter
     $adapter = static::adapter($type);
     if (isset($adapter['read'])) {
         return call($adapter['read'], $file);
     } else {
         return data::decode(f::read($file), $type);
     }
 }
开发者ID:robinandersen,项目名称:robin,代码行数:14,代码来源:data.php

示例8: check_cache

 public function check_cache($type)
 {
     $cache_path = __DIR__ . '/../cache/' . $type . '.json';
     if (\f::exists($cache_path)) {
         $cache = json_decode(\f::read($cache_path, 'json'));
         if ($cache->to < time()) {
             return false;
         } else {
             return $cache->payload;
         }
     } else {
         return false;
     }
 }
开发者ID:sethmcleod,项目名称:patsymcenroe.com,代码行数:14,代码来源:Instagram.php

示例9: get

 static function get($file, $raw = false, $expires = false)
 {
     if (!c::get('cache')) {
         return false;
     }
     // check for an expired cache
     if ($expires && self::expired($file, $expires)) {
         return false;
     }
     $content = f::read(self::file($file));
     if ($raw == false) {
         $content = @unserialize($content);
     }
     return $content;
 }
开发者ID:narrenfrei,项目名称:kirbycms,代码行数:15,代码来源:cache.php

示例10: routes

 private static function routes()
 {
     kirby()->routes(array(array('pattern' => self::$route, 'action' => function () {
         echo SplitviewTool::html();
     }), array('pattern' => self::$route . '/css/(:any)', 'action' => function ($slug) {
         $path = self::$assets . 'css' . DS . $slug . '.min.css';
         return new Response(f::read($path), 'css');
     }), array('pattern' => self::$route . '/js/dist/(:any)', 'action' => function ($slug) {
         $path = self::$assets . 'js' . DS . 'dist' . DS . $slug . '.min.js';
         return new Response(f::read($path), 'js');
     }), array('pattern' => self::$route . '/js/src/(:any)', 'action' => function ($slug) {
         $path = self::$assets . 'js' . DS . 'src' . DS . $slug . DS . $slug . '.js';
         return new Response(f::read($path), 'js');
     }), array('pattern' => self::$route . '/svg/(:any)', 'action' => function ($slug) {
         $path = self::$assets . 'images' . DS . 'svg' . DS . $slug . '.svg';
         return new Response(f::read($path), 'svg');
     }), array('pattern' => self::$route . '/svg/inverted/(:any)', 'action' => function ($slug) {
         $path = self::$assets . 'images' . DS . 'svg' . DS . 'inverted' . DS . $slug . '.svg';
         return new Response(f::read($path), 'svg');
     })));
 }
开发者ID:texnixe,项目名称:splitview,代码行数:21,代码来源:routes.php

示例11: fetch

 static function fetch($file)
 {
     if (!file_exists($file)) {
         return array('raw' => false, 'data' => array());
     }
     $content = f::read($file);
     $content = str_replace("", '', $content);
     $sections = preg_split('![\\r\\n]+[-]{4,}!i', $content);
     $data = array();
     foreach ($sections as $s) {
         $parts = explode(':', $s);
         if (count($parts) == 1 && count($sections) == 1) {
             return $content;
         }
         $key = str::lower(preg_replace('![^a-z0-9]+!i', '_', trim($parts[0])));
         if (empty($key)) {
             continue;
         }
         $value = trim(implode(':', array_slice($parts, 1)));
         $data[$key] = $value;
     }
     return array('raw' => $content, 'data' => $data);
 }
开发者ID:nilshendriks,项目名称:kirbycms,代码行数:23,代码来源:variables.php

示例12: fetch

 static function fetch($file)
 {
     if (!file_exists($file)) {
         return array();
     }
     $content = f::read($file);
     $content = str_replace("", '', $content);
     $sections = preg_split('!\\R[-]{4,}!', $content);
     $data = array();
     foreach ($sections as $s) {
         $parts = explode(':', $s);
         if (count($parts) == 1 && count($sections) == 1) {
             return $content;
         }
         $key = str::urlify($parts[0]);
         if (empty($key)) {
             continue;
         }
         $value = trim(implode(':', array_slice($parts, 1)));
         $data[$key] = $value;
     }
     return $data;
 }
开发者ID:robeam,项目名称:kirbycms,代码行数:23,代码来源:variables.php

示例13: assets

 public function assets($type)
 {
     $output = [];
     $defaultRoot = panel()->roots()->fields();
     foreach (kirby()->get('field') as $name => $field) {
         $root = $field->root();
         $base = dirname($root);
         // only fetch assets for custom fields
         if ($base == $defaultRoot) {
             continue;
         }
         $classname = $field->class();
         if (!class_exists($classname)) {
             throw new Exception('The field class is missing for: ' . $classname);
         }
         if (!isset($classname::$assets) || !isset($classname::$assets[$type])) {
             continue;
         }
         foreach ($classname::$assets[$type] as $filename) {
             $output[] = f::read($field->root() . DS . 'assets' . DS . $type . DS . $filename);
         }
     }
     return implode(PHP_EOL . PHP_EOL, $output);
 }
开发者ID:robinandersen,项目名称:robin,代码行数:24,代码来源:plugins.php

示例14: assets

 public static function assets($type, $compress = true)
 {
     $files = static::files();
     $output = array();
     foreach (static::files() as $field => $file) {
         if (isset($field::$assets) and isset($field::$assets[$type])) {
             foreach ($field::$assets[$type] as $f) {
                 $output[] = f::read(dirname($file) . DS . 'assets' . DS . $type . DS . $f);
             }
         }
     }
     $output = implode(PHP_EOL . PHP_EOL, $output);
     if ($compress) {
         $output = preg_replace('!/\\*[^*]*\\*+([^/][^*]*\\*+)*/!', '', $output);
         $output = trim(str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), ' ', $output));
     }
     return $output;
 }
开发者ID:muten84,项目名称:luigibifulco.it,代码行数:18,代码来源:form.php

示例15: routes

 /**
  * Registers all routes
  *
  * @param array $routes New routes
  * @return array
  */
 public function routes($routes = array())
 {
     // extend the existing routes
     if (!empty($routes) and is_array($routes)) {
         return $this->options['routes'] = array_merge($this->options['routes'], $routes);
     }
     $routes = $this->options['routes'];
     $kirby = $this;
     $site = $this->site();
     if ($site->multilang()) {
         foreach ($site->languages() as $lang) {
             $routes[] = array('pattern' => ltrim($lang->url . '/(:all?)', '/'), 'method' => 'ALL', 'lang' => $lang, 'action' => function ($path = null) use($kirby, $site) {
                 return $site->visit($path, $kirby->route->lang->code());
             });
         }
         // fallback for the homepage
         $routes[] = array('pattern' => '/', 'method' => 'ALL', 'action' => function () use($kirby, $site) {
             // check if the language detector is activated
             if ($kirby->option('language.detect')) {
                 if (s::get('language') and $language = $kirby->site()->sessionLanguage()) {
                     // $language is already set but the user wants to
                     // select the default language
                     $referer = r::referer();
                     if (!empty($referer) && str::startsWith($referer, $this->urls()->index())) {
                         $language = $kirby->site()->defaultLanguage();
                     }
                 } else {
                     // detect the user language
                     $language = $kirby->site()->detectedLanguage();
                 }
             } else {
                 // always use the default language if the detector is disabled
                 $language = $kirby->site()->defaultLanguage();
             }
             // redirect to the language homepage if necessary
             if ($language->url != '/' and $language->url != '') {
                 go($language->url());
             }
             // plain home pages
             return $site->visit('/', $language->code());
         });
     }
     // tinyurl handling
     $routes['tinyurl'] = $this->component('tinyurl')->route();
     // home redirect
     $routes['homeRedirect'] = array('pattern' => $this->options['home'], 'action' => function () {
         redirect::send(page('home')->url(), 307);
     });
     // plugin assets
     $routes['pluginAssets'] = array('pattern' => 'assets/plugins/(:any)/(:all)', 'method' => 'GET', 'action' => function ($plugin, $path) use($kirby) {
         $root = $kirby->roots()->plugins() . DS . $plugin . DS . 'assets' . DS . $path;
         $file = new Media($root);
         if ($file->exists()) {
             return new Response(f::read($root), f::extension($root));
         } else {
             return new Response('The file could not be found', f::extension($path), 404);
         }
     });
     // all other urls
     $routes['others'] = array('pattern' => '(:all)', 'method' => 'ALL', 'action' => function ($path = null) use($site, $kirby) {
         // visit the currently active page
         $page = $site->visit($path);
         // react on errors for invalid URLs
         if ($page->isErrorPage() and $page->uri() != $path) {
             // get the filename
             $filename = rawurldecode(basename($path));
             $pagepath = dirname($path);
             // check if there's a page for the parent path
             if ($page = $site->find($pagepath)) {
                 // check if there's a file for the last element of the path
                 if ($file = $page->file($filename)) {
                     go($file->url());
                 }
             }
             // return the error page if there's no such page
             return $site->errorPage();
         }
         return $page;
     });
     return $routes;
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:87,代码来源:kirby.php


注:本文中的f::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。