PHP Classes

spanish language

Recommend this page to a friend!

      PHP data grid class  >  All threads  >  spanish language  >  (Un) Subscribe thread alerts  
Subject:spanish language
Summary:ampliation of this class
Messages:1
Author:GABRIEL PEREZ
Date:2007-04-11 15:28:51
 

  1. spanish language   Reply   Report abuse  
Picture of GABRIEL PEREZ GABRIEL PEREZ - 2007-04-11 15:28:51
hi all:

I think the class is very usefull, but it has only 2 languages: english and portuguese.

i haven't found any method to change language without edit the class source.

now, i 've do then file spanish.php, and you can put it in the same directory than english.php, and portuguese.php,

-------begin------------------
<?php
/**
* spanish language file for the Data Grid class created by Stefan Gabos <ix@nivelzero.ro>.
*
* @version 1.0
* @author Stefan Gabos <ix@nivelzero.ro>
* @copyright Copyright (C) 2006 - 2007 Stefan Gabos
* @ translate by Gabriel Perez <gabriel.perezmartinez@gmail.com>
*/
$this->languageStrings = array(
"strLang_noJavaScript" => "la tabla mostrada necerita javascript, que parece que no esta activado en tu navegador.<br />
No puedes realizar ninguna operacion en ella.",

"strLang_checkAll" => "seleccionar todo",
"strLang_invertSelection" => "invertir seleccion",
"strLang_nextPage" => "pagina siguiente",
"strLang_noRecords" => "no hay registros para mostrar",
"strLang_of" => "de",
"strLang_page" => "pagina",
"strLang_pages" => "paginas",
"strLang_previousPage" => "pagina anterior",
"strLang_recordsOnPage" => "registros en pagina",
"strLang_showingRecords" => "Mostrando registros",
"strLang_to" => "a ",
"strLang_uncheckAll" => "desmarcar todo"
)
?>
---------------------end--------------

now, i have added the function language in the source.
--------------begin---------------------
function language($languagefile){
// select language file to display messages
$this->languageFile=$languagefile;
}
---------end---------------------------------

I have put this function after function DataGrid, and before function
showColumn ( this is only one example).


and now, to use this new function, this is te *new* example5 file:

--------------begin--------------------

<html>
<body>
<?php

/**
* This example is the same as example4 but this time the data grid will be SEO friendly!
*
* See the documentation about useSEO and URLa properties
*/

// change these to match your mySQL host's settings
mysql_connect("localhost", "", "");
mysql_select_db("infancia_local");

// require the class
require "../class.datagrid.php";

// this is the query that will be displayed
// remember: no ORDER BY and no LIMIT!
$query = "
SELECT
*
FROM
articles
";

// instantiate the class and pass the query string to it
$grid = new dataGrid($query);

// show all the columns
$grid->showColumn("title");
$grid->showColumn("created");
$grid->showColumn("modified");

//////////////////////////////////////////////////////////////
$grid->language("spanish.php"); /// this is the modificacion!!!
//////////////////////////////////////////////////////////////



// make the title column stretch 100%
$grid->setColumnHTMLProperties("title", "style='text-align:left;width:100%'");

// sort the data by the "title" column
$grid->setDefaultSortColumn("title");

// create the function that will change a unix timestamp to an user-readable date
function convert_unixtimestamp($timestamp)
{

return date("M-d-Y H:i", $timestamp);

}

// bound this function to the "created" and "modified" column's fields
$grid->setCallbackFunction(array("created", "modified"), "convert_unixtimestamp");

// create a function that will set a javascript action for when clicking on the rows
// you could use this to redirect the page
function action($value_of_clicked_field, $array_with_the_values_of_all_fields_in_clicked_row)
{

return "javascript:alert('the title on this row is \'".$array_with_the_values_of_all_fields_in_clicked_row["title"]."\' \\nCreated on ".date("M-d-Y H:i", $array_with_the_values_of_all_fields_in_clicked_row["created"])."')";

}

// bound the function to the rows
$grid->setRowActionFunction("action");

// we add a custom column
$grid->showCustomColumn("operations");

// make both the "created", "modified" and "operations" columns not wrappable and center aligned
// note that we make the call here because otherwise setting these properties for the "operations" column, before making it available,
// would have no sense
$grid->setColumnHTMLProperties(array("created", "modified", "operations"), "style='text-align:center;white-space:nowrap'");

// we add content to it by using a callback function
// first create the function
function custom_content($value)
{

return "[<a href=\"javascript:if(confirm('Are you sure?')){}else{}\">delete</a>]";

}

// bound this function to the "operations" column's fields
$grid->setCallbackFunction("operations", "custom_content");

// disable sorting on it
$grid->disableSorting("operations");

// unset for this column the action function set before with setRowActionFunction()
$grid->unsetActionFunction("operations");

// add a "selector" column
$grid->showSelectorColumn("&nbsp;", "check", "id");

// add a title to the table
$grid->setHeaderHTML("<h2>data grid class</h2>");

// and also add a footer
// you could use this button to dynamically change the form's action and submit the checked values...
$grid->setFooterHTML("<br /><input type='submit' value='Submit'>");

// make the data grid SEO friendly
$grid->useSEO = true;

// witness magic!
$grid->render();

?>
</body>
</html>

----------------end------------------------------------


Thanks to everybody for your attention.


gabriel.perezmartinezATgmail.com