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


PHP f类代码示例

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


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

示例1: set_cache

 public function set_cache($type, $result)
 {
     $cache_path = __DIR__ . '/../cache/' . $type . '.json';
     $period = c::get('kg.cache_period') ? c::get('kg.cache_period') : '30 Minutes';
     $cache = array('to' => strtotime($period), 'payload' => $result);
     \f::write($cache_path, json_encode($cache));
 }
开发者ID:sethmcleod,项目名称:patsymcenroe.com,代码行数:7,代码来源:Instagram.php

示例2: view

 function view()
 {
     events::observe('save', 'feedback');
     events::observer();
     $settings = settings::get('feedback');
     f::set($settings);
 }
开发者ID:rigidus,项目名称:ea,代码行数:7,代码来源:main.module.php

示例3: save

 public static function save()
 {
     if (!security::isLogged() || !USER_IS_ADMIN) {
         return;
     }
     $status = f::getParam("status");
     $clientId = f::getParam("client_id");
     $name = f::getParam("name");
     if ($status != 1 && $status != 0) {
         f::setError(400, "Invalid Client Status");
     }
     if (!$clientId && !$name) {
         f::setError(400, "Invalid Client Name");
     }
     $clientExists = f::dbRes("select 1 from fm_clients where id = {p:client_id}") == 1;
     if ($clientId && !$clientExists) {
         f::setError(400, "Invalid Client Id");
     }
     if (!f::hasErrors()) {
         if ($clientId) {
             f::dbQuery("update fm_clients set status = {p:status} where id = {p:client_id}");
         } else {
             f::dbQuery("insert into fm_clients set name = {p:name}, status = {p:status}");
         }
         f::setResponseJson(array("ok" => 1));
     }
 }
开发者ID:jumper9,项目名称:test,代码行数:27,代码来源:clients.php

示例4: validateFields

 private static function validateFields($fields)
 {
     // validate fields
     $dataFields = array();
     foreach ($fields as $field) {
         if ($field["name"]) {
             if (!isset($field["type"])) {
                 $field["type"] = "string";
             }
             $validations = array();
             $validations[0] = $field["type"];
             if (isset($field["minlength"]) && $field["minlength"]) {
                 $validations[] = "minlength:{$field["minlength"]}";
             }
             if (isset($field["maxlength"]) && $field["maxlength"]) {
                 $validations[] = "maxlength:{$field["maxlength"]}";
             }
             if (isset($field["minvalue"]) && $field["minvalue"]) {
                 $validations[] = "minvalue:{$field["minvalue"]}";
             }
             if (isset($field["maxvalue"]) && $field["maxvalue"]) {
                 $validations[] = "maxvalue:{$field["maxvalue"]}";
             }
             if (!isset($field["errorMessage"])) {
                 $field["errorMessage"] = "Invalid {$field["name"]}";
             }
             f::validateParam($field["name"], $validations, $field["errorMessage"]);
             $dataFields[$field["name"]] = f::getParam($field["name"]);
         }
     }
     return $dataFields;
 }
开发者ID:jumper9,项目名称:test,代码行数:32,代码来源:post.php

