. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ /** * * * * * * * Table class definition * Render table * * @package gulliver.system * @author Fernando Ontiveros Lira * @copyright (C) 2002 by Colosa Development Team. * */ class Table { public $Columns = null; public $Labels = null; public $rows_per_page = 25; public $show_nummbers = null; public $first_row = 0; public $row_pos = 0; public $Action = ""; //not used public $ActionLabel = "Continuar"; //not used public $_dbc = null; public $_dbses = null; public $_dbset = null; public $_source = ""; public $DefaultOrder = "UID"; public $DefaultOrderDir = 'ASC'; public $CustomOrder = ""; public $WhereClause = ""; public $_row_values = null; public $_ordered = true; public $orderprefix = ""; public $CountQry = ""; public $filtro = 1; public $title = ''; /** * Asocia un arreglo con valores de traducci?n/conversi?n a un contexto * * @var array */ public $contexto = null; /** * Arreglo que contiene las cadenas que van a ser usadas al traducir/convertir * * @var array */ public $translate = null; /** * Establece el ?ltimo contexto utilizado * * @var string */ public $_contexto = ''; /** * Set conecction using default values * * @author Fernando Ontiveros Lira * @access public * @param string $objConnection connection string * @return void */ public function Table ($objConnection = null) { $this->SetTo( $objConnection ); } /** * Set conecction using default values * * @author Fernando Ontiveros Lira * @access public * @param string $objConnection connection string * @return void */ public function SetTo ($objConnection = null) { $this->_dbc = $objConnection; } /** * Set query string * * @author Fernando Ontiveros Lira * @access public * @param string $stQry query string * @param string $stDefaultOrder index to order by, default value='UID' * @return void */ public function SetSource ($stQry = "", $stDefaultOrder = "UID", $stDefaultOrderDir = 'ASC') { //to fix missing value for variable orderDir, when between pages changes. $url1 = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?'; $url2 = strstr( $_SERVER['HTTP_REFERER'] . '?', $_SERVER['HTTP_HOST'] ); $url1 = substr( $url1, 0, strpos( $url1, '?' ) ); $url2 = substr( $url2, 0, strpos( $url2, '?' ) ); if ($url1 != $url2) { if (isset( $_SESSION['OrderBy'] )) { unset( $_SESSION['OrderBy'] ); } if (isset( $_SESSION['OrderDir'] )) { unset( $_SESSION['OrderDir'] ); } } $this->_source = $stQry; $this->DefaultOrder = $stDefaultOrder; $this->DefaultOrderDir = $stDefaultOrderDir; } /** * Obtains query string asociated * * @author Fernando Ontiveros Lira * @access public * @return void */ public function GetSource () { global $HTTP_GET_VARS; global $HTTP_SESSION_VARS; $stOrderByDir = $this->DefaultOrderDir; if (isset( $HTTP_SESSION_VARS['OrderDir'] ) && ($HTTP_SESSION_VARS['OrderDir'] == 'DESC' || $HTTP_SESSION_VARS['OrderDir'] == 'ASC')) { $stOrderByDir = $HTTP_SESSION_VARS['OrderDir']; } $stQry = $this->_source; if ($this->WhereClause != "") { $stQry .= " WHERE " . $this->WhereClause; } if ($this->_ordered == true) { $stOrderBy = (isset( $HTTP_GET_VARS[$this->orderprefix . 'order'] ) ? $HTTP_GET_VARS[$this->orderprefix . 'order'] : ''); $stOrderLb = (isset( $HTTP_GET_VARS[$this->orderprefix . 'label'] ) ? $HTTP_GET_VARS[$this->orderprefix . 'label'] : ''); //if( isset( $HTTP_SESSION_VARS['OrderDir'] ) && $HTTP_SESSION_VARS['OrderDir'] == $stOrderBy ) { if ($stOrderLb) { if ($HTTP_SESSION_VARS['OrderDir'] == 'ASC') { $stOrderByDir = 'DESC'; } elseif ($HTTP_SESSION_VARS['OrderDir'] == 'DESC') { $stOrderByDir = 'ASC'; } } elseif (isset( $HTTP_SESSION_VARS['OrderDir'] ) && $HTTP_SESSION_VARS['OrderDir'] != '') { $stOrderByDir = $HTTP_SESSION_VARS['OrderDir']; } else { $stOrderByDir = $this->DefaultOrderDir; } if ($stOrderBy == "") { if ($this->DefaultOrder != "") { $aux = str_replace( ' ASC|', '', $this->DefaultOrder . '|' ); $aux = str_replace( ' DESC|', '', $aux ); $aux = str_replace( '|', '', $aux ); $stQry .= " ORDER BY " . $aux . " " . $stOrderByDir; } } else { $stQry .= " ORDER BY " . $stOrderBy; if ($stOrderByDir != "") { $stQry .= " $stOrderByDir"; } } } else { if ($this->DefaultOrder != "") { $stQry .= " ORDER BY " . $this->DefaultOrder . " " . (isset( $stOrderBy ) ? $stOrderBy : ''); } } //print $stQry; $HTTP_SESSION_VARS['OrderBy'] = isset( $stOrderBy ) ? $stOrderBy : ''; $HTTP_SESSION_VARS['OrderDir'] = $stOrderByDir; $page = (isset( $HTTP_GET_VARS["page"] ) ? $HTTP_GET_VARS["page"] : ''); $tr = (isset( $HTTP_SESSION_VARS['TP'] ) ? $HTTP_SESSION_VARS['TP'] : ''); $desde = 0; if ($page != "") { //$desde=(($page-1)*25); $desde = (($page - 1) * $this->rows_per_page); //$strLimit = " LIMIT $desde , 25"; $strLimit = " LIMIT $desde , $this->rows_per_page"; if (PEAR_DATABASE == 'pgsql') { //$strLimit = " OFFSET $desde LIMIT 25"; $strLimit = " OFFSET $desde LIMIT $this->rows_per_page"; } $stQry .= $strLimit; } //print $stQry; $this->_dbses = new DBSession( $this->_dbc ); $this->_dbses->UseDB( DB_NAME ); $this->_dbses->Query( $stQry ); $this->_dbset = new DBRecordset( $this->_dbses->result ); } /** * Obtains number of elements of asociated query * * @author Fernando Ontiveros Lira * @access public * @return int */ public function TotalCount () { global $HTTP_GET_VARS; global $HTTP_SESSION_VARS; $stQry = $this->_source; if ($this->WhereClause != "") { $stQry .= " WHERE " . $this->WhereClause; } if ($this->_ordered == true) { $stOrderBy = (isset( $HTTP_GET_VARS[$this->orderprefix . 'order'] ) ? $HTTP_GET_VARS[$this->orderprefix . 'order'] : ''); if ($stOrderBy == "") { if ($this->DefaultOrder != "") { $stQry .= " ORDER BY " . $this->DefaultOrder; } } else { $stQry .= " ORDER BY " . $stOrderBy; } } else { if ($this->DefaultOrder != "") { $stQry .= " ORDER BY " . $this->DefaultOrder; } } $dbses = new DBSession( $this->_dbc ); $dbses->UseDB( DB_NAME ); $dset = $dbses->Execute( $stQry ); return $dset->Count(); } /** * Obtains number of elements of asociated recordset * * @author Fernando Ontiveros Lira * @access public * @return int */ public function Count () { if (is_object( $this->_dbset )) { return $this->_dbset->Count(); } else { return 0; } } /** * Obtains row position * * @author Fernando Ontiveros Lira * @access public * @return int */ public function CurRow () { return $this->row_pos; } /** * Obtains number columns * * @author Fernando Ontiveros Lira * @access public * @return int */ public function ColumnCount () { $result = 0; if (is_array( $this->Columns )) { $result = count( $this->Columns ); } return $result; } /** * Obtains a row array and moves the internal data pointer ahead * * @author Fernando Ontiveros Lira * @access public * @return array */ public function Read () { $this->_row_values = $this->_dbset->Read(); $this->row_pos ++; return $this->_row_values; } /** * Moves the internal row pointer * * @author Fernando Ontiveros Lira * @access public * @param int $intPos position to seek * @return int */ public function Seek ($intPos = 0) { $result = $this->_dbset->Seek( $intPos ); if ($result) { $this->row_pos = $intPos; } return $result; } /** * Moves the internal row pointer to first position * * @author Fernando Ontiveros Lira * @access public * @return int */ public function MoveFirst () { if ($this->Count() != 0) { if ($this->first_row < $this->Count()) { $this->Seek( $this->first_row ); } } } /** * Verify if row position is in the end * * @author Fernando Ontiveros Lira * @access public * @return boolean */ public function EOF () { $result = false; if ($this->Count() == 0) { $result = true; } else { if ($this->row_pos >= $this->Count()) { $result = true; } else { if ($this->rows_per_page != 0) { if ($this->row_pos >= $this->first_row + $this->rows_per_page) { $result = true; } } } } return $result; } /** * Set values to add a column to show in the dynaform * * @author Fernando Ontiveros Lira * @access public * @param $strLabel * @param $strType * @param $strName * @param $strAlign * @param $intWidth * @param $strTarget * @param $strContent * @return void */ public function AddColumn ($strLabel = "", $strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "") { $tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent ); $pos = 0; if (is_array( $this->Columns )) { $pos = count( $this->Columns ); } $this->Columns[$pos] = $tmpCol; $this->Labels[$pos] = $strLabel; } /** * Set values to add a column to show in the dynaform * * @author Fernando Ontiveros Lira * @access public * @param $strType * @param $strName * @param $strAlign * @param $intWidth * @param $strTarget * @param $strContent * @param $strExtra * @param $strCondition * @param $orderByThis * @return void */ public function AddRawColumn ($strType = "text", $strName = "", $strAlign = "left", $intWidth = 0, $strTarget = "", $strContent = "", $strExtra = "", $strCondition = "", $orderByThis = true) { $tmpCol = array ("Name" => $strName,"Type" => $strType,"Width" => $intWidth,"Align" => $strAlign,"Target" => $strTarget,"Content" => $strContent,"Extra" => $strExtra,"Condition" => $strCondition,"orderByThis" => $orderByThis ); $pos = 0; if (is_array( $this->Columns )) { $pos = count( $this->Columns ); } $this->Columns[$pos] = $tmpCol; $this->Labels[$pos] = ""; } /** * Show dynaform's title * * @author Fernando Ontiveros Lira * @access public * @param $pa * @param $intPos * @param $strClass * @return void */ public function RenderTitle ($pa, $intPos = 1, $strClass = "tblHeader") { if (! defined( 'ENABLE_ENCRYPT' )) { define( 'ENABLE_ENCRYPT', 'no' ); } global $HTTP_SESSION_VARS; $col = $this->Columns[$intPos]; $order = ! ($col["Type"] == "image"); if ($this->_ordered == true && $order) { $res = " 0) { $res .= " width=\"" . $col["Width"] . "\""; } $res .= ">"; //$res .= "" . $this->Labels[$intPos] . ""; $res .= "\n"; //echo $res;die; } else { $res = " 0) { $res .= " width=\"" . $col["Width"] . "\""; } $res .= ">"; $res .= $this->Labels[$intPos] . "\n"; } return $res; } /** * Show dynaform's title using ajax * * @author Fernando Ontiveros Lira * @access public * @param $pa * @param $intPos * @param $strClass * @return void */ public function RenderTitle_ajax ($pa, $intPos = 1, $strClass = "tblHeader") { global $HTTP_SESSION_VARS; $col = $this->Columns[$intPos]; $order = ! (($col["Type"] == "image") || ($col["Type"] == "jsimglink")); if ($this->_ordered == true && $order) { $res = " 0) { $res .= " width=\"" . $col["Width"] . "\""; } $res .= ">"; //$res .= "Columns[$intPos]['Name']; $res .= "Javascript:changetableOrder('$_temp_var',$pa)"; //$res .= $_SERVER['REDIRECT_URL'] . "?order=" . $this->Columns[$intPos]['Name']."&page=".$pa."&label=true"; $res .= "\">" . $this->Labels[$intPos] . ""; if ($HTTP_SESSION_VARS['OrderBy'] == $this->Columns[$intPos]['Name']) { if ($HTTP_SESSION_VARS['OrderDir'] == 'DESC') { $res .= " "; } else { $res .= " "; } } $res .= "\n"; //echo $res;die; } else { $res = " 0) { $res .= " width=\"" . $col["Width"] . "\""; } $res .= ">"; $res .= $this->Labels[$intPos] . "\n"; } return $res; } /** * Show dynaform title * * @author Fernando Ontiveros Lira * @access public * @param $pa * @param $fil * @param $intPos * @param $strClass * @param $auxgetval * @return void */ public function RenderTitle2 ($pa, $fil, $intPos, $strClass = "tblHeader", $auxgetval = '') { if (! defined( 'ENABLE_ENCRYPT' )) { define( 'ENABLE_ENCRYPT', 'no' ); } global $HTTP_SESSION_VARS; if ($auxgetval == '') { $targ = SYS_TARGET . ".html"; } else { $targ = SYS_TARGET . '.html?' . $auxgetval; } $target = (ENABLE_ENCRYPT == 'yes' ? G::encryptUrl( urldecode( $targ ), URL_KEY ) : $targ); $col = $this->Columns[$intPos]; if ($col['Type'] == 'hidden') { return ''; } $order = ! ($col["Type"] == "image"); if (($this->_ordered == true) && ($order) && ($this->Columns[$intPos]['orderByThis'])) { $res = ""; if (($this->show_nummbers) and ($intPos == 0)) { $res = "# "; } $res .= " 0) { $res .= " width=\"" . $col["Width"] . "\""; } $res .= "> "; $res .= "" . $this->Labels[$intPos] . ""; $res .= "\n"; } else { $col = $this->Columns[$intPos]; $res = " 0) { $res .= " width=\"" . $col["Width"] . "\""; } $res .= ">"; $res .= (isset( $this->Labels[$intPos] ) ? $this->Labels[$intPos] : '') . "\n"; } return $res; } /** * Show dynaform column * * @author Fernando Ontiveros Lira * @access public * @param $intPos * @param $strClass * @param $strClassLink * @param $number * @param $renderTD if this value = 1, this function will include the TD tags * @return void */ public function RenderColumn ($intPos = 0, $strClass = "tblCell", $strClassLink = "tblCellA", $number = 0, $renderTD = 1) { if (! defined( 'ENABLE_ENCRYPT' )) { define( 'ENABLE_ENCRYPT', 'no' ); } global $G_DATE_FORMAT; global $G_TABLE_DATE_FORMAT; $col = $this->Columns[$intPos]; switch (substr( $col['Name'], 0, 1 )) { case '=': // Si empieza con '=' entonces se toma como valor constante $val = substr( $col['Name'], 1, strlen( $col['Name'] ) - 1 ); break; case '%': // Si empieza con '%' entonces traducir/convertir el valor $fieldname = substr( $col['Name'], 1, strlen( $col['Name'] ) - 1 ); $val = $this->_row_values[$fieldname]; $val = $this->translateValue( $this->_contexto, $val, SYS_LANG ); break; default: $fieldname = $col['Name']; $val = isset( $this->_row_values[$fieldname] ) ? $this->_row_values[$fieldname] : ''; } $res = ""; if (($this->show_nummbers) and ($intPos == 0)) { $res = "$number"; } if (! (stristr( $val, "script" ) === false)) { $val = htmlentities( $val, ENT_QUOTES, 'utf-8' ); } if ($renderTD == 1) { $res .= " 0) { $res .= " width=\"" . $col["Width"] . "\""; } $res .= "> "; } switch ($col["Type"]) { case 'hidden': return ''; break; case "text": if ($val != "") { $res .= G::unhtmlentities( $val, ENT_QUOTES, 'utf-8' ); } else { $res .= " "; } break; case "text-dontSearch": if ($val != "") { $res .= G::unhtmlentities( $val ); } else { $res .= " "; } break; case "html": if ($val != "") { $res .= ($val); } else { $res .= " "; } break; case "textPlain": if ($val != "") { $res .= ($this->ParsingFromHtml( G::unhtmlentities( $val ), "300" )); //if ( $val != "" ) $res .= (($val)); } else { $res .= " "; } break; case "currency": if ($val != "") { $aux = explode( ' ', $val ); $format = number_format( (float) $aux[0], 2, ".", "," ); $res .= htmlentities( $format . ' ' . (isset( $aux[1] ) ? $aux[1] : ''), ENT_QUOTES, 'utf-8' ); } else { $res .= " "; } break; case "currency2": if ($val != "") { $res .= G::NumberToCurrency( $val ); } else { $res .= "$ 0.00"; } break; case "percentage2": if ($val != "") { $res .= G::NumberToPercentage( $val ); } else { $res .= "0.00 %"; } break; case "percentage": if ($val != "") { $res .= htmlentities( number_format( (float) $val, 2, ".", "," ) . " %", ENT_QUOTES, 'utf-8' ); } else { $res .= " "; } break; case "date": if ($val != "" && $val != '0000-00-00 00:00:00') { $part = explode( ' ', $val ); $aux = explode( '-', $part[0] ); switch ($G_DATE_FORMAT) { case 'DD/MM/AAAA': $res .= formatDate( '$d/$m/$Y $H:$i:$s', $val ); break; case 'MM/DD/AAAA': $res .= formatDate( '$m/$d/$Y $H:$i:$s EST', $val ); break; case 'AAAA/MM/DD': $res .= formatDate( '$Y/$m/$d $H:$i:$s', $val ); break; case 'LITERAL': $res .= formatDate( '$M $d $Y', $val ); break; } } else { $res .= " "; } break; case "email": if ($val != "") { $res .= ""; $res .= $val; $res .= ""; } else { $res .= " "; } break; case "ifpdf": if ($val == '1') { $image = ""; //valor $tlabel = substr( $col["Content"], 0, 1 ); $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; //$res .= " $image "; //It open a new window... better the other way By JHL 16/11/06 $res .= " $image "; } else { $res .= " "; } break; case "ifimg": $image = ""; if ($val == '1') { //valor $tlabel = substr( $col["Content"], 0, 1 ); $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; $res .= " $image "; } else { $res .= " "; } break; case "ifrtf": if ($val == '1') { $image = ""; //valor $tlabel = substr( $col["Content"], 0, 1 ); $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; //$res .= " $image "; //It open a new window... better the other way By JHL 16/11/06 $res .= " $image "; } else { $res .= " "; } break; case "image": if (is_array( $col["Condition"] )) { //By JHL to enable Condition to display a image -- New parameter Condition in Addrawcolumn $field_compare = $col["Condition"]['field']; $tlabel = substr( $field_compare, 0, 1 ); switch ($tlabel) { case "&": $vname = substr( $field_compare, 1, (strlen( $field_compare ) - 1) ); $field_val = $this->_row_values[$vname]; break; } } else { $val = ""; } // break; case "textimage": $AAS = $col['Extra']; $val1 = " "; // break; case "image-text": if (is_array( $col['Content'] ) && $col['Content'] != "") { // Hay mas de un valor para el link $values = $col['Content']; $n = count( $values ); $res .= "_row_values[$vname]; $res .= $i == $n - 1 ? $lval : $lval . "/"; break; } } $res .= "\">" . strtoupper( $fieldname ) . "$val"; } else { $val2 = "" . strtoupper( $fieldname ) . ""; } //break; case "link": if ($val == "") { $res .= " "; } $title = ''; if ($col["Type"] == 'link' && trim( isset( $this->_row_values['TOOLTIP'] ) ? $this->_row_values['TOOLTIP'] : '' )); $title = (isset( $this->_row_values['TOOLTIP'] ) ? "title=\" " . $this->_row_values['TOOLTIP'] . " \"" : ''); if (is_array( $col['Content'] ) && $col['Content'] != "") { // Hay mas de un valor para el link $values = $col['Content']; $n = count( $values ); $res .= "_row_values[$vname]; $res .= $i == $n - 1 ? $lval : $lval . "/"; break; } } $res .= "\">$val"; } elseif ($col["Content"] != "" && ! is_array( $col['Content'] )) { $tlabel = substr( $col["Content"], 0, 1 ); switch ($tlabel) { case "&": $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; if (ENABLE_ENCRYPT == 'yes') { //$encoded = G::encrypt ( $col["Target"] . "/" . $lval . ".html", URL_KEY ); $encoded = G::encryptUrl( $col["Target"] . "/" . $lval . ".html", URL_KEY ); $res .= ""; if ($col["Type"] == "textimage") { $res .= $val1; $val = " (" . $val . ")"; } if ($col["Type"] == "image-text") { $res .= $val2; } $res .= $val; $res .= ""; } else { $res .= ""; if ($col["Type"] == "textimage") { $res .= $val1; $val = " (" . $val . ")"; } if ($col["Type"] == "image-text") { $res .= $val2; } $res .= $val; $res .= ""; } break; case "$": $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $HTTP_SESSION_VARS[$vname]; $res .= ""; $res .= $val; $res .= ""; break; default: $res .= ""; $res .= $col["Content"]; $res .= ""; break; } } else { $res .= ""; $res .= $val; $res .= ""; } break; case "linknew": if ($val == "") { $res .= " "; } if ($col["Content"] != "") { $tlabel = substr( $col["Content"], 0, 1 ); switch ($tlabel) { case "&": if (ENABLE_ENCRYPT == 'yes') { $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; //$encoded = G::encryptUrl ( $col["Target"] , URL_KEY ). "/" . $lval . ".html"; $encoded = G::encryptUrl( $col["Target"] . "/" . $lval . "", URL_KEY ); $res .= ""; $res .= $val; $res .= ""; } else { $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; $res .= ""; $res .= $val; $res .= ""; } break; case "$": $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $HTTP_SESSION_VARS[$vname]; $res .= ""; $res .= $val; $res .= ""; break; default: $res .= ""; $res .= $col["Content"]; $res .= ""; break; } } else { $res .= ""; $res .= $val; $res .= ""; } break; case "iflink": if ($col["Content"] != "") { $tlabel = substr( $col["Content"], 0, 1 ); if ($val != "") { switch ($tlabel) { case "&": $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; $res .= ""; $res .= $val; $res .= ""; break; case "$": $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $HTTP_SESSION_VARS[$vname]; $res .= ""; $res .= $val; $res .= ""; break; default: $res .= ""; $res .= $col["Content"]; $res .= ""; break; } } else { $res .= " "; } } else { $res .= ""; $res .= $val; $res .= ""; } break; case "jsimglink": $val = ""; case "jslink": if ($val == "") { $val .= " " . $col['Name'] . ''; } if ($val == "") { $res .= " "; } if ($col["Content"] != "") { $tlabel = substr( $col["Content"], 0, 1 ); switch ($tlabel) { case "&": $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $this->_row_values[$vname]; $res .= ""; $res .= $val; $res .= ""; break; case "$": $vname = substr( $col["Content"], 1, (strlen( $col["Content"] ) - 1) ); $lval = $HTTP_SESSION_VARS[$vname]; $res .= ""; $res .= $val; $res .= ""; break; case '_': $Values = explode( ',', substr( $col['Content'], 1, strlen( $col['Content'] ) ) ); $res .= "_row_values[substr( $Value, 1, strlen( $Value ) )] . ','; } else { $res .= "'" . $this->_row_values[substr( $Value, 1, strlen( $Value ) )] . "',"; } } else { $res .= $Value . ','; } } $res = substr( $res, 0, strlen( $res ) - 1 ); $res .= ")\"" . $col['Extra'] . ">"; $res .= $val; $res .= ""; break; default: $res .= ""; $res .= $col["Content"]; $res .= ""; break; } } else { $res .= ""; $res .= $val; $res .= ""; } break; case "checkbox": $res .= " * @access public * @param string $strAction Next action to do * @param string $strLabel Label * @return void */ public function SetAction ($strAction, $strLabel = "Continue") { $this->Action = $strAction; $this->ActionLabel = $strLabel; } /** * Set contaxt and table (array) of translate * * @author Hardy Beltran Monasterios * @param string $contexto Contexto en el cual se busca la traducci?n * @param array $tabla Tabla con valores para traducir * @param string $nombre Nombre del array $tabla * @access public * @return void */ public function setTranslate ($contexto, $tabla, $nombre) { if (is_array( $this->contexto )) { $this->contexto[0][] = $contexto; $this->contexto[1][] = $nombre; } else { $this->contexto = array (); $this->contexto[0][] = $contexto; $this->contexto[1][] = $nombre; // array_push($this->contexto[0], $contexto); // array_push($this->contexto[1], $nombre); } if (is_array( $this->translate )) { $this->translate = array (); $this->translate[$nombre] = $tabla; } else { $this->translate[$nombre] = $tabla; } // Fijamos ultimo contexto usado $this->_contexto = $contexto; } /** * Search value in the table of translation and returns last accourding to choised context * Retorna el valor a su equivalente traducido/convertido * * @author Hardy Beltran Monasterios * @param string $contexto Contexto en el cual se busca la traducci?n * @param mixed $valor Valor que se va traducir/convertir * @param string $lang El lenguaje que se va utilizar * @return mixed */ public function translateValue ($contexto, $valor, $lang) { // Verificar si exite el contexto if (in_array( $contexto, $this->contexto[0] )) { $j = count( $this->contexto[0] ); for ($i = 0; $i < $j; $i ++) { if ($contexto == $this->contexto[0][$i]) { $origen = $this->contexto[1][$i]; } } $tabla = $this->translate[$origen]; if (isset( $tabla[$lang][$valor] )) { return $tabla[$lang][$valor]; } else { print ("l10n error:no lang or value.") ; } } else { print ("l10n error:no context.") ; } } /** * Estable el contexto de traducci?n/conversi?n * * @author Hardy Beltran Monasterios * @param string $contexto Contexto en el cual se busca la traducci?n * @return void */ public function setContext ($contexto) { $this->_context = $contexto; } /** * Parse from HTML * * @author Fernando Ontiveros Lira * @access public * @return void */ public function ParsingFromHtml ($value, $number = '100000000') { $car = substr( $value, 0, 1 ); $len = strlen( $value ); $Flag = 1; $token = ''; $i = 0; while ($i <= $len and $i <= $number) { $car = substr( $value, $i, 1 ); $br = strtoupper( substr( $value, $i, 4 ) ); if ($car == '<') { $Flag = 0; } if ($car == '>') { $Flag = 1; } if ($br == '
' || $br == '

') { $token .= "
"; } if (($Flag == 1) && ($car != '>')) { $token .= $car; if ($i == $number) { $token .= "... "; } } $i = $i + 1; } return $token; } }