Пример #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Pages();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Pages'])) {
         $model->attributes = $_POST['Pages'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->Objid));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #2
0
 public function postCreate()
 {
     $page = new Pages();
     $page->name = Input::get('name');
     $page->title = Input::get('title');
     $page->content = Input::get('content');
     $page->status = Input::get('status');
     $page->url = Input::get('url');
     $page->id_parent = 0;
     $page->order = count(Pages::all());
     $page->save();
     return Redirect::to($this->route)->with('msg_success', Lang::get('messages.companies_create', array('title' => $page->title)));
 }
Пример #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Pages();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Pages'])) {
         $model->attributes = $_POST['Pages'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
             $this->redirect(array('update', 'id' => $model->id));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка!'));
         }
     }
     $this->render('create', array('model' => $model));
 }
	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new Pages;
		if(isset($_POST['Pages']))
		{
			$model->attributes=$_POST['Pages'];
            if($model->save()) {
                Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
                $this->redirect(array('update','id'=>$model->id));
            } else {
                Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка сохранения данных!'));
            }
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
Пример #5
0
/**
 * page_add 
 * 
 * @access public
 * @return string
 */
function page_add()
{
    $data = array();
    $page = new Pages();
    if (is_post()) {
        $page->fromArray($_POST);
        if ($page->isValid()) {
            $page->save();
            return redirect('/page/list');
        } else {
            $errors = array();
            $errors['page'] = get_errors($page);
            print_r($errors['page']);
        }
    }
    $data['page'] = $page;
    return render('page_form.tpl', $data);
}
Пример #6
0
 public function actionCreate()
 {
     $role_id = Users::model()->findByPk(Yii::app()->user->id)->role_id;
     if ($role_id != 7) {
         $this->pageTitle = 'Создание раздела';
         $model = new Pages();
         if (isset($_POST['Pages'])) {
             $model->attributes = $_POST['Pages'];
             if ($model->save()) {
                 $this->redirect(YII::app()->baseUrl . '/admin.php?r=pages/update&id=' . $model->id);
             } else {
                 $this->render('create', array('model' => $model));
             }
         } else {
             $this->render('create', array('model' => $model));
         }
     } else {
         $this->redirect(Yii::app()->baseUrl . '/admin.php?r=pages/access');
     }
 }
    } else {
        $section = Sections::where('name_of_section', '=', Input::get('page_section'))->first();
        $xmlFileName = $section->section_url . '\\' . Input::get('page_shortname') . '.xml';
        $page = new Pages();
        $page->page_description = Input::get('page_description');
        $page->page_name = Input::get('page_name');
        $page->type_of_page = Input::get('type_of_page');
        $page->page_title = Input::get('page_title');
        $page->page_subtitle = Input::get('page_subtitle') . ": " . Input::get('page_description');
        $page->page_section = Input::get('page_section');
        $page->page_link_value = $section->shortname . "/" . Input::get('page_shortname');
        $page->color_code = Input::get('color_code');
        $page->page_shortname = Input::get('page_shortname');
        $page->page_url = $xmlFileName;
        //
        $page->save();
    }
    return Redirect::to('/add')->withMessage('Page created successfully');
});
Route::post('addPageDetails', function () {
    if (Input::hasFile('image')) {
        $image = Input::file('image');
        $name = $image->getClientOriginalName();
    }
    $oldPage = Pages::where('id', '=', Input::get('id'))->first();
    if (File::exists($oldPage->page_url)) {
        File::delete($oldPage->page_url);
    }
    $rule = array('page_description' => 'required', 'page_name' => 'required', 'page_title' => 'required', 'page_subtitle' => 'required', 'type_of_page' => 'required', 'page_section' => 'required', 'page_shortname' => 'required');
    $validator = Validator::make(Input::all(), $rule);
    if ($validator->fails()) {
Пример #8
0
 public function savepage()
 {
     if (Input::get('pageid')) {
         $page = Pages::find(Input::get('pageid'));
     } else {
         $page = new Pages();
     }
     $page->slug = Input::get('page_slug');
     $page->title = Input::get('title');
     $page->subtitle = Input::get('subtitle');
     $page->content = Input::get('content');
     $page->status = Input::get('status');
     $page->save();
     if (Input::get('saveclose')) {
         return Redirect::to('backend/pages/')->withMessage($this->notifyView(Lang::get('laracms::messages.page_saved')));
     } else {
         return Redirect::to('backend/editpage/' . $page->id)->withMessage($this->notifyView(Lang::get('laracms::messages.page_saved')));
     }
 }
Пример #9
0
 public function actionUpload()
 {
     //$path = Yii::app()->baseUrl."/uploads";
     $model = new XUploadForm();
     if (!isset($this->path)) {
         $this->path = realpath(Yii::app()->basePath . "/../uploads");
     }
     if (!is_dir($this->path)) {
         throw new CHttpException(500, "{$this->path} does not exists.");
     } else {
         if (!is_writable($this->path)) {
             throw new CHttpException(500, "{$this->path} is not writable.");
         }
     }
     if ($model->validate()) {
         $model->file = CUploadedFile::getInstance($model, 'file');
         $model->mime_type = $model->file->getType();
         $model->size = $model->file->getSize();
         $model->name = $model->file->getName();
         $path = $this->path . "/" . Yii::app()->session['userId'];
         $model->file->saveAs($path . $model->name);
         $pageImage = new Pages();
         $pageImage->user_id = Yii::app()->user->userId;
         $pageImage->image = $model->name;
         $pageImage->save();
         Yii::app()->session['pageId'] = $pageImage->id;
         Yii::app()->session['imageName'] = $model->name;
         echo json_encode(array("name" => $model->name, "type" => $model->mime_type, "size" => $model->getReadableFileSize()));
         /*            $user_id = Yii::app()->session['userId'];
                     if ($model->file->getType() != 'image/jpeg' && $model->file->getType() !='image/png' && $model->file->getType() !='image/bmp' && $model->file->getType() != 'image/jpg')
                     {
                         echo "Invalid File Type, only jpg allowed";
                     }
                     else
                     {
                         $profile = UserProfile::model()->find('user_id=:id', array('id' => Yii::app()->session['userId']));
                         $old_pic = $profile['photo'];
                         if ((strpos($old_pic, "h")) === 0)
                         {
                             $profile->photo = Yii::app()->session['userId'] . '_' . $model->name;
                             $profile->save();
                             $model->file->saveAs($path . '_' . $model->name);
                             //Yii::app()->user->setFlash('success', "Upload Picture Successfully");
                         }
                         elseif ((strpos($old_pic, $profile['user_id'])) === 0)
                         {
                             unlink(realpath(Yii::app()->getBasePath() . "/../images/uploads") . "/" . urldecode($old_pic));
                             $profile->photo = Yii::app()->session['userId'] . '_' . $model->name;
                             $profile->save();
                             $model->file->saveAs($path . '_' . $model->name);
                             //Yii::app()->user->setFlash('success', "Upload Picture Successfully");
                         }
                         else
                         {
                             //unlink(realpath(Yii::app()->getBasePath()."/../images/uploads")."/".urldecode($old_pic));
                             //$profile->photo = Yii::app()->session['userId'] . '_' . $model->name;
                             //$profile->save();
                             //$model->file->saveAs($path . '_' . $model->name);
                             //Yii::app()->user->setFlash('success', "Upload Picture Successfully");
                         }
                         echo json_encode(array("name" => $model->name,"type" => $model->mime_type,"size"=> $model->getReadableFileSize()));
                         //echo "hogya hai ";
                         //$this->redirect(Yii::app()->baseUrl.'/index.php/user/userprofile/'.$user_id);
                         //echo '<script type="text/javascript">window.top.href = "' . Yii::app()->baseUrl . '/index.php/user/userprofile/' . $user_id . '"; </script>';
                     }
                 }
                 else
                 {
                     /*echo CVarDumper::dumpAsString($model->getErrors());
                       Yii::log("XUploadAction: ".CVarDumper::dumpAsString($model->getErrors()), CLogger::LEVEL_ERROR, "application.extensions.xupload.actions.XUploadAction");
                       throw new CHttpException(500, "Could not upload file"); */
         //echo $this->redirect(Yii::app()->baseUrl);
         //echo "<script type='text/javascript'>alert('chage');</script>";
     }
     /*  $model=new Image;
         if(isset($_POST['Image']))
         {
             $model->attributes=$_POST['Image'];
             $model->image=CUploadedFile::getInstance($model,'image');
             
             $fileTempName=$model->thumbnail->tempName;
             $fileName=$model->thumbnail->name;
             
             if($model->save())
             {
                 $userId=Yii::app()->session['userId'];
                 $upload_dir=realpath(getcwd()).'/images/uploads/';                 
                 move_uploaded_file($fileTempName, "$upload_dir/$userId".'_'."$fileName");
                 // $model->image->saveAs('path/to/localFile');
                 // redirect to success page
                 return;
             }
             return;
         }*/
     //$this->render('create', array('model'=>$model));
 }
Пример #10
0
 public function actionCreate()
 {
     $this->breadcrumbs = array_merge($this->breadcrumbs, array('Создание страницы'));
     $this->pageTitle = Yii::t('app', 'Создание страницы');
     $model = new Pages();
     $modelLang = new PagesLang();
     if (Yii::app()->request->getPost('Pages')) {
         $model->attributes = Yii::app()->request->getPost('Pages');
         $modelLang->attributes = Yii::app()->request->getPost('PagesLang');
         $transaction = Yii::app()->db->beginTransaction();
         try {
             $model->validate();
             if (!$model->save()) {
                 throw new Exception('Ошибка при сохранении данных.');
             }
             $modelLang->page_id = $model->id;
             $modelLang->lang = Yii::app()->sourceLanguage;
             $modelLang->langs = "|" . Yii::app()->sourceLanguage . "|";
             if (!$modelLang->save()) {
                 throw new Exception('Ошибка при сохранении данных.');
             }
             $transaction->commit();
             Yii::app()->user->setFlash('success', Yii::t('app', 'Страница успешно создана'));
             Yii::app()->request->redirect($this->createUrl('index'));
         } catch (Exception $e) {
             $transaction->rollBack();
             $error = $e->getMessage();
         }
     }
     $this->render('create', array('model' => $model, 'modelLang' => $modelLang));
 }
Пример #11
0
 public function add_page()
 {
     try {
         $_arData = array();
         $destinationPath_TextImage = 'asserts/images/FeatureText';
         $destinationPath_BannerImage = 'asserts/images/SecondPage';
         $destinationPath_Button = 'asserts/images/Features';
         $total_files = '';
         $detailType = Input::get("detailType");
         if (empty($detailType)) {
             $detailType = '';
         }
         /* ==============================
               == File Upload
            ============================== */
         $_countFiles = count(Input::file("fileTextImage"));
         $_number = 1;
         if (Input::hasfile('fileTextImage')) {
             foreach (Input::file("fileTextImage") as $file) {
                 $filename = $file->getClientOriginalName();
                 if ($_number == $_countFiles) {
                     $total_files .= $filename;
                 } else {
                     $total_files .= $filename . ';';
                 }
                 $upload_success = $file->move($destinationPath_TextImage, $filename);
                 $_number++;
             }
         }
         if (empty($total_files)) {
             $total_files = '';
         }
         /* ==============================
            == Variables
            ============================== */
         $detailId = $this->get_pageid();
         $detailKeyTitle = Input::get("detailKeyTitle");
         if (empty($detailKeyTitle)) {
             $detailKeyTitle = '';
         }
         $detailKeyword = Input::get("detailKeyword");
         if (empty($detailKeyword)) {
             $detailKeyword;
         }
         $detailDescription = Input::get("detailDescription");
         if (empty($detailDescription)) {
             $detailDescription = '';
         }
         $detailUrl = Input::get("detailUrl");
         if (empty($detailUrl)) {
             $detailUrl = '';
         }
         $detailName = Input::get("detailName");
         if (empty($detailName)) {
             $detailName = '';
         }
         $detailTitle = Input::get("detailTitle");
         if (empty($detailTitle)) {
             $detailTitle = '';
         }
         $detailVisible = Input::get("detailVisible");
         if ($detailVisible == '1') {
             $detailVisible = '1';
         } else {
             $detailVisible = '0';
         }
         if (empty($detailVisible)) {
             $detailVisible = '0';
         }
         $isMenu = Input::get("isMenu");
         if ($isMenu == '1') {
             $isMenu = '1';
         } else {
             $isMenu = '0';
         }
         if (empty($isMenu)) {
             $isMenu = '0';
         }
         $detailParent = Input::get("detailParent");
         if (empty($detailParent)) {
             $detailParent = '';
         }
         if ($detailType == '1') {
             $detailContent = Input::get("detailContent_1");
         } else {
             $detailContent = Input::get("detailContent_2");
         }
         if (empty($detailContent)) {
             $detailContent = '';
         }
         $buttonName = Input::get("buttonName");
         if (empty($buttonName)) {
             $buttonName = '';
         }
         $filename_Button = '';
         if (Input::hasfile('filebuttonPicture')) {
             $file_Button = Input::file("filebuttonPicture");
             $filename_Button = $file_Button->getClientOriginalName();
             $upload_success_button = $file_Button->move($destinationPath_Button, $filename_Button);
         }
         if (empty($filename_Button)) {
             $filename_Button = '';
         }
         $typeOrder = Input::get("typeOrder");
         if (!empty($typeOrder)) {
             $typeOrder = '';
         }
         if ($detailId == '' || $detailKeyword == '' || $detailDescription == '' || $detailKeyTitle == '' || $detailName == '' || $detailTitle == '' || $detailName == '' || $detailTitle == '' || $detailUrl == '' || $detailContent == '' || $total_files == '' || $detailVisible == '' || $buttonName == '' || ($filename_Button = '')) {
             Session::flash('error', '$$$ --- Please input all of informations in the blanks  --- $$$');
             return Redirect::to('qlm-admin/add-new-page');
         } else {
             $_page = new Pages();
             $_page->detailId = $detailId;
             $_page->detailType = $detailType;
             $_page->detailKeyword = $detailKeyword;
             $_page->detailDescription = $detailDescription;
             $_page->detailKeyTitle = $detailKeyTitle;
             $_page->detailName = $detailName;
             $_page->detailTitle = $detailTitle;
             $_page->detailUrl = $detailUrl;
             $_page->detailParent = $detailParent;
             $_page->detailContent = $detailContent;
             $_page->detailTextImage = $total_files;
             $_page->detailVisible = $detailVisible;
             $_userData = Session::get('login');
             $_page->detailCreater = $_userData["username"];
             $_page->detailCreatedDate = date("Y-m-d H:i:s");
             if ($detailType == 1) {
                 $filename_Banner = null;
                 if (Input::hasfile('input-banner-id')) {
                     $file_Banner = Input::file("input-banner-id");
                     $filename_Banner = $file_Banner->getClientOriginalName();
                     $upload_success_banner = $file_Banner->move($destinationPath_BannerImage, $filename_Banner);
                 }
                 $detailBannerTitle = Input::get("detailBannerTitle");
                 if (empty($detailBannerTitle)) {
                     $detailBannerTitle = '';
                 }
                 $detailBannerDescription = Input::get("detailBannerDescription");
                 if (empty($detailBannerDescription)) {
                     $detailBannerDescription = '';
                 }
                 if (empty($filename_Banner)) {
                     $filename_Banner = '';
                 }
                 $_page->detailBannerImage = $filename_Banner;
                 if ($detailBannerTitle == '' || $detailBannerDescription == '' || $filename_Banner == '') {
                     Session::flash('error', '$$$ --- Please input all of informations in the blanks  --- $$$');
                     return Redirect::to('qlm-admin/add-new-page');
                 }
             }
             $_page->buttonName = $buttonName;
             $_page->buttonPicture = $filename_Button;
             $_page->typeOrder = $typeOrder;
             $_page->isMenu = $isMenu;
             $_page->detailTemplate = 'TQLM001';
             $_page->save();
         }
     } catch (Exception $_ex) {
         Session::flash('error', '$$$ --- Error (' . $_ex->getMessage() . ') --- $$$');
     }
     Session::flash('success', '$$$ --- Add Page Successfully  --- $$$');
     return Redirect::to('qlm-admin/add-new-page/' . $detailUrl);
 }