示例#1
0
 public function format($value)
 {
     if ($this->module->flag == "L") {
         return Str::limit($value, $this->listLimit);
     }
     return $value;
 }
示例#2
0
 public function getDatatable()
 {
     $products = $this->ProductRepo->find(Input::get('sSearch'));
     return Datatable::query($products)->addColumn('checkbox', function ($model) {
         return '<input type="checkbox" name="ids[]" value="' . $model->public_id . '">';
     })->addColumn('product_key', function ($model) {
         return link_to('products/' . $model->public_id, $model->product_key);
     })->addColumn('notes', function ($model) {
         return nl2br(Str::limit($model->notes, 50));
     })->addColumn('cost', function ($model) {
         return Utils::formatMoney($model->cost, 1);
     })->addColumn('name', function ($model) {
         return nl2br($model->category_name);
     })->addColumn('dropdown', function ($model) {
         return '<div class="btn-group tr-action" style="visibility:hidden;">
             <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
               ' . trans('texts.select') . ' <span class="caret"></span>
             </button>
             <ul class="dropdown-menu" role="menu">
             <li><a href="' . URL::to('products/' . $model->public_id) . '/edit">' . uctrans('texts.edit_product') . '</a></li>                
             <li class="divider"></li>
             <li><a href="' . URL::to('products/' . $model->public_id) . '/archive">' . uctrans('texts.delete_product') . '</a></li>
           </ul>
         </div>';
     })->make();
 }
示例#3
0
 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => 'required', 'content' => 'required|min:100', 'published_at' => 'required', 'meta_description' => 'max:500', 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/post/{$id}/edit")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Post::find($id);
             $table->title = e(Input::get('title'));
             $table->link = Input::get('link');
             $table->user_id = Auth::user()->id;
             $table->content = e(Input::get('content'));
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : Str::limit(strip_tags(HTML::decode($table->content)), 155);
             $table->meta_keywords = Input::get('meta_keywords');
             $table->published_at = Post::toDate(Input::get('published_at'));
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.{$this->name}");
                 return Redirect::to("admin/{$this->name}")->with('success', trans("message.{$this->action}", ['name' => $name]));
             }
             return Redirect::to("admin/{$this->name}")->with('error', trans('message.error'));
         }
     }
     return View::make("admin.{$this->name}.{$this->action}", ['item' => Post::find($id), 'name' => $this->name, 'action' => $this->action]);
 }
示例#4
0
 public function index($id)
 {
     $post = $this->postRepository->findById($id);
     if (!$post or !$post->present()->canView()) {
         if (\Request::ajax()) {
             return '';
         }
         return $this->theme->section('error-page');
     }
     $this->theme->share('site_description', $post->text ? \Str::limit($post->text, 100) : \Config::get('site_description'));
     $this->theme->share('ogUrl', \URL::route('post-page', ['id' => $post->id]));
     if ($post->text) {
         $this->theme->share('ogTitle', \Str::limit($post->text, 100));
     }
     if ($post->present()->hasValidImage()) {
         foreach ($post->present()->images() as $image) {
             $this->theme->share('ogImage', \Image::url($image, 600));
         }
     }
     $ad = empty($post->text) ? trans('post.post') : str_limit($post->text, 60);
     $design = [];
     if ($post->page_id) {
         $design = $post->page->present()->readDesign();
     } elseif ($post->community_id) {
         $design = $post->community->present()->readDesign();
     } else {
         $design = $post->user->present()->readDesign();
     }
     return $this->render('post.page', ['post' => $post], ['title' => $this->setTitle($ad), 'design' => $design]);
 }
示例#5
0
 /**
  * Get the page's excerpt
  * @return string
  */
 public function excerpt($length = 80)
 {
     if (strpos($this->content, '<!--more-->')) {
         list($excerpt, $more) = explode('<!--more-->', $this->content);
         return Services\String::tidy($excerpt);
     } else {
         return Services\String::tidy(Str::limit($this->content, $length));
     }
 }
示例#6
0
 public function format($value)
 {
     $flag = $this->module->flag;
     if ($flag == "L") {
         return Markdown::defaultTransform(Str::limit($value, $this->listLimit));
     }
     if ($flag == "R") {
         return Markdown::defaultTransform($value);
     }
     return $value;
 }
