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


PHP a::first方法代码示例

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


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

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

示例2: testSort

 public function testSort()
 {
     $users = $this->users;
     $users = a::sort($users, 'username', 'asc');
     $first = a::first($users);
     $last = a::last($users);
     $this->assertEquals('mary', $first['username']);
     $this->assertEquals('peter', $last['username']);
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:9,代码来源:ATest.php

示例3: avatar

 public function avatar()
 {
     if (isset($this->cache['avatar'])) {
         return $this->cache['avatar'];
     }
     // try to find the avatar
     $root = c::get('root') . DS . 'assets' . DS . 'avatars' . DS . $this->username() . '.{jpg,png}';
     if ($avatar = a::first((array) glob($root, GLOB_BRACE))) {
         return $this->cache['avatar'] = new Media($avatar, url('assets/avatars/' . f::filename($avatar)));
     } else {
         return $this->cache['avatar'] = false;
     }
 }
开发者ID:gBokiau,项目名称:kirby,代码行数:13,代码来源:user.php

示例4: find

 function find()
 {
     global $site;
     $args = func_get_args();
     // find multiple pages
     if (count($args) > 1) {
         $result = array();
         foreach ($args as $arg) {
             $page = $this->find($arg);
             if ($page) {
                 $result[] = $page;
             }
         }
         return empty($result) ? false : new relatedPages($result);
     }
     return $site->pages()->find(a::first($args));
 }
开发者ID:ajmalafif,项目名称:bradshawsguide,代码行数:17,代码来源:related.php

示例5: randomimage

function randomimage($dir)
{
    $files = dir::read(c::get('root') . '/' . $dir);
    shuffle($files);
    return url($dir . '/' . a::first($files));
}
开发者ID:scheibome,项目名称:kirbycms-extensions,代码行数:6,代码来源:randomimage.php

示例6: parse

 /**
  * Parses the hashed value from a cookie
  * and tries to extract the value 
  * 
  * @param string $hash
  * @return mixed
  */
 protected static function parse($string)
 {
     // extract hash and value
     $parts = str::split($string, '+');
     $hash = a::first($parts);
     $value = a::last($parts);
     // if the hash or the value is missing at all return null
     if (empty($hash) or empty($value)) {
         return null;
     }
     // compare the extracted hash with the hashed value
     if ($hash !== static::hash($value)) {
         return null;
     }
     return $value;
 }
开发者ID:williampan,项目名称:w,代码行数:23,代码来源:cookie.php

示例7: find

 function find()
 {
     $args = func_get_args();
     // find multiple pages
     if (count($args) > 1) {
         $result = array();
         foreach ($args as $arg) {
             $page = $this->find($arg);
             if ($page) {
                 $result[$page->uid] = $page;
             }
         }
         return empty($result) ? false : new pages($result);
     }
     // find a single page
     $path = a::first($args);
     $array = str::split($path, '/');
     $obj = $this;
     $page = false;
     foreach ($array as $p) {
         $next = $obj->{$p};
         if (!$next) {
             return $page;
         }
         $page = $next;
         $obj = $next->children();
     }
     return $page;
 }
开发者ID:robeam,项目名称:kirbycms,代码行数:29,代码来源:pages.php

示例8: email

 /**
  * Generates an "a mailto" tag
  *
  * @param string $email The url for the a tag
  * @param mixed $text The optional text. If null, the url will be used as text
  * @param array $attr Additional attributes for the tag
  * @return string the generated html
  */
 public static function email($email, $text = null, $attr = array())
 {
     if (empty($text)) {
         // show only the eMail address without additional parameters (if the 'text' argument is empty)
         $text = str::encode(a::first(str::split($email, '?')));
     }
     $email = str::encode($email);
     $attr = array_merge(array('href' => 'mailto:' . $email), $attr);
     return static::tag('a', $text, $attr);
 }
开发者ID:getkirby,项目名称:toolkit,代码行数:18,代码来源:html.php

示例9: acceptance

 /**
  * Returns a number between 0 and 1 that defines how "accepted"
  * a specified MIME type is for the visitor's browser using the
  * HTTP Accept header
  *
  * @param  string $type MIME type like "text/html"
  * @return float        Number between 0 (not accepted) and 1 (very accepted)
  */
 public static function acceptance($type)
 {
     $accept = a::get($_SERVER, 'HTTP_ACCEPT');
     // if there is no header, everything is accepted
     if (!$accept) {
         return 1;
     }
     // check each type in the Accept header
     foreach (str::split($accept, ',') as $item) {
         $item = str::split($item, ';');
         $mime = a::first($item);
         // $item now only contains params
         // check if the type matches
         if (!fnmatch($mime, $type, FNM_PATHNAME)) {
             continue;
         }
         // check for the q param ("quality" of the type)
         foreach ($item as $param) {
             $param = str::split($param, '=');
             if (a::get($param, 0) === 'q' && ($value = a::get($param, 1))) {
                 return (double) $value;
             }
         }
         // no quality param, default to a quality of 1
         return 1;
     }
     // no match at all, the type is not accepted
     return 0;
 }
开发者ID:getkirby,项目名称:toolkit,代码行数:37,代码来源:visitor.php

示例10: languageSetup

 function languageSetup()
 {
     // check for activated language support
     if (!c::get('lang.support')) {
         return false;
     }
     // get the available languages
     $available = c::get('lang.available');
     // sanitize the available languages
     if (!is_array($available)) {
         // switch off language support
         c::set('lang.support', false);
         return false;
     }
     // get the raw uri
     $uri = uri::raw();
     // get the current language code
     $code = a::first(explode('/', $uri));
     // try to detect the language code if the code is empty
     if (empty($code)) {
         if (c::get('lang.detect')) {
             // detect the current language
             $detected = str::split(server::get('http_accept_language'), '-');
             $detected = str::trim(a::first($detected));
             $detected = !in_array($detected, $available) ? c::get('lang.default') : $detected;
             // set the detected code as current code
             $code = $detected;
         } else {
             $code = c::get('lang.default');
         }
         // go to the default homepage
         go(url(false, $code));
     }
     // http://yourdomain.com/error
     // will redirect to http://yourdomain.com/en/error
     if ($code == c::get('404')) {
         go(url('error', c::get('lang.default')));
     }
     // validate the code and switch back to the homepage if it is invalid
     if (!in_array($code, c::get('lang.available'))) {
         go(url());
     }
     // set the current language
     c::set('lang.current', $code);
     // mark if this is a translated version or the default version
     $code != c::get('lang.default') ? c::set('lang.translated', true) : c::set('lang.translated', false);
     // load the additional language files if available
     load::language();
 }
开发者ID:codecuts,项目名称:lanningsmith-website,代码行数:49,代码来源:site.php

示例11: find

 function find()
 {
     $args = func_get_args();
     // find multiple files
     if (count($args) > 1) {
         $result = array();
         foreach ($args as $arg) {
             $file = $this->find($arg);
             if ($file) {
                 $result[$file->filename] = $file;
             }
         }
         return empty($result) ? false : new files($result);
     }
     // find a single file
     $key = a::first($args);
     if (!$key) {
         return $this->_;
     }
     return a::get($this->_, $key);
 }
开发者ID:nilshendriks,项目名称:kirbycms,代码行数:21,代码来源:files.php

示例12: inventory

 /**
  * Modified inventory fetcher
  *
  * @return array
  */
 public function inventory()
 {
     $inventory = parent::inventory();
     $defaultLang = $this->site->defaultLanguage->code;
     $expression = '!(.*?)(\\.(' . implode('|', $this->site->languages->codes()) . ')|)\\.' . $this->kirby->options['content.file.extension'] . '$!i';
     foreach ($inventory['meta'] as $key => $meta) {
         $inventory['meta'][$key] = array($defaultLang => $meta);
     }
     foreach ($inventory['content'] as $key => $content) {
         preg_match($expression, $content, $match);
         $file = $match[1];
         $lang = isset($match[3]) ? $match[3] : null;
         if (in_array($file, $inventory['files'])) {
             $inventory['meta'][$file][$lang] = $content;
         } else {
             if (is_null($lang)) {
                 $lang = f::extension($file);
                 if (empty($lang)) {
                     $lang = $defaultLang;
                 }
             }
             $inventory['content'][$lang] = $content;
         }
         unset($inventory['content'][$key]);
     }
     // try to fill the default language with something else
     if (!isset($inventory['content'][$defaultLang])) {
         $inventory['content'][$defaultLang] = a::first($inventory['content']);
     }
     return $inventory;
 }
开发者ID:aoimedia,项目名称:kosmonautensofa,代码行数:36,代码来源:page.php

示例13: first

 function first()
 {
     return a::first($this->_);
 }
开发者ID:narrenfrei,项目名称:kirbycms,代码行数:4,代码来源:obj.php

示例14: find

 function find()
 {
     $args = func_get_args();
     // find multiple pages
     if (count($args) > 1) {
         $result = array();
         foreach ($args as $arg) {
             $page = $this->find($arg);
             if ($page) {
                 $result[$page->uid] = $page;
             }
         }
         return empty($result) ? false : new pages($result);
     }
     // find a single page
     $path = a::first($args);
     $array = str::split($path, '/');
     $obj = $this;
     $page = false;
     // check if we need to search for translated urls
     $translated = c::get('lang.support');
     foreach ($array as $p) {
         $next = $translated ? $obj->findBy('translatedUID', $p) : $obj->{'_' . $p};
         if (!$next) {
             return $page;
         }
         $page = $next;
         $obj = $next->children();
     }
     return $page;
 }
开发者ID:nilshendriks,项目名称:kirbycms,代码行数:31,代码来源:pages.php

示例15: html

" />
      </div>

                         <!-- manually prevented the popup from being shown when the page is of type 'project'.
                        the population of the menu is then limited to "media type" - templates
                        in the end i made sure that the default-template is chosen if the panel is "home"
                        so that we can add categories which are then NOT of type 'project' but use the
                        default template -->


      <div class="field">
        <?php 
if (count($templates) == 1) {
    ?>
          <?php 
    $template = a::first($templates);
    ?>
          <label><?php 
    echo l::get('pages.add.label.template');
    ?>
: <em><?php 
    echo html(data::templateName($template));
    ?>
 (<?php 
    echo html($template);
    ?>
)</em></label>
          <input type="hidden" name="template" value="<?php 
    echo html($template);
    ?>
" />
开发者ID:codecuts,项目名称:lanningsmith-website,代码行数:31,代码来源:pages.add.php


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