Beispiel #1
0
 /**
  * Log the user out
  * 
  * @return Redirect
  */
 public function getLogout()
 {
     Auth::logout();
     Session::flush();
     Message::success(pick_trans('success_logout'));
     return redirect($this->accessUrl . '/login');
 }
 public function make(array $data)
 {
     $otherSetting = $data['others'];
     $categoryType = array_get($otherSetting['setting'], 'category');
     $categoryLayer = config("module.category.layer.{$categoryType}");
     $attributes = $this->attributes($data);
     $categories = Categorize::getCategoryProvider()->root()->whereType($categoryType)->orderBy('sort', 'asc')->get();
     $option = Categorize::tree($categories)->lists('title', 'id');
     $form = '<select' . $attributes . '><option value="0">' . pick_trans('option.pleaseSelect') . '</option>';
     if ($categoryLayer === 2) {
         if (count($option)) {
             foreach ($option as $key => $value) {
                 $category = Categorize::getCategoryProvider()->whereType($categoryType)->whereTitle($value)->first()->getChildren()->toArray();
                 $optgroup = $this->getSelectOptgroup($category['title']);
                 if (isset($category['children']) && count($category['children']) > 0) {
                     $form .= sprintf($optgroup, $this->getSelectOption($data, array_pluck($category['children'], 'title', 'id')));
                 } else {
                     $form .= $optgroup;
                 }
             }
         }
     } else {
         $form .= $this->getSelectOption($data, $option);
     }
     $form .= '</select>';
     return $form;
 }
Beispiel #3
0
    public function make(array $data)
    {
        $otherSetting = $data['others'];
        $name = $data['name'];
        $value = $data['value'];
        $select_image = pick_trans('buttons.select_file');
        $change = pick_trans('buttons.change');
        $remove = pick_trans('buttons.remove');
        $form = <<<EOE
            <div class="fileinput fileinput-new file-pick-open-manager">
                <div data-type="file" class="fileinput-new thumbnail" id="file-{$name}" style="width: 100px; height: 100px;">
EOE;
        $form .= '<input type="hidden" name="' . $name . '" value="' . $value . '">';
        $form .= <<<EOE
                    <img src="http://placehold.it/100&text=FILE">
                </div>
                <div>
                    <span class="btn btn-white btn-file">
                        <span class="fileinput-new">{$select_image}</span>
                        <span class="fileinput-exists">{$change}</span>
                    </span>
                </div>
            </div>
            <a href="#" class="btn btn-orange fileinput-remove" style="display: none; width: 60px" data-target="file-{$name}">{$remove}</a>
EOE;
        set_package_asset_to_view('file-picker-reload');
        return $form;
    }
Beispiel #4
0
    public function make(array $data)
    {
        $otherSetting = $data['others'];
        $name = $data['name'];
        $value = $data['value'];
        $size = array_get($otherSetting['setting'], 'size') ?: '/200x150&text=-';
        $img = $value ? asset('uploads/' . $value) : "http://placehold.it/{$size}";
        $select_image = pick_trans('buttons.select_image');
        $change = pick_trans('buttons.change');
        $remove = pick_trans('buttons.remove');
        $form = <<<EOE
            <div class="fileinput fileinput-new file-pick-open-manager">
                <div data-type="image" class="fileinput-new thumbnail" id="image-{$name}" style="width: 200px; height: 150px;">
EOE;
        $form .= '<input type="hidden" name="' . $name . '" value="' . $value . '">';
        $form .= <<<EOE
                    <img src="{$img}">
                </div>
                <div>
                    <span class="btn btn-white btn-file">
                        <span class="fileinput-new">{$select_image}</span>
                        <span class="fileinput-exists">{$change}</span>
                    </span>
                    <a href="#" class="btn btn-orange fileinput-exists" data-dismiss="fileinput">{$remove}</a>
                </div>
            </div>
EOE;
        set_package_asset_to_view('file-picker-reload');
        return $form;
    }
 protected function getSelectField()
 {
     return '<select name="processors" class="form-control processors-field-select">
               <option value="0" selected="selected">' . pick_trans('option.pleaseSelect') . '</option>
               ' . $this->getOptions() . '
             </select>';
 }