示例#7
0
 public function editAlbum()
 {
     $id = \Input::get('id');
     $title = \Input::get('text');
     $album = $this->albumRepository->get($id);
     if (!$album) {
         return '0';
     }
     if (empty($title)) {
         return \Str::limit(ucwords($album->title), 30);
     }
     $album = $this->albumRepository->save($title, $album);
     return \Str::limit(ucwords($album->title), 30);
 }
示例#8
0
 /**
  * Attempts to upload a file, adds it to the database and removes other database entries for that file type if they are asked to be removed
  * @param  string  $field             The name of the $_FILES field you want to upload
  * @param  boolean $upload_type       The type of upload ('news', 'gallery', 'section') etc
  * @param  boolean $type_id           The ID of the item (above) that the upload is linked to
  * @param  boolean $remove_existing   Setting this to true will remove all existing uploads of the passed in type (useful for replacing news article images when a new on
  * @param  boolean $title             Sets the title of the upload
  * @param  boolean $path_to_store     Sets the path to the upload (where it should go)
  * @return object                     Returns the upload object so we can work with the uploaded file and details
  */
 public static function upload($details = array())
 {
     $upload_details = array('remove_existing_for_link' => true, 'path_to_store' => path('public') . 'uploads/', 'resizing' => array('small' => array('w' => 200, 'h' => 200), 'thumb' => array('w' => 200, 'h' => 200)));
     if (!empty($details)) {
         $required_keys = array('upload_field_name', 'upload_type', 'upload_link_id', 'title');
         $continue = true;
         foreach ($required_keys as $key) {
             if (!isset($details[$key]) || empty($details[$key])) {
                 Messages::add('error', 'Your upload array details are not complete... please fill this in properly.');
                 $continue = false;
             }
         }
         if ($continue) {
             $configuration = $details + $upload_details;
             $input = Input::file($configuration['upload_field_name']);
             if ($input && $input['error'] == UPLOAD_ERR_OK) {
                 if ($configuration['remove_existing_for_link']) {
                     static::remove($configuration['upload_type'], $configuration['upload_link_id']);
                 }
                 $ext = File::extension($input['name']);
                 $filename = Str::slug($configuration['upload_type'] . '-' . $configuration['upload_link_id'] . '-' . Str::limit(md5($input['name']), 10, false) . '-' . $configuration['title'], '-');
                 Input::upload($configuration['upload_field_name'], $configuration['path_to_store'], $filename . '.' . $ext);
                 $upload = new Upload();
                 $upload->link_type = $configuration['upload_type'];
                 $upload->link_id = $configuration['upload_link_id'];
                 $upload->filename = $filename . '.' . $ext;
                 if (Koki::is_image($configuration['path_to_store'] . $filename . '.' . $ext)) {
                     $upload->small_filename = $filename . '_small' . '.' . $ext;
                     $upload->thumb_filename = $filename . '_thumb' . '.' . $ext;
                     $upload->image = 1;
                 }
                 $upload->extension = $ext;
                 $upload->user_id = Auth::user()->id;
                 $upload->save();
                 if (Koki::is_image($configuration['path_to_store'] . $filename . '.' . $ext)) {
                     WideImage::load($configuration['path_to_store'] . $upload->filename)->resize($configuration['resizing']['small']['w'], $configuration['resizing']['small']['h'])->saveToFile($configuration['path_to_store'] . $upload->small_filename);
                     WideImage::load($configuration['path_to_store'] . $upload->small_filename)->crop('center', 'center', $configuration['resizing']['thumb']['w'], $configuration['resizing']['thumb']['h'])->saveToFile($configuration['path_to_store'] . $upload->thumb_filename);
                 }
                 return true;
             }
         }
     } else {
         Messages::add('error', 'Your upload array details are empty... please fill this in properly.');
     }
     return false;
 }
