예제 #1
0
 function LookupTextField($field, $pageObject, $id, $connection)
 {
     parent::EditControl($field, $pageObject, $id, $connection);
     $this->format = EDIT_FORMAT_LOOKUP_WIZARD;
     $this->lookupPageType = $this->pageObject->pSetEdit->getPageTypeByFieldEditFormat($this->field, EDIT_FORMAT_LOOKUP_WIZARD);
     $this->localPSet = new ProjectSettings($this->pageObject->tName, $this->lookupPageType);
     $this->lookupTable = $this->localPSet->getLookupTable($this->field);
     $this->lookupType = $this->localPSet->getLookupType($this->field);
     if ($this->lookupType == LT_QUERY) {
         $this->lookupPSet = new ProjectSettings($this->lookupTable);
     }
     $this->displayFieldName = $this->localPSet->getDisplayField($this->field);
     $this->linkFieldName = $this->localPSet->getLinkField($this->field);
     $this->linkAndDisplaySame = $this->displayFieldName == $this->linkFieldName;
     $this->ciphererLink = new RunnerCipherer($this->pageObject->tName);
     if ($this->lookupType == LT_QUERY) {
         $this->ciphererDisplay = new RunnerCipherer($this->lookupTable);
     } else {
         $this->ciphererDisplay = $this->ciphererLink;
     }
     $this->LCType = $this->localPSet->lookupControlType($this->field);
     $this->multiselect = $this->localPSet->multiSelect($this->field);
     $this->lwLinkField = $connection->addFieldWrappers($this->localPSet->getLinkField($this->field));
     $this->lwDisplayFieldWrapped = RunnerPage::sqlFormattedDisplayField($this->field, $connection, $this->localPSet);
     $this->customDisplay = $this->localPSet->getCustomDisplay($this->field);
 }
 public function ViewLookupWizardField($field, $container, $pageObject)
 {
     parent::ViewControl($field, $container, $pageObject);
     $this->lookupPSet = null;
     $this->cipherer = null;
     $this->lookupQueryObj = null;
     $this->displayFieldIndex = 0;
     $this->linkFieldIndex = 1;
     $this->LookupSQL = "";
     if ($this->container->pSet->getEditFormat($field) != EDIT_FORMAT_LOOKUP_WIZARD) {
         $this->pSet = new ProjectSettings($this->container->pSet->_table);
         //	set view page
         $this->pSet->setPage($this->container->pageType);
         //	set edit page
         $this->pSet->setPage($this->container->pSet->getPageTypeByFieldEditFormat($field, EDIT_FORMAT_LOOKUP_WIZARD));
     } else {
         $this->pSet = $this->container->pSet;
     }
     $this->nLookupType = $this->pSet->getLookupType($this->field);
     $this->lookupTable = $this->pSet->getLookupTable($this->field);
     $this->setLookupConnection();
     $this->displayFieldName = $this->pSet->getDisplayField($this->field);
     $this->linkFieldName = $this->pSet->getLinkField($this->field);
     $this->linkAndDisplaySame = $this->displayFieldName == $this->linkFieldName;
     if ($this->nLookupType == LT_QUERY) {
         $this->lookupPSet = new ProjectSettings($this->lookupTable, $this->container->pageType);
         $this->cipherer = new RunnerCipherer($this->lookupTable);
         $this->lookupQueryObj = $this->lookupPSet->getSQLQuery()->CloneObject();
         if ($this->pSet->getCustomDisplay($this->field)) {
             $this->lookupQueryObj->AddCustomExpression($this->displayFieldName, $this->lookupPSet, $this->pSet->_table, $this->field);
         }
         $this->lookupQueryObj->ReplaceFieldsWithDummies($this->lookupPSet->getBinaryFieldsIndices());
         $lookupIndexes = GetLookupFieldsIndexes($this->pSet, $this->field);
         $this->displayFieldIndex = $lookupIndexes["displayFieldIndex"];
         $this->linkFieldIndex = $lookupIndexes["linkFieldIndex"];
     } else {
         $this->cipherer = new RunnerCipherer($this->pSet->_table);
         $this->LookupSQL = "SELECT ";
         $this->LookupSQL .= RunnerPage::sqlFormattedDisplayField($this->field, $this->lookupConnection, $this->pSet);
         $this->LookupSQL .= ", " . $this->lookupConnection->addFieldWrappers($this->pSet->getLinkField($this->field));
         $this->LookupSQL .= " FROM " . $this->lookupConnection->addTableWrappers($this->lookupTable) . " WHERE ";
     }
     $this->localControlsContainer = new ViewControlsContainer($this->pSet, $this->container->pageType, $pageObject);
     $this->localControlsContainer->isLocal = true;
 }
