本文整理汇总了PHP中Arr::Get方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::Get方法的具体用法?PHP Arr::Get怎么用?PHP Arr::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::Get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_gallery
/**
* Action: gallery
*/
public function action_gallery()
{
/** @var Model_Gallery $gallery */
$gallery_id = (int) $this->request->param('id');
$gallery = Model_Gallery::factory($gallery_id);
if (!$gallery->loaded()) {
throw new Model_Exception($gallery, $gallery_id);
}
// Are we approving pending images?
if ($this->request->action() == 'pending') {
// Can we see galleries with un-approved images?
Permission::required($gallery, Model_Gallery::PERMISSION_APPROVE_WAITING, self::$user);
// Can we see all of them and approve?
$approve = Permission::has($gallery, Model_Gallery::PERMISSION_APPROVE, self::$user);
// Handle images?
if ($_POST && Security::csrf_valid()) {
$pending = $gallery->find_images_pending($approve ? null : self::$user);
$images = (array) Arr::get($_POST, 'image_id');
$authors = array();
if (count($pending) && count($images)) {
foreach ($pending as $image) {
$action = Arr::Get($images, $image->id, 'wait');
switch ($action) {
case 'approve':
if ($approve) {
$author = $image->author();
//$gallery->image_count++;
$authors[$author['id']] = $author['username'];
$image->state(AutoModeler::STATE_LOADED);
$image->status = Model_Image::VISIBLE;
$image->save();
}
break;
case 'deny':
$gallery->remove('image', $image->id);
$gallery->image_count--;
$image->delete();
break;
}
}
// Admin actions
if ($approve) {
// Set default image if none set
if (!$gallery->default_image_id) {
$gallery->default_image_id = $gallery->images()->current()->id;
}
$gallery->update_copyright();
$gallery->updated = time();
}
$gallery->save();
// Redirect to normal gallery if all images approved/denied
if (!count($gallery->find_images_pending($approve ? null : self::$user))) {
$this->request->redirect(Route::model($gallery));
} else {
$this->request->redirect(Route::model($gallery, 'pending'));
}
}
}
} else {
Permission::required($gallery, Model_Gallery::PERMISSION_READ, self::$user);
}
// Build page
$this->view = View_Page::factory(__('Gallery'));
$this->_set_page_actions(Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_CREATE, self::$user));
$this->_set_gallery($gallery);
if (Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_UPDATE, self::$user)) {
$this->view->actions[] = array('link' => Route::model($gallery, 'update'), 'text' => '<i class="icon-refresh icon-white"></i> ' . __('Update gallery'));
}
// Share
if ($this->request->action() !== 'pending' && Kohana::$config->load('site.facebook')) {
Anqh::open_graph('title', __('Gallery') . ': ' . $gallery->name);
Anqh::open_graph('url', URL::site(Route::get('gallery')->uri(array('id' => $gallery->id, 'action' => '')), true));
Anqh::open_graph('description', __($gallery->image_count == 1 ? ':images image' : ':images images', array(':images' => $gallery->image_count)) . ' - ' . date('l ', $gallery->date) . Date::format(Date::DMY_SHORT, $gallery->date) . ($event ? ' @ ' . $event->venue_name : ''));
if ($event && ($image = $event->flyer_front())) {
Anqh::open_graph('image', URL::site($image->get_url('thumbnail'), true));
} else {
if ($image = $gallery->default_image()) {
Anqh::open_graph('image', URL::site($image->get_url('thumbnail'), true));
}
}
}
Anqh::share(true);
$this->view->add(View_Page::COLUMN_SIDE, $this->section_share());
// Event info
if ($event = $gallery->event()) {
// Event flyer
$this->view->add(View_Page::COLUMN_SIDE, $this->section_event_image($event));
// Event info
$this->view->add(View_Page::COLUMN_SIDE, $this->section_event_info($event));
}
// Pictures
$this->view->add(View_Page::COLUMN_MAIN, $this->section_gallery_thumbs($gallery, $this->request->action() == 'pending', isset($approve) ? $approve : null));
}
示例2: content
//.........这里部分代码省略.........
<?php
echo Form::button('preview', __('Preview'), array('class' => 'btn btn-default btn-lg', 'data-content-class' => '*', 'data-prepend' => '#preview'));
?>
<?php
echo $this->cancel ? HTML::anchor($this->cancel, __('Cancel'), array('class' => 'cancel')) : '';
?>
<?php
echo Form::csrf();
?>
<?php
echo Form::hidden('latitude', $this->venue->latitude, array('data-geo' => 'lat'));
?>
<?php
echo Form::hidden('longitude', $this->venue->longitude, array('data-geo' => 'lng'));
?>
<?php
echo Form::hidden('city', $this->event->city_name, array('data-geo' => 'locality'));
?>
<?php
echo Form::hidden('venue_id', $this->venue->id);
?>
<?php
echo Form::hidden('foursquare_id', $this->venue->foursquare_id);
?>
</fieldset>
</div>
<div class="col-md-4">
<fieldset id="fields-when" class="row form-inline">
<div class="col-md-3">
<?php
echo Form::input_wrap('stamp_begin[date]', is_numeric($this->event->stamp_begin) ? Date::format('DMYYYY', $this->event->stamp_begin) : $this->event->stamp_begin, array('class' => 'date', 'maxlength' => 10, 'size' => 7, 'placeholder' => 'd.m.yyyy'), __('From'), Arr::Get($this->event_errors, 'stamp_begin'));
?>
</div>
<div class="col-md-3">
<?php
echo Form::select_wrap('stamp_begin[time]', array_reverse(Date::hours_minutes(30, true)), is_numeric($this->event->stamp_begin) ? Date::format('HHMM', $this->event->stamp_begin) : (empty($this->event->stamp_begin) ? '22:00' : $this->event->stamp_begin), array('class' => 'time'), ' ', Arr::get($this->event_errors, 'stamp_begin'));
?>
</div>
<div class="col-md-3">
<?php
echo Form::select_wrap('stamp_end[time]', Date::hours_minutes(30, true), is_numeric($this->event->stamp_end) ? Date::format('HHMM', $this->event->stamp_end) : (empty($this->event->stamp_end) ? '04:00' : $this->event->stamp_end), array('class' => 'time'), __('To'), Arr::get($this->event_errors, 'stamp_end'));
?>
</div>
<div class="col-md-3">
<?php
echo Form::input_wrap('stamp_end[date]', is_numeric($this->event->stamp_end) ? Date::format('DMYYYY', $this->event->stamp_end) : $this->event->stamp_end, array('class' => 'date', 'maxlength' => 10, 'size' => 7, 'placeholder' => 'd.m.yyyy'), ' ', Arr::Get($this->event_errors, 'stamp_end'));
?>
</div>
</fieldset>
<br>
<fieldset id="fields-venue" class="row">
<div class="col-md-12">
<?php
echo Form::input_wrap('city_name', $this->event->city_name, null, __('City'), Arr::get($this->event_errors, 'city_name'));
?>
</div>
<div class="col-md-7">