示例#9
0
 public static function agregar($info)
 {
     $respuesta = array();
     $rules = array('archivo' => array('mimes:pdf'));
     $validator = Validator::make($info, $rules);
     if ($validator->fails()) {
         //return Response::make($validator->errors->first(), 400);
         //Si está todo mal, carga lo que corresponde en el mensaje.
         $respuesta['mensaje'] = $validator;
         $respuesta['error'] = 'no pasa';
     } else {
         $file = $info['archivo'];
         $count = count($file->getClientOriginalName()) - 4;
         $nombreArchivo = Str::limit(Str::slug($file->getClientOriginalName()), $count, "");
         $extension = $file->getClientOriginalExtension();
         //if you need extension of the file
         //$extension = File::extension($file['name']);
         $carpeta = '/uploads/archivos/';
         $directory = public_path() . $carpeta;
         //$filename = sha1(time() . Hash::make($filename) . time()) . ".{$extension}";
         //Pregunto para que no se repita el nombre de la imagen
         if (!is_null(Archivo::archivoPorNombre($nombreArchivo . ".{$extension}"))) {
             $filename = $nombreArchivo . "(" . Str::limit(sha1(time()), 3, "") . ")" . ".{$extension}";
         } else {
             $filename = $nombreArchivo . ".{$extension}";
         }
         //$upload_success = $file->move($directory, $filename);
         if ($file->move($directory, $filename)) {
             $datos = array('nombre' => $filename, 'titulo' => $nombreArchivo . ".{$extension}", 'carpeta' => $carpeta, 'tipo' => "{$extension}", 'estado' => 'A', 'fecha_carga' => date("Y-m-d H:i:s"), 'usuario_id_carga' => Auth::user()->id);
             $archivo = static::create($datos);
             //Mensaje correspondiente a la agregacion exitosa
             $respuesta['mensaje'] = 'Archivo creado.';
             $respuesta['error'] = false;
             $respuesta['data'] = $archivo;
             //return Response::json('success', 200);
         } else {
             //Mensaje correspondiente a la agregacion exitosa
             $respuesta['mensaje'] = 'Archivo erróneo.';
             $respuesta['error'] = true;
             $respuesta['data'] = null;
             //return Response::json('error', 400);
         }
     }
     return $respuesta;
 }
示例#10
0
 public function participantsListsExport()
 {
     $users_list = $this->getParticipants(10000);
     $glue = Input::get('glue');
     $headers = array('local_id', 'remote_id', iconv("UTF-8", Input::get('coding'), 'Имя'), iconv("UTF-8", Input::get('coding'), 'Фамилия'), iconv("UTF-8", Input::get('coding'), 'Элект.почта'), iconv("UTF-8", Input::get('coding'), 'Фотография'), iconv("UTF-8", Input::get('coding'), 'Пол. 1 - жен, 2 - муж.'), iconv("UTF-8", Input::get('coding'), 'Телефон'), iconv("UTF-8", Input::get('coding'), 'Город'), iconv("UTF-8", Input::get('coding'), 'Победитель'), iconv("UTF-8", Input::get('coding'), 'Номер недели'), iconv("UTF-8", Input::get('coding'), 'Дата рождения'), iconv("UTF-8", Input::get('coding'), 'Дата регистрации'), iconv("UTF-8", Input::get('coding'), 'Всего лайков'), iconv("UTF-8", Input::get('coding'), 'Лайки по соц.сетям'), iconv("UTF-8", Input::get('coding'), 'Фотография из соц.сети'), iconv("UTF-8", Input::get('coding'), 'Кол.введ.кодов'), iconv("UTF-8", Input::get('coding'), 'Рассказ'), iconv("UTF-8", Input::get('coding'), 'ID рассказа'), iconv("UTF-8", Input::get('coding'), 'Статус рассказа. 0-отсутсвует. 1-одобрен. 2-на модерации. 3-отклонен'));
     if ($glue === 'tab') {
         $output = implode("\t", $headers) . "\n";
     } else {
         $output = implode("{$glue}", $headers) . "\n";
     }
     foreach ($users_list as $user) {
         try {
             $user->name = iconv("UTF-8", Input::get('coding'), $user->name);
         } catch (Exception $e) {
         }
         try {
             $user->surname = iconv("UTF-8", Input::get('coding'), $user->surname);
         } catch (Exception $e) {
         }
         try {
             $user->total_extend = iconv("UTF-8", Input::get('coding'), $user->total_extend);
         } catch (Exception $e) {
         }
         try {
             $user->writing = iconv("UTF-8", Input::get('coding'), str_replace(array("\r\n", "\n\r", "\r", "\n", "\t", ";"), "", strip_tags(Str::limit($user->writing, 1000))));
         } catch (Exception $e) {
             $user->writing = iconv("UTF-8", Input::get('coding'), 'ВНИМАНИЕ! ВОЗНИКЛА ОШИБКА ПРИ ПЕРЕКОДИРОВАНИИ.');
         }
         try {
             $user->city = iconv("UTF-8", Input::get('coding'), $user->city);
         } catch (Exception $e) {
         }
         $fields = (array) $user;
         if ($glue === 'tab') {
             $output .= implode("\t", $fields) . "\n";
         } else {
             $output .= implode("{$glue}", $fields) . "\n";
         }
     }
     $headers = array('Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="ExportList.csv"');
     return Response::make(rtrim($output, "\n"), 200, $headers);
 }
