本文整理汇总了PHP中Preferences::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Preferences::model方法的具体用法?PHP Preferences::model怎么用?PHP Preferences::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preferences
的用法示例。
在下文中一共展示了Preferences::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSearchSample
public function actionSearchSample()
{
$id = CommonTools::getBiobankInfo();
if (Yii::app()->user->isGuest) {
$this->redirect(array('login', 'id' => $id));
}
$model = new Sample('search');
$model->unsetAttributes();
$model->biobank_id = $id;
$prefs = Preferences::model()->findByAttributes(array('id_user' => Yii::app()->user->id));
if ($prefs == null) {
$prefs = new Preferences();
$prefs->id_user = Yii::app()->user->id;
$prefs->save();
}
if (isset($_GET['Preferences'])) {
$prefs->attributes = $_GET['Preferences'];
$prefs->save();
}
if (isset($_GET['Sample'])) {
$model->attributes = $_GET['Sample'];
$content = '';
foreach ($_GET['Sample'] as $key => $value) {
if ($value != null && !empty($value) && (string) $value != '0') {
$content = $content . (string) $key . '=' . str_replace(';', ',', (string) $value) . ';';
}
}
if (Yii::app()->session['SampleForm'] != $_GET['Sample']) {
$_GET['Echantillon_page'] = null;
}
Yii::app()->session['SampleForm'] = $_GET['Sample'];
}
//form de la recherche intelligente
$smartForm = new SampleSmartForm();
if (isset($_POST['SampleSmartForm'])) {
$model->unsetAttributes();
$model->biobank_id = $id;
$smartForm->attributes = $_POST['SampleSmartForm'];
if (Yii::app()->session['keywords'] != $smartForm->keywords) {
$_GET['Echantillon_page'] = null;
}
Yii::app()->session['keywords'] = $smartForm->keywords;
$model = SmartResearcherTool::search($smartForm->keywords, $id);
}
$this->render('search_samples', array('model' => $model, 'smartForm' => $smartForm));
}
示例2: Preferences
<?php
$prefs = Preferences::model()->findByAttributes(array('id_user' => Yii::app()->user->id));
if ($prefs == null) {
$prefs = new Preferences();
$prefs->id_user = Yii::app()->user->id;
$prefs->save();
}
$prefsNames = Preferences::model()->attributeNames();
$scriptCB = '';
foreach ($prefsNames as $property) {
if ($property != 'id_user') {
$scriptCB = $scriptCB . '$(\'#Preferences_' . $property . '\').change(function(){
$(\'.col_' . $property . '\').toggle();
$(\'.prefs-form form\').submit();
return false;
});
';
}
}
// recharge le tableau d'affichage des échantillons après envoi du formulaire de recherche avancée
Yii::app()->clientScript->registerScript('search', "\n\$('.smart-search-form form').submit(function(){\n\t\$('#sample-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\n\treturn false;\n});\n\$('.prefs-form form').submit(function(){\n\t\$('#sample-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\t\t\n\treturn false;\n});\n{$scriptCB};\n");
?>
<h1><?php
echo Yii::t('common', 'searchsamples');
?>
</h1>
<div style="margin: 5px;"><?php
echo Yii::t('common', 'totalnumbersamples');