コード例 #1
0
 public function getList()
 {
     $thumbs = [];
     $themesPath = base_path('resources/views/themes');
     if (is_dir($themesPath)) {
         foreach (Theme::all() as $databaseTheme) {
             $databaseThemes[$databaseTheme->theme] = $databaseTheme;
         }
         foreach (scandir($themesPath) as $themeFile) {
             if (!is_dir($themesPath . '/' . $themeFile) && substr($themeFile, -4) == '.zip') {
                 Theme::unzip($themeFile);
             }
         }
         foreach (scandir($themesPath) as $themeFolder) {
             if (is_dir($themesPath . '/' . $themeFolder) && strpos($themeFolder, '.') !== 0) {
                 $theme = new \stdClass();
                 $theme->name = $themeFolder;
                 $theme->image = 'https://placeholdit.imgix.net/~text?txtsize=19&bg=efefef&txtclr=aaaaaa%26text%3Dno%2Bimage&txt=no+image&w=200&h=150';
                 $publicLocations = [public_path('themes/' . $themeFolder), $themesPath . '/' . $themeFolder . '/public'];
                 foreach ($publicLocations as $k => $publicLocation) {
                     if (is_dir($publicLocation)) {
                         foreach (scandir($publicLocation) as $file) {
                             if (!is_dir($publicLocation . '/' . $file)) {
                                 if (strpos($file, 'screenshot.') === 0) {
                                     if ($k == 0) {
                                         $theme->image = \Croppa::url(URL::to('themes/' . $themeFolder . '/' . $file), 252, 142);
                                     } else {
                                         $saveInCache = public_path('coaster/tmp/themes/' . $themeFolder);
                                         @mkdir($saveInCache, 0777, true);
                                         copy($publicLocation . '/' . $file, $saveInCache . '/' . $file);
                                         $theme->image = \Croppa::url(URL::to('coaster/tmp/themes/' . $themeFolder . '/' . $file), 252, 142);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (isset($databaseThemes[$themeFolder])) {
                     $theme->id = $databaseThemes[$themeFolder]->id;
                     if ($databaseThemes[$themeFolder]->id != config('coaster::frontend.theme')) {
                         $theme->activate = 1;
                     } else {
                         $theme->active = 1;
                     }
                 } else {
                     $theme->install = 1;
                 }
                 $thumbs[] = $theme;
             }
         }
     }
     $theme_auth = ['update' => Auth::action('themes.update'), 'manage' => Auth::action('themes.manage'), 'export' => Auth::action('themes.export'), 'edit' => Auth::action('themes.edit')];
     $themes_installed = View::make('coaster::partials.themes.thumbs', ['thumbs' => $thumbs, 'auth' => $theme_auth]);
     if (!empty(self::$_error)) {
         $this->addAlert('danger', self::$_error);
     }
     $this->layoutData['content'] = View::make('coaster::pages.themes.list', ['themes_installed' => $themes_installed, 'can_upload' => $theme_auth['manage']]);
     $this->layoutData['modals'] = View::make('coaster::modals.themes.delete')->render() . View::make('coaster::modals.themes.export')->render() . View::make('coaster::modals.themes.install')->render() . View::make('coaster::modals.themes.install_confirm')->render() . View::make('coaster::modals.themes.install_error')->render();
 }
コード例 #2
0
ファイル: Image.php プロジェクト: web-feet/coasterframework
 /**
  * Display image, image can be cropped with croppa
  * @param string $content
  * @param array $options
  * @return string
  */
 public function display($content, $options = [])
 {
     $imageData = $this->_defaultData($content);
     if (empty($imageData->file)) {
         return '';
     }
     if (empty($imageData->title)) {
         if (empty($options['title'])) {
             $fileName = substr(strrchr($imageData->file, '/'), 1);
             $imageData->title = str_replace('_', ' ', preg_replace('/\\.[^.\\s]{3,4}$/', '', $fileName));
         } else {
             $imageData->title = $options['title'];
         }
     }
     $imageData->extra_attrs = '';
     $ignoreAttributes = ['height', 'width', 'group', 'view', 'title', 'croppaOptions', 'version'];
     foreach ($options as $option => $val) {
         if (!in_array($option, $ignoreAttributes)) {
             $imageData->extra_attrs .= $option . '="' . $val . '" ';
         }
     }
     $imageData->group = !empty($options['group']) ? $options['group'] : '';
     $imageData->original = URL::to($imageData->file);
     $height = !empty($options['height']) ? $options['height'] : null;
     $width = !empty($options['width']) ? $options['width'] : null;
     if ($height || $width) {
         $croppaOptions = !empty($options['croppaOptions']) ? $options['croppaOptions'] : [];
         $imageData->file = str_replace(URL::to('/'), '', $imageData->file);
         $imageData->file = \Croppa::url($imageData->file, $width, $height, $croppaOptions);
     } else {
         $imageData->file = $imageData->original;
     }
     $template = !empty($options['view']) ? $options['view'] : 'default';
     $imageViews = 'themes.' . PageBuilder::getData('theme') . '.blocks.images.';
     if (View::exists($imageViews . $template)) {
         return View::make($imageViews . $template, array('image' => $imageData))->render();
     } else {
         return 'Image template not found';
     }
 }
コード例 #3
0
ファイル: Category.php プロジェクト: ddcint/benefund
 public function get_thumb($width = 64, $height = 64)
 {
     $file_url = 'uploads/categories/thumbs/' . $this->id . '.png';
     return File::exists($file_url) ? asset(Croppa::url($file_url, $width, $height)) : 'http://placehold.it/' . $width . 'x' . $height . '/ccc/ccc';
 }
コード例 #4
0
            <!-- widget div-->
            <div role="content" class="">
                <!-- widget content -->
                <div class="widget-body">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary"><i class="fa fa-cog"></i>Save &amp; Publish</button>
                            <!--<a class="btn btn-primary" href="javascript:void(0);"><i class="fa fa-cog"></i> Save &amp; Publish</a>-->
                        </div>
                        <hr>
                        <div class="form-group">
                            <div class="col-md-12" style="margin: 0; padding: 0">
                                <div id="imgg" style="background-color: #c3c3c3; padding: 10px; text-align: center">
                                    <?php 
if ($myproduct->image != "") {
    echo "<img alt='' src='" . \Croppa::url(ASSETS_URL . '/uploads/images/thumbs/' . $myproduct->image, 100, 100) . "' />";
} else {
    echo "<i class='fa fa-camera fa-5x'></i>";
}
?>

                                </div>
                                <a class="inline2" href="#inline_content2" id="dd">Browse</a>
                                <input class="form-control" id="sort_order" name="sort_order" placeholder="Sort Order" value="{{$myproduct->sort_order}}" type="text">
                                <input type="hidden" id="image" name="image" value="{{$myproduct->image}}">
                                <input type="hidden" id="oldimage" name="oldimage" value="{{$myproduct->image}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-12">
                                <label class="checkbox-inline">
コード例 #5
0
ファイル: User.php プロジェクト: urashima82/intranet
 public function getAvatarUrl($size)
 {
     if (!empty($this->avatar)) {
         $src_filename = sprintf('/uploads/users/%d/%s', $this->id, $this->avatar);
         if (is_file(public_path() . $src_filename)) {
             $result = Croppa::url($src_filename, $size, $size, array('resize'));
             //$result = preg_replace('!^(.+)\?.+$!', '$1', $result);
             return $result;
         }
     }
     return "http://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email))) . "?d=mm&s=" . $size;
 }
コード例 #6
0
 /**
  * Remove a log
  * @return Response request response
  */
 public function postDelete($id)
 {
     $category = Category::find($id);
     // If no item in database
     if (empty($category) || empty($category->id)) {
         return Redirect::route('admin.categories')->with('message', Lang::get('admin/categories.edit.inexistant'));
     }
     try {
         $category->delete();
         Croppa::delete('uploads/categories/thumbs/' . $id . '.png');
         Croppa::delete('uploads/categories/covers/' . $id . '.png');
     } catch (Exception $e) {
         return Redirect::back()->with('message', Lang::get('admin/categories.new.error_delete'))->withInput();
     }
     return Redirect::route('admin.categories')->with('message', Lang::get('admin/categories.delete.message', array('title' => Input::get('title'))));
 }
コード例 #7
0
 /**
  * Modify user (form)
  */
 public function modify_check($id)
 {
     $user = User::find($id);
     if (!$user) {
         return Redirect::route('members')->with('mError', 'Cet utilisateur est introuvable !');
     }
     if (!Auth::user()->isSuperAdmin() && $id != Auth::id()) {
         App::abort(403, 'Unauthorized action.');
         return false;
     }
     $validator = Validator::make(Input::all(), User::$rules);
     if (!$validator->fails()) {
         // Vérifier que l'adresse email soit unique (peut-être à améliorer... directement dans l'entity ?)
         $check = User::where('email', '=', $user->email)->where('id', '!=', $user->id)->first();
         if (!$check) {
             $user->email = Input::get('email');
             $user->firstname = Input::get('firstname');
             $user->lastname = Input::get('lastname');
             if (Input::get('password')) {
                 $user->password = Hash::make(Input::get('password'));
             }
             $user->bio_short = Input::get('bio_short');
             $user->bio_long = Input::get('bio_long');
             $user->twitter = Input::get('twitter');
             $user->website = Input::get('website');
             $user->phone = Input::get('phone');
             $user->social_github = Input::get('social_github');
             $user->social_instagram = Input::get('social_instagram');
             $user->social_linkedin = Input::get('social_linkedin');
             $user->social_facebook = Input::get('social_facebook');
             if (Auth::user()->isSuperAdmin()) {
                 $user->is_member = Input::get('is_member', false);
             }
             if (Input::get('birthday')) {
                 $birthday = explode('/', Input::get('birthday'));
                 $user->birthday = $birthday[2] . '-' . $birthday[1] . '-' . $birthday[0];
             } else {
                 $user->birthday = '';
             }
             if (!$user->role) {
                 $user->role = 'member';
             }
             $need_to_move_file = false;
             if (Input::hasFile('avatar')) {
                 // remove previous
                 if ($user->avatar) {
                     try {
                         Croppa::delete(sprintf('/uploads/users/%d/%s', $user->id, $user->avatar));
                     } catch (\League\Flysystem\FileNotFoundException $e) {
                     }
                 }
                 $filename = Str::random(8) . '.' . File::extension(Input::file('avatar')->getClientOriginalName());
                 $user->avatar = $filename;
                 $need_to_move_file = true;
             }
             if ($user->save()) {
                 if ($need_to_move_file) {
                     $target_folder = public_path() . '/uploads/users/' . $user->id;
                     if (!is_dir($target_folder)) {
                         mkdir($target_folder);
                     }
                     Input::file('avatar')->move($target_folder, $filename);
                 }
                 return Redirect::route('user_profile', $user->id)->with('mSuccess', 'Cet utilisateur a bien été modifié');
             } else {
                 return Redirect::route('user_modify', $user->id)->with('mError', 'Impossible de modifier cet utilisateur');
             }
         }
     } else {
         return Redirect::route('user_modify', $user->id)->with('mError', 'Il y a des erreurs')->withErrors($validator->messages())->withInput();
     }
 }
コード例 #8
0
ファイル: item.blade.php プロジェクト: neonbug/meexo-gallery
	.gallery-image:hover
	{
		background-position: 0px -20px;
		filter: drop-shadow(0px 2px 4px #222222);
	}
</style>

<h1>{{ $item->title }}</h1>
<strong>{{ date('d.m.Y', strtotime($item->updated_at)) }}</strong>

<?php 
$root_dir = 'uploads';
$package_name = 'gallery';
$id_gallery = $item->{$item->getKeyName()};
$id_language = 0;
//language independent field
$column_name = 'images';
$images = Neonbug\Gallery\Models\GalleryImage::where('id_row', $item->{$item->getKeyName()})->where('column_name', $column_name)->orderBy('ord')->get();
?>

<div class="gallery-images">
	@foreach ($images as $image)
		<?php 
$image_path = implode('/', [$root_dir, $package_name, $id_gallery, $id_language, $column_name, $image->image]);
$url = Croppa::url($image_path);
$thumb = Croppa::url($image_path, 180, 120);
?>
		<a target="_blank" class="gallery-image" href="{{ $url }}" style="background-image: url('{{ $thumb }}');"></a>
	@endforeach
</div>
コード例 #9
0
 public function postUpdate($id)
 {
     $campaign = Campaign::find($id);
     // If no item in database
     if (empty($campaign) || empty($campaign->id)) {
         return Redirect::route('public.campaigns')->with('message', Lang::get('campaigns.edit.inexistant'));
     }
     if (!($campaign->vendor->id == Auth::user()->id || Auth::user()->role()->first()->name_tag == 'admin')) {
         return Redirect::back()->with('message', Lang::get('campaigns.edit.unauthorized'));
     }
     $validator = Validator::make(Input::all(), Campaign::$rules);
     $data = Input::all();
     $data['item_price'] = intval(Input::get('item_price', 0) * 100);
     if ($validator->passes()) {
         $campaign->fill($data)->save();
         $cover = Input::file('cover', null);
         if (null !== $cover) {
             Croppa::delete('uploads/campaigns/covers/' . $id . '.png');
             $destination_path = 'uploads/campaigns/covers';
             $file_name = $campaign->id;
             $path_parts = explode('.', $cover->getClientOriginalName());
             $ext = $path_parts[count($path_parts) - 1];
             $cover_passes = Input::file('cover')->move($destination_path, $file_name . '.png');
         } else {
             $cover_passes = true;
         }
         if (is_bool($cover_passes) && $cover_passes == false) {
             return Redirect::back()->with('message', Lang::get('campaigns.cover.bad_upload_error'))->withInput();
         }
         $thumb = Input::file('thumb', null);
         if (null !== $thumb) {
             Croppa::delete('uploads/campaigns/thumbs/' . $id . '.png');
             $destination_path = 'uploads/campaigns/thumbs';
             $file_name = $campaign->id;
             $path_parts = explode('.', $thumb->getClientOriginalName());
             $ext = $path_parts[count($path_parts) - 1];
             $thumb_passes = Input::file('thumb')->move($destination_path, $file_name . '.png');
         } else {
             $thumb_passes = true;
         }
         if (is_bool($thumb_passes) && $thumb_passes == false) {
             return Redirect::back()->with('message', Lang::get('campaigns.thumb.bad_upload_error'))->withInput();
         }
         return Redirect::back()->with('message', Lang::get('campaigns.edit.message', array('title' => Input::get('title'))));
     } else {
         return Redirect::back()->with('message', Lang::get('campaigns.edit.error'))->withErrors($validator)->withInput();
     }
 }
コード例 #10
0
                                            <th data-class="expand">Img</th>
                                            <th data-hide="phone">Category Name</th>
                                            <th data-hide="phone">Sort Order</th>
                                            <th data-hide="phone,tablet">Date Crreated</th>
                                            <th data-hide="phone,tablet">Date Modified</th>
                                            <th data-hide="phone">Action</th>
                                        </tr>
                                        </thead>
                                        <tbody id="listdata">
                                        @if($categories)
                                        {{--*/$x=1/*--}}
                                        @foreach($categories as $category)
                                        <tr>
                                            <td>{{$x}}</td>
                                            <td><?php 
echo "<img src='" . \Croppa::url(ASSETS_URL . "/uploads/images/thumbs/" . $category->image, 50, 50) . "' >";
?>
</td>
                                            <td>{{$category->title}}</td>
                                            <td>{{$category->sort_order}}</td>
                                            <td>{{date_format(date_create($category->created_at),"d-m-Y")}}</td>
                                            <td>{{date_format(date_create($category->updated_at),"d-m-Y")}}</td>
                                            <td>{{HTML::linkRoute('editpcategory',"Edit",$category->id)}}</td>
                                        </tr>
                                        {{--*/$x++/*--}}
                                        @endforeach
                                        @else
                                        <td colspan="6" >No listing available</td>
                                        @endif
                                        </tbody>
                                    </table>