cvs: pear /Translation2/Container dataobjectsimple.php
| From: | Alan Knowles | Date: | Thu, 06 May 2004 05:50:00 +0000 |
| Subject: | cvs: pear /Translation2/Container dataobjectsimple.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-19247@lists.php.net to get a copy of this message | ||
alan_k Thu May 6 01:50:00 2004 EDT
Modified files:
/pear/Translation2/Container dataobjectsimple.php
Log:
remove DOS line endings
http://cvs.php.net/diff.php/pear/Translation2/Container/dataobjectsimple.php?r1=1.3&r2=1.4&ty=u Index: pear/Translation2/Container/dataobjectsimple.php diff -u pear/Translation2/Container/dataobjectsimple.php:1.3 pear/Translation2/Container/dataobjectsimple.php:1.4 --- pear/Translation2/Container/dataobjectsimple.php:1.3 Mon Apr 19 10:58:47 2004 +++ pear/Translation2/Container/dataobjectsimple.php Thu May 6 01:50:00 2004 @@ -1,85 +1,85 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Alan Knowles <alan@akbkhome.com> | -// +----------------------------------------------------------------------+ -// -// $Id: dataobjectsimple.php,v 1.3 2004/04/19 14:58:47 quipo Exp $ -// -/** -* @package Translation2 -* @version $Id: dataobjectsimple.php,v 1.3 2004/04/19 14:58:47 quipo Exp $ -*/ - -/** -* require Translation2_Container class and DB_DataObjects -*/ -require_once 'Translation2/Container.php'; -require_once 'DB/DataObject.php'; - -/** - * Storage driver for fetching data from a simple dataobject - * - * Database Structure: - * +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.0 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/3_0.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Author: Alan Knowles <alan@akbkhome.com> | +// +----------------------------------------------------------------------+ +// +// $Id: dataobjectsimple.php,v 1.4 2004/05/06 05:50:00 alan_k Exp $ +// +/** +* @package Translation2 +* @version $Id: dataobjectsimple.php,v 1.4 2004/05/06 05:50:00 alan_k Exp $ +*/ + +/** +* require Translation2_Container class and DB_DataObjects +*/ +require_once 'Translation2/Container.php'; +require_once 'DB/DataObject.php'; + +/** + * Storage driver for fetching data from a simple dataobject + * + * Database Structure: + * * // meta data etc. not supported yet... - * - * create table translations ( - * id int(11) auto_increment not null primary key, - * string_id int(11), - * page varchar(128), - * lang varchar(10), - * translation text + * + * create table translations ( + * id int(11) auto_increment not null primary key, + * string_id int(11), + * page varchar(128), + * lang varchar(10), + * translation text * ); * alter table translations add index page (page); * alter table translations add index lang (lang); * alter table translations add index string_id (string_id); - * - * - then just run the dataobjects createtables script. - * - * - * This storage driver can use all databases which are supported - * by the PEAR DB abstraction layer to fetch data. - * - * @package Translation2 - * @version $Revision: 1.3 $ - */ -class Translation2_Container_dataobjectsimple extends Translation2_Container -{ - - // {{{ class vars - - // }}} - // {{{ Constructor - - /** - * Constructor of the container class - * - * Initate connection to the database via PEAR::DB - * - * @param string table name - * @return object Returns an error object if something went wrong - */ - function Translation2_Container_dataobjectsimple($table=null) - { + * + * - then just run the dataobjects createtables script. + * + * + * This storage driver can use all databases which are supported + * by the PEAR DB abstraction layer to fetch data. + * + * @package Translation2 + * @version $Revision: 1.4 $ + */ +class Translation2_Container_dataobjectsimple extends Translation2_Container +{ + + // {{{ class vars + + // }}} + // {{{ Constructor + + /** + * Constructor of the container class + * + * Initate connection to the database via PEAR::DB + * + * @param string table name + * @return object Returns an error object if something went wrong + */ + function Translation2_Container_dataobjectsimple($table=null) + { $this->_setDefaultOptions(); - if (!is_null($table)) { - $this->options['table'] = $table; - } - } - + if (!is_null($table)) { + $this->options['table'] = $table; + } + } + // }}} // {{{ _setDefaultOptions() @@ -94,124 +94,124 @@ $this->options['table'] = 'translations'; } - // }}} - // {{{ fetchLangs() - - /** - * Fetch the available langs if they're not cached yet. - */ - function fetchLangs() - { - $do = DB_DataObject::factory($this->options['table']); - $do->selectAdd(); - $do->selectAdd('distinct lang'); - $do->find(); - - $ret = array(); - while ($do->fetch()) { - $l = $do->lang; - $ret[$l] = array( - 'id' => $l, - 'name' => $l, - 'meta' => '', - 'error_text' => '', - ); - } - $this->langs = $ret; - } - - // }}} - // {{{ getPage() - - /** - * Returns an array of the strings in the selected page - * - * @param string $pageID - * @param string $langID - * @return array - */ - function getPage($page=null, $lang=null) - { - if (is_null($langID)) { - $lang= $this->currentLang['id']; - } - - $do = DB_DataObject::factory($this->options['table']); - $do->lang = $lang; - $do->page = $page; - - $do->find(); - $strings = array(); - while ($do->fetch()) { - $strings[$do->string_id] = $do->translation; - } - - return $strings; - } - - // }}} - // {{{ getOne() - - /** - * Get a single item from the container, without caching the whole page - * - * @param string $stringID - * @param string $pageID - * @param string $langID - * @return string - */ - function getOne($string, $page=null, $lang=null) - { - $lang = $lang ? $lang : $this->currentLang['id']; - // get the string id - $do = DB_DataObject::factory($this->options['table']); - $do->lang = '-'; - $do->page = $page; - $do->translation = $string; - // we dont have the base language translation.. - if (!$do->find(true)) { - return ''; - } - $stringID = $do->string_id; - - $do = DB_DataObject::factory($this->options['table']); - $do->lang = $lang; - $do->page = $page; - $do->string_id = $stringID; - //print_r($do); - $do->selectAdd(); - $do->selectAdd('translation'); - if (!$do->find(true)) { - return ''; - } - return $do->translation; - - } - - // }}} - // {{{ getStringID() - - /** - * Get the stringID for the given string - * - * @param string $stringID - * @param string $pageID - * @return string - */ - function getStringID($string, $page=null) - { - // get the enlgish version.. - - $do = DB_DataObject::factory($this->options['table']); - $do->lang = $this->currentLang['id']; - $do->page = $page; - $do->translation = $string; - if ($do->find(true)) { - return ''; - } - return $do->string_id; - } - - // }}} -} -?> \ No newline at end of file + // }}} + // {{{ fetchLangs() + + /** + * Fetch the available langs if they're not cached yet. + */ + function fetchLangs() + { + $do = DB_DataObject::factory($this->options['table']); + $do->selectAdd(); + $do->selectAdd('distinct lang'); + $do->find(); + + $ret = array(); + while ($do->fetch()) { + $l = $do->lang; + $ret[$l] = array( + 'id' => $l, + 'name' => $l, + 'meta' => '', + 'error_text' => '', + ); + } + $this->langs = $ret; + } + + // }}} + // {{{ getPage() + + /** + * Returns an array of the strings in the selected page + * + * @param string $pageID + * @param string $langID + * @return array + */ + function getPage($page=null, $lang=null) + { + if (is_null($langID)) { + $lang= $this->currentLang['id']; + } + + $do = DB_DataObject::factory($this->options['table']); + $do->lang = $lang; + $do->page = $page; + + $do->find(); + $strings = array(); + while ($do->fetch()) { + $strings[$do->string_id] = $do->translation; + } + + return $strings; + } + + // }}} + // {{{ getOne() + + /** + * Get a single item from the container, without caching the whole page + * + * @param string $stringID + * @param string $pageID + * @param string $langID + * @return string + */ + function getOne($string, $page=null, $lang=null) + { + $lang = $lang ? $lang : $this->currentLang['id']; + // get the string id + $do = DB_DataObject::factory($this->options['table']); + $do->lang = '-'; + $do->page = $page; + $do->translation = $string; + // we dont have the base language translation.. + if (!$do->find(true)) { + return ''; + } + $stringID = $do->string_id; + + $do = DB_DataObject::factory($this->options['table']); + $do->lang = $lang; + $do->page = $page; + $do->string_id = $stringID; + //print_r($do); + $do->selectAdd(); + $do->selectAdd('translation'); + if (!$do->find(true)) { + return ''; + } + return $do->translation; + + } + + // }}} + // {{{ getStringID() + + /** + * Get the stringID for the given string + * + * @param string $stringID + * @param string $pageID + * @return string + */ + function getStringID($string, $page=null) + { + // get the enlgish version.. + + $do = DB_DataObject::factory($this->options['table']); + $do->lang = $this->currentLang['id']; + $do->page = $page; + $do->translation = $string; + if ($do->find(true)) { + return ''; + } + return $do->string_id; + } + + // }}} +} +?>
http://cvs.php.net/diff.php/pear/Translation2/Container/dataobjectsimple.php?r1=1.3&r2=1.4&ty=u Index: pear/Translation2/Container/dataobjectsimple.php diff -u pear/Translation2/Container/dataobjectsimple.php:1.3 pear/Translation2/Container/dataobjectsimple.php:1.4 --- pear/Translation2/Container/dataobjectsimple.php:1.3 Mon Apr 19 10:58:47 2004 +++ pear/Translation2/Container/dataobjectsimple.php Thu May 6 01:50:00 2004 @@ -1,85 +1,85 @@ -<?php -/* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP Version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available at through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | license@php.net so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Author: Alan Knowles <alan@akbkhome.com> | -// +----------------------------------------------------------------------+ -// -// $Id: dataobjectsimple.php,v 1.3 2004/04/19 14:58:47 quipo Exp $ -// -/** -* @package Translation2 -* @version $Id: dataobjectsimple.php,v 1.3 2004/04/19 14:58:47 quipo Exp $ -*/ - -/** -* require Translation2_Container class and DB_DataObjects -*/ -require_once 'Translation2/Container.php'; -require_once 'DB/DataObject.php'; - -/** - * Storage driver for fetching data from a simple dataobject - * - * Database Structure: - * +<?php +/* vim: set expandtab tabstop=4 shiftwidth=4: */ +// +----------------------------------------------------------------------+ +// | PHP Version 4 | +// +----------------------------------------------------------------------+ +// | Copyright (c) 1997-2004 The PHP Group | +// +----------------------------------------------------------------------+ +// | This source file is subject to version 3.0 of the PHP license, | +// | that is bundled with this package in the file LICENSE, and is | +// | available at through the world-wide-web at | +// | http://www.php.net/license/3_0.txt. | +// | If you did not receive a copy of the PHP license and are unable to | +// | obtain it through the world-wide-web, please send a note to | +// | license@php.net so we can mail you a copy immediately. | +// +----------------------------------------------------------------------+ +// | Author: Alan Knowles <alan@akbkhome.com> | +// +----------------------------------------------------------------------+ +// +// $Id: dataobjectsimple.php,v 1.4 2004/05/06 05:50:00 alan_k Exp $ +// +/** +* @package Translation2 +* @version $Id: dataobjectsimple.php,v 1.4 2004/05/06 05:50:00 alan_k Exp $ +*/ + +/** +* require Translation2_Container class and DB_DataObjects +*/ +require_once 'Translation2/Container.php'; +require_once 'DB/DataObject.php'; + +/** + * Storage driver for fetching data from a simple dataobject + * + * Database Structure: + * * // meta data etc. not supported yet... - * - * create table translations ( - * id int(11) auto_increment not null primary key, - * string_id int(11), - * page varchar(128), - * lang varchar(10), - * translation text + * + * create table translations ( + * id int(11) auto_increment not null primary key, + * string_id int(11), + * page varchar(128), + * lang varchar(10), + * translation text * ); * alter table translations add index page (page); * alter table translations add index lang (lang); * alter table translations add index string_id (string_id); - * - * - then just run the dataobjects createtables script. - * - * - * This storage driver can use all databases which are supported - * by the PEAR DB abstraction layer to fetch data. - * - * @package Translation2 - * @version $Revision: 1.3 $ - */ -class Translation2_Container_dataobjectsimple extends Translation2_Container -{ - - // {{{ class vars - - // }}} - // {{{ Constructor - - /** - * Constructor of the container class - * - * Initate connection to the database via PEAR::DB - * - * @param string table name - * @return object Returns an error object if something went wrong - */ - function Translation2_Container_dataobjectsimple($table=null) - { + * + * - then just run the dataobjects createtables script. + * + * + * This storage driver can use all databases which are supported + * by the PEAR DB abstraction layer to fetch data. + * + * @package Translation2 + * @version $Revision: 1.4 $ + */ +class Translation2_Container_dataobjectsimple extends Translation2_Container +{ + + // {{{ class vars + + // }}} + // {{{ Constructor + + /** + * Constructor of the container class + * + * Initate connection to the database via PEAR::DB + * + * @param string table name + * @return object Returns an error object if something went wrong + */ + function Translation2_Container_dataobjectsimple($table=null) + { $this->_setDefaultOptions(); - if (!is_null($table)) { - $this->options['table'] = $table; - } - } - + if (!is_null($table)) { + $this->options['table'] = $table; + } + } + // }}} // {{{ _setDefaultOptions() @@ -94,124 +94,124 @@ $this->options['table'] = 'translations'; } - // }}} - // {{{ fetchLangs() - - /** - * Fetch the available langs if they're not cached yet. - */ - function fetchLangs() - { - $do = DB_DataObject::factory($this->options['table']); - $do->selectAdd(); - $do->selectAdd('distinct lang'); - $do->find(); - - $ret = array(); - while ($do->fetch()) { - $l = $do->lang; - $ret[$l] = array( - 'id' => $l, - 'name' => $l, - 'meta' => '', - 'error_text' => '', - ); - } - $this->langs = $ret; - } - - // }}} - // {{{ getPage() - - /** - * Returns an array of the strings in the selected page - * - * @param string $pageID - * @param string $langID - * @return array - */ - function getPage($page=null, $lang=null) - { - if (is_null($langID)) { - $lang= $this->currentLang['id']; - } - - $do = DB_DataObject::factory($this->options['table']); - $do->lang = $lang; - $do->page = $page; - - $do->find(); - $strings = array(); - while ($do->fetch()) { - $strings[$do->string_id] = $do->translation; - } - - return $strings; - } - - // }}} - // {{{ getOne() - - /** - * Get a single item from the container, without caching the whole page - * - * @param string $stringID - * @param string $pageID - * @param string $langID - * @return string - */ - function getOne($string, $page=null, $lang=null) - { - $lang = $lang ? $lang : $this->currentLang['id']; - // get the string id - $do = DB_DataObject::factory($this->options['table']); - $do->lang = '-'; - $do->page = $page; - $do->translation = $string; - // we dont have the base language translation.. - if (!$do->find(true)) { - return ''; - } - $stringID = $do->string_id; - - $do = DB_DataObject::factory($this->options['table']); - $do->lang = $lang; - $do->page = $page; - $do->string_id = $stringID; - //print_r($do); - $do->selectAdd(); - $do->selectAdd('translation'); - if (!$do->find(true)) { - return ''; - } - return $do->translation; - - } - - // }}} - // {{{ getStringID() - - /** - * Get the stringID for the given string - * - * @param string $stringID - * @param string $pageID - * @return string - */ - function getStringID($string, $page=null) - { - // get the enlgish version.. - - $do = DB_DataObject::factory($this->options['table']); - $do->lang = $this->currentLang['id']; - $do->page = $page; - $do->translation = $string; - if ($do->find(true)) { - return ''; - } - return $do->string_id; - } - - // }}} -} -?> \ No newline at end of file + // }}} + // {{{ fetchLangs() + + /** + * Fetch the available langs if they're not cached yet. + */ + function fetchLangs() + { + $do = DB_DataObject::factory($this->options['table']); + $do->selectAdd(); + $do->selectAdd('distinct lang'); + $do->find(); + + $ret = array(); + while ($do->fetch()) { + $l = $do->lang; + $ret[$l] = array( + 'id' => $l, + 'name' => $l, + 'meta' => '', + 'error_text' => '', + ); + } + $this->langs = $ret; + } + + // }}} + // {{{ getPage() + + /** + * Returns an array of the strings in the selected page + * + * @param string $pageID + * @param string $langID + * @return array + */ + function getPage($page=null, $lang=null) + { + if (is_null($langID)) { + $lang= $this->currentLang['id']; + } + + $do = DB_DataObject::factory($this->options['table']); + $do->lang = $lang; + $do->page = $page; + + $do->find(); + $strings = array(); + while ($do->fetch()) { + $strings[$do->string_id] = $do->translation; + } + + return $strings; + } + + // }}} + // {{{ getOne() + + /** + * Get a single item from the container, without caching the whole page + * + * @param string $stringID + * @param string $pageID + * @param string $langID + * @return string + */ + function getOne($string, $page=null, $lang=null) + { + $lang = $lang ? $lang : $this->currentLang['id']; + // get the string id + $do = DB_DataObject::factory($this->options['table']); + $do->lang = '-'; + $do->page = $page; + $do->translation = $string; + // we dont have the base language translation.. + if (!$do->find(true)) { + return ''; + } + $stringID = $do->string_id; + + $do = DB_DataObject::factory($this->options['table']); + $do->lang = $lang; + $do->page = $page; + $do->string_id = $stringID; + //print_r($do); + $do->selectAdd(); + $do->selectAdd('translation'); + if (!$do->find(true)) { + return ''; + } + return $do->translation; + + } + + // }}} + // {{{ getStringID() + + /** + * Get the stringID for the given string + * + * @param string $stringID + * @param string $pageID + * @return string + */ + function getStringID($string, $page=null) + { + // get the enlgish version.. + + $do = DB_DataObject::factory($this->options['table']); + $do->lang = $this->currentLang['id']; + $do->page = $page; + $do->translation = $string; + if ($do->find(true)) { + return ''; + } + return $do->string_id; + } + + // }}} +} +?>