Beispiel #6
0
 public function postOrder(Request $request)
 {
     if (!$request->ajax()) {
         response()->json('error', 400);
     }
     $result = json_decode($request->input('sort_value'), true);
     $sortNum = 0;
     foreach ($result as $keyOne => $valueOne) {
         $categoryOne = Categorize::getCategoryProvider()->findById($valueOne['id']);
         $categoryOne->makeRoot();
         $this->storeSortById($categoryOne, ++$sortNum);
         if (isset($valueOne['children']) && count($valueOne['children'])) {
             foreach ($valueOne['children'] as $keyTwo => $valueTwo) {
                 $categoryTwo = Categorize::getCategoryProvider()->findById($valueTwo['id']);
                 $categoryTwo->makeChildOf($categoryOne);
                 $this->storeSortById($categoryTwo, ++$sortNum);
                 if (isset($valueTwo['children']) && count($valueTwo['children'])) {
                     foreach ($valueTwo['children'] as $keyThree => $valueThree) {
                         $categoryThree = Categorize::getCategoryProvider()->findById($valueThree['id']);
                         $categoryThree->makeChildOf($categoryTwo);
                         $this->storeSortById($categoryThree, ++$sortNum);
                     }
                 }
             }
         }
     }
     return message()->json(200, pick_trans('success_ordered'));
 }
Beispiel #7
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof TokenMismatchException && $request->path() == 'admin/login') {
         Message::warning(pick_trans('login_csrf_token_failed'));
         return redirect($request->fullUrl());
     }
     return parent::render($request, $e);
 }
Beispiel #8
0
 public function make(array $data)
 {
     $form = '<button type="button" class="btn btn-info btn-lg btn-icon album-pick-open-manager">
                 ' . pick_trans('buttons.open') . '
                 <i class="entypo-picture"></i>
             </button>';
     return $form;
 }
 public function make(array $data)
 {
     $content = '<li>
         <a href="' . Session::get('objectUrl') . '/sendmessage/' . $data['item']['id'] . '" class="tooltip-primary" data-toggle="tooltip" data-placement="top" title="' . pick_trans('buttons.sendmessage') . '" data-original-title="' . pick_trans('buttons.sendmessage') . '">
             <i class="fa fa-phone fa-lg"></i>
         </a>
     </li>';
     return $content;
 }
 public function make(array $data)
 {
     $content = '<li>
         <a href="#" class="tooltip-primary common_modal" data-toggle="tooltip" data-placement="top" title="' . pick_trans('buttons.delete') . '" data-original-title="' . pick_trans('buttons.delete') . '" data-type="delete" data-id="' . $data['item']['id'] . '">
             <i class="fa fa-trash-o fa-lg"></i>
         </a>
     </li>';
     return $content;
 }
Beispiel #11
0
 public function make($item, $column, $config)
 {
     $content = '<td align="' . $config['align'] . '" width="' . $config['width'] . '">';
     if ($item->{$column} != '') {
         $content .= '<a href="' . $item[$column] . '" target="_blank">' . pick_trans('linkto') . '</a>';
     } else {
         $content .= '-';
     }
     $content .= '</td>';
     return $content;
 }
Beispiel #12
0
 protected function pagination()
 {
     $content = '<div class="row"><div class="' . $this->data['config']['pagecount-div-class'] . '"><div class="dataTables_info">';
     $content .= Form::open(['method' => 'get', 'role' => 'form', 'id' => 'pagination_count_form']);
     $content .= Form::select('perPage', ['10' => '10', '15' => '15', '20' => '20', '30' => '30', '50' => '50'], $this->data['data']['paginationCount'], ['class' => 'form-control pagination_count', 'id' => 'pagination_count']);
     if ($_SERVER['QUERY_STRING'] != '') {
         $content .= Form::hidden('query_string', $_SERVER['QUERY_STRING']);
     }
     // dd($this->data['items']);
     $content .= '&nbsp;&nbsp;' . pick_trans('pagination_desc', ['from' => $this->data['items']->firstItem(), 'to' => $this->data['items']->lastItem(), 'total' => $this->data['items']->total()]);
     $content .= Form::close();
     $content .= '</div></div><div class="' . $this->data['config']['pagination-div-class'] . '"><div class="dataTables_paginate paging_bootstrap">' . $this->data['items']->render() . '</div></div></div>';
     return $content;
 }
 /**
  * Clean up the field name for the label
  * @param string $name
  */
 protected function prettifyFieldName()
 {
     $name = $this->data['name'];
     $reference = 'form.' . Session::get('onController') . '.' . $name;
     // If doesn't set the config of lang
     if (pick_trans($reference)) {
         return pick_trans($reference);
     }
     if (pick_trans('form.' . $name)) {
         return pick_trans('form.' . $name);
     }
     // convert foo_boo to fooBoo and then convert to Foo Boo
     return ucwords(preg_replace('/(?<=\\w)(?=[A-Z])/', " \$1", camel_case($name)));
 }
