Exemple #1
0
	/**
	 * testing to see that if the aFields are passed by reference do they update the table object?
	 * @param array containing field sql
	 * @param array containing field aliases
	 * @param array options
	 */

	function getAsField_html(&$aFields, &$aAsFields, $opts = array())
	{
		if ($this->isJoin()) {// $$$ rob was commented out - but  meant that the SELECT GROUP_CONCAT subquery was never user
			return parent::getAsField_html($aFields, $aAsFields, $opts);
		}
		$table = $this->actualTableName();
		$params = $this->getParams();
		$db = FabrikWorker::getDbo();
		$listModel = $this->getlistModel();

		$element = $this->getElement();
		$tableRow = $listModel->getTable();
		$joins = $listModel->getJoins();
		foreach ($joins as $tmpjoin) {
			if ($tmpjoin->element_id == $element->id) {
				$join = $tmpjoin;
				break;
			}
		}

		$connection = $listModel->getConnection();
		//make sure same connection as this table
		$fullElName = JArrayHelper::getValue($opts, 'alias', $table."___".$element->name);
		if ($params->get('join_conn_id') == $connection->get('_id') || $element->plugin != 'databasejoin') {
			$join = $this->getJoin();
			if (!$join) {
				return false;
			}
			$joinTableName = $join->table_join_alias;

			$tables = $this->getForm()->getLinkedFabrikLists($params->get('join_db_name'));

			//	store unjoined values as well (used in non-join group table views)
			//this wasnt working for test case:
			//events -> (db join) event_artists -> el join (artist)

			// $$$ rob in csv import keytable not set
			// $$$ hugh - if keytable isn't set, the safeColName blows up!
			// Trying to debug issue with linked join elements, which don't get detected by
			// getJoins or getJoin 'cos element ID doesn't match element_id in fabrik_joins
			//$k = isset($join->keytable ) ? $join->keytable : $join->join_from_table;
			//$k = FabrikString::safeColName("`$join->keytable`.`$element->name`");
			$keytable = isset($join->keytable) ? $join->keytable : $join->join_from_table;
			$k = FabrikString::safeColName($keytable.'.'.$element->name);

			$k2 = $this->getJoinLabelColumn();

			if (JArrayHelper::getValue($opts, 'inc_raw', true)) {
				$aFields[]				= "$k AS ".$db->nameQuote($fullElName."_raw");
				$aAsFields[]			= $db->nameQuote($fullElName."_raw");
			}
			$aFields[] 				= "$k2 AS ".$db->nameQuote($fullElName);
			$aAsFields[] 			= $db->nameQuote($fullElName);

		} else {
			$aFields[] 		= $db->nameQuote($table).'.'.$db->nameQuote($element->name).' AS '.$db->nameQuote($fullElName);
			$aAsFields[] 	= $db->nameQuote($fullElName);
		}
	}