本文整理汇总了PHP中Objects::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Objects::model方法的具体用法?PHP Objects::model怎么用?PHP Objects::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Objects
的用法示例。
在下文中一共展示了Objects::model方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// $cats = Category::model()->findAll(array('condition'=>'lft=1 and rgt=2 and level=1','order'=>'title'));
$this->pageTitle = 'Быстрые отзывы покупателей о товарах и услугах';
$cats = Category::getRubsByParentId();
$lasts = Objects::model()->active()->findAll(array('order' => 'created_date DESC', 'limit' => 15));
$last_array = array();
if (!empty($lasts)) {
foreach ($lasts as $last) {
$last_array[] = $last->id;
}
}
/* $criteria = new CDbCriteria;
$criteria->order = 'created_date DESC';
$criteria->limit = 3;
$criteria->addNotInCondition('org_id', $last_array);
$lasts_poll = PollChoice::model()->findAll($criteria);
if(!empty($lasts_poll)){
foreach ($lasts_poll as $last_poll) {
if(!in_array($last_poll->org->id, $last_array)){
$last_array[] = $last_poll->org->id;
$lasts[] = $last_poll->org;
}
}
} */
$this->render('index', array('cats' => $cats, 'lasts' => $lasts));
}
示例2: actionIndex
public function actionIndex() {
$this->active_link = 'dashboard';
//count users
$users = User::model()->count('status != '.User::STATUS_DELETED);
$objects = Objects::model()->active()->count(array('select'=>'id'));
$objectsNew = Objects::model()->active()->count(array('select'=>'id','condition'=>'verified = false'));
$polls = PollChoice::model()->count();
$photos = ObjectsImages::model()->count();
$videos = ObjectsHttp::model()->count(array('condition'=>'type='.ObjectsHttp::TYPE_VIDEO));
$this->render('dashboard',array('users'=>$users,'objects'=>$objects,
'objectsNew'=>$objectsNew, 'polls'=>$polls,'photos'=>$photos,
'videos'=>$videos
));
}
示例3: substr
<?php
echo '<div class="">';
$num = substr($data['id'], 0, 1);
$id = substr_replace($data['id'], '', 0, 1);
$id = (int) $id;
if ($num == 2) {
$data['uploaded_by'] = $this->user->id;
$bl = $this->renderPartial('_lastimages', array('model' => $data, 'addClass' => 'col-sm-3 col-xs-6'), true);
} elseif ($num == 1) {
$comment = Comment::model()->with('obj')->findByPk($id);
$bl = $this->renderPartial('_itemmain', array('model' => $comment, 'org' => $comment->obj), true);
} else {
$object = Objects::model()->findByPk($id);
$bl = $this->renderPartial('_objects_view', array('data' => $object), true);
}
echo $bl;
echo '</div>';
示例4: array
<?php
$user = User::model()->findByPk($model['uploaded_by']);
$org = Objects::model()->findByPk($model['org']);
$url = Yii::app()->createAbsoluteUrl('/fastreview/item', array( 'id'=>$org->id, 'dash'=>'-', 'itemurl'=>$org->url));
if(!empty($user)){
$user_avatar = $user->getAvatar();
$user_name = $user->fullname;
} else {
$user_avatar = '/img/avatar.png';
$user_name = 'Аноним';
}
?>
<div class="oblects_view">
<div class="media">
<div class="pull-left">
<div class="iAvatar">
<img class="lv-img-lg" src="<?php echo $user_avatar; ?>" alt="">
</div>
</div>
<div class="media-body">
<div class="iAuthor">
<span style="color:#333;font-size:17px;font-weight:300;display:block;line-height:1.3em;"><?php echo $user_name; ?></span>
<span class="c-gray f-11" style="display:block;"><?php echo Yii::app()->dateFormatter->format('d MMMM yyyy', $model['date']); ?></span>
</div>
<span style="font-weight:bold;"><?php
echo CHtml::link($org->title,$url,array('class'=>'nocolor'));
?></span>
<div class="lightbox row lastimages">
示例5: _loadItem
protected function _loadItem($id = null)
{
if (!$id && !$url) {
throw new CHttpException(404, 'Страница не найдена.');
}
if ($id) {
$model = Objects::model()->active()->findByPk($id);
}
if (!$model) {
throw new CHttpException(404, 'Страница не найдена.');
}
// $model->saveCounters(array('views_count'=>1));
return $model;
}
示例6: beforeDelete
protected function beforeDelete()
{
if (!parent::beforeDelete()) {
return false;
}
Comment::model()->updateAll(array('user_id' => 0), array('condition' => 'user_id=' . $this->id));
ObjectsImages::model()->updateAll(array('uploaded_by' => null), array('condition' => 'uploaded_by=' . $this->id));
Objects::model()->updateAll(array('author' => null), array('condition' => 'author=' . $this->id));
$this->deleteModelDir();
// удалили модель? удаляем и файл и всю папку
return true;
}
示例7: actionObjectsFiles
public function actionObjectsFiles($id){
$id = (int)$id;
$model = Objects::model()->findByPk($id);
if(!$model)
throw new CHttpException(404, Yii::t('site','Page not found'));
$uploadPath = $model->getFileFolder();
if($model->images){
foreach($model->images as $file){ //get an array which has the names of all the files and loop through it
$obj['id'] = $file->id; //get the filename in array
$obj['name'] = $file->realname;
if(file_exists($uploadPath.$file->filename)){
$obj['size'] = filesize($uploadPath.$file->filename); //get the flesize in array
} else {
$obj['size'] = '0';
}
$result[] = $obj; // copy it to another array
}
header('Content-Type: application/json');
echo json_encode($result); // now you have a json response which you can use in client side
}
}
示例8: getViewUrlAdmin
public function getViewUrlAdmin()
{
$model = Objects::model()->findByPk($this->object_pk);
if($model){
$ret = '';
if(get_class($model) == 'Objects'){
$ret .= Yii::app()->createUrl("/catalog/admin/company/update", array("id"=>$model->id));
}
return Yii::app()->createAbsoluteUrl($ret);
}
}
示例9: actionUpdate
public function actionUpdate($obj, $id=null)
{
// $this->layout = '//layouts/new_item';
$object = Objects::model()->active()->findByPk($obj);
if(!$object)
throw new CHttpException(404, 'Страница не найдена.');
$model = null;
if($id)
{
$new = false;
$this->action_title = 'РЕДАКТИРОВАТЬ СТАТЬЮ';
$this->pageTitle = 'Редактировать обзор';
if(Yii::app()->user->isGuest){
$this->redirect(Yii::app()->createAbsoluteUrl('/catalog/article/new',array('obj'=>$object->id)));
Yii::app()->end();
}
$model = Article::model()->findByPk($id,'author='.Yii::app()->user->id);
if(!$model)
$this->redirect(Yii::app()->createAbsoluteUrl('/catalog/article/new',array('obj'=>$object->id)));
}
if(!$model)
{
$new = true;
$this->action_title = 'ДОБАВИТЬ СТАТЬЮ';
$this->pageTitle = 'Добавление нового обзора - '.Yii::app()->name;
$model = new Article;
}
if(isset($_POST['Article']))
{
$model->attributes = $_POST['Article'];
$model->object_id = $object->id;
/*
if(!$model->categories_ar || !is_array($model->categories_ar) || (isset($model->categories_ar[0]) && empty($model->categories_ar[0]))){
$model->categories_ar = array();
$model->categorie = null;
} else {
$model->categorie = 1;
}*/
// Uncomment the following line if AJAX validation is needed
if(isset($_POST['ajax']) && $_POST['ajax']==='article-form')
{
$errors = CActiveForm::validate($model);
if ($errors !== '[]') {
$errors = CJSON::decode($errors);
echo CJSON::encode(array('success'=>false, 'message'=>$errors));
Yii::app()->end();
}
}
if(isset($_POST['preview']) && $_POST['preview'] == 1){
$message = $this->renderPartial('_article_listview_preview',array('data'=>$model),true);
echo CJSON::encode(array(
'flag' => true,
'preview' => true,
'message'=>$message
));
Yii::app()->end();
}
$model->status_org = Article::STATUS_ACTIVE;
$model->verified = false;
$model->mywork = false;
if(isset($_POST['Article']['mywork'])){
$model->mywork = true;
}
if($model->save()){
// $model->setCategories($model->categories_ar);
$model->addDropboxLogoFiles($this->uploadlogosession);
Yii::app()->session->remove($this->uploadlogosession);
$model->addDropboxFiles($this->uploadsession);
Yii::app()->session->remove($this->uploadsession);
$replace = $model->getOrigFilePath();
$model->description = str_replace ( '/uploads/tmp/' , $replace , $model->description );
$model->save('false',array('description'));
$article_url = Yii::app()->createAbsoluteUrl('/fastreview/item', array( 'id'=>$object->id, 'dash'=>'-', 'itemurl'=>$object->url));
if(Yii::app()->request->isAjaxRequest){
echo CJSON::encode(array('success'=>true, 'message'=>array('url'=>$article_url)));
Yii::app()->end();
} else {
$this->redirect($article_url);
}
}
}
//.........这里部分代码省略.........
示例10: checkUniqueUrl
protected function checkUniqueUrl($unique){
// Check if url available
if($this->isNewRecord) {
$test = Objects::model()
->withUrl($unique)
->count();
} else {
$test = Objects::model()
->withUrl($unique)
->count('id!=:id', array(':id'=>$this->id));
}
return $test;
}
示例11: loadModel
/**
* 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 City the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model=Objects::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
示例12: actionUpdate
/**
* 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($new = false)
{
if ($new === true)
$model = new Article;
else
{
$id = (int)$_GET['id'];
$model=$this->loadModel($id);
}
if($model->verified !== true){
$this->active_link = 'new_article';
}
$firms = array(); $ar_url = array(); $error = false; $ids = array();
if(!empty($_POST['Article']['article_ar'])){
$ars = $_POST['Article']['article_ar'];
if(isset($ars['firmname']) && !empty($ars['firmname'])){
foreach ($ars['firmname'] as $key => $value) {
$value = trim(strip_tags($value));
$firms[$key]['firmname'] = $value;
}
}
if(isset($ars['firmphotoh']) && !empty($ars['firmphotoh'])){
foreach ($ars['firmphotoh'] as $key => $value) {
$firms[$key]['firmphotoh'] = $value;
}
}
if(isset($ars['firmurl']) && !empty($ars['firmurl'])){
$ids = 0;
foreach ($ars['firmurl'] as $key => $value) {
$value = trim(strip_tags($value));
if(!empty($value)){
$stri = stristr($value, Yii::app()->params['serverName']);
if($stri === FALSE) {
if (is_numeric($value)) {
$ids = (int) $value;
} else {
$this->addFlashMessage('Фирма '. ($key+1) .', url - неверная ссылка', 'error');
$error = true;
break;
}
} else {
$id_url = explode('/',$stri);
if(isset($id_url[1])){
$ids = $id_url[1];
}
}
}
$ids_check = Objects::model()->findByPk($ids);
if(!$ids_check){
$this->addFlashMessage('Объект '. ($key+1) .', url - не найден', 'error');
$error = true;
break;
}
$firms[$key]['firmurl'] = (int)$ids;
}
}
if(isset($ars['firmdescription']) && !empty($ars['firmdescription'])){
foreach ($ars['firmdescription'] as $key => $value) {
$value = trim(strip_tags($value));
$firms[$key]['firmdescription'] = $value;
if(!empty($value)){
} else {
$this->addFlashMessage('Фирма '. ($key+1) .' - нет описания', 'error');
$error = true;
break;
}
}
}
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model, 'orgs-form');
/* if(isset($_POST['Article']['articleorg_ar']) &&
!empty($_POST['Article']['articleorg_ar']) &&
is_array($_POST['Article']['articleorg_ar']))
{
$ar_url = $_POST['Article']['articleorg_ar'];
for($i=0;$i<count($ar_url);$i++)
{
if(empty($ar_url[$i]))
continue;
$model->articleorg = $ar_url[$i];
if($model->validate(array('articleorg')))
{
$ar_url[$i] = $model->articleorg;
} else {
//.........这里部分代码省略.........