示例5: combine

 public static function combine($type, $files, $compress = false)
 {
     $root = panel::instance()->roots()->assets() . DS . $type;
     $cache = new Media($root . DS . 'panel.' . $type);
     $media = new Collection(array_map(function ($file) use($root) {
         return new Media($root . DS . str_replace('/', DS, $file));
     }, $files));
     // get the max modification date
     $modified = max($media->pluck('modified'));
     if (is_writable($root) and (!$cache->exists() or $cache->modified() < $modified)) {
         $cache->remove();
         $content = '';
         foreach ($media as $asset) {
             $content .= $asset->read() . PHP_EOL;
         }
         if ($compress) {
             $content = static::compress($content);
         }
         f::write($root . DS . 'panel.' . $type, $content);
     }
     if ($cache->exists()) {
         return $type(panel()->urls()->{$type}() . '/panel.' . $type . '?v=' . panel()->version());
     }
     return $type(array_map(function ($item) use($type) {
         return 'panel/assets/' . $type . '/' . $item;
     }, $files));
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:27,代码来源:assets.php

示例6: 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

示例7: crawl

 function crawl()
 {
     $path = url::strip_query($this->raw);
     $path = (array) str::split($path, '/');
     if (a::first($path) == 'index.php') {
         array_shift($path);
     }
     // parse params
     foreach ($path as $p) {
         if (str::contains($p, ':')) {
             $parts = explode(':', $p);
             if (count($parts) < 2) {
                 continue;
             }
             $this->params->{$parts}[0] = $parts[1];
         } else {
             $this->path->_[] = $p;
         }
     }
     // get the extension from the last part of the path
     $this->extension = f::extension($this->path->last());
     if ($this->extension != false) {
         // remove the last part of the path
         $last = array_pop($this->path->_);
         $this->path->_[] = f::name($last);
     }
     return $this->path;
 }
开发者ID:narrenfrei,项目名称:kirbycms,代码行数:28,代码来源:uri.php

示例8: edit

 function edit()
 {
     events::observe('save', 'templates', 'apps', '_save');
     events::observer();
     $tmpl_file = events::get('tmpl_file');
     $app = events::get('app');
     if (events::detect('restore')) {
         self::restoreVersion($app, $tmpl_file, events::get('restore'));
     }
     admin::components('tabs', 'validator');
     f::set('app', $app);
     f::set('tmpl_file', $tmpl_file);
     s::set('app', $app);
     s::set('tmpl_file', $tmpl_file);
     $file = SYS_ROOT . 'tmpls/' . ADMIN_SITE . '/' . $app . '/' . $tmpl_file;
     $code = files::get($file);
     f::set('tmpl_code', $code);
     self::getApps();
     /*
     	Load versions
     */
     db::table('templates_versions');
     db::where('app', $app);
     db::where('tmpl_file', $tmpl_file);
     db::order('version_date', 'DESC');
     $res = db::select();
     while ($row = mysql_fetch_assoc($res)) {
         $row['version_date'] = dt::date2print('%H:%i %d.%m.%Y', $row['version_date']);
         $row['version_code'] = '{non}' . htmlspecialchars($row['version_code']) . '{/non}';
         s::roll('versions', $row);
     }
 }
开发者ID:rigidus,项目名称:ea,代码行数:32,代码来源:apps.module.php

示例9: 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

示例10: edit

 public static function edit()
 {
     if (!security::isLogged() || !USER_IS_ADMIN) {
         return;
     }
     $name = f::getParam("name");
     $availableFrom = f::date2sql(f::getParam("available_from"));
     $availableTo = f::date2sql(f::getParam("available_to"));
     $status = f::getParam("status");
     if ($status != 1 && $status != 0 && $status != 2) {
         f::setError(400, "Wrong Status");
     }
     if (!$name) {
         f::setError(400, "Invalid form name");
     }
     $clientExists = f::dbRes("select 1 from fm_clients where id = {p:client_id}");
     if (!$clientExists) {
         f::setError(400, "Client does not Exist");
     }
     if (!f::hasErrors()) {
         if (f::getParam("form_id")) {
             f::dbQuery("insert into fm_forms_log (created_date, form_id, client_id, name, enabled_domains, detail, available_from, available_to, status, description)\n\t\t\t\t\tselect now(), id, client_id, name, enabled_domains, detail, available_from, available_to, status, description from fm_forms where id = {p:form_id}");
             f::dbQuery("update fm_forms set name = {p:name}, detail = {p:detail}, available_from = {availableFrom}, available_to = {availableTo}, status = {p:status} where id = {p:form_id}", array("availableFrom" => $availableFrom, "availableTo" => $availableTo));
         } else {
             f::dbQuery("insert into fm_forms set client_id = {p:client_id}, name = {p:name}, detail = {p:detail}, available_from = {availableFrom}, available_to = {availableTo}, status = {p:status} ", array("availableFrom" => $availableFrom, "availableTo" => $availableTo));
         }
         f::setResponseJson(array("ok" => 1));
     }
 }
开发者ID:jumper9,项目名称:test,代码行数:29,代码来源:forms.php

示例11: view

 function view()
 {
     events::observe('save', 'pages', 'settings', 'save');
     events::observer();
     $settings = settings::get('pages');
     f::set($settings);
 }
开发者ID:rigidus,项目名称:ea,代码行数:7,代码来源:settings.module.php

示例12: send

 /**
  * Sets up all curl options and sends the request
  *
  * @return object Response
  */
 protected function send()
 {
     // start a curl request
     $curl = curl_init();
     // curl options
     $params = array(CURLOPT_URL => $this->options['url'], CURLOPT_ENCODING => $this->options['encoding'], CURLOPT_CONNECTTIMEOUT => $this->options['timeout'], CURLOPT_TIMEOUT => $this->options['timeout'], CURLOPT_AUTOREFERER => true, CURLOPT_RETURNTRANSFER => $this->options['body'], CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_HEADER => false, CURLOPT_HEADERFUNCTION => array($this, 'header'));
     // add the progress
     if (is_callable($this->options['progress'])) {
         $params[CURLOPT_NOPROGRESS] = false;
         $params[CURLOPT_PROGRESSFUNCTION] = $this->options['progress'];
     }
     // add all headers
     if (!empty($this->options['headers'])) {
         $params[CURLOPT_HTTPHEADER] = $this->options['headers'];
     }
     // add the user agent
     if (!empty($this->options['agent'])) {
         $params[CURLOPT_USERAGENT] = $this->options['agent'];
     }
     // do some request specific stuff
     switch (strtolower($this->options['method'])) {
         case 'post':
             $params[CURLOPT_POST] = true;
             $params[CURLOPT_POSTFIELDS] = $this->postfields($this->options['data']);
             break;
         case 'put':
             $params[CURLOPT_CUSTOMREQUEST] = 'PUT';
             $params[CURLOPT_POSTFIELDS] = $this->postfields($this->options['data']);
             // put a file
             if ($this->options['file']) {
                 $params[CURLOPT_INFILE] = fopen($this->options['file'], 'r');
                 $params[CURLOPT_INFILESIZE] = f::size($this->options['file']);
             }
             break;
         case 'delete':
             $params[CURLOPT_CUSTOMREQUEST] = 'DELETE';
             $params[CURLOPT_POSTFIELDS] = $this->postfields($this->options['data']);
             break;
         case 'head':
             $params[CURLOPT_CUSTOMREQUEST] = 'HEAD';
             $params[CURLOPT_POSTFIELDS] = $this->postfields($this->options['data']);
             $params[CURLOPT_NOBODY] = true;
             break;
     }
     curl_setopt_array($curl, $params);
     $content = curl_exec($curl);
     $error = curl_errno($curl);
     $message = curl_error($curl);
     $info = curl_getinfo($curl);
     curl_close($curl);
     $this->response = new RemoteResponse();
     $this->response->headers = $this->headers;
     $this->response->error = $error;
     $this->response->message = $message;
     $this->response->content = $content;
     $this->response->code = $info['http_code'];
     $this->response->info = $info;
     return $this->response;
 }
开发者ID:getkirby,项目名称:toolkit,代码行数:64,代码来源:remote.php

示例13: render

 public function render()
 {
     $file = $this->root . DS . str_replace('.', DS, $this->file) . '.php';
     if (!file_exists($file)) {
         throw new Exception('Invalid view: ' . $this->file);
     }
     return f::load($file, $this->data);
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:8,代码来源:view.php

示例14: delete

 protected function delete($name, $output)
 {
     if ($file = f::resolve($this->root() . DS . $name, ['yaml', 'yml', 'php'])) {
         f::remove($file);
     }
     $output->writeln('<comment>The "' . $name . '" blueprint has been deleted!</comment>');
     $output->writeln('');
 }
开发者ID:getkirby,项目名称:cli,代码行数:8,代码来源:Blueprint.php

示例15: write

 public static function write($file, $data, $type = null)
 {
     // type autodetection
     if (is_null($type)) {
         $type = f::extension($file);
     }
     return f::write($file, data::encode($data, $type));
 }
开发者ID:robinandersen,项目名称:robin,代码行数:8,代码来源:data.php


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