示例#11
0
 /**
  * Register bindings in the container.
  *
  * @param Dispatcher $events
  *
  * @return void
  */
 public function boot(Dispatcher $events)
 {
     $this->app->booted(function () {
         if (Request::getUser() && Request::getPassword()) {
             return Auth::onceBasic('name');
         }
     });
     $events->listen('auth.login', function ($user) {
         $user->last_login = new Carbon();
         $user->last_ip = Request::getClientIp();
         $user->save();
     });
     /* IRC Notification */
     $events->listen('eloquent.created: Strimoid\\Models\\User', function (User $user) {
         $url = Config::get('app.hubot_url');
         if (!$url) {
             return;
         }
         try {
             Guzzle::post($url, ['json' => ['room' => '#strimoid', 'text' => 'Mamy nowego użytkownika ' . $user->name . '!']]);
         } catch (Exception $e) {
         }
     });
     $events->listen('eloquent.created: Strimoid\\Models\\Entry', function (Entry $entry) {
         $url = Config::get('app.hubot_url');
         if (!$url) {
             return;
         }
         try {
             $text = strip_tags($entry->text);
             $text = trim(preg_replace('/\\s+/', ' ', $text));
             $text = Str::limit($text, 100);
             Guzzle::post($url, ['json' => ['room' => '#strimoid-entries', 'text' => '[' . $entry->group->name . '] ' . $entry->user->name . ': ' . $text]]);
         } catch (Exception $e) {
         }
     });
     $events->subscribe(NewActionHandler::class);
     $events->subscribe(NotificationsHandler::class);
     $events->subscribe(PubSubHandler::class);
 }
 public function getDatatable()
 {
     $query = DB::table('products')->where('products.account_id', '=', Auth::user()->account_id)->where('products.deleted_at', '=', null)->select('products.public_id', 'products.product_key', 'products.notes', 'products.cost');
     return Datatable::query($query)->addColumn('product_key', function ($model) {
         return link_to('products/' . $model->public_id . '/edit', $model->product_key);
     })->addColumn('notes', function ($model) {
         return nl2br(Str::limit($model->notes, 100));
     })->addColumn('cost', function ($model) {
         return Utils::formatMoney($model->cost);
     })->addColumn('dropdown', function ($model) {
         return '<div class="btn-group tr-action" style="visibility:hidden;">
         <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
           ' . trans('texts.select') . ' <span class="caret"></span>
         </button>
         <ul class="dropdown-menu" role="menu">
         <li><a href="' . URL::to('products/' . $model->public_id) . '/edit">' . uctrans('texts.edit_product') . '</a></li>                
         <li class="divider"></li>
         <li><a href="' . URL::to('products/' . $model->public_id) . '/archive">' . uctrans('texts.archive_product') . '</a></li>
       </ul>
     </div>';
     })->orderColumns(['cost', 'product_key', 'cost'])->make();
 }
示例#13
0
 public function getDatatable()
 {
     $query = DB::table('branches')->where('branches.account_id', '=', Auth::user()->account_id)->where('branches.deleted_at', '=', null)->where('branches.public_id', '>', 0)->select('branches.public_id', 'branches.name', 'branches.address1', 'branches.address2');
     return Datatable::query($query)->addColumn('name', function ($model) {
         return link_to('branches/' . $model->public_id . '/edit', $model->name);
     })->addColumn('address1', function ($model) {
         return nl2br(Str::limit($model->address1, 100));
     })->addColumn('address2', function ($model) {
         return nl2br(Str::limit($model->address2, 100));
     })->addColumn('dropdown', function ($model) {
         return '<div class="btn-group tr-action" style="visibility:hidden;">
         <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
           ' . trans('texts.select') . ' <span class="caret"></span>
         </button>
         <ul class="dropdown-menu" role="menu">
         <li><a href="' . URL::to('branches/' . $model->public_id) . '/edit">' . uctrans('texts.edit_branch') . '</a></li>                
         <li class="divider"></li>
         <li><a href="' . URL::to('branches/' . $model->public_id) . '/archive">' . uctrans('texts.archive_branch') . '</a></li>
       </ul>
     </div>';
     })->orderColumns(['name', 'address1'])->make();
 }