Beispiel #14
0
 public function make(array $data)
 {
     $otherSetting = $data['others'];
     $categoryType = array_get($otherSetting['setting'], 'category');
     $attributes = $this->attributes($data);
     $categories = Categorize::getCategoryProvider()->root()->whereType($categoryType)->orderBy('sort', 'asc')->get();
     $option = array('0' => pick_trans('option.pleaseSelect')) + Categorize::tree($categories)->lists('title', 'id')->toArray();
     $form = '<select' . $attributes . '>';
     if (count($option)) {
         foreach ($option as $key => $value) {
             $selected = $key == $data['value'] ? ' selected' : null;
             $form .= '<option value="' . e($key) . '"' . $selected . '>' . e($value) . '</option>';
         }
     }
     $form .= '</select>';
     return $form;
 }
 public function make(array $data)
 {
     $data['class'] = array_get($data, 'others.setting.args.class') ?: 'select2';
     $otherSetting = $data['others'];
     $attributes = $this->attributes($data);
     $form = '<select' . $attributes . 'data-allow-clear="true" data-placeholder="' . pick_trans('option.pleaseSelect') . '">';
     $form .= '<option></option>';
     if (count($otherSetting['option'])) {
         foreach ($otherSetting['option'] as $key => $value) {
             $selected = $key == $data['value'] ? ' selected' : null;
             $form .= '<option value="' . e($key) . '"' . $selected . '>' . e($value) . '</option>';
         }
     }
     $form .= '</select>';
     // To add the asset of package to View
     set_package_asset_to_view('multi-select2');
     return $form;
 }
 /**
  * Output some message and status the format is json
  * @param  string $status  success, error, warning
  * @param  string $message This is message wants to output
  * @param  mixed  $date
  * @return Response
  */
 public function json($status, $message = null, $data = null)
 {
     switch ($status) {
         case 200:
             $content = ['title' => pick_trans('success'), 'message' => $message ?: 'OK', 'data' => $data];
             break;
         case 201:
             $content = ['title' => pick_trans('success'), 'message' => $message ?: 'Created', 'data' => $data];
             break;
         case 400:
             $content = ['error' => ['title' => pick_trans('fail'), 'message' => $message ?: 'Bad Request', 'data' => $data]];
             break;
         case 404:
             $content = ['error' => ['title' => pick_trans('fail'), 'message' => $message ?: 'Not found', 'data' => $data]];
             break;
         default:
             throw new \InvalidArgumentException("The status code {$status} that you pass doesn't match.");
             break;
     }
     return Response::json($content, $status);
 }
 public function postStore(Request $request)
 {
     if (!$request->ajax()) {
         response()->json('error', 400);
     }
     $data['item'] = $request->input('item');
     $data['value'] = $request->input('value');
     if ($request->input('type') == 'checkbox' && $data['value'] != '') {
         $array = explode('&', $data['value']);
         foreach ($array as $value) {
             $val = explode('=', $value);
             $ary[] = $val[1];
         }
         $data['value'] = implode(',', $ary);
     }
     try {
         $this->repo->edit($data['item'], ['value' => $data['value']], 'key');
     } catch (\Sharenjoy\Cmsharenjoy\Exception\EntityNotFoundException $e) {
         return Message::json(400, pick_trans('fail_updated'), $data);
     }
     return Message::json(200, pick_trans('success_updated'), $data);
 }
