-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfulltext.php
102 lines (84 loc) · 2.92 KB
/
fulltext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
@ini_set("display_errors","1");
@ini_set("display_startup_errors","1");
require_once("include/dbcommon.php");
require_once("classes/searchclause.php");
require_once("classes/controls/ViewControl.php");
require_once("classes/controls/ViewControlsContainer.php");
$mode = postvalue("mode");
$shortTable = postvalue("table");
$field = postvalue("field");
$pageType = postvalue('pagetype');
$pageName = postvalue('page');
$mainTable = postvalue("maintable");
$mainField = postvalue("mainfield");
$lookup = false;
if($mainTable && $mainField) {
$lookup = true;
}
$table = GetTableByShort( $shortTable );
if( !$table )
exit(0);
/* TODO: add exception for List page fields from Lookup:list page with search on the Register page */
if( !Security::userHasFieldPermissions( $table, $field, $pageType, $pageName, false ) )
return;
$pSet = new ProjectSettings( $table , $pageType, $pageName );
$cipherer = new RunnerCipherer( $table, $pSet);
$_connection = $cman->byTable( $table );
/*
$gQuery = $pSet->getSQLQuery();
if(!$gQuery->HasGroupBy())
{
// Do not select any fields except current (full text) field.
// If query has 'group by' clause then other fields are used in it and we may not simply cut 'em off.
// Just don't do anything in that case.
$gQuery->RemoveAllFieldsExcept($pSet->getFieldIndex($field));
}
*/
$keysArr = $pSet->getTableKeys();
$keys = array();
foreach ($keysArr as $ind=>$k)
$keys[$k] = postvalue("key".($ind+1));
$dc = new DsCommand();
$dc->filter = Security::SelectCondition( "S", $pSet );
$dc->keys = $keys;
$dataSource = getDataSource( $table, $pSet, $_connection );
$qResult = $dataSource->getSingle( $dc );
if(!$qResult || !($data = $cipherer->DecryptFetchedArray( $qResult->fetchAssoc() )))
{
$returnJSON = array("success"=>false, "error"=>'Error: Wrong SQL query');
echo printJSON($returnJSON);
return;
}
$fieldValue = $data[$field];
$sessionPrefix = $pSet->getOriginalTableName();
if ( $mode == LIST_DASHBOARD )
{
//set the session prefix for the dashboard list page
$sessionPrefix = "Dashboard_".$pSet->getOriginalTableName();
}
if($lookup)
{
//set the session prefix for the lookup list page
$sessionPrefix = $pSet->getOriginalTableName()."_lookup_".$mainTable.'_'.$mainField;
}
$searchClauseObj = SearchClause::UnserializeObject($_SESSION[$sessionPrefix."_advsearch"]);
$container = new ViewControlsContainer($pSet, PAGE_LIST, null);
$cViewControl = $container->getControl($field);
if($cViewControl->localControlsContainer && !$cViewControl->linkAndDisplaySame)
$cViewControl->localControlsContainer->fullText = true;
else
$cViewControl->container->fullText = true;
if($searchClauseObj)
{
if($searchClauseObj->bIsUsedSrch || $useViewControl)
{
$cViewControl->searchClauseObj = $searchClauseObj;
$cViewControl->searchHighlight = true;
}
}
$htmlEncodedValue = $cViewControl->showDBValue($data, "");
$returnJSON = array("success"=>true, "textCont"=>$htmlEncodedValue);
echo printJSON($returnJSON);
return;
?>