/**
  * 添加栏目
  *
  */
 public function actionCreate()
 {
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             $upload = new Uploader();
             $upload->uploadFile($_FILES['attach'], 'image', true);
             if ($upload->_error) {
                 $upload->deleteFile($upload->_file_name);
                 $upload->deleteFile($upload->_thumb_name);
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             $model->attach_file = $upload->_file_name;
             $model->attach_thumb = $upload->_thumb_name;
         }
         $now = time();
         $model->create_time = $now;
         $model->update_time = $now;
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $parentId = intval($_GET['id']);
     $this->render('create', array('model' => $model, 'parentId' => $parentId));
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $inputs = Input::all();
     $catalog = new Catalog();
     $catalog->title = $inputs['title'];
     $catalog->description = $inputs['description'];
     $catalog->user_id = Auth::user()->id;
     $catalog->save();
     $car = new Car();
     $car->brand = $inputs['brand'];
     $car->engine = $inputs['engine'];
     $car->make = $inputs['make'];
     $car->milage = $inputs['milage'];
     $car->type = $inputs['type'];
     $car->transmission = $inputs['transmission'];
     $car->status = $inputs['status'];
     $car->location = $inputs['location'];
     $car->price = $inputs['price'];
     $car->youtube = $inputs['youtube'];
     $car->main_pic = 0;
     $car->user_id = Auth::user()->id;
     $car->catalog_id = $catalog->id;
     $car->save();
     $pictures = $inputs['pictures'];
     Log::info(user_photo_path() . $catalog->id . '/');
     if (!File::isDirectory(user_photo_path() . $catalog->id . '/')) {
         File::makeDirectory(user_photo_path() . $catalog->id . '/', 0777, true, true);
     }
     if (Input::hasFile('pictures[]')) {
         foreach ($pictures as $picture) {
             if ($picture != null) {
                 $image = Image::make($picture->getRealPath());
                 $fileName = str_replace(' ', '_', strrolower($picture->getClientOriginalName()));
                 $image->resize(1024, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . $fileName)->resize(750, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '750-' . $fileName)->resize(500, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '500-' . $fileName)->resize(250, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '250-' . $fileName);
                 $pic = new Pictures();
                 $pic->url = $fileName;
                 $pic->user_id = Auth::user()->id;
                 $pic->catalog_id = $catalog->id;
                 $pic->type = 'catalog';
                 $pic->save();
             }
         }
     }
     return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_created'));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Catalog();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #4
0
 public function run()
 {
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         $now = time();
         $model->create_time = $now;
         $model->update_time = $now;
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     $parentId = intval(Yii::app()->request->getParam('id'));
     $this->controller->render('create', array('model' => $model, 'parentId' => $parentId));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $inputs = Input::all();
     $catalog = new Catalog();
     $catalog->title = $inputs['title'];
     $catalog->description = $inputs['description'];
     $catalog->user_id = Auth::user()->id;
     $catalog->save();
     $project = new Project();
     $project->role = $inputs['role'];
     $project->customer = $inputs['customer'];
     $project->location = $inputs['location'];
     $project->start = $inputs['start-month'] . '-' . $inputs['start-year'];
     $project->end = isset($inputs['not-ended']) && $inputs['not-ended'] ? 'present' : $inputs['end-month'] . '-' . $inputs['end-year'];
     $project->catalog_id = $catalog->id;
     $project->user_id = Auth::user()->id;
     $project->save();
     $pictures = $inputs['pictures'];
     Log::info(user_photo_path() . $catalog->id . '/');
     if (!File::isDirectory(user_photo_path() . $catalog->id . '/')) {
         File::makeDirectory(user_photo_path() . $catalog->id . '/', 0777, true, true);
     }
     if (Input::hasFile('pictures[]')) {
         foreach ($pictures as $picture) {
             if ($picture != null) {
                 $image = Image::make($picture->getRealPath());
                 $fileName = str_replace(' ', '_', $picture->getClientOriginalName());
                 $image->resize(1024, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . $fileName)->resize(750, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '750-' . $fileName)->resize(500, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '500-' . $fileName)->resize(250, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(user_photo_path() . $catalog->id . '/' . '250-' . $fileName);
                 $pic = new Pictures();
                 $pic->url = $fileName;
                 $pic->user_id = Auth::user()->id;
                 $pic->catalog_id = $catalog->id;
                 $pic->type = 'catalog';
                 $pic->save();
             }
         }
     }
     return Redirect::route('admin.catalog.index')->with('success', Lang::get('messages.catalog_created'));
 }
Пример #6
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl('catalog_create');
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         $file = XUpload::upload($_FILES['attach']);
         if (is_array($file)) {
             $model->image = $file['pathname'];
         }
         if ($model->save()) {
             XXcache::refresh('_catalog');
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入类别,ID:' . $model->id . '名称:' . $model->catalog_name));
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #7
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     //        parent::_acl();
     //        ppr($this->_catalogAll,1);
     parent::_acl();
     $model = new Catalog();
     //若有选择父分类的
     $parentId = reqGet('fid');
     if (!empty($parentId)) {
         $model->attributes = array('parent_id' => (int) $parentId);
     }
     $catalogAll = reqPost('Catalog');
     if (!empty($catalogAll)) {
         $catalogAll['create_time'] = $this->_thetime;
         //先判断是外链图片还是本地图片
         $imgtype = reqPost('imgtype', null);
         //ppr($_POST,1);
         if (!empty($imgtype)) {
             if ($imgtype == 'local') {
                 $catalogAll['image_link'] = $this->_doLocalImage('image_link');
             }
             if (empty($catalogAll['image_link'])) {
                 $catalogAll['image_link'] = null;
             }
         }
         $model->attributes = $catalogAll;
         //            ppr($catalogAll,1);
         unset($catalogAll);
         if ($model->save()) {
             XXcache::refresh('_catalog');
             XXcache::refresh('_catalogAll');
             parent::_backendLogger(array('catalog' => 'create', 'intro' => '录入全局分类,父分类ID:' . $model->parent_id . '名称:' . $model->catalog_name));
             $fid = $this->_getParentCatalogId($model->parent_id);
             $this->redirect(array('index', 'fid' => $fid));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #8
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl();
     $model = new Catalog();
     if (isset($_POST['Catalog'])) {
         $model->attributes = $_POST['Catalog'];
         $file = XUpload::upload($_FILES['attach'], array('thumb' => true, 'thumbSize' => array(100, 150)));
         if (is_array($file)) {
             $model->attach_file = $file['pathname'];
             $model->attach_thumb = $file['paththumbname'];
         }
         if ($model->save()) {
             XXcache::refresh('_catalog');
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入全局分类,ID:' . $id . '名称:' . $model->catalog_name));
             $this->redirect(array('index'));
         }
     }
     $parentId = intval($this->_gets->getParam('id'));
     $model->template_list = 'list_text';
     $model->template_page = 'list_page';
     $model->template_show = 'show_post';
     $this->render('create', array('model' => $model, 'parentId' => $parentId));
 }
Пример #9
0
 /**
  * 添加 文件编目
  */
 function actionCatalogAdd()
 {
     $this->_pathway->addStep('添加文件编目信息');
     $id = $this->_context->id;
     if ($id == 1) {
         return "{msg:'不能添加到根'}";
     }
     $form = new Form_Catalog(url('admin::dictmanager/catalogAdd'));
     $form->add(QForm::ELEMENT, 'parent_id', array('_ui' => 'hidden', 'value' => $id));
     if ($this->_context->isPOST() && $form->validate($_POST)) {
         try {
             $catalog = new Catalog($form->values());
             $catalog->save();
             return "{id:'{$catalog->parent_id}', msg:'添加成功'}";
         } catch (QDB_ActiveRecord_ValidateFailedException $ex) {
             $form->invalidate($ex);
         }
     }
     $this->_view['form'] = $form;
     $this->_viewname = 'catalogedit';
 }