Beispiel #18
0
 public function make(array $data)
 {
     $data['class'] = array_get($data, 'others.setting.args.class') ?: 'select2';
     $data['data-allow-clear'] = "true";
     $data['data-placeholder'] = pick_trans('option.pleaseSelect');
     $attributes = $this->attributes($data);
     $options = Department::with('employees')->orderBy('sort')->get()->toArray();
     $form = '<select ' . $attributes . '><option></option>';
     if (count($options)) {
         foreach ($options as $department) {
             $form .= '<optgroup label=' . e($department['name']) . '>';
             foreach ($department['employees'] as $employee) {
                 $selected = $employee['id'] == $data['value'] ? ' selected' : null;
                 $form .= '<option value="' . e($employee['id']) . '"' . $selected . '>' . e($employee['name']) . ' ' . e($employee['name_en']) . '</option>';
             }
             $form .= '</optgroup>';
         }
     }
     $form .= '</select>';
     // To add the asset of package to View
     set_package_asset_to_view('multi-select2');
     return $form;
 }
 public function login($input)
 {
     $credentials = array('email' => $input['email'], 'password' => $input['password']);
     if (Auth::guard('admin')->attempt($credentials)) {
         if (Auth::guard('admin')->user()->activated == false) {
             Auth::guard('admin')->logout();
             return ['status' => false, 'message' => pick_trans('invalid_email_password')];
         }
         return ['status' => true, 'message' => pick_trans('success_login')];
     } else {
         return ['status' => false, 'message' => pick_trans('invalid_email_password')];
     }
 }
 /**
  * Set the order of the list
  * @return Response
  */
 public function postOrder(Request $request)
 {
     // This should only be accessible via AJAX you know...
     if (!$request->ajax()) {
         response()->json('error', 400);
     }
     $id_value = $request->input('id_value');
     $sort_value = $request->input('sort_value');
     foreach ($id_value as $key => $id) {
         if ($id) {
             try {
                 $sort = $sort_value[$key];
                 $this->repo->edit($id, array('sort' => $sort));
             } catch (\Sharenjoy\Cmsharenjoy\Exception\EntityNotFoundException $e) {
                 error(pick_trans('exception.not_found', ['id' => $id]));
                 return redirect($this->objectUrl);
             }
         }
     }
     $message = pick_trans('success_ordered');
     $data = ['success' => pick_trans('success')];
     return message()->json(200, $message, $data);
 }
 protected function getFormText($type)
 {
     // Set the lang of placeholder from config
     $targetA = 'form.' . Session::get('onController') . '.' . $type . '.' . $this->name;
     $targetB = 'form.' . $type . '.' . Session::get('onController') . '.' . $this->name;
     $targetC = 'form.' . $type . '.' . $this->name;
     if (isset($this->setting[$type]) && !is_null($this->setting[$type])) {
         return $this->setting[$type];
     }
     if (pick_trans($targetA)) {
         return pick_trans($targetA);
     }
     if (pick_trans($targetB)) {
         return pick_trans($targetB);
     }
     if (pick_trans($targetC)) {
         return pick_trans($targetC);
     }
     return;
 }
 /**
  * Set the order of files and folders
  */
 public function postOrder(Request $request)
 {
     if (!$request->ajax()) {
         Response::json('error', 400);
     }
     $id_value = $request->input('id_value');
     $sort_value = $request->input('sort_value');
     foreach ($id_value as $key => $id) {
         if ($id) {
             $sort = $sort_value[$key];
             $file = File::find($id);
             $file->update(array('sort' => $sort));
         }
     }
     // let the files library format the return array like all the others
     return Message::json(200, pick_trans('success_ordered'));
 }
Beispiel #23
0
 /**
  * To translate the option
  */
 function trans_options($name)
 {
     $options = config($name);
     if (!$options) {
         return false;
     }
     $fun = function ($value) {
         if (!pick_trans($value)) {
             return $value;
         }
         return pick_trans($value);
     };
     return array_map($fun, $options);
 }
 /**
  * Delete the model passed in
  * @param  int This is the id that needs to delete
  * @return boolean
  */
 public function delete($id)
 {
     try {
         $model = $this->model->findOrFail($id);
         $result = $model->delete();
     } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
         Message::error(pick_trans('exception.not_found', ['id' => $id]));
         return false;
     }
     return $result;
 }
