CoolFace
Apppublic

kenken999/php

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