本文整理汇总了PHP中Style::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Style::model方法的具体用法?PHP Style::model怎么用?PHP Style::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Style
的用法示例。
在下文中一共展示了Style::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$tags = Style::model()->findStyleWeights($this->limit, $this->singer_id);
foreach ($tags as $tag => $options) {
//$color = '#'.dechex(rand(100, 255)).dechex(rand(0, 200)).dechex(rand(50, 100));
$text = CHtml::encode($tag);
//$id_hidden = CHtml::hiddenField('style_'.$options['id'], $options['id']);
//$content = $link.$id_hidden;
echo CHtml::tag('span', array('id' => $options['id'], 'style' => "font-size:{$options['weight']}pt; color: #2E3CA3; cursor: pointer;"), $text) . "\n";
}
}
示例2: selectBySingerId
public function selectBySingerId($singer_id)
{
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->condition = 'id=:singer_id';
$criteria->params = array(':singer_id' => $singer_id);
$result = Singer::model()->find($criteria);
$image = Image::model()->selectByRow('singer', $singer_id);
$style = Style::model()->selectBySingerId($singer_id);
$result = $result['attributes'];
if ($image) {
$result['path'] = $image->path;
}
if ($style) {
$result['style'] = $style;
}
return $result;
}
示例3: actionGenre
public function actionGenre()
{
// error_log('genre_id ' . Yii::app()->request->getPost('genre'));
Filter::setGenreId(Yii::app()->request->getPost('genre'));
$tagList = '';
if (Filter::getGenreId() != 0) {
$data = Style::model()->selectStyleAllParameters();
$tagList .= CHtml::tag('option', array('value' => $data[Filter::getGenreId()]['style_id'], 'selected' => true), CHtml::encode($data[Filter::getGenreId()]['name']), true) . "\n";
} else {
$data = Style::model()->selectStyle();
//Filter::setStyleId(0);
foreach ($data as $key => $value) {
if (Filter::getStyleId() == $key) {
$tagList .= CHtml::tag('option', array('value' => $key, 'selected' => true), CHtml::encode($value), true) . "\n";
} else {
$tagList .= CHtml::tag('option', array('value' => $key), CHtml::encode($value), true) . "\n";
}
}
$this->responceAjax($tagList);
Yii::app()->end();
/*$nameStyle=$data[0];
echo CHtml::tag('option', array('value'=>0), CHtml::encode($data[0]), true) . "\n";*/
}
//error_log(print_r($data,true));
$name = '';
//echo CHtml::tag('option', array('value'=>0, 'selected'=>true), CHtml::encode('All genre'), true) . "\n";
$nameStyle = $data[Filter::getGenreId()]['name'];
// error_log($nameStyle);
Filter::setStyleId($data[Filter::getGenreId()]['style_id']);
//error_log(Filter::getStyleId());
foreach ($data as $key => $value) {
if ($name == $value['name'] || $nameStyle == $value['name']) {
continue;
}
$tagList .= CHtml::tag('option', array('value' => $value['style_id']), CHtml::encode($value['name']), true) . "\n";
$name = $value['name'];
}
$this->responceAjax($tagList);
}
示例4: findStyleWeights
public function findStyleWeights($limit = 50, $singer_id = false)
{
$tags = array();
//$id = array('0');
$style = Singer_style::model()->selectBySingerId($singer_id);
$id = isset($style) ? $style : array('0');
/*foreach ($style as $i=>$value)
$id[] = $value;*/
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->addNotInCondition('id', $id);
$criteria->order = 'name';
$criteria->limit = $limit;
$models = Style::model()->findAll($criteria);
$sizeRange = 8;
$minCount = log(3 + 1);
//log(Yii::app()->db->createCommand("SELECT MIN(frequency) FROM " . $this->tableName())->queryScalar() + 1);
$maxCount = log(0 + 1);
//log(Yii::app()->db->createCommand("SELECT MAX(frequency) FROM " . $this->tableName())->queryScalar() + 1);
$countRange = $maxCount - $minCount == 0 ? 1 : $maxCount - $minCount;
foreach ($models as $model) {
$tags[$model->name] = array('weight' => round(12 + (log($model->parent_id + 1) - $minCount) * ($sizeRange / $countRange)), 'id' => $model->id);
}
return $tags;
}
示例5: 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 the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Style::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例6: run
public function run()
{
$model = new Singer();
$exist = $model->findByAttributes(array('id' => Yii::app()->request->getPost('singer_id')));
if ($exist) {
$model = $exist;
$row_id = $model->id;
} else {
$model->name = Yii::app()->request->getPost('name') ? Yii::app()->request->getPost('name') : 'noname';
$model->user_id = Yii::app()->user->getId();
if (!($row_id = $model->Add())) {
echo CJSON::encode(array('status' => 'error'));
Yii::app()->end();
}
}
switch (Yii::app()->request->getPost('object')) {
//редагуєм текстові поля
case 'name':
$this->edit_element($model, 'name', Yii::app()->request->getPost('name'));
break;
case 'description':
$this->edit_element($model, 'description', Yii::app()->request->getPost('description'));
break;
case 'site':
$this->edit_element($model, 'site', Yii::app()->request->getPost('site'));
break;
}
if (Yii::app()->request->getPost('object') == 'poster') {
//редагуєм постер
$poster = new Image();
$exist = $poster->findByAttributes(array('table' => 'singer', 'row_id' => $row_id));
if ($exist) {
$poster = $exist;
$new = false;
} else {
$new = true;
}
$poster->image = CUploadedFile::getInstance($poster, 'image');
$poster->table = 'singer';
$poster->type_id = '3';
$poster->row_id = $row_id;
if ($image_name = $poster->Add($new)) {
echo CJSON::encode(array('part' => CHtml::image('/images/singer/' . $image_name, 'постер', array('class' => 'singer_poster_image', 'title' => "Постер Друга ріка")), 'status' => 'success', 'singer_id' => $row_id));
Yii::app()->end();
} else {
echo CJSON::encode(array('part' => CHtml::textField('ERROR', ''), 'status' => $status));
Yii::app()->end();
}
}
if (Yii::app()->request->getPost('object') == 'style') {
//редагуєм стилі
$style_id = explode(',', Yii::app()->request->getPost('id'));
$exist = Singer_style::model()->selectBySingerId($model->id);
$parent = Style::model()->getNewParent($style_id, $exist);
//error_log(var_export($parent,1));
if ($parent) {
foreach ($parent as $key => $id) {
if (!in_array($id, $style_id)) {
$style_id[] = $id;
}
}
}
foreach ($style_id as $i => $id) {
if (in_array($id, $exist)) {
unset($style_id[$id]);
continue;
}
$style[$i] = new Singer_style();
$style[$i]->singer_id = $model->id;
$style[$i]->style_id = $id;
}
if (isset($style)) {
$transaction = Yii::app()->db->beginTransaction();
try {
foreach ($style as $i => $item) {
$item->save(false);
}
$transaction->commit();
} catch (Exception $e) {
$transaction->rollback();
echo CJSON::encode(array('status' => 'error'));
Yii::app()->end();
}
}
echo CJSON::encode(array('status' => 'success', 'singer_id' => $row_id));
Yii::app()->end();
}
}