本文整理汇总了PHP中Portfolio::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Portfolio::model方法的具体用法?PHP Portfolio::model怎么用?PHP Portfolio::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfolio
的用法示例。
在下文中一共展示了Portfolio::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
$model = Portfolio::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: actionDelete
public function actionDelete($id)
{
$user = User::model()->findByPk((int) $id);
//delete all portfolio of specified company
$criteria = new CDbCriteria();
$idcompany = (int) $user->company->id;
$criteria->condition = "company_id={$idcompany}";
Portfolio::model()->deleteAll($criteria);
// delelte company
Company::model()->deleteByPk($idcompany);
// delete user
$user->delete();
}
示例3: actionIndex
public function actionIndex()
{
$type = Type::model()->findAll();
$skill = Skill::model()->findAll();
$usr = User::model()->findbyPk(1);
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->order = 'rand()';
$total = Portfolio::model()->count();
$pages = new CPagination($total);
$pages->pageSize = 10;
$pages->applyLimit($criteria);
$port = Portfolio::model()->findAll($criteria);
$this->render('index', array('type' => $type, 'port' => $port, 'pages' => $pages, 'skill' => $skill, 'usr' => $usr));
}
示例4: actionIndex
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->layout = 'index';
// one page about
$criteriaAbout = new CDbCriteria(array('condition' => "t.key='about'"));
$about = Pages::model()->findAll($criteriaAbout);
// one page features
$criteriaFeatures = new CDbCriteria(array('condition' => "t.key='features'"));
$features = Pages::model()->findAll($criteriaFeatures);
// one page portfolio
$criteriaPortfolio = new CDbCriteria(array('condition' => "t.active='1'"));
$portfolio = Portfolio::model()->findAll($criteriaPortfolio);
$this->render('index', array('about' => $about, 'features' => $features, 'portfolio' => $portfolio));
}
示例5: actionIndex
public function actionIndex()
{
$urls = array();
// Actions
$urls[] = $this->createUrl('actions/index');
$actions = Actions::model()->findAll('t.picture != "" AND t.date_end <= ' . date('Y-m-d'));
if (count($actions) > 0) {
foreach ($actions as $action) {
$urls[] = $this->createUrl('actions/view', array('id' => $action->id));
}
}
// Tenders
$urls[] = $this->createUrl('tenders/index');
$tenders = Tenders::model()->findAll('t.date_end <= ' . date('Y-m-d'));
if (count($tenders) > 0) {
foreach ($tenders as $tender) {
$urls[] = $this->createUrl('tenders/view', array('id' => $tender->id));
}
}
// Freefoto
$urls[] = $this->createUrl('freefoto/index');
// Static Pages
$urls[] = $this->createUrl('page/hmagent');
$urls[] = $this->createUrl('page/advertisment');
$urls[] = $this->createUrl('page/help_us');
$urls[] = $this->createUrl('page/about');
$urls[] = $this->createUrl('page/accounts');
// News
$urls[] = $this->createUrl('page/news');
$news = News::model()->findAll('t.title != "" AND t.intro_text != ""');
if (count($news) > 0) {
foreach ($news as $item) {
$urls[] = $this->createUrl('page/news', array('id' => $item->id));
}
}
// Categories
$cats = Occupation::model()->localized('ru')->findAll(array('condition' => 't.name!="" AND t.active=1', 'order' => 't.cat_id ASC'));
if (count($cats) > 0) {
foreach ($cats as $cat) {
$urls[] = $this->createUrl('/cat/view', array('id' => 'c' . $cat->id . '_' . Settings::toLatin($cat->name)));
}
}
// Users
$users = Users::model()->findAll('t.name!="" AND t.activate=1');
if (count($users) > 0) {
foreach ($users as $user) {
if ($user->filesCount >= 4 || $user->videosCount >= 4 || $user->floCount >= 4) {
$urls[] = '/id' . $user->id;
// Photo albums
if ($user->occupation_id == 1) {
$alb = Portfolio::model()->findAllByAttributes(array('uid' => $user->id, 'visible' => 1));
if (count($alb) > 0) {
foreach ($alb as $item) {
if ($item->filesCount > 0) {
$urls[] = $this->createUrl('user/album', array('id' => $item->id));
}
}
}
}
// Video albums
if ($user->occupation_id == 2) {
$vid = Video::model()->findAllByAttributes(array('uid' => $user->id, 'visible' => 1));
if (count($vid) > 0) {
foreach ($vid as $item) {
if ($item->filesCount > 0) {
$urls[] = $this->createUrl('user/videoalbum', array('id' => $item->id));
}
}
}
}
}
}
}
// Photo albums
$users_alb = Users::model()->findAll('t.name!="" AND t.activate=1 AND t.occupation_id=1');
if (count($users_alb) > 0) {
foreach ($users_alb as $user_alb) {
if ($user_alb->filesCount >= 4 || $user->videosCount >= 4 || $user->floCount >= 4) {
$urls[] = '/id' . $user->id;
}
}
}
/*// Страницы
$pages = Page::model()->findAll(array(
'condition' => 't.public = 1';
));
foreach ($posts as $page){
$urls[] = $this->createUrl('page/view', array('alias'=>$page->alias));
}
// Новости
$news = News::model()->findAll(array(
'condition' => 't.public = 1';
));
foreach ($news as $new){
$urls[] = $this->createUrl('news/view', array('id'=>$new->id));
}
// Работы портфолио
$works = Work::model()->findAll(array(
//.........这里部分代码省略.........
示例6: parse_url
</div>
</div>
<div class="middle_photo">
<div class="cur_photo">
<?php
echo '<div id="content_photo">';
if ($next != '') {
echo '<a href="' . parse_url(Yii::app()->request->requestUri, PHP_URL_PATH) . '?photo=photo' . $next . '" class="next_item">';
}
if (!is_file($_SERVER['DOCUMENT_ROOT'] . '/users/' . $user->id . '/940_' . $current)) {
$ih = new CImageHandler();
$ih->load($_SERVER['DOCUMENT_ROOT'] . '/users/' . $user->id . '/' . $current)->resize(940, 680)->save($_SERVER['DOCUMENT_ROOT'] . '/users/' . $user->id . '/940_' . $current);
echo '<img src="/users/' . $user->id . '/940_' . $current . '" alt="' . $user->name . ' - Фотограф - ' . Portfolio::model()->findByPk(Yii::app()->getRequest()->getParam('id'))->title . '">';
} else {
echo '<img src="/users/' . $user->id . '/940_' . $current . '" alt="' . $user->name . ' - Фотограф - ' . Portfolio::model()->findByPk(Yii::app()->getRequest()->getParam('id'))->title . '">';
}
if ($next != '') {
echo '</a>';
}
echo '<a href="/users/' . $user->id . '/' . $current . '" class="gallery__zoom" rel="big" data-img="/users/' . $user->id . '/' . $current . '"></a>';
echo '</div>';
?>
</div>
</div>
</div>
<div id="big_gallery" style="display: none;">
<?php
foreach ($model as $item) {
示例7: actionShowform
public function actionShowform($id)
{
$data = explode('_', $id);
$pack = Prices::model()->findByAttributes(array('genre_id' => $data[0], 'package' => $data[1], 'user_id' => Yii::app()->user->id));
if (Yii::app()->user->role == 2) {
//videooperator
$title = Video::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'id' => $data[0]));
} else {
$title = Portfolio::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'id' => $data[0]));
}
if (is_object($pack)) {
$html = '<form action="/my/prices/update/id/' . $pack->id . '" method="post">';
$html .= '<script>
$(document).ready(function() {
$("#price__price").keydown(function (e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110]) !== -1 ||
// Allow: Ctrl+A
(e.keyCode == 65 && e.ctrlKey === true) ||
// Allow: home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40)) {
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
});
</script>';
$html .= '<div class="tooltip_cost_title">' . $title->title . '</div>
<label for="albom__name" class="tool_label" style="margin-top: 25px;">Цена</label>
<input type="text" name="Prices[price]" value="' . $pack->price . '" id="price__price" class="default__input search__hidden__input--city" maxlength="7" title="Это поле обязательно для заполнение" placeholder="500 грн" required="">
<label for="albom__name" class="tool_label">Описание</label>
<textarea name="Prices[about]" id="about__user" cols="25" rows="10" class="default__textarea" placeholder="Описание услуги:">' . $pack->about . '</textarea>
<div class="col-12 text_center" style="margin-top: 25px;">
<div class="btn__group clfx">
<div class="col-179">
<button type="button" class="t-cls cabinet__profile__btn" id="close_tip" onclick="closeTip(\'' . $id . '\')">ОТМЕНА</button>
</div>
<div class="col-179">
<input type="hidden" name="Prices[user_id]" value="' . Yii::app()->user->id . '" />
<input type="hidden" name="Prices[package]" value="' . $data[1] . '" />
<input type="hidden" name="Prices[genre_id]" value="' . $data[0] . '" />
<button type="submit" class="t-cls cabinet__profile__btn cabinet__profile__btn-submit">СОХРАНИТЬ</button>
</div>
</div>
</div>
</form>';
} else {
$html = '<form action="/my/prices/create/" method="post">';
$html .= '<div class="tooltip_cost_title">' . $title->title . '</div>
<label for="albom__name" class="tool_label" style="margin-top: 25px;">Цена</label>
<input type="text" name="Prices[price]" id="albom__name" class="default__input search__hidden__input--city" title="Это поле обязательно для заполнение" placeholder="500 грн" required="">
<label for="albom__name" class="tool_label">Описание</label>
<textarea name="Prices[about]" id="about__user" cols="25" rows="10" class="default__textarea" placeholder="Описание услуги:"></textarea>
<div class="col-12 text_center" style="margin-top: 25px;">
<div class="btn__group clfx">
<div class="col-179">
<button type="button" class="t-cls cabinet__profile__btn" id="close_tip" onclick="closeTip(\'' . $id . '\')">ОТМЕНА</button>
</div>
<div class="col-179">
<input type="hidden" name="Prices[user_id]" value="' . Yii::app()->user->id . '" />
<input type="hidden" name="Prices[package]" value="' . $data[1] . '" />
<input type="hidden" name="Prices[genre_id]" value="' . $data[0] . '" />
<button type="submit" class="t-cls cabinet__profile__btn cabinet__profile__btn-submit">СОХРАНИТЬ</button>
</div>
</div>
</div>
</form>';
}
echo $html;
}
示例8: actionUpdatefiles
public function actionUpdatefiles()
{
//print_r($_POST); print_r($_FILES); exit();
if (isset($_POST)) {
$err = false;
if (!empty($_POST['Files'])) {
foreach ($_POST['Files'] as $k => $item) {
$model = Files::model()->findByPk($item['id']);
if ($item['description'] != '') {
$model->description = $item['description'];
}
$model->source = 'portfolio';
if (!$model->save()) {
$err = true;
}
}
}
if ($err == false) {
if (!empty($_POST['cover'])) {
$cover = explode('__', $_POST['cover']);
Portfolio::model()->updateByPk($cover[0], array('picture' => $cover[1]));
//$this->redirect('/my/portfolio/album/id/'.$cover[0]);
$this->redirect($_POST['back']);
} else {
$this->redirect('/my/portfolio/');
}
}
}
}
示例9: array
<figure class="accaunt-gallery__thumbnail">
<a href="<?php
echo $this->createUrl('user/album', array('id' => Yii::app()->getRequest()->getParam('id'), 'photo' => 'photo' . $data->id));
?>
">
<img src="/users/<?php
echo $data->uid;
?>
/370_<?php
echo $data->file;
?>
" alt="<?php
echo Users::model()->findByPk($data->uid)->name;
?>
- Фотограф - <?php
echo Portfolio::model()->findByPk(Yii::app()->getRequest()->getParam('id'))->title;
?>
" />
</a>
</figure>
示例10: afterDelete
public function afterDelete()
{
//DebugBreak();
Portfolio::model()->batchDelete(array($this->gallery_id));
//deleting via DeletableBehavior
return parent::afterDelete();
//run parent event handler
}
示例11: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadModel($id);
if ($model->occupation->templ == 'members') {
$model->scenario = 'genre';
}
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if (isset($_POST['Users'])) {
if ($_POST['member'] == 0) {
$model->name = $_POST['Users']['name'];
Yii::app()->user->name = $model->name;
$model->gender = $_POST['Users']['gender'];
$model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
$model->birth_public = $_POST['Users']['birth_public'];
$model->city_id = $_POST['Users']['city_id'];
$model->email = $_POST['Users']['email'];
$model->about = $_POST['Users']['about'];
$model->phone = $_POST['Users']['phone'];
$model->phone2 = $_POST['Users']['phone2'];
$model->phone3 = $_POST['Users']['phone3'];
if ($model->validate() && $model->save()) {
Yii::app()->user->setFlash('success_save', '1');
$this->redirect(array('index'));
}
/*else {
echo CHtml::errorSummary($model);
//exit();
}*/
}
if ($_POST['member'] == 1) {
//$model->attributes=$_POST['Users'];
if (isset($_POST['Users']['name_studio'])) {
$_POST['Users']['name'] = $_POST['Users']['name_studio'];
//unset($_POST['Users']['name_studio']);
$model->setScenario('studio_update');
}
foreach ($_POST['Users'] as $k => $v) {
if ($k == 'photo') {
if ($v != '') {
$model->photo = CUploadedFile::getInstance($model, 'photo');
}
} elseif ($k == 'url') {
$v = str_replace('http://', '', $v);
$model->{$k} = $v;
} else {
$model->{$k} = $v;
}
}
if (!isset($_POST['Users']['phone2'])) {
$model->phone2 = '';
}
if (!isset($_POST['Users']['phone3'])) {
$model->phone3 = '';
}
if (isset($_POST['year_b'])) {
$model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
}
Yii::app()->user->name = $model->name;
//echo '<pre>';
//print_r($_POST);
//echo '</pre>';
//exit();
if (isset($_POST['Users']['genre_id'])) {
$model->genre_id = serialize($_POST['Users']['genre_id']);
}
if ($model->save()) {
if (isset($_POST['Users']['genre_id'])) {
Yii::import('application.modules.my.models.Portfolio');
Yii::import('application.modules.my.models.Video');
Yii::import('application.modules.my.models.Genre');
$keys = array();
$data = '';
$data = Portfolio::model()->findAllByAttributes(array('uid' => Yii::app()->user->id));
//print_r($data); exit();
if (is_array($data) && !empty($data)) {
//Portfolio::model()->deleteAllByAttributes(array('uid'=>Yii::app()->user->id));
//exit();
foreach ($_POST['Users']['genre_id'] as $genre) {
$item = Portfolio::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'title' => Genre::getName($genre)));
if (count($item) > 0) {
$keys[] = $item->id;
} else {
$mod = new Portfolio();
$mod->title = Genre::getName($genre);
$mod->uid = Yii::app()->user->id;
$mod->save();
$keys[] = $mod->id;
}
}
$del = new Portfolio();
$criteria = new CDbCriteria();
$criteria->condition = 'uid=' . Yii::app()->user->id;
$criteria->addNotInCondition('id', $keys);
$del->deleteAll($criteria);
} else {
foreach ($_POST['Users']['genre_id'] as $genre) {
$mod = new Portfolio();
$mod->title = Genre::getName($genre);
$mod->uid = Yii::app()->user->id;
//.........这里部分代码省略.........
示例12: actionVisible
public function actionVisible($id)
{
$m = $this->loadModel($id);
if ($m->uid == Yii::app()->user->id) {
if ($m->visible == 1) {
$m->visible = 0;
View::model()->deleteAllByAttributes(array('uid' => $m->uid, 'photo' => $m->file));
$cover = Portfolio::model()->findBySql('select id from {{portfolio}} where uid=:uid and picture=:pic', array('uid' => $m->uid, 'pic' => $m->file));
Portfolio::model()->updateByPk($cover->id, array('picture' => ''));
} elseif ($m->visible == 0) {
$m->visible = 1;
}
if ($m->save()) {
$this->redirect($_GET['back']);
}
} else {
throw new CHttpException(404, 'The requested album does not exist.');
}
}
示例13: actionGetphotos
public function actionGetphotos()
{
$portfolio = Portfolio::model()->findAllByAttributes(array('uid' => $_POST['id']));
$this->renderPartial('_photos', array('model' => $this->loadModel($_POST['id']), 'portfolio' => $portfolio));
}
示例14: validatePortfolio
/**
* Validate data from form post
* it's must making before saving into database
* @param mixed $postData
*/
public function validatePortfolio($postData)
{
$arrayPortfolio = array();
foreach ($_POST['FileForm'] as $gallery_idx => $postPortfolio) {
if (empty($postPortfolio['gallery_id'])) {
$portfolio = new Portfolio();
} else {
$portfolio_id = $postPortfolio['gallery_id'];
$portfolio = Portfolio::model()->with('photos')->findByPk($portfolio_id);
if (!isset($portfolio)) {
$portfolio = new Portfolio();
}
}
$portfolio->attributes = $postPortfolio;
//assign attributes
$valOK = $portfolio->validate();
$arrayPhotosIds = array();
//additional array for deleted photos search
$deletedPhotos = array();
//array for deleted photos
$photos = array();
//array of edited photos of portfolio
$isTopPresent = false;
//process photos array
if (isset($postPortfolio['photos'])) {
foreach ($postPortfolio['photos'] as $idx => $postPhoto) {
$photo_id = $postPhoto['photo_id'];
$isNewPhoto = empty($photo_id);
$photo = $isNewPhoto ? new Photo() : Photo::model()->findByPk($photo_id);
if ($isNewPhoto = !isset($photo)) {
$photo = new Photo();
}
$photo->attributes = $postPhoto;
$photo->gallery_id = $portfolio->gallery_id;
$photo->is_top = isset($postPortfolio['is_top']) && $idx == $postPortfolio['is_top'] ? Photo::POSITION_IS_TOP : Photo::POSITION_NO_TOP;
if ($photo->is_top) {
$isTopPresent = true;
}
//mark is_top present
$valOK = $photo->validate() && $valOK;
$arrayPhotosIds[$idx] = $postPhoto['photo_id'];
//add item to search array
$photos[$idx] = $photo;
}
}
//validate photos (count)
if ($postPortfolio['gallery_type'] == 1) {
if (!count($photos)) {
$portfolio->addError('is_top', Yii::t('main', 'Portfolio must have photos'));
} else {
if (!$isTopPresent) {
$portfolio->addError('is_top', Yii::t('main', 'In photo portfolio one of photo must be in top'));
}
}
}
//search for deleted photos
if (isset($portfolio->photos)) {
foreach ($portfolio->photos as $photo) {
if (!in_array($photo->photo_id, $arrayPhotosIds)) {
$portfolio->deletedPhotos[] = $photo;
}
}
}
$portfolio->photos = $photos;
//add photo items to portfolio model
$arrayPortfolio[] = $portfolio;
//add instance of portfolio to returning array
}
return $arrayPortfolio;
//returning result array of portfolio instances
}
示例15: array
echo $form->error($model, 'title');
?>
</div>
<div class="col-6 edit-photo__title"><label for="text1">Описание</label></div>
<div class="col-12 edit-photo__description">
<?php
echo $form->textArea($model, 'description', array('cols' => 30, 'rows' => 3, 'placeholder' => 'Данная информаця будет видна другим авторам и потенциальным клиентам'));
?>
<?php
echo $form->error($model, 'description');
?>
</div>
<div class="col-6 edit-photo__title"><label for="text1">Альбом</label></div>
<div class="col-12 edit-photo__description">
<?php
echo $form->dropDownList($model, 'portfolio_id', CHtml::listData(Portfolio::model()->findAllByAttributes(array('uid' => Yii::app()->user->id)), 'id', 'title'), array('class' => 'default__input', 'empty' => ''));
?>
<?php
echo $form->error($model, 'portfolio_id');
?>
</div>
<div class="col-179">
<?php
echo CHtml::hiddenField('Files[type]', 'photo');
?>
<?php
echo CHtml::hiddenField('Files[uid]', Yii::app()->user->id);
?>
<?php
echo CHtml::submitButton('СОХРАНИТЬ', array('class' => 'cabinet__profile__btn cabinet__profile__btn-submit'));
?>