/** * 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 Album the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Album::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested album does not exist.'); } return $model; }
protected function unlinkAlbumFromArtist($albumid) { $sql = "DELETE FROM artist_album WHERE album_id=:album_id"; $command = Album::model()->getDbConnection()->createCommand($sql); $command->bindValues(array(":album_id" => $albumid)); $command->execute(); return true; }
/** * 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 Album the loaded model * @throws CHttpException */ public function loadModel($id) { $user = $this->getUser(); $model = Album::model()->findByAttributes(['id' => $id, 'created_by' => $user->id]); if ($model === null) { throw new CHttpException(404, 'The requested album does not exist.'); } return $model; }
public function run() { $st = 'Music[artist_id]'; echo "<option>" . $_GET[$st] . "</option>"; exit; $data = Album::model()->findAll('artist_id=:artist_id', array(':artist_id' => (int) $_GET['Music[artist_id]'])); $data = CHtml::listData($data, 'id', 'name'); foreach ($data as $value => $name) { echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true); } }
public function actionIndex($id) { $model = Album::model()->findByAttributes(['id' => $id, 'created_by' => Yii::app()->user->id]); if ($model === null) { throw new CHttpException(404, 'The requested album does not exists.'); } $this->subLayout = "application.modules.album.views._layout"; $criteria = new CDbCriteria(['condition' => 'album_id = ' . $model->id, 'with' => 'image']); $dataProvider = new CActiveDataProvider('AlbumImage', ['criteria' => $criteria]); $this->render('/album/details', ['model' => $model, 'dataProvider' => $dataProvider]); }
/** * 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. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Album::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
public function getOne($keyid, $return = '') { if (!$keyid) { return false; } $info = Album::model()->findByPk($keyid); if (!$info) { return false; } if ($return != '') { return $info[$return]; } else { return $info; } }
function actionIndex() { //首页幻灯片展示,读取最新4条 $ppt = Article::model()->findAll(array('order' => 'create_time desc', 'limit' => 4)); //首页最新微语展示 $wei = Weiyu::model()->findAll(array('order' => 'create_time desc')); // 首页点击率思想展示 $sixiang = Article::model()->findAll(array('order' => 'click desc', 'limit' => 8)); // 首页得瑟会员、小丫丫展示 $jiaoya = User::model()->findAll(array('order' => 'regtime desc', 'limit' => 5)); //首页展示标签 $pictag = Albumcate::model()->findAll(); $articletag = Type::model()->findAll(); //首页展示新的图 $likepic = Album::model()->findAll(array('order' => 'create_time desc', 'limit' => 9)); $data = array('quote' => $this->getRandomQuote(), 'ppt' => $ppt, 'wei' => $wei, 'sixiang' => $sixiang, 'jiaoya' => $jiaoya, 'pictag' => $pictag, 'likepic' => $likepic, 'articletag' => $articletag); $this->render('index', $data); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id) { $album = Album::model()->findByPk($id); if ($album === null) { throw new CHttpException(404, 'The requested album does not exists.'); } $model = new AlbumImage(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['AlbumImage'])) { $model->attributes = $_POST['AlbumImage']; $model->album_id = $album->id; if ($model->save()) { PublicFile::attachPrecreated($model, $model->_image); $this->redirect(['/album/details', 'id' => $album->id]); } } $this->render('create', ['model' => $model, 'album' => $album]); }
public function run() { $model = new Music(); if (isset($_GET['artist_id'])) { $model->artist_id = (int) $_GET['artist_id']; } elseif (isset($_GET['album_id'])) { $album_id = (int) $_GET['album_id']; $album_info = Album::model()->findByPk($album_id); $model->artist_id = $album_info->artist_id; $model->album_id = $album_id; } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Music'])) { $model->attributes = $_POST['Music']; $model->musicfile = CUploadedFile::getInstance($model, 'musicfile'); if ($model->save()) { $this->redirect(array('admin')); } } $this->render('create', array('model' => $model)); }
<li class="list"><a href="<?php echo Yii::app()->createUrl('backend/weiyu/index'); ?> ">微语: <?php echo count(Weiyu::model()->findAll()); ?> 句</a></li> <li class="list"><a href="<?php echo Yii::app()->createUrl('backend/user/index'); ?> ">注册会员: <?php echo count(User::model()->findAll()); ?> 名</a></li> <li class="list"><a href="">美图: <?php echo count(Album::model()->findAll()); ?> 张</a></li> <!-- <li class="list">余额:0.00元</li> <li class="list">短信:无</li> --> </ul> <div class="clear"></div> </div> <ul class="tabui"> <li class="on"><a href="">服务器信息</a></li> </ul> <div class="table-ui"> <br>
<p><strong><?php echo CHtml::link('最新专辑', array('album/newRelease')); ?> </strong></p> <div style="clear:both;width:100%"> <?php foreach (Album::model()->published()->recently()->findAll() as $album) { ?> <div style="float:left;text-align:center;"> <?php echo CHtml::link(CHtml::image($album->picture, $album->name, array('width' => '90', 'height' => '90')), array('album/view', 'id' => $album->id)); ?> <p><?php echo CHtml::link($album->name, array('album/view', 'id' => $album->id)); ?> </p> <p><?php echo CHtml::link($album->artist->name, array('artist/view', 'id' => $album->artist->id)); ?> </p> </div> <?php } ?> </div> <hr />
private function newAlbum() { //check if this is an album or collection //will also check if is a legall request, and if isn't, will throw an exception and stop $isCollection = self::isCollection(); $models = $isCollection ? Collection::model()->findAll() : Album::model()->findAll(); //if we haven't set a pid manually, we will set first free pid if (!$this->pid) { $max = 0; for ($i = 0; $i < 2; $i++) { $testmodel = $i === 0 ? new Album() : new Collection(); $criteria = new CDbCriteria(); $criteria->select = 'max(pid) AS pid'; $row = $testmodel->model()->find($criteria); $max = $max < $row['pid'] ? $row['pid'] : $max; } //if is first created albums or collections, we set $this->pid to 1; $this->pid = $max ? (int) $max + 1 : 1; $max; } $arrModelsNames = array(); foreach ($models as $m => $detail) { $trs = unserialize($detail['translations']); $name = $trs['name'][$this->lang->default]; $arrModelsNames[] = $name; } $modelNameTranslations = array(); $modelDescriptionTranslations = array(); $albumName = ''; foreach ($this->lang->all as $key => $language) { $name = self::purifiedTtext($_POST['newAlbumName_' . $language]); $name = $name ? $name : $this->tr('noName'); $description = self::purifiedTtext($_POST['newAlbumDescription_' . $language]); $description = $description ? $description : $this->tr('noDescription'); if (count($arrModelsNames)) { $p = explode(' ', $name); $last = $p[count($p) - 1]; $name = is_numeric($last) ? self::firstFreeNameIndex($arrModelsNames, $name, $last) : ($name = self::firstFreeNameIndex($arrModelsNames, $name)); } $modelNameTranslations[$language] = $name; $modelDescriptionTranslations[$language] = $description; $albumName .= ' ' . strtolower($name); } $translationsArr = array('name' => $modelNameTranslations, 'description' => $modelDescriptionTranslations); $model = $isCollection ? new Collection() : new Album(); $model->pid = $this->pid; $model->url = $this->getUrlRouteStructure(); $model->translations = serialize($translationsArr); $model->author = Yii::app()->user->name; $model->tags = self::tags($albumName); if (!$model->save()) { throw new Exception('fbgallery - newAlbum - ' . $this->tr('cantSave')); } else { if (!isset($_POST['isCollection'])) { self::createFoldersStructure(); } } }
/** * delete all albums created by the given user. * @param User $user */ public function disableUserModule(User $user) { $albums = Album::model()->findAll('created_by = :user', array(':user' => $user->id)); foreach ($albums as $album) { $album->delete(); } }
public function restEvents() { /** * req.get.resources.render * * Called when a GET request for when a list resources is to be rendered * * @param (Array) (data) this is an array of models representing the resources * @param (String) (model_name) the name of the resources model * @param (Array) (relations) the list of relations to include with the data * @param (Int) (count) the count of records to return */ $this->onRest('req.get.resources.render', function ($data, $model_name, $relations, $count) { //Handler for GET (list resources) request $this->setHttpStatus($count > 0 ? 200 : 204); $this->renderJSON(array('type' => 'rest', 'success' => $count > 0 ? true : false, 'message' => $count > 0 ? "Record(s) Found" : "No Record(s) Found", 'totalCount' => $count, 'modelName' => $model_name, 'relations' => $relations, 'data' => $data)); }); /** * req.get.resource.render * * Called when a GET request for a single resource is to be rendered * @param (Object) (data) this is the resources model * @param (String) (model_name) the name of the resources model * @param (Array) (relations) the list of relations to include with the data * @param (Int) (count) the count of records to return (will be either 1 or 0) */ $this->onRest('req.get.resource.render', function ($data, $model_name, $relations, $count) { //Handler for GET (single resource) request $this->setHttpStatus($count > 0 ? 200 : 204); $this->renderJSON(array('type' => 'rest', 'success' => $count > 0 ? true : false, 'message' => $count > 0 ? "Record Found" : "No Record Found", 'totalCount' => $count, 'modelName' => $model_name, 'relations' => $relations, 'data' => $data)); }); $this->onRest('req.post.album.', function ($data) { //$data is the data sent in the POST echo CJSON::encode(array('data' => $data)); }); /** * model.delete * * Called whenever a model resource needs deleting * * @param (Object) (model) the model resource to be deleted */ $this->onRest('model.delete', function ($artist) { /*print_r(Artist::PROTECTED_ARTISTS()); print_r($artist->id); exit;*/ //DON'T LET USERS DELETE PROTECTED ARTISTS if (in_array($artist->id, Artist::PROTECTED_ARTISTS())) { throw new CHttpException(403, '<i>You cannot delete </i><h4>' . $artist->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.'); exit; } $albumsDeleted = true; $tracksDeleted = true; foreach ($artist->albums as $album) { //delete tracks $albumid = $album->id; $tracks = Track::model()->findAllByAttributes(array('album_id' => $albumid)); foreach ($tracks as $track) { $trackDeleted = $track->delete(); $tracksDeleted = $tracksDeleted && $trackDeleted; } //delete album $albumdeleted = $album->delete(); $albumsDeleted = $albumsDeleted && $albumdeleted; } if (!$artist->delete()) { throw new CHttpException(500, 'Could not delete model'); } if (!$albumsDeleted) { throw new CHttpException(500, 'Some artist\'s albums were not deleted'); } if (!$tracksDeleted) { throw new CHttpException(500, 'Some album tracks were not deleted'); } if (!$this->unlinkArtistFromAlbums($artist->id)) { throw new CHttpException(500, 'Artist was not unlinked from albums.'); } return $artist; }); //DON'T LET USERS UPDATE PROTECTED ARTISTS $this->onRest('pre.filter.model.apply.put.data', function ($model, $data, $restricted_properties) { if (in_array($model->id, Artist::PROTECTED_ARTISTS())) { throw new CHttpException(403, '<i>You cannot modify </i><h4>' . $model->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.'); exit; } else { return array($model, $data, $restricted_properties); } //Array [Object, Array, Array] }); /** * model.subresources.save * * Called whenever a sub-resource is saved * * @param (Object) (model) the owner of the sub-resource * @param (String) (subresource_name) the name of the subresource * @param (Mixed/Int) (subresource_id) the primary key of the subresource * * @return (Object) the updated model representing the owner of the sub-resource */ //DON'T LET USERS ADD ALBUMS TO PROTECTED ARTISTS $this->onRest(ERestEvent::MODEL_SUBRESOURCE_SAVE, function ($model, $subresource_name, $subresource_id) { if (in_array($model->id, Artist::PROTECTED_ARTISTS())) { Album::model()->findByPk($subresource_id)->delete(); //rollback,can't add album to protected artist throw new CHttpException(403, '<i>You cannot modify </i><h4>' . $model->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.'); exit; } if (!$this->getSubresourceHelper()->putSubresourceHelper($model, $subresource_name, $subresource_id)) { throw new CHttpException('500', 'Could not save Sub-Resource'); } $model->refresh(); return true; }); }
/** * 版本更新 */ public function actionVersion() { if (!isset($_POST['version']) || !$_POST['version']) { $this->_exit($this->_error['20032'], '20032'); } $version = trim($_POST['version']); $res = Album::model()->getVersion($version); if ($res) { $this->_exit($this->_error['20000'], '20000', $res, 'data'); } $this->_exit($this->_error['20000'], '20000'); }
public function actionSearch($id) { $sql = "select * from {{album}} where photo_cate_id={$id} order by create_time desc"; $model = Album::model()->findAllBySql($sql); $tj = count($model); $cate = Albumcate::model()->findByPk($id); $data = array('model' => $model, 'tj' => $tj, 'cate' => $cate); $this->render('search', $data); }
echo $form->labelEx($model, 'description'); ?> <?php echo $form->textArea($model, 'description', array('rows' => 6, 'cols' => 50)); ?> <?php echo $form->error($model, 'description'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'album_id'); ?> <?php echo $form->dropDownList($model, 'album', CHtml::listData(Album::model()->findAll(), 'id', 'page.title'), array('prompt' => 'None')); ?> <?php echo $form->error($model, 'album_id'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton(Yii::t('app', 'Save')); echo CHtml::Button(Yii::t('app', 'Cancel'), array('submit' => 'javascript:history.go(-1)')); ?> </div> <?php $this->endWidget(); ?>
" class="userlink"><?php echo Yii::app()->user->nickname; ?> </a> <a href="<?php echo Yii::app()->createUrl('user/myprofile'); ?> " title="帐号设置" class="settings"></a> </div> <div class="profile-stats"> <a href="<?php echo Yii::app()->createUrl('album/myalbum'); ?> "><strong><?php echo $sl = Album::model()->countByAttributes(array('user_id' => Yii::app()->user->id)); ?> </strong>我的照片</a> <a href="<?php echo Yii::app()->createUrl('user/mystore'); ?> " class="middle"><strong><?php echo $count = Picshoucang::model()->countByAttributes(array('pic_uid' => Yii::app()->user->id)); ?> </strong>收藏</a> <a href="<?php echo Yii::app()->createUrl('follow', array('uid' => Yii::app()->user->id)); ?> "><strong><?php $byshui = Yii::app()->user->id; $fansnu = "select * from {{follow}} where touid={$byshui}";
protected function afterFind() { parent::afterFind(); $this->_tags = $this->_oldTags = ItemsTags::returnTagsString(ItemsTags::ALBUM_TYPE, $this->id); Album::model()->updateCounters(array('click' => 1), 'id=:id', array(':id' => $this->id)); }
/** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return Album the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
<?php $this->breadcrumbs = array(Yii::t('app', 'Gallery') => array('/gallery'), Yii::t('app', 'All Images') => array('/gallery/image'), Yii::t('app', 'Manage')); if (!isset($this->menu) || $this->menu === array()) { $this->menu = array(array('label' => Yii::t('app', 'List all albums'), 'url' => array('/gallery/album')), array('label' => Yii::t('app', 'Create new album'), 'url' => array('/gallery/album/create')), array('label' => Yii::t('app', 'Manage all albums'), 'url' => array('/gallery/album/manage')), array('label' => Yii::t('app', 'All images'), 'url' => array('/gallery/image')), array('label' => Yii::t('app', 'Manage all images'))); } ?> <h1> <?php echo Yii::t('app', 'Manage'); ?> <?php echo Yii::t('app', 'Images'); ?> </h1> <?php if (count($model->search()->data)) { $this->widget('zii.widgets.grid.CGridView', array('id' => 'image-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('title', array('name' => 'album_id', 'value' => 'isset($data->album->id)?$data->album->page->title:"N/A"', 'filter' => CHtml::listData(Album::model()->findAll(), 'id', 'page.title')), 'file', array('header' => 'Size', 'name' => 'readableSize', 'filter' => ''), array('class' => 'CButtonColumn')))); } else { echo Yii::t('app', 'No results found!'); }
public function combineAlbumsTagOfCollection() { $tags = explode(', ', $this->collection->tags); $albums = explode(',', $this->collection->albums); foreach ($albums as $pid) { $tags = array_merge($tags, array_map('trim', explode(',', Album::model()->find(array('condition' => "pid='{$pid}'"))->tags))); } array_unique($tags); sort($tags); return implode(', ', $tags); }
public function actionUpload() { //handle folders $this->path = Settings::get('gallery', 'uploadPath'); $path = Yii::app()->getBasePath() . Settings::get('gallery', 'uploadPath'); $this->publicPath = Settings::get('gallery', 'uploadUrl'); if (!is_dir($path)) { mkdir($path, 0777, true); chmod($path, 0777); //throw new CHttpException(500, "{$this->path} does not exists."); } else { if (!is_writable($path)) { chmod($path, 0777); //throw new CHttpException(500, "{$this->path} is not writable."); } } if ($this->subfolderVar !== null && Yii::app()->request->getQuery($this->subfolderVar)) { $this->_subfolder = Yii::app()->request->getQuery($this->subfolderVar, date("mdY")); } else { if (isset($_GET['album_id'])) { $this->_subfolder = Awecms::getCamelCase(Album::model()->findByPk($_GET['album_id'])->page->title); } else { if ($this->subfolderVar !== false) { $this->_subfolder = date("mdY"); } } } //handle upload file header('Vary: Accept'); if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false) { header('Content-type: application/json'); } else { header('Content-type: text/plain'); } if (isset($_GET["_method"])) { if ($_GET["_method"] == "delete") { $success = is_file($_GET["file"]) && $_GET["file"][0] !== '.' && unlink($_GET["file"]); echo json_encode($success); } } else { $model = new Image(); $file = CUploadedFile::getInstance($model, 'file'); if ($file !== null) { $path = $this->_subfolder != "" ? "{$path}/{$this->_subfolder}/" : "{$path}/"; $this->path = $this->_subfolder != "" ? "{$this->path}/{$this->_subfolder}/" : "{$this->path}/"; $time = time(); $model->mime_type = $file->getType(); $model->size = $file->getSize(); $model->name = $file->getName(); $model->title = $_POST['title'][$model->size . $model->name]; $model->description = $_POST['description'][$model->size . $model->name]; $model->file = $this->_subfolder . '/' . $time . $model->name; if (isset($_GET['album_id'])) { $model->album_id = $_GET['album_id']; } if ($model->save()) { $this->publicPath = rtrim($this->publicPath, '/'); $publicPath = $this->_subfolder != "" ? "{$this->publicPath}/{$this->_subfolder}/" : "{$this->publicPath}/"; if (!is_dir($path)) { mkdir($path, 0777, true); chmod($path, 0777); } $file->saveAs($path . $time . $model->name); chmod($path . $time . $model->name, 0777); echo json_encode(array(array("name" => $time . $model->name, "title" => $model->title, "description" => $model->description, "type" => $model->mime_type, "size" => $model->size, "url" => $publicPath . $time . $model->name, "thumbnail_url" => $publicPath . $time . $model->name, "delete_url" => $this->createUrl("/gallery/image/delete", array("id" => $model->id)), "delete_type" => "POST"))); } else { echo json_encode(array(array("error" => $model->getErrors('file')))); Yii::log("XUploadAction: " . CVarDumper::dumpAsString($model->getErrors()), CLogger::LEVEL_ERROR, "xupload.actions.XUploadAction"); } } else { throw new CHttpException(500, "Could not upload file"); } } }
public function restEvents() { /** * req.get.resources.render * * Called when a GET request for when a list resources is to be rendered * * @param (Array) (data) this is an array of models representing the resources * @param (String) (model_name) the name of the resources model * @param (Array) (relations) the list of relations to include with the data * @param (Int) (count) the count of records to return */ $this->onRest('req.get.resources.render', function ($data, $model_name, $relations, $count) { //Handler for GET (list resources) request $this->setHttpStatus($count > 0 ? 200 : 204); $this->renderJSON(array('type' => 'rest', 'success' => $count > 0 ? true : false, 'message' => $count > 0 ? "Record(s) Found" : "No Record(s) Found", 'totalCount' => $count, 'modelName' => $model_name, 'relations' => $relations, 'data' => $data)); }); /** * req.get.resource.render * * Called when a GET request for a single resource is to be rendered * @param (Object) (data) this is the resources model * @param (String) (model_name) the name of the resources model * @param (Array) (relations) the list of relations to include with the data * @param (Int) (count) the count of records to return (will be either 1 or 0) */ $this->onRest('req.get.resource.render', function ($data, $model_name, $relations, $count) { //Handler for GET (single resource) request $this->setHttpStatus($count > 0 ? 200 : 204); $this->renderJSON(array('type' => 'rest', 'success' => $count > 0 ? true : false, 'message' => $count > 0 ? "Record Found" : "No Record Found", 'totalCount' => $count, 'modelName' => $model_name, 'relations' => $relations, 'data' => $data)); }); /** * model.delete * * Called whenever a model resource needs deleting * * @param (Object) (model) the model resource to be deleted */ $this->onRest('model.delete', function ($model) { if (in_array($model->album->artists[0]->id, Artist::PROTECTED_ARTISTS())) { throw new CHttpException(403, '<i>You cannot delete </i><h4>' . $model->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.'); exit; } else { if (!$model->delete()) { throw new CHttpException(500, 'Could not delete model'); } } return $model; }); $this->onRest('pre.filter.model.apply.put.data', function ($model, $data, $restricted_properties) { if (in_array($model->album->artists[0]->id, Artist::PROTECTED_ARTISTS())) { throw new CHttpException(403, '<i>You cannot modify </i><h4>' . $model->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.'); exit; } else { return array($model, $data, $restricted_properties); } //Array [Object, Array, Array] }); $this->onRest('pre.filter.model.apply.post.data', function ($model, $data, $restricted_properties) { $album_id = $data['album_id']; $album = Album::model()->findByPk($album_id); if (in_array($album->artists[0]->id, Artist::PROTECTED_ARTISTS())) { throw new CHttpException(403, '<i>You cannot modify </i><h4>' . $model->name . '</h4><br> It\'s demo data.Feel free to create,update and delete your own data.'); exit; } else { return array($model, $data, $restricted_properties); } //Array [Object, Array, Array] }); }
</td> <td><?php date_default_timezone_set('PRC'); //设置默认时区 echo date('Y-m-d H:i:s', $_u->update_time); //时间戳转化date() ?> </td> <td><div align="center"><?php echo $ct = Article::model()->countByAttributes(array('author_id' => $_u->id)); ?> /<?php echo $ct2 = Weiyu::model()->countByAttributes(array('create_user_id' => $_u->id)); ?> /<?php echo $ct3 = Album::model()->countByAttributes(array('user_id' => $_u->id)); ?> </div></td> <td><?php $shui = $_u->id; $gznu = "select * from {{follow}} where uid={$shui}"; $numGZ = count(Follow::model()->findAllBySql($gznu)); echo $numGZ; ?> </td> <td><?php $byshui = $_u->id; $fansnu = "select * from {{follow}} where touid={$byshui}"; $numFAN = count(Follow::model()->findAllBySql($fansnu)); echo $numFAN; ?>
protected function setPid() { //step 1: //create standard url using actual url $thisUrl = $this->getUrlRouteStructure(); //chech if page is album //compare actual url route with routes from Album model $album = Album::model()->find(array('condition' => "url='{$thisUrl}'")); if ($album) { $this->pid = $album->pid; return; } //chech if page is collection $collection = Collection::model()->find(array('condition' => "url='{$thisUrl}'")); if ($collection) { $this->pid = $collection->pid; return; } //there isn't any album or collection for this page //if is visitor, there isn't necessary to generate next pid, we set it to 0; if (!$this->levelAccess) { $this->pid = 0; return; } }