コード例 #1
0
ファイル: day.php プロジェクト: anqh/events
 /**
  * Render flyer.
  *
  * @return  string
  */
 public function flyer()
 {
     if ($image = $this->event->flyer_front()) {
         $icon = $image->get_url($image::SIZE_ICON);
     } elseif ($image = $this->event->flyer_back()) {
         $icon = $image->get_url($image::SIZE_ICON);
     } elseif (count($flyers = $this->event->flyers())) {
         $image = $flyers[0]->image();
         $icon = $image->get_url($image::SIZE_ICON);
     } else {
         $icon = null;
     }
     return $icon ? HTML::anchor(Route::model($this->event), HTML::image($icon, array('alt' => __('Flyer'))), array('class' => 'avatar')) : '<div class="avatar empty"><i class="icon-picture"></i></div>';
 }
コード例 #2
0
ファイル: carousel.php プロジェクト: anqh/events
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        // Load images
        $flyers = $this->event->flyers();
        if (!count($flyers) && $this->event->flyer_front_url) {
            // Legacy support
            echo HTML::image($this->event->flyer_front_url, array('width' => 290));
        } elseif (count($flyers)) {
            // Check for actions
            if (Permission::has($this->event, Model_Event::PERMISSION_UPDATE, self::$_user)) {
                $action_uri = Route::model($this->event, 'image');
            }
            // Check for missing default image
            $active_id = $this->event->flyer_front_image_id;
            if (!$active_id) {
                $active_id = $flyers->current()->image_id;
            }
            ?>

	<div class="carousel-inner">

		<?php 
            foreach ($flyers as $flyer) {
                ?>

		<div class="item<?php 
                echo $flyer->image_id == $active_id ? ' active' : '';
                ?>
">

			<?php 
                echo HTML::image($flyer->image()->get_url(), array('width' => 290));
                ?>

			<?php 
                if (isset($action_uri)) {
                    ?>

			<div class="btn-group">
				<?php 
                    if ($flyer->image_id == $this->event->flyer_front_image_id) {
                        echo HTML::anchor('#', __('As front'), array('class' => 'btn btn-mini image-change disabled'));
                        echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&back=' . $flyer->image_id, __('As back'), array('class' => 'btn btn-mini image-change'));
                    } elseif ($flyer->image_id == $this->event->flyer_back_image_id) {
                        echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&front=' . $flyer->image_id, __('As front'), array('class' => 'btn btn-mini image-change'));
                        echo HTML::anchor('#', __('As back'), array('class' => 'btn btn-mini image-change disabled'));
                    } else {
                        echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&front=' . $flyer->image_id, __('As front'), array('class' => 'btn btn-mini image-change'));
                        echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&back=' . $flyer->image_id, __('As back'), array('class' => 'btn btn-mini image-change'));
                    }
                    ?>
				<?php 
                    echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&delete=' . $flyer->image_id, '<i class="icon-trash"></i> ' . __('Delete'), array('class' => 'btn btn-mini image-delete'));
                    ?>
			</div>

			<?php 
                }
                ?>

		</div>

<?php 
            }
            ?>

</div>

<?php 
            if (count($flyers) > 1) {
                ?>
<a class="carousel-control left" href="#<?php 
                echo $this->id;
                ?>
" data-slide="prev">&lsaquo;</a>
<a class="carousel-control right" href="#<?php 
                echo $this->id;
                ?>
" data-slide="next">&rsaquo;</a>
<?php 
            }
            ?>

<?php 
        } elseif (Permission::has($this->event, Model_Event::PERMISSION_UPDATE, self::$_user)) {
            // Add new flyer
            echo HTML::anchor(Route::model($this->event, 'image'), '<i class="icon-picture icon-white"></i> ' . __('Add flyer'), array('class' => 'empty ajaxify'));
        }
        return ob_get_clean();
    }
コード例 #3
0
ファイル: galleries.php プロジェクト: anqh/galleries
 /**
  * Get side image.
  *
  * @param   Model_Event  $event
  * @return  View_Generic_SideImage
  */
 protected function section_event_image(Model_Event $event)
 {
     // Display front flyer by default
     if ($image = $event->flyer_front()) {
         $flyer = Model_Flyer::factory()->find_by_image($image->id);
         $link = Route::model($flyer);
     } else {
         if ($image = $event->flyer_back()) {
             $flyer = Model_Flyer::factory()->find_by_image($image->id);
             $link = Route::model($flyer);
         } else {
             if (count($flyers = $event->flyers())) {
                 $flyer = $flyers[0];
                 $image = $flyer->image();
                 $link = Route::model($flyer);
             } else {
                 $image = null;
                 $link = null;
             }
         }
     }
     return new View_Generic_SideImage($image, $link);
 }
