本文整理汇总了PHP中SearchForm::populateFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm::populateFromArray方法的具体用法?PHP SearchForm::populateFromArray怎么用?PHP SearchForm::populateFromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchForm
的用法示例。
在下文中一共展示了SearchForm::populateFromArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGeneratedWhereClauseDoesNotHaveValueOfFieldNotSetInSearchForm
/**
* @ticket 44858
*/
public function testGeneratedWhereClauseDoesNotHaveValueOfFieldNotSetInSearchForm()
{
//test to check that if value of a dropdown field is already set in REQUEST object (from any form such as mass update form instead of search form)
//i.e. search is made on empty string, but REQUEST object gets value of that dropdown field from some other form on the same page
//then on clicking serach button, value of that field should not be used as filter in where clause
$this->markTestIncomplete('This test should actually check that the $whereArray is indeed populated');
return;
//array to simulate REQUEST object
$requestArray['module'] = 'Accounts';
$requestArray['action'] = 'index';
$requestArray['searchFormTab'] = 'basic_search';
$requestArray['account_type'] = 'Analyst';
//value of a dropdown field set in REQUEST object
$requestArray['query'] = 'true';
$requestArray['button'] = 'Search';
$requestArray['globalLinksOpen'] = 'true';
$requestArray['current_user_only_basic'] = 0;
$account = SugarTestAccountUtilities::createAccount();
$searchForm = new SearchForm($account, 'Accounts');
require 'modules/Accounts/vardefs.php';
require 'modules/Accounts/metadata/SearchFields.php';
require 'modules/Accounts/metadata/searchdefs.php';
$searchForm->searchFields = $searchFields[$searchForm->module];
$searchForm->searchdefs = $searchdefs[$searchForm->module];
$searchForm->populateFromArray($requestArray, 'basic_search', false);
$whereArray = $searchForm->generateSearchWhere(true, $account->module_dir);
//echo var_export($whereArray, true);
$this->assertEquals(0, count($whereArray));
}
示例2: display
//.........这里部分代码省略.........
}
}
$lv->displayColumns = $displayColumns;
$this->seed = $seed;
$this->module = $module;
$searchForm = null;
$storeQuery = new StoreQuery();
if (!isset($_REQUEST['query'])) {
$storeQuery->loadQuery($this->module);
$storeQuery->populateRequest();
} else {
$storeQuery->saveFromRequest($this->module);
}
//search
$view = 'basic_search';
if (!empty($_REQUEST['search_form_view'])) {
$view = $_REQUEST['search_form_view'];
}
$headers = true;
if (!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) {
$headers = false;
} elseif (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
$view = 'advanced_search';
} else {
$view = 'basic_search';
}
}
$use_old_search = true;
if (file_exists('modules/' . $this->module . '/SearchForm.html')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($this->module, $this->seed);
} else {
$use_old_search = false;
require_once 'include/SearchForm/SearchForm2.php';
if (file_exists('custom/modules/' . $this->module . '/metadata/searchdefs.php')) {
require_once 'custom/modules/' . $this->module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$this->module]['searchdefs'])) {
require_once $metafiles[$this->module]['searchdefs'];
} elseif (file_exists('modules/' . $this->module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $this->module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$this->module]['searchfields'])) {
require_once $metafiles[$this->module]['searchfields'];
} elseif (file_exists('modules/' . $this->module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $this->module . '/metadata/SearchFields.php';
}
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
$searchForm->lv = $lv;
}
if (isset($this->options['show_title']) && $this->options['show_title']) {
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
}
$where = '';
if (isset($_REQUEST['query'])) {
// we have a query
if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) {
// from EditView cancel
$searchForm->populateFromArray($storeQuery->query);
} else {
$searchForm->populateFromRequest();
}
$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("List View Where Clause: {$where}");
}
if ($use_old_search) {
switch ($view) {
case 'basic_search':
$searchForm->setup();
$searchForm->displayBasic($headers);
break;
case 'advanced_search':
$searchForm->setup();
$searchForm->displayAdvanced($headers);
break;
case 'saved_views':
echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
break;
}
} else {
echo $searchForm->display($headers);
}
if (!$headers) {
return;
}
if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
if (!is_admin($current_user)) {
$lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
} else {
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
}
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name'];
echo $lv->display();
}
}
示例3: generateSearchWhere
function generateSearchWhere($module, $query)
{
//this function is similar with function prepareSearchForm() in view.list.php
$seed = loadBean($module);
$this->use_old_search = true;
if (file_exists('modules/' . $module . '/SearchForm.html')) {
if (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($module, $seed);
} elseif (!empty($_SESSION['export_where'])) {
//bug 26026, sometimes some module doesn't have a metadata/SearchFields.php, the searchfrom is generated in the ListView.php.
//So currently massupdate will not gernerate the where sql. It will use the sql stored in the SESSION. But this will cause bug 24722, and it cannot be avoided now.
$where = $_SESSION['export_where'];
$whereArr = explode(" ", trim($where));
if ($whereArr[0] == trim('where')) {
$whereClean = array_shift($whereArr);
}
$this->where_clauses = implode(" ", $whereArr);
return;
} else {
$this->where_clauses = '';
return;
}
} else {
$this->use_old_search = false;
require_once 'include/SearchForm/SearchForm2.php';
if (file_exists('custom/modules/' . $module . '/metadata/metafiles.php')) {
require 'custom/modules/' . $module . '/metadata/metafiles.php';
} elseif (file_exists('modules/' . $module . '/metadata/metafiles.php')) {
require 'modules/' . $module . '/metadata/metafiles.php';
}
if (file_exists('custom/modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'custom/modules/' . $module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$module]['searchdefs'])) {
require_once $metafiles[$module]['searchdefs'];
} elseif (file_exists('modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$module]['searchfields'])) {
require_once $metafiles[$module]['searchfields'];
} elseif (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $module . '/metadata/SearchFields.php';
}
if (empty($searchdefs) || empty($searchFields)) {
$this->where_clauses = '';
//for some modules, such as iframe, it has massupdate, but it doesn't have search function, the where sql should be empty.
return;
}
$searchForm = new SearchForm($seed, $module);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl');
}
/* bug 31271: using false to not add all bean fields since some beans - like SavedReports
can have fields named 'module' etc. which may break the query */
$searchForm->populateFromArray(unserialize(base64_decode($query)), null, true);
// see bug 31271
$this->searchFields = $searchForm->searchFields;
$where_clauses = $searchForm->generateSearchWhere(true, $module);
if (count($where_clauses) > 0) {
$this->where_clauses = '(' . implode(' ) AND ( ', $where_clauses) . ')';
$GLOBALS['log']->info("MassUpdate Where Clause: {$this->where_clauses}");
} else {
$this->where_clauses = '';
}
}
示例4: generateSearchWhere
function generateSearchWhere($module, $query)
{
//this function is similar with function prepareSearchForm() in view.list.php
$seed = loadBean($module);
if (file_exists('modules/' . $module . '/SearchForm.html')) {
if (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($module, $seed);
} elseif (!empty($_SESSION['export_where'])) {
//bug 26026, sometimes some module doesn't have a metadata/SearchFields.php, the searchfrom is generated in the ListView.php.
//So currently massupdate will not gernerate the where sql. It will use the sql stored in the SESSION. But this will cause bug 24722, and it cannot be avoided now.
$where = $_SESSION['export_where'];
$whereArr = explode(" ", trim($where));
if ($whereArr[0] == trim('where')) {
$whereClean = array_shift($whereArr);
}
$where = implode(" ", $whereArr);
//rrs bug: 31329 - previously this was just returning $where, but the problem is the caller of this function
//expects the results in an array, not just a string. So rather than fixing the caller, I felt it would be best for
//the function to return the results in a standard format.
$ret_array['where'] = $where;
$ret_array['searchFields'] = array();
return $ret_array;
} else {
return;
}
} else {
require_once 'include/SearchForm/SearchForm2.php';
if (file_exists('custom/modules/' . $module . '/metadata/metafiles.php')) {
require 'custom/modules/' . $module . '/metadata/metafiles.php';
} elseif (file_exists('modules/' . $module . '/metadata/metafiles.php')) {
require 'modules/' . $module . '/metadata/metafiles.php';
}
if (file_exists('custom/modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'custom/modules/' . $module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$module]['searchdefs'])) {
require_once $metafiles[$module]['searchdefs'];
} elseif (file_exists('modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$module]['searchfields'])) {
require_once $metafiles[$module]['searchfields'];
} elseif (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $module . '/metadata/SearchFields.php';
}
if (empty($searchdefs) || empty($searchFields)) {
//for some modules, such as iframe, it has massupdate, but it doesn't have search function, the where sql should be empty.
return;
}
$searchForm = new SearchForm($seed, $module);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl');
}
$searchForm->populateFromArray(unserialize(base64_decode($query)));
$where_clauses = $searchForm->generateSearchWhere(true, $module);
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("Export Where Clause: {$where}");
$ret_array['where'] = $where;
$ret_array['searchFields'] = $searchForm->searchFields;
return $ret_array;
}
示例5: elseif
if (file_exists('custom/modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'custom/modules/' . $module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$module]['searchdefs'])) {
require_once $metafiles[$module]['searchdefs'];
} elseif (file_exists('modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$module]['searchfields'])) {
require_once $metafiles[$module]['searchfields'];
} elseif (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $module . '/metadata/SearchFields.php';
}
if (!empty($searchdefs) && !empty($searchFields)) {
$searchForm = new SearchForm($seed, $module);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl');
$searchForm->populateFromArray($current_query_by_page_array, 'advanced');
$where_clauses_arr = $searchForm->generateSearchWhere(true, $module);
if (count($where_clauses_arr) > 0) {
$where_clauses = '(' . implode(' ) AND ( ', $where_clauses_arr) . ')';
}
}
$ret_array = create_export_query_relate_link_patch($module, $searchFields, $where_clauses);
$query = $seed->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
$result = $GLOBALS['db']->query($query, true);
$uids = array();
while ($val = $GLOBALS['db']->fetchByAssoc($result, -1, false)) {
array_push($uids, $val['id']);
}
$_REQUEST['subpanel_id'] = $uids;
}
if ($bean_name == 'Team') {
示例6: implode
echo $searchForm->displaySavedViews($listViewDefs, $lv, false);
break;
}
return;
}
// use the stored query if there is one
if (!isset($where)) {
$where = "";
}
if (isset($_REQUEST['query'])) {
// we have a query
// first save columns
$current_user->setPreference('ListViewDisplayColumns', $displayColumns, 0, 'Users');
if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) {
// from EditView cancel
$searchForm->populateFromArray($storeQuery->query);
} else {
$searchForm->populateFromRequest();
}
$where_clauses = $searchForm->generateSearchWhere(true, "Users");
// builds the where clause from search field inputs
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("Here is the where clause for the list view: {$where}");
}
// start display
// which tab of search form to display
if (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
$searchForm->setup();
if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
示例7: display
//.........这里部分代码省略.........
$storeQuery->saveFromRequest($this->module);
}
//search
$view = 'basic_search';
if (!empty($_REQUEST['search_form_view'])) {
$view = $_REQUEST['search_form_view'];
}
$headers = true;
if (!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) {
$headers = false;
} elseif (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
$view = 'advanced_search';
} else {
$view = 'basic_search';
}
}
$use_old_search = true;
if (SugarAutoLoader::existing('modules/' . $this->module . '/SearchForm.html')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($this->module, $this->seed);
} else {
$use_old_search = false;
require_once 'include/SearchForm/SearchForm2.php';
$defs = SugarAutoLoader::loadWithMetafiles($this->module, 'searchdefs');
if (!empty($defs)) {
require $defs;
}
$searchFields = SugarAutoLoader::loadSearchFields($this->module);
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
$searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl', $view, $listViewDefs);
$searchForm->lv = $lv;
}
if (isset($this->options['show_title']) && $this->options['show_title']) {
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
}
$where = '';
if (isset($_REQUEST['query'])) {
// we have a query
if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) {
// from EditView cancel
$searchForm->populateFromArray($storeQuery->query);
} else {
$searchForm->populateFromRequest();
}
$where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("List View Where Clause: {$where}");
}
if ($use_old_search) {
switch ($view) {
case 'basic_search':
$searchForm->setup();
$searchForm->displayBasic($headers);
break;
case 'advanced_search':
$searchForm->setup();
$searchForm->displayAdvanced($headers);
break;
case 'saved_views':
echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
break;
}
} else {
echo $searchForm->display($headers);
}
if (!$headers) {
return;
}
/*
* Bug 50575 - related search columns not inluded in query in a proper way
*/
$lv->searchColumns = $searchForm->searchColumns;
if (isset($GLOBALS['mod_strings']['LBL_MODULE_NAME_SINGULAR'])) {
$seed->module_title = $GLOBALS['mod_strings']['LBL_MODULE_NAME_SINGULAR'];
}
if (isset($GLOBALS['mod_strings']['LBL_LIST_PARENT_NAME'])) {
$seed->parent_title = $GLOBALS['mod_strings']['LBL_LIST_PARENT_NAME'];
$seed->parent_module_dir = 'Project';
}
$project = BeanFactory::getBean('Project');
$project_query = new SugarQuery();
$project_query->from($project);
$project_list = $project->fetchFromQuery($project_query);
if (count($project_list)) {
$seed->show_link = true;
}
if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
//Bug 58841 - mass update form was not displayed for non-admin users that should have access
if (ACLController::checkAccess($module, 'massupdate') || ACLController::checkAccess($module, 'export')) {
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
} else {
$lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
}
echo $lv->display();
}
}