PDA

View Full Version : مشکل در اجرای اکشن ادمین



Emir New
یک شنبه 26 بهمن 1393, 17:53 عصر
سلام
من یه کار رو روی سایت اپلود کردم همه چیز داره درست کار می کنه
منتها به اکشن admin که میرسه نمی دونم چرا محتوای layout رو زمینه نمی کنه ؟
من کنترلر رو میزارم اینجا


<?php

class CategoriesController extends Controller
{
/**
* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='/layouts/column2';

private $_assetsBase;
private $forceCopyAssets;
public $isActive = 1 ;
public function getAssetsBase()
{
if ($this->_assetsBase === null) {
$this->_assetsBase = Yii::app()->getAssetManager()->publish(
Yii::getPathOfAlias('application.assets'),
false,
-1,
defined('YII_DEBUG') && YII_DEBUG
);
}
return $this->_assetsBase;
}

protected function registerCoreCss()
{
$css_arr = array('bootstrap.rtl.css','style.css','bootstrap-select.css');
foreach($css_arr as $filename)
Yii::app()->clientScript->registerCssFile($this->getAssetsBase().'/css/'.$filename);
}

protected function registerScript(){
$js_arr = array('bootstrap.rtl.js','bootstrap-select.js'); //put what js file name that you need to import from admin assets folder
foreach($js_arr as $filename){
Yii::app()->getClientScript()->registerScriptFile($this->getAssetsBase().'/js/'.$filename);
}
Yii::app()->clientScript->registerCoreScript('jquery');
}

public function init()
{
if(Yii::app()->user->checkAccess("PublicUser"))
$this->redirect( Yii::app()->user->returnUrl) ;
$this->registerCoreCss();
$this->registerScript();
}
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
);
}

/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update','MultiDel','Archive','Publ ish','UnPublish','CPublish'),
'users'=>array('@'),
),
array('allow', // allow admin user to perform 'admin' and 'delete' actions
'actions'=>array('admin','delete'),
'users'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}

public function actionMultiDel()
{
if(isset($_POST['checked_value']))
{
$criteria = new CDbCriteria();
$data = $_POST['checked_value'] ;
$array = explode(',', $data);
foreach ($array as $key=>$value)
{
$criteria->addCondition("id=".$value);
$query = Categories::model()->find($criteria);
if($query->parent_id == 1)
{
$criteria = new CDbCriteria();
$criteria->addCondition("parent_id=".$query->id);
$parent = Categories::model()->findAll($criteria);
$count = count($parent) ;
for($i=0;$i<$count;$i++)
{
Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'4',
),
'id=:id',
array(':id'=>$parent[$i]['id'])
);
}
}

Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'4',
),
'id=:id',
array(':id'=>$value)
);
}
}
}

public function actionArchive()
{

if(isset($_POST['checked_value']))
{
$criteria = new CDbCriteria();
$data = $_POST['checked_value'] ;
$array = explode(',', $data);
foreach ($array as $key=>$value)
{
$criteria->addCondition("id=".$value);
$query = Categories::model()->find($criteria);
if($query->parent_id == 1)
{
$criteria = new CDbCriteria();
$criteria->addCondition("parent_id=".$query->id);
$parent = Categories::model()->findAll($criteria);
$count = count($parent) ;
for($i=0;$i<$count;$i++)
{
Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'3',
),
'id=:id',
array(':id'=>$parent[$i]['id'])
);
}
}

Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'3',
),
'id=:id',
array(':id'=>$value)
);
}
}
}

public function actionCPublish()
{
if(isset($_POST['id']) & isset($_POST['publish']))
{
$publish = $_POST['publish'] ;
$id = $_POST['id'];
if(is_numeric($publish) & is_numeric($id))
{
Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>$publish,
),
'id=:id',
array(':id'=>$id)
);

echo 'حالت انتشار با موفقیت ذخیره شد';
}
}
}

public function actionPublish()
{
if(isset($_POST['checked_value']))
{
$criteria = new CDbCriteria();
$data = $_POST['checked_value'] ;
$array = explode(',', $data);
foreach ($array as $key=>$value)
{
$criteria->addCondition("id=".$value);
$query = Categories::model()->find($criteria);
if($query->parent_id == 1)
{
$criteria = new CDbCriteria();
$criteria->addCondition("parent_id=".$query->id);
$parent = Categories::model()->findAll($criteria);
$count = count($parent) ;
for($i=0;$i<$count;$i++)
{
Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'1',
),
'id=:id',
array(':id'=>$parent[$i]['id'])
);
}
}

Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'1',
),
'id=:id',
array(':id'=>$value)
);
}
}
}


public function actionUnPublish()
{
if(isset($_POST['checked_value']))
{
$criteria = new CDbCriteria();
$data = $_POST['checked_value'] ;
$array = explode(',', $data);
foreach ($array as $key=>$value)
{
$criteria->addCondition("id=".$value);
$query = Categories::model()->find($criteria);
if($query->parent_id == 1)
{
$criteria = new CDbCriteria();
$criteria->addCondition("parent_id=".$query->id);
$parent = Categories::model()->findAll($criteria);
$count = count($parent) ;
for($i=0;$i<$count;$i++)
{
Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'2',
),
'id=:id',
array(':id'=>$parent[$i]['id'])
);
}
}

Yii::app()->db->createCommand()
->update('tbl_categories',
array(
'published'=>'2',
),
'id=:id',
array(':id'=>$value)
);
}
}
}

/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$this->render('view',array(
'model'=>$this->loadModel($id),
));
}

/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
if(Yii::app()->user->checkAccess("Editor"))
{
Yii::app()->user->setFlash('Access','کاربر گرامی : شما مجوز ایجاد مطلب را ندارید');
$this->redirect(array('admin'));
}
$model=new Categories;
$this->setPageTitle(' - افزودن مجموعه');
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

if(isset($_POST['Categories']))
{
$model->attributes=$_POST['Categories'];
if(Yii::app()->user->checkAccess("Editor") || Yii::app()->user->checkAccess("creator"))
$model->published = 2 ;
$model->created_time = date("Y/m/d H:i:s");
$model->modified_time = date("Y/m/d H:i:s") ;
$model->modified_user_id = 0;
if($model->save())
$this->redirect(array('admin'));
}

$this->render('create',array(
'model'=>$model,
));
}

/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdate($id)
{
$model=$this->loadModel($id);
$this->setPageTitle(' - بروزرسانی مجموعه');
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

if(isset($_POST['Categories']))
{
$model->modified_time = date("Y/m/d H:i:s") ;
$model->attributes=$_POST['Categories'];
if(Yii::app()->user->checkAccess("Editor") || Yii::app()->user->checkAccess("creator"))
$model->published = 2 ;
if($model->save())
$this->redirect(array('admin'));
}

$this->render('update',array(
'model'=>$model,
));
}

/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'admin' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
$this->loadModel($id)->delete();

// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}

/**
* Lists all models.
*/
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Categories');
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}