コード例 #4
0
ファイル: events.php プロジェクト: anqh/events
 /**
  * Get side image.
  *
  * @param   Model_Event  $event
  * @return  View_Generic_SideImage
  */
 protected function section_event_image(Model_Event $event)
 {
     // Display front flyer by default
     if ($image = $event->flyer_front()) {
         $flyer = Model_Flyer::factory()->find_by_image($image->id);
         $link = Route::model($flyer);
     } else {
         if ($image = $event->flyer_back()) {
             $flyer = Model_Flyer::factory()->find_by_image($image->id);
             $link = Route::model($flyer);
         } else {
             if (count($flyers = $event->flyers())) {
                 $flyer = $flyers[0];
                 $image = $flyer->image();
                 $link = Route::model($flyer);
             } else {
                 $image = null;
                 $link = null;
             }
         }
     }
     if (Permission::has($event, Model_User::PERMISSION_UPDATE, self::$user)) {
         $uri = Route::model($event, 'image');
         $actions = array();
         $actions[] = HTML::anchor($uri, '<i class="icon-plus-sign icon-white"></i> ' . __('Add flyer'), array('class' => 'btn btn-small btn-primary image-add ajaxify'));
         if ($image) {
             $actions[] = HTML::anchor($uri . '?token=' . Security::csrf() . '&front=' . $image->id, __('As front'), array('class' => 'btn btn-small btn-inverse image-change' . ($event->flyer_front_image_id == $image->id ? ' disabled' : ''), 'data-change' => 'front'));
             $actions[] = HTML::anchor($uri . '?token=' . Security::csrf() . '&back=' . $image->id, __('As back'), array('class' => 'btn btn-small btn-inverse image-change' . ($event->flyer_back_image_id == $image->id ? ' disabled' : ''), 'data-change' => 'back'));
             $actions[] = HTML::anchor($uri . '?token=' . Security::csrf() . '&delete=' . $image->id, '<i class="icon-trash"></i> ' . __('Delete'), array('class' => 'btn btn-small btn-inverse image-delete'));
         }
     } else {
         $actions = null;
     }
     $section = new View_Generic_SideImage($image, $link);
     $section->actions = $actions;
     return $section;
 }
コード例 #5
0
ファイル: carousel.php プロジェクト: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        // Load images
        $flyers = $this->event->flyers();
        if ((!count($flyers) || !$flyers->current()->image()) && $this->event->flyer_front_url) {
            // Legacy support
            $flyer_url = ($flyer = $flyers->current()) ? $flyer->image_url() : $this->event->flyer_front_url;
            echo HTML::image($flyer_url, ['class' => 'img-responsive']);
        } elseif (count($flyers)) {
            // Check for actions
            if (Permission::has($this->event, Model_Event::PERMISSION_UPDATE)) {
                $action_uri = Route::model($this->event, 'flyer');
            }
            // Check for missing default image
            $active_id = $this->event->flyer_id;
            if (!$active_id) {
                $active_id = $flyers->current()->id;
            }
            $slide = 0;
            ?>

<div class="carousel">

	<?php 
            if (count($flyers) > 1) {
                ?>
	<ol class="carousel-indicators">

		<?php 
                foreach ($flyers as $flyer) {
                    ?>
		<li data-target="#<?php 
                    echo $this->id;
                    ?>
" data-slide-to="<?php 
                    echo $slide++;
                    ?>
"<?php 
                    echo $flyer->id == $active_id ? ' class="active"' : '';
                    ?>
></li>
		<?php 
                }
                ?>

	</ol>
	<?php 
            }
            ?>

	<div class="carousel-inner">

		<?php 
            foreach ($flyers as $flyer) {
                if ($flyer->image()) {
                    ?>

		<div class="item<?php 
                    echo $flyer->id == $active_id ? ' active' : '';
                    ?>
">

			<?php 
                    echo HTML::anchor(Route::model($flyer), HTML::image($flyer->image()->get_url(), ['class' => 'img-responsive']));
                    ?>

			<?php 
                    if (isset($action_uri)) {
                        ?>

			<div class="actions">
				<?php 
                        if ($flyer->id == $this->event->flyer_id) {
                            echo HTML::anchor('#', '<i class="fa fa-picture-o"></i> ' . __('Set as default'), array('class' => 'btn btn-default btn-xs image-change disabled'));
                        } else {
                            echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&default=' . $flyer->id, '<i class="fa fa-picture-o"></i> ' . __('Set as default'), array('class' => 'btn btn-default btn-xs image-change'));
                        }
                        ?>
				<?php 
                        echo HTML::anchor($action_uri . '?token=' . Security::csrf() . '&delete=' . $flyer->id, '<i class="fa fa-trash-o"></i> ' . __('Delete'), array('class' => 'btn btn-default btn-xs image-delete'));
                        ?>
			</div>

			<?php 
                    }
                    ?>

		</div>

		<?php 
                }
            }
            ?>

	</div>

	<?php 
            if (count($flyers) > 1) {
                ?>
	<a class="carousel-control left" href="#<?php 
                echo $this->id;
                ?>
" data-slide="prev"><i class="fa fa-chevron-left icon-prev"></i></a>
	<a class="carousel-control right" href="#<?php 
                echo $this->id;
                ?>
" data-slide="next"><i class="fa fa-chevron-right icon-next"></i></a>
	<?php 
            }
            ?>

</div>

<?php 
        } elseif (Permission::has($this->event, Model_Event::PERMISSION_UPDATE)) {
            // Add new flyer
            echo HTML::anchor(Route::model($this->event, 'flyer'), '<i class="fa fa-picture-o"></i> ' . __('Upload flyer'), array('class' => 'empty ajaxify'));
        }
        return ob_get_clean();
    }