本文整理汇总了PHP中a类的典型用法代码示例。如果您正苦于以下问题:PHP a类的具体用法?PHP a怎么用?PHP a使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了a类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
$datas['title'] = 'Medoo-MVC';
$hello = new index();
$datas['hello'] = $hello->hello();
$lib_class = new a();
$datas['hi'] = $lib_class->hi();
$this->display($datas);
}
示例2: main
function main()
{
$b = new b();
$b->f($b);
t::f($b);
$b->set($b, 'new value');
t::set($b, 'newer value');
$a = new a();
$a->f($a);
t::f($a);
}
示例3: get
static function get($key = null, $default = null)
{
if ($key === null) {
return (array) self::$vars;
}
return a::get(self::$vars, $key, $default);
}
示例4: __construct
public function __construct($data = array())
{
if (!isset($data['id'])) {
throw new Exception('The role id is missing');
}
if (!isset($data['name'])) {
throw new Exception('The role name is missing');
}
// required data
$this->id = $data['id'];
$this->name = $data['name'];
if (isset($data['permissions']) and is_array($data['permissions'])) {
$this->permissions = a::merge($this->permissions, $data['permissions']);
} else {
if (isset($data['permissions']) and $data['permissions'] === false) {
$this->permissions = array_fill_keys(array_keys($this->permissions), false);
} else {
$this->permissions = $this->permissions;
}
}
// fallback permissions support for old 'panel' role variable
if (isset($data['panel']) and is_bool($data['panel'])) {
$this->permissions['panel.access'] = $data['panel'];
}
// is this role the default role?
if (isset($data['default'])) {
$this->default = $data['default'] === true;
}
}
示例5: tagcloud
function tagcloud($parent, $options = array())
{
global $site;
// default values
$defaults = array('limit' => false, 'field' => 'tags', 'children' => 'visible', 'baseurl' => $parent->url(), 'param' => 'tag', 'sort' => 'name', 'sortdir' => 'asc');
// merge defaults and options
$options = array_merge($defaults, $options);
switch ($options['children']) {
case 'invisible':
$children = $parent->children()->invisible();
break;
case 'visible':
$children = $parent->children()->visible();
break;
default:
$children = $parent->children();
break;
}
$cloud = array();
foreach ($children as $p) {
$tags = str::split($p->{$options}['field']());
foreach ($tags as $t) {
if (isset($cloud[$t])) {
$cloud[$t]->results++;
} else {
$cloud[$t] = new obj(array('results' => 1, 'name' => $t, 'url' => $options['baseurl'] . '/' . $options['param'] . ':' . $t, 'isActive' => param($options['param']) == $t ? true : false));
}
}
}
$cloud = a::sort($cloud, $options['sort'], $options['sortdir']);
if ($options['limit']) {
$cloud = array_slice($cloud, 0, $options['limit']);
}
return $cloud;
}
示例6: __construct
public function __construct($params = array())
{
// start the fields collection
$this->params = $params;
if ($params === false) {
$this->fields = array();
$this->type = array();
$this->size = false;
$this->width = false;
$this->height = false;
$this->max = 0;
$this->hide = true;
$this->sortable = false;
} else {
if (is_array($params)) {
$this->fields = a::get($params, 'fields', $this->fields);
$this->type = a::get($params, 'type', $this->type);
if (!is_array($this->type)) {
$this->type = array($this->type);
}
$this->size = a::get($params, 'size', $this->size);
$this->width = a::get($params, 'width', $this->width);
$this->height = a::get($params, 'height', $this->height);
$this->max = a::get($params, 'max', $this->max);
$this->hide = a::get($params, 'hide', $this->hide);
$this->sort = a::get($params, 'sort', $this->sort);
$this->sortable = a::get($params, 'sortable', $this->sortable);
$this->sanitize = a::get($params, 'sanitize', true);
}
}
}
示例7: update
public function update($data = array())
{
if (!panel()->user()->isAdmin() and !$this->isCurrent()) {
throw new Exception(l('users.form.error.update.rights'));
}
// users which are not an admin cannot change their role
if (!panel()->user()->isAdmin()) {
unset($data['role']);
}
if (str::length(a::get($data, 'password')) > 0) {
if (a::get($data, 'password') !== a::get($data, 'passwordconfirmation')) {
throw new Exception(l('users.form.error.password.confirm'));
}
} else {
unset($data['password']);
}
unset($data['passwordconfirmation']);
if ($this->isLastAdmin() and a::get($data, 'role') !== 'admin') {
// check the number of left admins to not convert the last one
throw new Exception(l('user.error.lastadmin'));
}
parent::update($data);
// flush the cache in case if the user data is
// used somewhere on the site (i.e. for profiles)
kirby()->cache()->flush();
kirby()->trigger('panel.user.update', $this);
return $this;
}
示例8: foo
function foo()
{
a::inFamilya();
a::inFamilyb();
a::notDefined();
c::notAClass();
}
示例9: _default
public function _default($default)
{
if (empty($default)) {
return '';
} else {
if (is_string($default)) {
return $default;
} else {
$type = a::get($default, 'type');
switch ($type) {
case 'date':
$format = a::get($default, 'format', 'Y-m-d');
return date($format);
break;
case 'datetime':
$format = a::get($default, 'format', 'Y-m-d H:i:s');
return date($format);
break;
case 'user':
$user = isset($default['user']) ? site()->users()->find($default['user']) : site()->user();
if (!$user) {
return '';
}
return (isset($default['field']) and $default['field'] != 'password') ? $user->{$default['field']}() : $user->username();
break;
default:
return $default;
break;
}
}
}
}
示例10: get
/**
* Gets a value from the _SERVER array
*
* <code>
*
* server::get('document_root');
* // sample output: /var/www/kirby
*
* server::get();
* // returns the whole server array
*
* </code>
*
* @param mixed $key The key to look for. Pass false or null to return the entire server array.
* @param mixed $default Optional default value, which should be returned if no element has been found
* @return mixed
*/
public static function get($key = false, $default = null)
{
if (empty($key)) {
return $_SERVER;
}
return a::get($_SERVER, str::upper($key), $default);
}
示例11: __construct
function __construct($image, $options = array())
{
$this->root = c::get('thumb.cache.root', c::get('root') . '/thumbs');
$this->url = c::get('thumb.cache.url', c::get('url') . '/thumbs');
if (!$image) {
return false;
}
$this->obj = $image;
// set some values from the image
$this->sourceWidth = $this->obj->width();
$this->sourceHeight = $this->obj->height();
$this->width = $this->sourceWidth;
$this->height = $this->sourceHeight;
$this->source = $this->obj->root();
$this->mime = $this->obj->mime();
// set the max width and height
$this->maxWidth = @$options['width'];
$this->maxHeight = @$options['height'];
// set the quality
$this->crop = @$options['crop'];
// set the quality
$this->quality = a::get($options, 'quality', c::get('thumb.quality', 100));
// set the default upscale behavior
$this->upscale = a::get($options, 'upscale', c::get('thumb.upscale', false));
// set the alt text
$this->alt = a::get($options, 'alt', $this->obj->name());
// set the className text
$this->className = @$options['class'];
// set the new size
$this->size();
// create the thumbnail
$this->create();
}
示例12: fields
public function fields()
{
$fields = $this->config->fields();
$fields = new Fields($fields, $this->model);
$fields = $fields->toArray();
// make sure that no unwanted options or fields
// are being included here
foreach ($fields as $name => $field) {
// remove all structure fields within structures
if ($field['type'] == 'structure') {
unset($fields[$name]);
// remove invalid buttons from textareas
} else {
if ($field['type'] == 'textarea') {
$buttons = a::get($fields[$name], 'buttons');
if (is_array($buttons)) {
foreach ($buttons as $index => $value) {
if (in_array($value, array('link', 'email'))) {
unset($fields[$name]['buttons'][$index]);
}
}
} else {
if ($buttons !== false) {
$fields[$name]['buttons'] = array('bold', 'italic');
}
}
}
}
}
return $fields;
}
示例13: get
/**
* Retreives a field info object from the registry
*
* @param string|null $name If null, all registered fields will be returned as array
* @param Obj|null|array
*/
public function get($name = null)
{
if (is_null($name)) {
return static::$fields;
}
return a::get(static::$fields, $name);
}
示例14: message
public function message()
{
if ($message = s::get('message') and is_array($message)) {
$text = a::get($message, 'text');
$type = a::get($message, 'type', 'notification');
$element = new Brick('div');
$element->addClass('message');
if ($type == 'error') {
$element->addClass('message-is-alert');
} else {
$element->addClass('message-is-notice');
}
$element->append(function () use($text) {
$content = new Brick('span');
$content->addClass('message-content');
$content->text($text);
return $content;
});
$element->append(function () {
$toggle = new Brick('a');
$toggle->attr('href', url::current());
$toggle->addClass('message-toggle');
$toggle->html('<i>×</i>');
return $toggle;
});
s::remove('message');
return $element;
}
}
示例15: create
public function create($uid, $template, $content = array())
{
if (empty($template)) {
throw new Exception(l('pages.add.error.template'));
}
$uid = empty($uid) ? str::random(32) : $uid;
$blueprint = new Blueprint($template);
$data = array();
foreach ($blueprint->fields(null) as $key => $field) {
$data[$key] = $field->default();
}
$data = array_merge($data, $content);
// create the new page and convert it to a page model
$page = new Page($this->page, parent::create($uid, $template, $data)->dirname());
if (!$page) {
throw new Exception(l('pages.add.error.create'));
}
kirby()->trigger('panel.page.create', $page);
// subpage builder
foreach ((array) $page->blueprint()->pages()->build() as $build) {
$missing = a::missing($build, array('title', 'template', 'uid'));
if (!empty($missing)) {
continue;
}
$subpage = $page->children()->create($build['uid'], $build['template'], array('title' => $build['title']));
if (isset($build['num'])) {
$subpage->sort($build['num']);
}
}
return $page;
}