Home » Internationalization » Translation2 » Bug #2667
method to fetch all page ids
Details
| Request #2667 | method to fetch all page ids |
|---|---|
| Submitted | 2004-11-01 19:01 UTC |
| From | michael dot caplan at lechateau dot ca |
| Assigned | quipo |
| Status | Closed |
| Package | Translation2 |
| PHP Version | Irrelevant |
| OS | irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2004-11-01 19:01 UTC] michael dot caplan at lechateau dot ca
Description:
------------
I'm developing an admin interface for translating all pages. Perhasp I am missing something here, but is there a way I can fetch an array of all possible page ids so I can present a form of strings to be translated by page id?
If not, I have coded one that I can submit for your review
Thanks,
Michael
[2004-11-09 19:29 UTC] michael dot caplan at lechateau dot ca
here is a diff:
===================================================================
RCS file: /prod/cvs/intranet_3/lib/Translation2/Admin.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -p --unified=3 -r1.1 -r1.2
--- Admin.php 2004/10/25 18:40:35 1.1
+++ Admin.php 2004/11/02 15:18:14 1.2
@@ -16,11 +16,11 @@
// | Authors: Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: Admin.php,v 1.1 2004/10/25 18:40:35 intranet Exp $
+// $Id: Admin.php,v 1.2 2004/11/02 15:18:14 michael Exp $
//
/**
* @package Translation2
- * @version $Id: Admin.php,v 1.1 2004/10/25 18:40:35 intranet Exp $
+ * @version $Id: Admin.php,v 1.2 2004/11/02 15:18:14 michael Exp $
*/
/**
@@ -35,7 +35,7 @@ require_once 'Translation2.php';
* with a common API for all the containers.
*
* @package Translation2
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
class Translation2_Admin extends Translation2
{
@@ -191,5 +191,18 @@ class Translation2_Admin extends Transla
}
// }}}
+ // {{{ getDefinedPages()
+
+ /**
+ * Retreive a list of all defined pages
+ *
+ * @return mixed Array on success, PEAR_Error on failure
+ */
+ function getDefinedPages()
+ {
+ return $this->storage->getDefinedPages();
+ }
+
+ // }}}
}
?>
===================================================================
RCS file: /prod/cvs/intranet_3/lib/Translation2/Admin/Container/mdb2.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -p --unified=3 -r1.1 -r1.2
--- mdb2.php 2004/10/25 18:40:35 1.1
+++ mdb2.php 2004/11/02 15:18:14 1.2
@@ -16,11 +16,11 @@
// | Author: Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: mdb2.php,v 1.1 2004/10/25 18:40:35 intranet Exp $
+// $Id: mdb2.php,v 1.2 2004/11/02 15:18:14 michael Exp $
//
/**
* @package Translation2
- * @version $Id: mdb2.php,v 1.1 2004/10/25 18:40:35 intranet Exp $
+ * @version $Id: mdb2.php,v 1.2 2004/11/02 15:18:14 michael Exp $
*/
/**
@@ -35,7 +35,7 @@ require_once 'Translation2/Container/mdb
* by the PEAR MDB2 abstraction layer to fetch data.
*
* @package Translation2
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
class Translation2_Admin_Container_mdb2 extends Translation2_Container_mdb2
{
@@ -46,25 +46,15 @@ class Translation2_Admin_Container_mdb2
// }}}
// {{{
- /**
- * Fetch the table names from the db
- * @access private
- * @return mixed array on success, PEAR_Error on failure
- */
- function _fetchTableNames()
- {
- $res = $this->query('SHOW TABLES', 'queryAll');
- if (PEAR::isError($res)) {
- return $res;
- }
- if (empty($res) || !is_array($res)) {
- //return error
- }
- $tables = array();
- foreach ($res as $record) {
- $tables[] = $record[0];
- }
- return $tables;
+ /**
+ * Fetch the table names from the db
+ * @access private
+ * @return mixed array on success, PEAR_Error on failure
+ */
+ function _fetchTableNames()
+ {
+ $this->db->loadModule('manager');
+ return $this->db->manager->listTables();
}
// }}}
@@ -178,6 +168,41 @@ class Translation2_Admin_Container_mdb2
}
// }}}
+ // {{{ getDefinedPages()
+
+ /**
+ * Retreive a list of all defined pages
+ *
+ * @return mixed Array on success, PEAR_Error on failure
+ */
+ function getDefinedPages()
+ {
+
+ //var_dump::display($this->options);
+ $pages = array();
+ foreach ($this->options['strings_tables'] as $lang => $table) {
+ $query = 'SELECT UNIQUE '
+ . $this->options['string_page_id_col']
+ . ' FROM ' . $table;
+ $res = $this->query($query, 'queryAll');
+
+ if (PEAR::isError($res)) {
+ return $res;
+ }
+
+ foreach($res as $page) {
+ if (in_array($page[0], $pages)) {
+ continue;
+ }
+ $pages[] = $page[0];
+ }
+ }
+
+ return $pages;
+ }
+
+ // }}}
+
// {{{ add()
/**
[2004-11-26 18:14 UTC] tobias dot eberle at gmx dot de
I am coding an interface either and I miss this feature very much.
[2004-11-29 17:55 UTC] michael dot caplan at lechateau dot ca
FYI, here is the diff (only covers MDB2 admin container)
===================================================================
RCS file: /prod/cvs/intranet_3/lib/Translation2/Admin.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -bB -p --unified=3 -r1.4 -r1.5
--- Admin.php 2004/11/12 13:54:35 1.4
+++ Admin.php 2004/11/29 17:46:53 1.5
@@ -16,11 +16,11 @@
// | Authors: Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: Admin.php,v 1.4 2004/11/12 13:54:35 michael Exp $
+// $Id: Admin.php,v 1.5 2004/11/29 17:46:53 michael Exp $
//
/**
* @package Translation2
- * @version $Id: Admin.php,v 1.4 2004/11/12 13:54:35 michael Exp $
+ * @version $Id: Admin.php,v 1.5 2004/11/29 17:46:53 michael Exp $
*/
/**
@@ -35,7 +35,7 @@ require_once 'Translation2.php';
* with a common API for all the containers.
*
* @package Translation2
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
class Translation2_Admin extends Translation2
{
@@ -284,18 +284,5 @@ class Translation2_Admin extends Transla
}
// }}}
- // {{{ getDefinedPages()
-
- /**
- * Retreive a list of all defined pages
- *
- * @return mixed Array on success, PEAR_Error on failure
- */
- function getDefinedPages()
- {
- return $this->storage->getDefinedPages();
- }
-
- // }}}
}
?>
===================================================================
RCS file: /prod/cvs/intranet_3/lib/Translation2/Admin/Container/mdb2.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -bB -p --unified=3 -r1.4 -r1.5
--- mdb2.php 2004/11/12 13:54:35 1.4
+++ mdb2.php 2004/11/29 17:46:53 1.5
@@ -16,11 +16,11 @@
// | Author: Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: mdb2.php,v 1.4 2004/11/12 13:54:35 michael Exp $
+// $Id: mdb2.php,v 1.5 2004/11/29 17:46:53 michael Exp $
//
/**
* @package Translation2
- * @version $Id: mdb2.php,v 1.4 2004/11/12 13:54:35 michael Exp $
+ * @version $Id: mdb2.php,v 1.5 2004/11/29 17:46:53 michael Exp $
*/
/**
@@ -35,7 +35,7 @@ require_once 'Translation2/Container/mdb
* by the PEAR MDB2 abstraction layer to fetch data.
*
* @package Translation2
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
class Translation2_Admin_Container_mdb2 extends Translation2_Container_mdb2
{
@@ -220,7 +220,7 @@ class Translation2_Admin_Container_mdb2
$this->options['lang_id_col'],
$this->db->quote($langID, 'text')
);
- ++$this->queries;
+ ++$this->_queries;
$res = $this->db->query($query);
if (PEAR::isError($res)) {
return $res;
@@ -234,7 +234,7 @@ class Translation2_Admin_Container_mdb2
$lang_table,
$this->_getLangCol($langID)
);
- ++$this->queries;
+ ++$this->_queries;
return $this->db->query($query);
}
@@ -557,38 +557,5 @@ class Translation2_Admin_Container_mdb2
}
// }}}
- // {{{ getDefinedPages()
-
- /**
- * Retreive a list of all defined pages
- *
- * @return mixed Array on success, PEAR_Error on failure
- */
- function getDefinedPages()
- {
-
- $pages = array();
- foreach ($this->options['strings_tables'] as $lang => $table) {
- $query = 'SELECT UNIQUE '
- . $this->options['string_page_id_col']
- . ' FROM ' . $table;
-
- $res = $this->db->queryCol($query);
-
- if (PEAR::isError($res)) {
- return $res;
- }
-
- foreach($res as $page) {
- if (in_array($page, $pages)) {
- continue;
- }
- $pages[] = $page;
- }
- }
- return $pages;
- }
-
- // }}}
}
?>