LEFT JOIN geoloc_region AS gr ON (adr.pays = gr.a2 AND adr.region = gr.region)
WHERE c.uid = $uid
ORDER BY sortkey, a.prenom";
- $page->mysql_assign($sql,'contacts','nb_contacts');
+
+ $page->assign_by_ref('citer', $globals->xdb->iterator($sql));
}
$page->run();
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once("diogenes.core.globals.inc.php");
-require_once("diogenes.database.inc.php");
+require_once('diogenes.core.globals.inc.php');
// {{{ class XorgGlobals
var $hook;
/** The x.org version */
- var $version = "@VERSION@";
+ var $version = '@VERSION@';
var $debug = false;
/** db params */
var $table_log_events = 'logger.events';
/** logger */
- var $tauth = array('native'=>"auth_user_md5");
- var $tlabel = array('native'=>"X.Org");
+ var $tauth = array('native'=>'auth_user_md5');
+ var $tlabel = array('native'=>'X.Org');
/** paths */
- var $baseurl = "http://localhost/xorg";
- var $spoolroot = "/var/spool/xorg";
+ var $baseurl = 'http://localhost/xorg';
+ var $spoolroot = '/var/spool/xorg';
var $root = null;
function init()
{
global $globals;
- require_once("xorg/hook.inc.php");
- require_once("xorg/menu.inc.php");
+ require_once('xorg/hook.inc.php');
+ require_once('xorg/menu.inc.php');
$globals = new XorgGlobals;
$globals->root = dirname(dirname(__FILE__));
$globals->db->trace_on();
}
}
+
+ function dbconnect()
+ {
+ parent::dbconnect();
+ $this->xdb =& new XOrgDB($this->db);
+ }
}
// }}}
// }}}
// {{{ globals + session init
-require_once("xorg.globals.inc.php");
-require_once('xorg/session.inc.php');
require_once('xorg/env.inc.php');
+require_once('xorg/iterator.inc.php');
+require_once('xorg/database.inc.php');
+require_once('xorg.globals.inc.php');
+require_once('xorg/session.inc.php');
XorgGlobals::init();
XorgSession::init();
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ **************************************************************************/
+
+require_once('diogenes.database.inc.php');
+
+// {{{ class XOrgDB
+
+class XOrgDB
+{
+ // {{{ properties
+
+ var $_db;
+
+ // }}}
+ // {{{ constructor
+
+ function XOrgDB(&$diog_db)
+ {
+ $this->_db =& $diog_db;
+ }
+
+ // }}}
+ // {{{ function query
+
+ function &query()
+ {
+ $args = func_get_args();
+ $query = array_map(Array($this, '_db_escape'), $args);
+ $query[0] = $args[0];
+ return new XOrgDBResult(call_user_func_array('sprintf', $query), $this->_db);
+ }
+
+ // }}}
+ // {{{ function iterator()
+
+ function &iterator()
+ {
+ $args = func_get_args();
+ $query = array_map(Array($this, '_db_escape'), $args);
+ $query[0] = $args[0];
+ return new XOrgDBIterator(call_user_func_array('sprintf', $query), $this->_db);
+ }
+
+ // }}}
+ // {{{ function _db_escape
+
+ function _db_escape(&$var)
+ {
+ switch (gettype($var)) {
+ case 'boolean':
+ return $var ? 1 : 0;
+
+ case 'integer':
+ case 'double':
+ case 'float':
+ return $var;
+
+ case 'string':
+ if (get_magic_quotes_gpc()) {
+ return addslashes(stripslashes($var));
+ } else {
+ return addslashes($var);
+ }
+
+ case 'NULL':
+ return 'NULL';
+
+ case 'object':
+ case 'array':
+ return addslashes(serialize($var));
+
+ default:
+ die(var_export($var, true).' is not a valid for a database entry');
+ }
+ }
+
+ // }}}
+}
+
+// }}}
+// {{{ class XOrgDBResult
+
+class XOrgDBResult
+{
+ // {{{ properties
+
+ var $_res;
+
+ // }}}
+ // {{{ constructor
+
+ function XOrgDBResult($query, &$db)
+ {
+ $this->_res =& $db->query($query);
+ }
+
+ // }}}
+ // {{{ destructor
+
+ function free()
+ {
+ mysql_free_result($this->_res);
+ unset($this);
+ }
+
+ // }}}
+ // {{{ function fetchRow
+
+ function &fetchRow()
+ {
+ return mysql_fetch_row($this->_res);
+ }
+
+ // }}}
+ // {{{ function fetchAssoc
+
+ function &fetchAssoc()
+ {
+ return mysql_fetch_assoc($this->_res);
+ }
+
+ // }}}
+ // {{{ function fetchAllRow
+
+ function &fetchAllRow()
+ {
+ $result = Array();
+ while ($result[] = mysql_fetch_row($this->_res)) { }
+ array_pop($result);
+ return $result;
+ }
+
+ // }}}
+ // {{{ function fetchAssoc
+
+ function &fetchAllAssoc()
+ {
+ $result = Array();
+ while ($result[] = mysql_fetch_assoc($this->_res)) { }
+ array_pop($result);
+ return $result;
+ }
+
+ // }}}
+ // {{{ function numRows
+
+ function numRows()
+ {
+ return mysql_num_rows($this->_res);
+ }
+
+ // }}}
+}
+
+// }}}
+// {{{ class XOrgDBIterator
+
+class XOrgDBIterator extends XOrgIterator
+{
+ // {{{ properties
+
+ var $_result;
+ var $_pos;
+ var $_total;
+ var $_mode = MYSQL_ASSOC;
+
+ // }}}
+ // {{{
+
+ function XOrgDBIterator($query, &$db, $mode = MYSQL_ASSOC)
+ {
+ $this->_result =& new XOrgDBResult($query, $db);
+ $this->_pos = 0;
+ $this->_total = $this->_result->numRows();
+ $this->_mode = $mode;
+ }
+
+ // }}}
+ // {{{ function next ()
+
+ function &next()
+ {
+ $this->_pos ++;
+ if ($this->_pos > $this->_total) {
+ $this->_result->free();
+ unset($this);
+ return null;
+ }
+ return $this->_mode != MYSQL_ASSOC ? $this->_result->fetchRow() : $this->_result->fetchAssoc();
+ }
+
+ // }}}
+ // {{{ function first
+
+ function first()
+ {
+ return $this->_pos == 1;
+ }
+
+ // }}}
+ // {{{ function last
+
+ function last()
+ {
+ return $this->_last == $this->_total;
+ }
+
+ // }}}
+ // {{{ function total()
+
+ function total()
+ {
+ return $this->_total;
+ }
+
+ // }}}
+}
+
+// }}}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ **************************************************************************/
+
+// {{{ class XOrgIterator
+
+class XOrgIterator
+{
+ // {{{ function next
+
+ function &next()
+ {
+ return null;
+ }
+
+ // }}}
+ // {{{ function first
+
+ function first()
+ {
+ return false;
+ }
+
+ // }}}
+ // {{{ function last
+
+ function last()
+ {
+ return false;
+ }
+
+ // }}}
+ // {{{ function total
+
+ function total()
+ {
+ return 0;
+ }
+
+ // }}}
+
+}
+
+// }}}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
+?>
$this->cache_dir = $globals->spoolroot."/cache/";
$this->use_sub_dirs = false;
-
$this->config_overwrite = false;
$this->compile_check = !empty($globals->debug);
$this->caching = ($type == SKINNED);
- if ($type == SKINNED) {
- $this->register_modifier('escape_html', 'escape_html');
- $this->default_modifiers = Array('escape_html');
- }
+
+ if ($type == SKINNED) {
+ $this->register_modifier('escape_html', 'escape_html');
+ $this->default_modifiers[] = '@escape_html';
+ }
$this->_page_type = $type;
$this->_tpl = $tpl;
$this->caching = ($type == SKINNED);
if ($type == SKINNED) {
$this->register_modifier('escape_html', 'escape_html');
- $this->default_modifiers = Array('escape_html');
+ $this->default_modifiers = Array('@escape_html');
}
$this->_page_type = $type;
* " --> "
* & not followed by some entity --> &
*/
-function escape_html(&$string)
+function escape_html($string)
{
if(is_string($string)) {
$transtbl = Array('<' => '<', '>' => '>', '"' => '"');
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2004 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+function iterate_end($tag_attrs, &$compiler) {
+ return 'endwhile;';
+}
+
+function smarty_compiler_iterate($tag_attrs, &$compiler)
+{
+ static $reg = false;
+ if (!$reg) {
+ $reg = true;
+ $compiler->register_compiler_function("/iterate", 'iterate_end');
+ }
+
+ $_params = $compiler->_parse_attrs($tag_attrs);
+
+ if (!isset($_params['from'])) {
+ $compiler->_syntax_error("iterate: missing 'from' parameter", E_USER_ERROR, __FILE__, __LINE__);
+ return;
+ }
+
+ if (empty($_params['item'])) {
+ $compiler->_syntax_error("iterate: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
+ return;
+ }
+
+ $_from = $compiler->_dequote($_params['from']);
+ $_item = $compiler->_dequote($_params['item']);
+
+ if (!is_subclass_of($compiler->_tpl_vars[$_from], 'XOrgIterator')) {
+ $compiler->_syntax_error("iterate: 'from' parameter has to be a instance of an XOrgIterator Object",
+ E_USER_ERROR, __FILE__, __LINE__);
+ return;
+ }
+
+
+ return "while ((\$this->_tpl_vars['$_item'] =& \$this->_tpl_vars['$_from']->next()) !== null):";
+}
+
+/* vim: set expandtab: */
+
+?>
il te suffit de cliquer sur l'icône <img src="{"images/ajouter.gif"|url}" alt="ajout contact" /> en face de son nom dans les résultats !
</p>
-{if $nb_contacts || $trombi}
+{if $citer->total()}
<p>
Pour récupérer ta liste de contacts dans un PDF imprimable :<br />
[<a href="mescontacts_pdf.php/mes_contacts.pdf?order=promo" class='popup'><strong>Triée par promo</strong></a>]
<br />
<div class="contact-list">
-{foreach item=contact from=$contacts}
+{iterate from=citer item=contact}
{include file=include/minifiche.tpl c=$contact show_action="retirer"}
-{/foreach}
+{/iterate}
</div>
{/if}