/**
* Manages all models.
*/
public function actionAdmin()
{
$this->setPageTitle(' - مدیریت مجموعه');
$model=new Categories('search');
$data = Categories::model()->findAll('id>1 and published <= 2');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Categories']))
$model->attributes=$_GET['Categories'];

$this->render('admin',array(
'model'=>$model,
'data'=>$data,
));
}

/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Categories the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Categories::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}

/**
* Performs the AJAX validation.
* @param Categories $model the model to be validated
*/
protected function performAjaxValidation($model)
{
if(isset($_POST['ajax']) && $_POST['ajax']==='categories-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
}
}

googoli
دوشنبه 27 بهمن 1393, 10:27 صبح
کسی نمی تونه من رو راهنمایی کنه ؟

qartalonline
پنج شنبه 30 بهمن 1393, 07:08 صبح
خطا میده؟ چه خطایی؟ فقط رو هاست مشکل دارید؟ تو لوکال هاست مشکلی نیست؟

googoli
پنج شنبه 30 بهمن 1393, 08:46 صبح
خطا نمیده
روی لوکال داره درست کار می کنه فقط روی هاست با این مشکل روبرو هستم

qartalonline
جمعه 01 اسفند 1393, 11:27 صبح
کدهای کنترل ظاهرا درست هستن. کدهای مربوط به view و همچنین ساختار پوشه view و محتوای اون رو بررسی کنید.

MMSHFE
جمعه 01 اسفند 1393, 12:53 عصر
حروف کوچک و بزرگ رو توی نامگذاری فایلهای view و پوشه ها و... رعایت کردین؟ اسم پوشه viewها و... رو حروف کوچک بگذارین و اسم فایل هم مطابق با اسمی باشه که توی کنترلر render میکنید. لینوکس به بزرگی و کوچکی حروف حساسه.

googoli
جمعه 01 اسفند 1393, 16:20 عصر
سلام استاد
من اصلا به ساختار فریم ورک دست نزدم منظورم این هست که اصلا همون پوشه هایی هست که با gii ساختم
الان که شما گفتید رفتم نگاه کردم حتی تو ادرس هم حروف کوچک و بزرگ هم تغییر دادم ولی نشد

googoli
شنبه 02 اسفند 1393, 00:31 صبح
من الان مقدار 'caseSensitive' => false قرار دادم و وقتی برنامه اجرا میشه
این هم کدش


'urlManager' => array(
'urlFormat' => 'path',
'caseSensitive' => false,
'rules' => array(
'contact' => 'site/contact',
'manager/<module:\w+>/<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
'showScriptName' => false,
)

این مشکل در ماژول
manager هست