本文整理汇总了PHP中Sample::setArrayOfBiobanks方法的典型用法代码示例。如果您正苦于以下问题:PHP Sample::setArrayOfBiobanks方法的具体用法?PHP Sample::setArrayOfBiobanks怎么用?PHP Sample::setArrayOfBiobanks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sample
的用法示例。
在下文中一共展示了Sample::setArrayOfBiobanks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSearch
/**
* affichage de la page de recherche des echantillons
*/
public function actionSearch()
{
$model = new Sample('search');
$model->unsetAttributes();
$biobankId = null;
if (isset($_GET['id']) && isset($_GET['layout']) && $_GET['layout'] == 'vitrine_layout') {
$biobankId = $_GET['id'];
}
$model->biobank_id = $biobankId;
$user = CommonTools::getConnectedUser();
if (isset($_GET['Preferences'])) {
$user->preferences->attributes = $_GET['Preferences'];
$user->disableBehavior('LoggableBehavior');
if ($user->validate(array('preferences'))) {
$user->save(false);
} else {
var_dump($user->preferences->errors);
}
}
if (isset($_GET['Sample'])) {
$model->attributes = $_GET['Sample'];
//Used to search terms in model->biobank->collection_id and model->biobank->collection_name
$arrayOfBiobanks = array();
if (!empty($_GET['collection_id'])) {
$criteria = new EMongoCriteria();
$listWords = explode(",", $_GET['collection_id']);
$regexId = "";
foreach ($listWords as $word) {
$regexId .= "{$word}|";
}
$regexId = substr($regexId, 0, -1);
$criteria->addCond('collection_id', '==', new MongoRegex("/({$regexId})/i"));
$criteria->select(array('_id'));
$biobanks = Biobank::model()->findAll($criteria);
foreach ($biobanks as $biobank) {
$arrayOfBiobanks[(string) $biobank->_id] = (string) $biobank->_id;
}
}
if (!empty($_GET['collection_name'])) {
$criteria = new EMongoCriteria();
$listWords = explode(",", $_GET['collection_name']);
$regexId = "";
foreach ($listWords as $word) {
$regexId .= "{$word}|";
}
$regexId = substr($regexId, 0, -1);
$criteria->addCond('collection_name', '==', new MongoRegex("/({$regexId})/i"));
$criteria->select(array('_id'));
$biobanks = Biobank::model()->findAll($criteria);
foreach ($biobanks as $biobank) {
$arrayOfBiobanks[$biobank->_id] = (string) $biobank->_id;
}
}
if (!empty($arrayOfBiobanks)) {
// $model->arrayOfBiobanks;
$model->setArrayOfBiobanks(array_values($arrayOfBiobanks));
}
$content = '';
foreach ($_GET['Sample'] as $key => $value) {
if (is_array($value)) {
foreach ($value as $vkey => $vval) {
$content = $content . (string) $vkey . '=' . str_replace(';', ',', (string) $vval) . ';';
}
} else {
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;
$this->logAdvancedSearch($content);
}
Yii::app()->session['SampleForm'] = $_GET['Sample'];
}
//form de la recherche intelligente
$smartForm = new SampleSmartForm();
if (isset($_POST['SampleSmartForm'])) {
$model->unsetAttributes();
$smartForm->attributes = $_POST['SampleSmartForm'];
if (Yii::app()->session['keywords'] != $smartForm->keywords) {
$_GET['Echantillon_page'] = null;
$this->logSmartSearch($smartForm->keywords);
}
Yii::app()->session['keywords'] = $smartForm->keywords;
$model = SmartResearcherTool::search($smartForm->keywords, $biobankId);
}
$this->render('search_samples', array('model' => $model, 'smartForm' => $smartForm));
}