示例#14
0
<li onclick="window.location='<?php 
echo $issue->to();
?>
#comment<?php 
echo $comment->id;
?>
';">

	<div class="tag">
		<label class="label notice">Comment</label>
	</div>

	<div class="data">
		<span class="comment">
			"<?php 
echo Str::limit($comment->comment, 60);
?>
"
		</span>
		by
		<strong><?php 
echo $user->firstname . ' ' . $user->lastname;
?>
</strong> on issue <a href="<?php 
echo $issue->to();
?>
"><?php 
echo $issue->title;
?>
</a>
		<span class="time">
示例#15
0
 /**
  * Accessor. Returns a truncated and escaped comment string for use in the administrator package index
  *
  * @param $value
  * @return string
  */
 public function getCommentForAdministratorAttribute($value)
 {
     return \Str::limit(htmlspecialchars($value, null, 'UTF-8'), 50);
 }
示例#16
0
function get_more_locations_text($locations)
{
    $moreHTML = "";
    $more = [];
    $moreHTML = '<ul class="list-unstyled popover-list">';
    foreach ($locations as $location) {
        $image;
        $name;
        $url;
        $locationName;
        if (get_class($location) == 'Activity' && $location->spot) {
            $name = $location->spot->name;
            $url = $location->spot->getURL();
            $image = $location->spot->getThumbnail();
            $locationName = $location->spot->location->getLocationName();
        } else {
            $name = $location->hasSpot() ? $location->spot->name : $location->name;
            $image = $location->hasSpot() ? $location->spot->getThumbnail() : $location->getThumbnail();
            $url = $location->getURL();
            $locationName = $location->getLocationName();
        }
        if ($name) {
            $moreHTML .= '<li class="media">
          <div class="media-left media-middle"><a href="' . $url . '"><img class="img-circle" src="' . $image->url('s30') . '"></a></div>
          <div class="media-body">
            <a href="' . $url . '">' . Str::limit($name, 24) . '</a>
            <div class="location"><small class="text-muted">' . $locationName . '</small></div>
          </div>
        </li>';
        }
    }
    $moreHTML .= '</ul>';
    $moreHTML = urlencode($moreHTML);
    return array('count' => $locations->count(), 'html' => $moreHTML);
}
示例#17
0
 public function postView()
 {
     $rules = array('id' => 'required|exists:leagues,id', 'name' => 'required|max:255|unique:leagues,name,' . Input::get('id'), 'description' => 'max:1000', 'upload-logo' => 'max:2500');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::action('Admin_LeaguesController@getView', array(Input::get('id')))->withInput()->withErrors($validator);
     } else {
         $league = League::find(Input::get('id'));
         $league->name = Input::get('name');
         $league->description = Input::get('description');
         if (Input::hasFile('upload-logo')) {
             $oldlogopath = $this->dir . $league->logo;
             File::delete($oldlogopath);
             $logofile = Input::file('upload-logo');
             $logofileext = $logofile->getClientOriginalExtension();
             $logo_name = "League_" . Str::limit(md5(Input::get('name')), 10, false) . '-' . Str::limit(md5(time()), 10, false) . "_" . Str::slug(Input::get('name')) . "." . $logofileext;
             $league->logo = $logo_name;
             $logofile->move($this->dir, $logo_name);
         }
         $league->save();
         return Redirect::action('Admin_LeaguesController@getIndex');
     }
 }
示例#18
0
#comment<?php 
echo $comment->id;
?>
';">

	<div class="tag">
		<label class="label notice"><?php 
echo __('tinyissue.label_comment');
?>
</label>
	</div>

	<div class="data">
		<span class="comment">
			<?php 
echo str_replace(array("<p>", "</p>"), "", \Sparkdown\Markdown('"' . Str::limit($comment->comment, 60) . '"'));
?>
		</span>
		<?php 
echo __('tinyissue.by');
?>
		<strong><?php 
echo $user->firstname . ' ' . $user->lastname;
?>
</strong> <?php 
echo __('tinyissue.on_issue');
?>
 <a href="<?php 
echo $issue->to();
?>
"><?php 
示例#19
0
</th>
    </tr>

    <?php 