예제 #3
0
 }
 $lookupField = $f;
 $LookupType = $gSettings->getLookupType($f);
 if ($LookupType == LT_LOOKUPTABLE || $LookupType == LT_QUERY) {
     $lookupTable = $gSettings->getLookupTable($f);
     if ($LookupType == LT_QUERY) {
         $lookupConnection = $cman->byTable($lookupTable);
     } else {
         $connId = $gSettings->getNotProjectLookupTableConnId($f);
         $lookupConnection = strlen($connId) ? $cman->byId($connId) : $cman->getDefault();
     }
     $linkFieldName = $gSettings->getLinkField($f);
     $displayFieldName = $gSettings->getDisplayField($f);
     $linkAndDisplaySame = $displayFieldName == $linkFieldName;
     $lookupOrderBy = $gSettings->getLookupOrderBy($f);
     $lwDisplayField = RunnerPage::sqlFormattedDisplayField($f, $lookupConnection, $gSettings);
     if ($lookupConnection->dbType == nDATABASE_MSSQLServer) {
         $strUniqueOrderBy = $lookupOrderBy;
     }
     if ($LookupType == LT_QUERY) {
         $lookupPSet = new ProjectSettings($lookupTable, $pageType);
         $lookupCipherer = new RunnerCipherer($lookupTable);
         $lookupQueryObj = $lookupPSet->getSQLQuery();
         if ($gSettings->getCustomDisplay($f)) {
             $lookupQueryObj->AddCustomExpression($displayFieldName, $lookupPSet, $strTableName, $f);
         }
         $lookupQueryObj->ReplaceFieldsWithDummies($lookupPSet->getBinaryFieldsIndices());
     } else {
         $LookupSQLTable = "SELECT ";
         $lwLinkField = $lookupConnection->addFieldWrappers($gSettings->getLinkField($f));
         if ($gSettings->isLookupUnique($f)) {
예제 #4
0
 /**
  * Get the lookup SQL Query string
  *
  * @param String parentValue
  * @param String childVal
  * @param Boolean doCategoryFilter (optional)
  * @param Boolean doValueFilter (optional)
  * @param Boolean addCategoryField (optional)
  * @param Boolean doWhereFilter (optional)
  * @param Boolean oneRecordMode (optional)
  * @return String	
  */
 protected function getLookupSQL($parentVal, $childVal = "", $doCategoryFilter = true, $doValueFilter = false, $addCategoryField = false, $doWhereFilter = true, $oneRecordMode = false)
 {
     if ($this->lookupType != LT_LOOKUPTABLE && $this->lookupType != LT_QUERY) {
         return "";
     }
     $pSet = $this->pageObject->pSetEdit;
     $strCategoryFilter = $pSet->getCategoryFilter($this->field);
     // build Order By clause
     $strOrderBy = $pSet->getLookupOrderBy($this->field);
     if ($this->lookupConnection->dbType == nDATABASE_MSSQLServer) {
         $strUniqueOrderBy = $strOrderBy;
     }
     if (strlen($strOrderBy)) {
         if ($this->lookupType == LT_QUERY) {
             $strOrderBy = RunnerPage::_getFieldSQLDecrypt($strOrderBy, $this->lookupConnection, $this->lookupPSet, $this->ciphererDisplay);
         } else {
             $strOrderBy = $this->lookupConnection->addFieldWrappers($strOrderBy);
         }
         if ($pSet->isLookupDesc($this->field)) {
             $strOrderBy .= ' DESC';
         }
     }
     // build Where clause
     $lookupWhere = $doWhereFilter ? $this->getLookupWhere() : "";
     $categoryWhere = $doCategoryFilter ? $this->getCategoryWhere($parentVal, $strCategoryFilter) : "";
     $childWhere = $doValueFilter ? $this->getChildWhere($childVal) : "";
     $strWhere = combineSQLCriteria(array($lookupWhere, $categoryWhere, $childWhere));
     if ($this->lookupConnection->dbType == nDATABASE_Oracle) {
         if ($oneRecordMode) {
             $strWhere = whereAdd($strWhere, "rownum < 2");
         }
     }
     // build SQL string
     if ($this->lookupType == LT_QUERY) {
         $lookupQueryObj = $this->lookupPSet->getSQLQuery();
         if ($this->customDisplay) {
             $lookupQueryObj->AddCustomExpression($this->displayFieldName, $this->lookupPSet, $this->tName, $this->field);
         }
         $lookupQueryObj->ReplaceFieldsWithDummies($this->lookupPSet->getBinaryFieldsIndices());
         $strWhere = whereAdd($lookupQueryObj->m_where->toSql($lookupQueryObj), $strWhere);
         $orderByClause = strlen($strOrderBy) ? ' ORDER BY ' . $strOrderBy : null;
         return $lookupQueryObj->toSql($strWhere, $orderByClause, null, $oneRecordMode);
     }
     $LookupSQL = "SELECT ";
     if ($this->lookupConnection->dbType == nDATABASE_MSSQLServer || $this->lookupConnection->dbType == nDATABASE_Access) {
         if ($oneRecordMode) {
             $LookupSQL .= "top 1 ";
         }
     }
     $bUnique = $pSet->isLookupUnique($this->field);
     if ($bUnique && !$oneRecordMode) {
         $LookupSQL .= "DISTINCT ";
     }
     $LookupSQL .= $this->lwLinkField;
     if (!$this->linkAndDisplaySame) {
         $LookupSQL .= "," . RunnerPage::sqlFormattedDisplayField($this->field, $this->lookupConnection, $pSet);
     }
     if ($addCategoryField && strlen($strCategoryFilter)) {
         $LookupSQL .= "," . $this->lookupConnection->addFieldWrappers($strCategoryFilter);
     }
     if ($this->lookupConnection->dbType == nDATABASE_MSSQLServer) {
         if ($strUniqueOrderBy && $bUnique && !$oneRecordMode) {
             $LookupSQL .= "," . $this->lookupConnection->addFieldWrappers($strUniqueOrderBy);
         }
     }
     $LookupSQL .= " FROM " . $this->lookupConnection->addTableWrappers($this->lookupTable);
     if (strlen($strWhere)) {
         $LookupSQL .= " WHERE " . $strWhere;
     }
     if (strlen($strOrderBy)) {
         $LookupSQL .= " ORDER BY " . $this->lookupConnection->addTableWrappers($this->lookupTable) . "." . $strOrderBy;
     }
     if ($this->lookupConnection->dbType == nDATABASE_MySQL) {
         if ($oneRecordMode) {
             $LookupSQL .= " limit 0,1";
         }
     }
     if ($this->lookupConnection->dbType == nDATABASE_PostgreSQL) {
         if ($oneRecordMode) {
             $LookupSQL .= " limit 1";
         }
     }
     if ($this->lookupConnection->dbType == nDATABASE_DB2) {
         if ($oneRecordMode) {
             $LookupSQL .= " fetch first 1 rows only";
         }
     }
     return $LookupSQL;
 }