Beispiel #25
0
    public function make(array $data)
    {
        // dd($data);
        if (!isset($data['others']['setting']['columns'])) {
            throw new \InvalidArgumentException("There is no 'columns' argument.");
        }
        $fields = '';
        if (count($data['value'])) {
            foreach ($data['value'] as $key => $value) {
                $fields .= '<div class="toclone"><div class="row">';
                foreach ($data['others']['setting']['columns'] as $columnName => $columnItem) {
                    $columnItem['name'] = $data['name'] . '[' . $columnName . ']';
                    $columnItem['value'] = $value[$columnName];
                    $columnItem['label-class'] = 'col-md-12';
                    $columnItem['inner-div-class'] = 'col-md-12';
                    $columnItem['duplicate-inner-div-class'] = isset($columnItem['duplicate-inner-div-class']) ? $columnItem['duplicate-inner-div-class'] : 'col-md-12';
                    $fields .= '<div class="' . $columnItem['duplicate-inner-div-class'] . '">' . Formaker::$columnName($columnItem) . '</div>';
                }
                $fields .= '</div>';
                $fields .= '<div class="row"><div class="col-md-12">';
                $fields .= '<div class="main-clone-button pull-left">';
                $fields .= Form::button(pick_trans('buttons.clone'), ['class' => 'btn btn-xs btn-blue clone']);
                $fields .= '</div>';
                $fields .= '<div class="main-clone-button pull-left">';
                $fields .= Form::button(pick_trans('buttons.delete'), ['class' => 'btn btn-xs btn-danger delete']);
                $fields .= '</div>';
                $fields .= '</div></div><div class="clearfix visible-xs-block"></div><hr></div>';
            }
        } else {
            $fields .= '<div class="toclone"><div class="row">';
            foreach ($data['others']['setting']['columns'] as $columnName => $columnItem) {
                $columnItem['name'] = $data['name'] . '[' . $columnName . ']';
                $columnItem['label-class'] = 'col-md-12';
                $columnItem['inner-div-class'] = 'col-md-12';
                $columnItem['duplicate-inner-div-class'] = isset($columnItem['duplicate-inner-div-class']) ? $columnItem['duplicate-inner-div-class'] : 'col-md-12';
                $fields .= '<div class="' . $columnItem['duplicate-inner-div-class'] . '">' . Formaker::$columnName($columnItem) . '</div>';
            }
            $fields .= '</div>';
            $fields .= '<div class="row"><div class="col-md-12">';
            $fields .= '<div class="main-clone-button pull-left">';
            $fields .= Form::button(pick_trans('buttons.clone'), ['class' => 'btn btn-xs btn-blue clone']);
            $fields .= '</div>';
            $fields .= '<div class="main-clone-button pull-left">';
            $fields .= Form::button(pick_trans('buttons.delete'), ['class' => 'btn btn-xs btn-danger delete']);
            $fields .= '</div>';
            $fields .= '</div></div><div class="clearfix visible-xs-block"></div><hr></div>';
        }
        // $data['class'] = array_get($data, 'others.setting.args.class') ?:
        //                  'form-control tagsinput';
        // $attributes = $this->attributes($data);
        $form = $fields;
        Formaker::dummy(['label-class' => isset($data['others']['setting']['label-class']) ? $data['others']['setting']['label-class'] : $data['others']['config']['label-class'], 'inner-div-class' => isset($data['others']['setting']['inner-div-class']) ? $data['others']['setting']['inner-div-class'] : $data['others']['config']['inner-div-class']]);
        // To add the asset of package to View
        set_package_asset_to_view('cloneya');
        set_package_asset_to_view('jquery-confirm');
        set_package_asset_to_view('ladda-bootstrap');
        Theme::asset()->writeScript('duplicateform-script', '
            $(function() {

                $("#clone-section")
                  .cloneya()
                  .on("clone_before_clone", function(event, toclone) {
                      // do something
                  })
                  .on("clone_after_clone", function(event, toclone, newclone) {
                      // do something   
                  })
                  .on("clone_before_append", function(event, toclone, newclone) {
                      $(newclone).css("display", "none");
                      $(toclone).fadeOut("fast", function() {
                          $(this).fadeIn("fast");
                      });
                  })
                  .on("clone_after_append", function(event, toclone, newclone) {
                      $(newclone).slideToggle();
                  })
                  // we remove the original binding, the call to remove is also gone
                  .off("clone_before_delete")
                  // we add our own, so make sure to remove the element
                  .on("clone_before_delete", function(event, clone) {
                      $.confirm({
                          // title: "{{pick_trans("warning")}}!!!",
                          text: "確定要刪除嗎?",
                          confirm: function() {

                            $(clone).slideToggle("slow", function() {
                              $(this).remove();
                            });

                            toastr.success(result.message, "成功", opts);

                          },
                          cancel: function() {
                              // nothing to do
                          },
                          confirmButton: "是",
                          cancelButton: "否",
                          confirmButtonClass: "btn-danger",
                          cancelButtonClass: "btn-default"
                      });
                  })
                  .on("clone_after_delete", function(event) {
                      // do something;
                  });

            });
        ');
        return $form;
    }
 /**
  * Test if form validator passes
  * @param  array The input needs to valid
  * @param  array The type of message, it can be 'messageBeg'
  * @return boolean|Message
  */
 public function valid(array $input, $errorType)
 {
     $result = $this->with($input)->passes();
     if (!$result) {
         switch ($errorType) {
             case 'flash':
                 $this->getErrorsToFlashMessageBag();
                 break;
             case 'json':
                 return Message::json(400, pick_trans('check_some_wrong'), $this->errors()->toArray());
                 break;
             default:
                 Session::flash('sharenjoy.validation.errors', $this->errors());
                 Message::error(pick_trans('check_some_wrong'));
                 break;
         }
     }
     return $result;
 }