foreach ($list as $log) {
    ?>
        <tr class="log-item log-<?php 
    echo $log->level;
    ?>
">
            <td><?php 
    echo $log->event_date;
    ?>
</td>
            <td><?php 
    echo Str::limit($log->message, 100);
    ?>
</td>
            <td>
                <?php 
    if ($log->user_id) {
        ?>
                    <b><?php 
        echo $log->username;
        ?>
</b>
                <?php 
    } else {
        ?>
                    <i><?php 
        echo varlang('anonim');
              echo '<table class="table table-striped table-bordered table-condensed">
              <thead>
                <tr>
                  <th>ID</th>
                  <th>Title</th>
                  <th>Content Exerpt</th>
                  <th>Created</th>
                  <th>Actions</th>
                </tr>
              </thead><tbody>
              ';
              foreach($news as $article){
                echo '<tr>
                  <td>'.$article->id.'</td>
                  <td>'.$article->title.'</td>
                  <td>'.Str::limit(strip_tags($article->content), 40).'</td>
                  <td>'.$article->created_at.'</td>
                  <td><a class="btn btn-primary" href="'.action('admin.news@edit', array($article->id)).'">Edit</a> <a class="delete_toggler btn btn-danger" rel="'.$article->id.'">Delete</a></td>
                </tr>';
              }
              echo '</tbody></table>';
            }else{
          ?>
            <div class="well">No news articles today. Why not create one using the button below.</div>
          <?
            }
          ?>
          <a href="<?php 
echo action('admin.news@create');
?>
" class="btn btn-primary right">New Article</a>
示例#21
0
 /**
  * Test the Str::limit method.
  *
  * @group laravel
  */
 public function testStringCanBeLimitedByCharacters()
 {
     $this->assertEquals('Tay...', Str::limit('Taylor', 3));
     $this->assertEquals('Taylor', Str::limit('Taylor', 6));
     $this->assertEquals('Tay___', Str::limit('Taylor', 3, '___'));
 }
 public function postPayment()
 {
     $payableId = Input::get('event_id');
     $token = Input::get('token');
     // payment token
     $paymentRepo = $this->paymentRepository->findByToken($token);
     $paymentRepo->method = 'paypal';
     $event = $this->eventRepository->findById($payableId);
     $country = $this->processCountry($event);
     $user = Auth::user();
     $subscription = $this->subscriptionRepository->findByEvent($user->id, $event->id);
     $eventPrice = $event->getPriceByCountryAndType($country->id, $subscription->registration_type)->first();
     $convertedPrice = $this->converter->convert($this->defaultCurrency, $eventPrice->price);
     if ($convertedPrice <= 0) {
         return Redirect::back('/')->with('error', trans('word.system_error'));
     }
     $paymentRepo->amount = $convertedPrice;
     $paymentRepo->currency = $this->defaultCurrency;
     $description = 'Total: ' . $convertedPrice . ' ' . $this->defaultCurrency . '. ';
     $description .= Str::limit(strip_tags($event->description), 50, '..');
     $baseUrl = App::make('url')->action('PaymentsController@getFinal') . '?t=' . $token;
     $item = ['title' => $event->title, 'amount' => $paymentRepo->amount, 'description' => $event->description];
     try {
         // Instantiate Paypal Class
         $payer = $this->paypal;
         // Make Payment
         $payment = $payer->makePayment($paymentRepo->amount, 'USD', $description, "{$baseUrl}&success=true", "{$baseUrl}&success=false", $item);
         $paymentRepo->status = 'CREATED';
         $paymentRepo->transaction_id = $payment->getId();
         $paymentRepo->save();
         // Redirect With Payment Params
         header("Location: " . $this->getLink($payment->getLinks(), 'approval_url'));
         exit;
     } catch (Exception $e) {
         // Set Status To Error
         $paymentRepo->status = 'ERROR';
         $paymentRepo->save();
         return Redirect::back()->with('info', trans('word.system_error'));
     }
 }
示例#23
0
 public static function agregarImagenSlideHome($imagen = null, $epigrafe = null, $coordenadas = null)
 {
     $respuesta = array();
     $datos = array('imagen' => $imagen, 'epigrafe' => $epigrafe);
     $rules = array('imagen' => array('mimes:jpeg,png,gif'));
     $validator = Validator::make($datos, $rules);
     if ($validator->fails()) {
         //return Response::make($validator->errors->first(), 400);
         //Si está todo mal, carga lo que corresponde en el mensaje.
         $respuesta['mensaje'] = $validator;
         $respuesta['error'] = 'no pasa';
     } else {
         $file = $imagen;
         $count = count($file->getClientOriginalName()) - 4;
         $filename = Str::limit(Str::slug($file->getClientOriginalName()), $count, "");
         $extension = $file->getClientOriginalExtension();
         //if you need extension of the file
         //$extension = File::extension($file['name']);
         $carpeta = '/uploads/';
         $directory = public_path() . $carpeta;
         //$filename = sha1(time() . Hash::make($filename) . time()) . ".{$extension}";
         //Pregunto para que no se repita el nombre de la imagen
         if (!is_null(Imagen::imagenPorNombre($filename . ".{$extension}"))) {
             $filename = $filename . "(" . Str::limit(sha1(time()), 3, "") . ")" . ".{$extension}";
         } else {
             $filename = $filename . ".{$extension}";
         }
         //$upload_success = $file->move($directory, $filename);
         if (Image::make($file)->resize(2000, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save($directory . $filename)) {
             $datos = array('nombre' => $filename, 'carpeta' => $carpeta, 'tipo' => 'G', 'ampliada' => '', 'estado' => 'A', 'fecha_carga' => date("Y-m-d H:i:s"), 'usuario_id_carga' => Auth::user()->id);
             $imagen = static::create($datos);
             $datos_lang = array('epigrafe' => $epigrafe, 'estado' => 'A', 'fecha_carga' => date("Y-m-d H:i:s"), 'usuario_id_carga' => Auth::user()->id);
             $idiomas = Idioma::where('estado', 'A')->get();
             foreach ($idiomas as $idioma) {
                 /*
                  if ($idioma->codigo != Config::get('app.locale')) {
                  $datos_lang['url'] = $idioma->codigo . "/" . $datos_lang['url'];
                  }
                 * 
                 */
                 $imagen->idiomas()->attach($idioma->id, $datos_lang);
             }
             //Mensaje correspondiente a la agregacion exitosa
             $respuesta['mensaje'] = 'Imagen creada.';
             $respuesta['error'] = false;
             $respuesta['data'] = $imagen;
             //return Response::json('success', 200);
         } else {
             //Mensaje correspondiente a la agregacion exitosa
             $respuesta['mensaje'] = 'Imagen errónea.';
             $respuesta['error'] = true;
             $respuesta['data'] = null;
             //return Response::json('error', 400);
         }
     }
     return $respuesta;
 }
示例#24
0
 /**
  * Limit the number of characters in a string.
  *
  * @param  string  $value
  * @param  int     $limit
  * @param  string  $end
  * @return string
  */
 function str_limit($value, $limit = 100, $end = '...')
 {
     return Str::limit($value, $limit, $end);
 }
示例#25
0
 /**
  * Replace a table column value (<td>...</td>)
  * @param  \Model $record The populated model used for the column
  * @param  string $columnName The column name to override
  * @param  string $definition List definition (optional)
  * @return string HTML view
  */
 public function listOverrideColumnValue($record, $columnName, $definition = null)
 {
     if ($columnName == 'message') {
         return \Str::limit($record->message, 140);
     }
 }
 public function getExcerptAttribute()
 {
     return Str::limit($this->content, 400);
 }
示例#27
0
 public function draw($class = false)
 {
     if ($class) {
         $class = ' ' . $class;
     }
     //start up
     if (self::$draggable) {
         array_unshift(self::$columns, ['head' => '', 'type' => 'draggy']);
     }
     if (self::$deletable) {
         self::$columns[] = ['head' => '', 'type' => 'delete'];
     }
     if (self::$grouped) {
         $last_group = '';
     }
     $colspan = count(self::$columns);
     $rowspan = count(self::$rows);
     //build <thead>
     $columns = self::$columns;
     foreach ($columns as &$column) {
         if ($column['type'] == 'color') {
             $column['head'] = '&nbsp;';
         }
         $column = '<th class="' . self::column_class($column['type']) . '">' . $column['head'] . '</th>';
     }
     $columns = implode($columns);
     $head = '<thead><tr>' . $columns . '</tr></thead>';
     //build rows
     $bodies = $rows = [];
     foreach (self::$rows as $row) {
         $columns = [];
         $link = true;
         foreach (self::$columns as $column) {
             //handle groupings
             if (self::$grouped && $last_group != $row->{self::$grouped}) {
                 $last_group = $row->{self::$grouped};
                 if (count($rows)) {
                     $bodies[] = '<tbody>' . implode($rows) . '</tbody>';
                 }
                 $bodies[] = '<tr class="group"><td colspan=' . $colspan . '">' . $last_group . '</td></tr>';
                 $rows = [];
             }
             //process value if necessary
             if ($column['type'] == 'draggy') {
                 $value = '<i class="glyphicon glyphicon-align-justify"></i>';
             } elseif ($column['type'] == 'delete') {
                 $value = '<a href="' . $row->delete . '">' . (!$row->deleted_at ? '<i class="glyphicon glyphicon-ok-circle"></i>' : '<i class="glyphicon glyphicon-remove-circle"></i>') . '</a>';
             } elseif ($column['type'] == 'image') {
                 $value = '<a href="' . $row->link . '"><img src="' . $row->{$column['key'] . '_url'} . '" width="' . $column['width'] . '" height="' . $column['height'] . '"></a>';
             } else {
                 $value = Str::limit(strip_tags($row->{$column['key']}));
                 if ($column['type'] == 'updated_at') {
                     $value = Dates::relative($value);
                 } elseif ($column['type'] == 'time') {
                     $value = Dates::time($value);
                 } elseif ($column['type'] == 'date') {
                     $value = Dates::absolute($value);
                 } elseif ($column['type'] == 'date-relative') {
                     $value = Dates::relative($value);
                 } elseif (in_array($column['type'], ['datetime', 'timestamp'])) {
                     $value = Dates::absolute($value);
                 }
                 if (isset($row->link) && $link) {
                     if ($column['type'] == 'color') {
                         $value = '<a href="' . $row->link . '" style="background-color: ' . $value . '"></a>';
                     } else {
                         if ($value == '') {
                             $value = '&hellip;';
                         }
                         $value = '<a href="' . $row->link . '">' . $value . '</a>';
                         $link = false;
                     }
                 }
             }
             //create cell
             $columns[] = '<td class="' . self::column_class($column['type']) . '">' . $value . '</td>';
         }
         //create row
         $rows[] = '<tr' . (empty($row->id) ?: ' id="' . $row->id . '"') . (self::$deletable && $row->deleted_at ? ' class="inactive"' : '') . '>' . implode($columns) . '</tr>';
     }
     $bodies[] = '<tbody>' . implode($rows) . '</tbody>';
     //output
     return '<table id="foobar" class="table table-condensed' . $class . (self::$draggable ? ' draggable" data-draggable-url="' . self::$draggable : '') . '">' . $head . implode($bodies) . '</table>';
 }
示例#28
0
              <thead>
                <tr>
                  <th>ID</th>
                  <th>Page</th>
                  <th>Title</th>
                  <th>Content Exerpt</th>
                  <th>Actions</th>
                </tr>
              </thead><tbody>
              ';
    foreach ($sections as $section) {
        echo '<tr>
                  <td>' . $section->id . '</td>
                  <td>' . ($section->page ? $section->page->title : 'No Page Association') . '</td>
                  <td>' . $section->title . '</td>
                  <td>' . Str::limit(strip_tags($section->content), 40) . '</td>
                  <td><a class="btn btn-primary" href="' . action('admin.sections@edit', array($section->id)) . '">Edit</a> <a class="delete_toggler btn btn-danger" rel="' . $section->id . '">Delete</a></td>
                </tr>';
    }
    echo '</tbody></table>';
} else {
    ?>
            <div class="well">No sections today. Why not create one using the button below.</div>
          <?php 
}
?>
          <a href="<?php 
echo action('admin.sections@create');
?>
" class="btn btn-primary right">New Section</a>
        </div>
示例#29
0
  
     <!-- ************* -->
   <a name="blogescrito"></a>
   <div class="blogescrito" id="blogescrito">
   	  <div class="container">
   	  	<center><h1><img src="/index/images/Blog.png" alt="Eventos"></h1></center><br>
   	   <div class="row text-center">


						@foreach ($blog as $post)

					   	    <div class="col-md-3 service_grid">
					   		  <p><img src="images/blog/{{$post->imagen}} " alt="{{ $post->titulo }}" class="img-thumbnail"></p>
					   		  <h3 class="m_1"><a href="#">{{$post->titulo}}</a></h3>
					   		  <p class="m_2" style="text-align:justify;"><?php 
echo Str::limit(strip_tags($post->contenido), 400);
?>
</p>
							 <!--
					   		  <span class="class1"><p align="right"><br><a href="/blog/{{$post->id}}" target="_self"><span><i class="fa fa-plus-circle"></i> Leer más...</span></a></p></span>
							  -->
					   		</div>

								
						@endforeach



   	  </div>
   	   <div class="row text-center">
示例#30
0
function short_string($string, $length = 25)
{
    return Str::limit(strip_tags($string), $length);
}