本文整理汇总了PHP中Vtiger_ListView_Model::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_ListView_Model::getInstance方法的具体用法?PHP Vtiger_ListView_Model::getInstance怎么用?PHP Vtiger_ListView_Model::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vtiger_ListView_Model
的用法示例。
在下文中一共展示了Vtiger_ListView_Model::getInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
function process(Vtiger_Request $request)
{
$branches = $request->get('branches');
$filter = $request->get('filter');
if (empty($branches)) {
return;
}
$moduleName = $request->getModule();
$viewer = $this->getViewer($request);
$baseModuleName = 'Accounts';
$multiReferenceFirld = Vtiger_MultiReferenceValue_UIType::getFieldsByModules($baseModuleName, $moduleName);
if (count($multiReferenceFirld) === 0) {
return;
}
$multiReferenceFirld = reset($multiReferenceFirld);
$searchParams = [['columns' => [['columnname' => $multiReferenceFirld['tablename'] . ':' . $multiReferenceFirld['columnname'] . ':' . $multiReferenceFirld['fieldname'], 'value' => implode(',', $branches), 'column_condition' => '', 'comparator' => 'c']]]];
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('limit', 'no_limit');
$listViewModel = Vtiger_ListView_Model::getInstance($baseModuleName, $filter);
$listViewModel->set('search_key', $multiReferenceFirld['fieldname']);
$listViewModel->set('search_params', $searchParams);
$listEntries = $listViewModel->getListViewEntries($pagingModel, true);
if (count($listEntries) === 0) {
return;
}
$listHeaders = $listViewModel->getListViewHeaders();
$viewer->assign('ENTRIES', $listEntries);
$viewer->assign('HEADERS', $listHeaders);
$viewer->assign('MODULE', $baseModuleName);
$viewer->view('TreeRecords.tpl', $moduleName);
}
示例2: process
function process(Vtiger_Request $request)
{
$branches = $request->get('branches');
$filter = $request->get('filter');
if (empty($branches)) {
return;
}
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$treeViewModel = Vtiger_TreeView_Model::getInstance($moduleModel);
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('limit', 'no_limit');
$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $filter);
$listViewModel->set('search_params', $treeViewModel->getSearchParams($branches));
$listEntries = $listViewModel->getListViewEntries($pagingModel, true);
if (count($listEntries) === 0) {
return;
}
$listHeaders = $listViewModel->getListViewHeaders();
$viewer->assign('ENTRIES', $listEntries);
$viewer->assign('HEADERS', $listHeaders);
$viewer->assign('MODULE', $moduleName);
$viewer->view('TreeRecords.tpl', $moduleName);
}
示例3: getPagination
public function getPagination(Vtiger_Request $request)
{
$viewer = $this->getViewer($request);
$pageNumber = $request->get('page');
$searchResult = $request->get('searchResult');
$moduleName = $request->getModule();
$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
if (empty($pageNumber)) {
$pageNumber = '1';
}
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('page', $pageNumber);
$pagingModel->set('viewid', $request->get('viewname'));
$searchKey = $request->get('search_key');
$searchValue = $request->get('search_value');
$operator = $request->get('operator');
if (!empty($operator)) {
$listViewModel->set('operator', $operator);
$viewer->assign('OPERATOR', $operator);
$viewer->assign('ALPHABET_VALUE', $searchValue);
}
if (!empty($searchKey) && !empty($searchValue)) {
$listViewModel->set('search_key', $searchKey);
$listViewModel->set('search_value', $searchValue);
}
$searchParmams = $request->get('search_params');
if (empty($searchParmams) || !is_array($searchParmams)) {
$searchParmams = [];
}
$transformedSearchParams = $this->transferListSearchParamsToFilterCondition($searchParmams, $listViewModel->getModule());
$listViewModel->set('search_params', $transformedSearchParams);
if (!$this->listViewEntries) {
$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel, $searchResult);
}
if (!$this->listViewCount) {
$this->listViewCount = $listViewModel->getListViewCount();
}
$noOfEntries = count($this->listViewEntries);
$totalCount = $this->listViewCount;
$pageLimit = $pagingModel->getPageLimit();
$pageCount = ceil((int) $totalCount / (int) $pageLimit);
if ($pageCount == 0) {
$pageCount = 1;
}
$viewer->assign('PAGE_COUNT', $pageCount);
$startPaginFrom = $pageNumber - 2;
if ($pageNumber == $totalCount && 1 != $pageNumber) {
$startPaginFrom = $pageNumber - 4;
}
if ($startPaginFrom <= 0 || 1 == $pageNumber) {
$startPaginFrom = 1;
}
$viewer->assign('LISTVIEW_ENTRIES_COUNT', $noOfEntries);
$viewer->assign('PAGE_NUMBER', $pageNumber);
$viewer->assign('LISTVIEW_COUNT', $totalCount);
$viewer->assign('START_PAGIN_FROM', $startPaginFrom);
$viewer->assign('PAGING_MODEL', $pagingModel);
echo $viewer->view('Pagination.tpl', $moduleName, true);
}
示例4: getRecords
private function getRecords()
{
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('limit', 'no_limit');
$listViewModel = Vtiger_ListView_Model::getInstance($this->getModuleName());
$listEntries = $listViewModel->getListViewEntries($pagingModel, true);
$tree = [];
foreach ($listEntries as $item) {
$this->lastTreeId++;
$parent = $item->get('pscategory');
$parent = (int) str_replace('T', '', $parent);
$tree[] = ['id' => $this->lastTreeId, 'record_id' => $item->getId(), 'parent' => $parent == 0 ? '#' : $parent, 'text' => $item->getName(), 'isrecord' => true, 'state' => [], 'icon' => 'glyphicon glyphicon-file'];
}
return $tree;
}
示例5: process
function process(Vtiger_Request $request)
{
$branches = $request->get('branches');
$filter = $request->get('filter');
$category = $request->get('category');
if (empty($branches) && empty($category)) {
return;
}
$moduleName = $request->getModule();
$viewer = $this->getViewer($request);
$baseModuleName = 'Accounts';
$multiReferenceFirld = Vtiger_MultiReferenceValue_UIType::getFieldsByModules($baseModuleName, $moduleName);
$multiReferenceFirld = reset($multiReferenceFirld);
if (count($multiReferenceFirld) === 0) {
return;
}
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('limit', 'no_limit');
$listViewModel = Vtiger_ListView_Model::getInstance($baseModuleName, $filter);
$queryGenerator = $listViewModel->get('query_generator');
$glue = '';
if (!empty($branches)) {
if (count($queryGenerator->getWhereFields()) > 0 && count($searchParams) > 0) {
$glue = QueryGenerator::$AND;
}
$queryGenerator->addCondition($multiReferenceFirld['columnname'], implode(',', $branches), 'c');
}
if (!empty($category)) {
$baseModuleId = Vtiger_Functions::getModuleId($baseModuleName);
$moduleId = Vtiger_Functions::getModuleId($moduleName);
$query = 'SELECT crmid FROM u_yf_crmentity_rel_tree WHERE module = ' . $baseModuleId . ' AND relmodule = ' . $moduleId . ' AND tree IN (\'' . implode("','", $category) . '\')';
if (count($queryGenerator->getWhereFields()) > 0 && count($searchParams) > 0) {
$glue = QueryGenerator::$AND;
}
$queryGenerator->addCondition($multiReferenceFirld['columnname'], $query, 'subQuery', 'OR', true);
}
$listViewModel->set('query_generator', $queryGenerator);
$listEntries = $listViewModel->getListViewEntries($pagingModel, true);
if (count($listEntries) === 0) {
return;
}
$listHeaders = $listViewModel->getListViewHeaders();
$viewer->assign('ENTRIES', $listEntries);
$viewer->assign('HEADERS', $listHeaders);
$viewer->assign('MODULE', $baseModuleName);
$viewer->view('TreeRecords.tpl', $moduleName);
}
示例6: getListViewCount
/**
* Function to get listView count
* @param Vtiger_Request $request
*/
function getListViewCount(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$cvId = $request->get('viewname');
if (empty($cvId)) {
$cvId = '0';
}
$searchKey = $request->get('search_key');
$searchValue = $request->get('search_value');
$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
$searchParmams = $request->get('search_params');
$listViewModel->set('search_params', $this->transferListSearchParamsToFilterCondition($searchParmams, $listViewModel->getModule()));
$listViewModel->set('search_key', $searchKey);
$listViewModel->set('search_value', $searchValue);
$listViewModel->set('operator', $request->get('operator'));
$count = $listViewModel->getListViewCount();
return $count;
}
示例7: getRecordIds
/**
* Function which provides the records for the current view
* @param <Boolean> $skipRecords - List of the RecordIds to be skipped
* @return <Array> List of RecordsIds
*/
public function getRecordIds($skipRecords = false, $module = false)
{
$db = PearDatabase::getInstance();
$cvId = $this->getId();
$moduleModel = $this->getModule();
$moduleName = $moduleModel->get('name');
$baseTableName = $moduleModel->get('basetable');
$baseTableId = $moduleModel->get('basetableid');
$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
$queryGenerator = $listViewModel->get('query_generator');
$searchKey = $this->get('search_key');
$searchValue = $this->get('search_value');
$operator = $this->get('operator');
if (!empty($searchValue)) {
$queryGenerator->addUserSearchConditions(array('search_field' => $searchKey, 'search_text' => $searchValue, 'operator' => $operator));
}
$searchParams = $this->get('search_params');
if (empty($searchParams)) {
$searchParams = array();
}
$transformedSearchParams = Vtiger_Util_Helper::transferListSearchParamsToFilterCondition($searchParams, $moduleModel);
$queryGenerator->parseAdvFilterList($transformedSearchParams);
$listQuery = $queryGenerator->getQuery();
if ($module == 'RecycleBin') {
$listQuery = preg_replace("/vtiger_crmentity.deleted\\s*=\\s*0/i", 'vtiger_crmentity.deleted = 1', $listQuery);
}
if ($skipRecords && !empty($skipRecords) && is_array($skipRecords) && count($skipRecords) > 0) {
$listQuery .= ' AND ' . $baseTableName . '.' . $baseTableId . ' NOT IN (' . implode(',', $skipRecords) . ')';
}
$result = $db->query($listQuery);
$noOfRecords = $db->num_rows($result);
$recordIds = array();
for ($i = 0; $i < $noOfRecords; ++$i) {
$recordIds[] = $db->query_result($result, $i, $baseTableId);
}
return $recordIds;
}
示例8: getChildComments
/**
* Returns child comments models for a comment
* @return ModComment_Record_Model(s)
*/
public function getChildComments()
{
$db = PearDatabase::getInstance();
$parentCommentId = $this->get('modcommentsid');
if (empty($parentCommentId)) {
return;
}
$parentRecordId = $this->get('related_to');
$listView = Vtiger_ListView_Model::getInstance('ModComments');
$queryGenerator = $listView->get('query_generator');
$queryGenerator->setFields(array('parent_comments', 'createdtime', 'modifiedtime', 'related_to', 'id', 'assigned_user_id', 'commentcontent', 'creator', 'reasontoedit', 'userid'));
$query = $queryGenerator->getQuery();
//Condition are directly added as query_generator transforms the
//reference field and searches their entity names
$query = $query . ' AND parent_comments = ? AND related_to = ?';
$recordInstances = array();
$result = $db->pquery($query, array($parentCommentId, $parentRecordId));
$rows = $db->num_rows($result);
for ($i = 0; $i < $rows; $i++) {
$row = $db->query_result_rowdata($result, $i);
$recordInstance = new self();
$recordInstance->setData($row);
$recordInstances[] = $recordInstance;
}
return $recordInstances;
}
示例9: getListViewCount
/**
* Function to get listView count
* @param Vtiger_Request $request
*/
function getListViewCount(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$cvId = $request->get('viewname');
if (empty($cvId)) {
$cvId = '0';
}
$searchKey = $request->get('search_key');
$searchValue = $request->get('search_value');
$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
$listViewModel->set('search_key', $searchKey);
$listViewModel->set('search_value', $searchValue);
$listViewModel->set('operator', $request->get('operator'));
$count = $listViewModel->getListViewCount();
return $count;
}
示例10: initializeListViewContents
public function initializeListViewContents(Vtiger_Request $request, Vtiger_Viewer $viewer)
{
$moduleName = $request->getModule();
$cvId = $request->get('viewname');
$pageNumber = $request->get('page');
$orderBy = $request->get('orderby');
$sortOrder = $request->get('sortorder');
if ($sortOrder == "ASC") {
$nextSortOrder = "DESC";
$sortImage = "icon-chevron-down";
} else {
$nextSortOrder = "ASC";
$sortImage = "icon-chevron-up";
}
if (empty($pageNumber)) {
$pageNumber = '1';
}
$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $cvId);
$linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view'), 'CVID' => $cvId);
$linkModels = $listViewModel->getListViewMassActions($linkParams);
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('page', $pageNumber);
if (!empty($orderBy)) {
$listViewModel->set('orderby', $orderBy);
$listViewModel->set('sortorder', $sortOrder);
}
$searchKey = $request->get('search_key');
$searchValue = $request->get('search_value');
$operator = $request->get('operator');
if (!empty($operator)) {
$listViewModel->set('operator', $operator);
$viewer->assign('OPERATOR', $operator);
$viewer->assign('ALPHABET_VALUE', $searchValue);
}
if (!empty($searchKey) && !empty($searchValue)) {
$listViewModel->set('search_key', $searchKey);
$listViewModel->set('search_value', $searchValue);
}
$listViewModel->set('folder_id', $request->get('folder_id'));
$listViewModel->set('folder_value', $request->get('folder_value'));
if (!$this->listViewHeaders) {
$this->listViewHeaders = $listViewModel->getListViewHeaders();
}
if (!$this->listViewEntries) {
$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
}
$noOfEntries = count($this->listViewEntries);
$viewer->assign('VIEWID', $cvId);
$viewer->assign('MODULE', $moduleName);
if (!$this->listViewLinks) {
$this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
}
$viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);
$viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']);
$viewer->assign('PAGING_MODEL', $pagingModel);
$viewer->assign('PAGE_NUMBER', $pageNumber);
$viewer->assign('ORDER_BY', $orderBy);
$viewer->assign('SORT_ORDER', $sortOrder);
$viewer->assign('NEXT_SORT_ORDER', $nextSortOrder);
$viewer->assign('SORT_IMAGE', $sortImage);
$viewer->assign('COLUMN_NAME', $orderBy);
$viewer->assign('FOLDER_NAME', $request->get('folder_value'));
$viewer->assign('LISTVIEW_ENTIRES_COUNT', $noOfEntries);
$viewer->assign('LISTVIEW_HEADERS', $this->listViewHeaders);
$viewer->assign('LISTVIEW_ENTRIES', $this->listViewEntries);
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false)) {
if (!$this->listViewCount) {
$this->listViewCount = $listViewModel->getListViewCount();
}
$totalCount = $this->listViewCount;
$pageLimit = $pagingModel->getPageLimit();
$pageCount = ceil((int) $totalCount / (int) $pageLimit);
if ($pageCount == 0) {
$pageCount = 1;
}
$viewer->assign('PAGE_COUNT', $pageCount);
$viewer->assign('LISTVIEW_COUNT', $totalCount);
}
$viewer->assign('IS_MODULE_EDITABLE', $listViewModel->getModule()->isPermitted('EditView'));
$viewer->assign('IS_MODULE_DELETABLE', $listViewModel->getModule()->isPermitted('Delete'));
}