/*
|---------------------------------------------------------------------------------------------------
| Obtiene la extensión de un archivo
|---------------------------------------------------------------------------------------------------
168866
public static function get_file_extension( $file_path = '' ){
		$file_path = strtolower( $file_path );
		$file_path = parse_url( $file_path, PHP_URL_PATH );
		return pathinfo( $file_path, PATHINFO_EXTENSION );
	}
859930
function archive($id)
    {
        $this->requestDecorator->setId($id  . '/archived');
        $result = $this->client->put($this->requestDecorator->makeResource(), $this->requestDecorator->makePayload(), $this->requestDecorator->makeHeaders());
        $this->refresh();
        return $result;
    }
928883
private function respaldarDocumentosEmitidos()
    {
        // obtener DTE emitidos en el Portal MIPYME del SII
        $this->log('Descargando documentos emitidos');
        $emitidos = $this->LibreDTE->post('/utilidades/sii/mipyme_dte_emitidos/'.$this->args['contribuyente'], [
            'auth'=>[
                'rut' => $this->args['usuario'],
                'clave' => $this->args['clave'],
            ],
        ]);
        if ($emitidos['status']['code']!=200) {
            $this->log(' [error] Al obtener DTE emitidos en Portal MIPYME del SII: '.$emitidos['body']);
            return;
        }
        file_put_contents($this->args['salida'].'/emitidos_'.$this->args['contribuyente'].'.json', json_encode($emitidos['body'], JSON_PRETTY_PRINT));
        // descargar PDF y XML de los documentos
        $n_docs = count($emitidos['body']);
        $i = 0;
        foreach ($emitidos['body'] as $doc) {
            $i++;
            $this->log('Descargando PDF y XML '.$this->num($i).'/'.$this->num($n_docs).' '.$doc['dte'].' #'.$doc['folio']);
            // descargar PDF
            $pdf = $this->LibreDTE->post('/utilidades/sii/mipyme_dte_emitido_pdf/'.$this->args['contribuyente'].'/'.$doc['codigo'], [
                'auth'=>[
                    'rut' => $this->args['usuario'],
                    'clave' => $this->args['clave'],
                ],
            ]);
            if ($pdf['status']['code']!=200) {
                $this->log(' [error] Al obtener el PDF '.$doc['codigo'].': '.$pdf['body']);
            } else {
                file_put_contents($this->args['salida'].'/emitidos/dte_'.$this->args['contribuyente'].'_T'.$this->getCodigoDTE($doc['dte']).'F'.$doc['folio'].'.pdf', $pdf['body']);
            }
            // descargar XML
            $xml = $this->LibreDTE->post('/utilidades/sii/mipyme_dte_emitido_xml/'.$this->args['contribuyente'].'/'.$this->getCodigoDTE($doc['dte']).'/'.$doc['folio'], [
                'auth'=>[
                    'rut' => $this->args['usuario'],
                    'clave' => $this->args['clave'],
                ],
            ]);
            if ($xml['status']['code']!=200) {
                $this->log(' [error] Al obtener el XML '.$doc['codigo'].': '.$xml['body']);
            } else {
                file_put_contents($this->args['salida'].'/emitidos/dte_'.$this->args['contribuyente'].'_T'.$this->getCodigoDTE($doc['dte']).'F'.$doc['folio'].'.xml', $xml['body']);
            }
        }
    }
1330275
function crop($c_width, $c_height, $pos = 'center')
    {
        $new_width = $c_width;
        $new_height = $c_height;

        // Calcula el alto en base al nuevo ancho
        $t_height = ($new_width * $this->height) / $this->width;

        // Calcula el ancho en base al nuevo alto
        $t_width = ($new_height * $this->width) / $this->height;

        if($t_width >= $new_width)
        {
            $new_width = $t_width;
        }
        else
        {
            $new_height = $t_height;
        }

        $image = imagecreatetruecolor( $new_width, $new_height );
        imagecopyresampled($image, $this->image, 0, 0, 0, 0, $new_width, $new_height, $this->width, $this->height);

        $this->width = imagesx($image);
        $this->height = imagesy($image);
        $this->image = $image;

        //---Crear la imagen tomando la porción del centro de la imagen redimensionada con las dimensiones deseadas
        $image = imagecreatetruecolor($c_width, $c_height);

        switch($pos)
        {
            case 'center':
                imagecopyresampled($image, $this->image, 0, 0, abs(($this->width - $c_width) / 2), abs(($this->height - $c_height) / 2), $c_width, $c_height, $c_width, $c_height);
                break;

            case 'left':
                imagecopyresampled($image, $this->image, 0, 0, 0, abs(($this->height - $c_height) / 2), $c_width, $c_height, $c_width, $c_height);
                break;

            case 'right':
                imagecopyresampled($image, $this->image, 0, 0, $this->width - $c_width, abs(($this->height - $c_height) / 2), $c_width, $c_height, $c_width, $c_height);
                break;

            case 'top':
                imagecopyresampled($image, $this->image, 0, 0, abs(($this->width - $c_width) / 2), 0, $c_width, $c_height, $c_width, $c_height);
                break;

            case 'bottom':
                imagecopyresampled($image, $this->image, 0, 0, abs(($this->width - $c_width) / 2), $this->height - $c_height, $c_width, $c_height, $c_width, $c_height);
                break;
        }

        $this->image = $image;
    }
912319
def EmitirRemito(self, archivo="qr.png"):
        ""
        response = self.client.emitirRemito(
                                authRequest={'token': self.Token, 'sign': self.Sign, 'cuitRepresentada': self.Cuit},
                                codRemito=self.remito['codRemito'],
                                viaje=self.remito.get('viaje'))
        ret = response.get("emitirRemitoReturn")
        if ret:
            self.__analizar_errores(ret)
            self.__analizar_observaciones(ret)
            self.__analizar_evento(ret)
            self.AnalizarRemito(ret, archivo)
        return bool(self.CodRemito)
987146
public function currentAction()
    {
        $objectId = !empty($this->getPost()->objectId) ? $this->getPost()->objectId : null;
        switch ($this->getPost()->fileTypes) {
            case 'images' :
                //zapytanie o obrazki
                $query = CmsFileQuery::imagesByObject($this->getPost()->object, $objectId);
                break;
            case 'notImages' :
                //wszystkie pliki bez obrazków
                $query = CmsFileQuery::notImagesByObject($this->getPost()->object, $objectId);
                break;
            default :
                //domyślne zapytanie o wszystkie pliki
                $query = CmsFileQuery::byObject($this->getPost()->object, $objectId);
        }

        $records = $query->find();
        foreach ($records as $record) {
            $record->data = $record->data->toArray();
        }

        //zwrot json'a z plikami
        return json_encode([
            'result' => 'OK',
            'files' => $records->toArray()
        ]);
    }
770236
public function savePost()
    {
        $key = $_REQUEST['id'];

        if (is_numeric($key)) {
            return $this->saveAsPostMeta($key);
        }

        if (\Modularity\Helper\Post::isArchive()) {
            global $archive;
            $key = $archive;
        }

        return $this->saveAsOption($key);
    }
620478
public function archiveTitle()
    {
        if (is_category()) {
            $output = sprintf('%s: %s', __('Category', 'novusopress'), single_cat_title('', false));
        } elseif (is_tag()) {
            $output = sprintf('%s: %s', __('Tag', 'novusopress'), single_tag_title('', false));
        } elseif (is_day()) {
            $output = sprintf('%s: %s', __('Date Archive', 'novusopress'), get_the_time(get_option('date_format')));
        } elseif (is_month()) {
            $output = sprintf('%s: %s', __('Month Archive', 'novusopress'), get_the_time('F Y'));
        } elseif (is_year()) {
            $output = sprintf('%s: %s', __('Year Archive', 'novusopress'), get_the_time('Y'));
        } elseif (is_author()) {
            global $author;

            $userdata = get_userdata($author);

            $output = sprintf('%s: %s', __('Author', 'novusopress'), $userdata->display_name);
        } else {
            $output = '';
        }

        return apply_filters('novusopress_view_archive_title_output', $output);
    }
996441
public function enregistreCommentaire()
    {
        $auth = new archiAuthentification();
        $fieldsCommentaires=$this->getCommentairesFields();
        $formulaire = new formGenerator();


        if ($auth->estConnecte()) {
            unset($fieldsCommentaires['captcha']);
        }

        $error = $formulaire->getArrayFromPost($fieldsCommentaires);

        if (count($error)==0) {
            $idUtilisateur=0;
            if ($auth->estConnecte()) {
                $idUtilisateur = $auth->getIdUtilisateur();
                // suite au SPAM mise en place d'un champ CommentaireValide 0/1 (by fabien 13/01/2012)
                $CommentaireValide=1;
                $user = new archiUtilisateur();
                $userInfos = $user->getArrayInfosFromUtilisateur($idUtilisateur);
            } else {
                $CommentaireValide=0;
            }


            // enregistrement du nouveau commentaire
            //$req = "insert into commentaires (nom,prenom,email,commentaire,idEvenementGroupeAdresse,date,idUtilisateur) values (\"".addslashes(strip_tags($this->variablesPost['nom']))."\",\"".addslashes(strip_tags($this->variablesPost['prenom']))."\",\"".addslashes(strip_tags($this->variablesPost['email']))."\",\"".addslashes(strip_tags($this->variablesPost['commentaire']))."\",'".$this->variablesPost['idEvenementGroupeAdresse']."',now(),'".$idUtilisateur."')";
            $nom=$auth->estConnecte()?$userInfos["nom"]:$this->variablesPost['nom'];
            $prenom=$auth->estConnecte()?$userInfos["prenom"]:$this->variablesPost['prenom'];
            $email=$auth->estConnecte()?$user->getMailUtilisateur($idUtilisateur):$this->variablesPost['email'];
            $uniqid = uniqid(null, true);

            $req = "INSERT INTO commentaires (nom, prenom, email, commentaire, idEvenementGroupeAdresse, date, idUtilisateur, CommentaireValide, uniqid) VALUES ('".mysql_real_escape_string(strip_tags($nom))."', '".mysql_real_escape_string(strip_tags($prenom))."', '".mysql_real_escape_string(strip_tags($email))."', '".mysql_real_escape_string(strip_tags($this->variablesPost['commentaire']))."', '".mysql_real_escape_string($this->variablesPost['idEvenementGroupeAdresse'])."', now(), '".mysql_real_escape_string($idUtilisateur). "'," . mysql_real_escape_string($CommentaireValide).", '".mysql_real_escape_string($uniqid)."')";

            $res = $this->connexionBdd->requete($req);

            $idCommentaire = mysql_insert_id();

            // retour a l'affichage de l'adresse
            $idAdresse = $this->getIdAdresseFromIdEvenementGroupeAdresse($this->variablesPost['idEvenementGroupeAdresse']);



            // ************************
            // envoi d'un mail a tous les participants pour le groupe d'adresse
            // ************************
            $mail = new mailObject();
            $utilisateur = new archiUtilisateur();
            $arrayUtilisateurs = $utilisateur->getParticipantsCommentaires($this->variablesPost['idEvenementGroupeAdresse']);
            $arrayCreatorAdresse = $utilisateur->getCreatorsFromAdresseFrom($this->variablesPost['idEvenementGroupeAdresse'], 'idEvenementGroupeAdresse');
            $arrayUtilisateurs = array_merge($arrayUtilisateurs, $arrayCreatorAdresse);
            $arrayUtilisateurs = array_unique($arrayUtilisateurs);
            $intituleAdresse = $this->getIntituleAdresseFrom($idAdresse, 'idAdresse');
            foreach ($arrayUtilisateurs as $indice => $idUtilisateurAdresse) {
                if ($idUtilisateurAdresse != $auth->getIdUtilisateur()) {
                    $infosUtilisateur = $utilisateur->getArrayInfosFromUtilisateur($idUtilisateurAdresse);
                    if ($infosUtilisateur['alerteCommentaires']=='1' && $infosUtilisateur['compteActif']=='1' && $infosUtilisateur['idProfil']!='4') {
                        $message = "Un utilisateur a ajouté un commentaire sur une adresse ou vous avez participé.";
                        $message.= "Pour vous rendre sur l'adresse : <a href='".$this->creerUrl('', '', array('archiAffichage'=>'adresseDetail','archiIdAdresse'=>$idAdresse,'archiIdEvenementGroupeAdresse'=>$this->variablesPost['idEvenementGroupeAdresse'])).'#commentaireAdresse'.$idCommentaire."'>".$intituleAdresse."</a><br>";
                        $message.= $this->getMessageDesabonnerAlerteMail();
                        $mail->sendMail($mail->getSiteMail(), $infosUtilisateur['mail'], 'Ajout d\'un commentaire sur une adresse sur laquelle vous avez participé.', $message, true);
                    }
                }
            }
            // ************************




            // envoi d'un mail aux administrateur pour la moderation
            $message="Merci d'avoir laissé un commentaire sur Archi-Strasbourg.<br>";
            $message .= "Afin qu'il soit publié, merci de le valider en cliquant sur ";
            $message .="<a href='".$this->getUrlRacine()."script/validateEmail.php?uniqid=".urlencode($uniqid)."'>ce lien</a>.<br>";
            $message .="<br/>Cordialement,</br>";
            $mail = new mailObject();

            $envoyeur['envoyeur'] = $mail->getSiteMail();
            $envoyeur['replyTo'] = strip_tags($this->variablesPost['email']);
            $u = new archiUtilisateur();
            if (!$CommentaireValide) {
                $mail->sendMail($envoyeur['envoyeur'], $this->variablesPost['email'], 'Votre commentaire sur Archi-Strasbourg', $message, true);
            } else {
                $message="Un utilisateur a ajouté un commentaire sur archiV2 : <br>";
                $message .= "nom ou pseudo : ".strip_tags($this->variablesPost['nom'])."<br>";
                $message .= "prenom : ".strip_tags($this->variablesPost['prenom'])."<br>";
                $message .= "email : ".strip_tags($this->variablesPost['email'])."<br>";
                $message .= "commentaire : ".stripslashes(strip_tags($this->variablesPost['commentaire']))."<br>";
                $message .="<a href='".$this->creerUrl('', '', array('archiAffichage'=>'adresseDetail','archiIdEvenementGroupeAdresse'=>$this->variablesPost['idEvenementGroupeAdresse'],'archiIdAdresse'=>$idAdresse)).'#commentaireAdresse'.$idCommentaire."'>".$intituleAdresse."</a><br>";

                $mail->sendMailToAdministrators($envoyeur, 'Un utilisateur a ajouté un commentaire', $message, " AND alerteCommentaires='1' ", true, true);
                // envoi mail aussi au moderateur si ajout sur adresse de ville que celui ci modere
                $arrayVilles=array();
                $arrayVilles[] = $this->getIdVilleFrom($idAdresse, 'idAdresse');
                $arrayVilles = array_unique($arrayVilles);
                $arrayListeModerateurs = $u->getArrayIdModerateursActifsFromVille($arrayVilles[0], array("sqlWhere"=>" AND alerteCommentaires='1' "));
                if (count($arrayListeModerateurs)>0) {
                    foreach ($arrayListeModerateurs as $indice => $idModerateur) {
                        if ($auth->getIdUtilisateur()!=$idModerateur) {
                            $mailModerateur = $u->getMailUtilisateur($idModerateur);

                            $mail->sendMail($mail->getSiteMail(), $mailModerateur, 'Un utilisateur a ajouté un commentaire', $message, true);
                        }
                    }
                }
            }


            // remise a zero des variables en post sinon on va reafficher les infos
            $_POST['commentaire']="";
            $_POST['email']="";
            $_POST['nom']="";
            $_POST['prenom']="";

            $this->variablesGet['archiIdEvenementGroupeAdresse'] = $this->variablesPost['idEvenementGroupeAdresse'];
            $idAdresse=$this->getIdAdresseFromIdEvenementGroupeAdresse($this->variablesGet['archiIdEvenementGroupeAdresse']);

            $this->messages->addConfirmation("Commentaire enregistré !");
            $this->messages->display();
            header("Location: ".$this->creerUrl('', '', array('archiAffichage'=>'adresseDetail', 'archiIdAdresse'=>$idAdresse, 'archiIdEvenementGroupeAdresse'=>$this->variablesGet['archiIdEvenementGroupeAdresse']), false, false).'#commentaireAdresse'.$idCommentaire);
        } else {
            $this->messages->addError("Il y a une erreur dans le formulaire.");
            $this->messages->display();
            echo $this->getListeCommentaires($this->variablesPost['idEvenementGroupeAdresse']);
            echo $this->getFormulaireCommentaires($this->variablesPost['idEvenementGroupeAdresse'], $fieldsCommentaires);
        }
    }
1077698
public function newsArchiveList()
    {
        $entries = $this->newsManager()->archive();
        foreach ($entries as $entry) {
            yield $this->newsFormatShort($entry);
        }
    }
1358252
function prefs_table($args)
    {
        global $CURR_SECTION;

        $this->add_texts('localization');

        $rcmail        = rcmail::get_instance();
        $dont_override = $rcmail->config->get('dont_override', array());

        if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) {
            $mbox = $rcmail->config->get('archive_mbox');
            $type = $rcmail->config->get('archive_type');

            // load folders list when needed
            if ($CURR_SECTION) {
                $select = $rcmail->folder_selector(array(
                        'noselection'   => '---',
                        'realnames'     => true,
                        'maxlength'     => 30,
                        'folder_filter' => 'mail',
                        'folder_rights' => 'w',
                        'onchange'      => "if ($(this).val() == 'INBOX') $(this).val('')",
                ));
            }
            else {
                $select = new html_select();
            }

            $args['blocks']['main']['options']['archive_mbox'] = array(
                'title'   => $this->gettext('archivefolder'),
                'content' => $select->show($mbox, array('name' => "_archive_mbox"))
            );

            // add option for structuring the archive folder
            $archive_type = new html_select(array('name' => '_archive_type', 'id' => 'ff_archive_type'));
            $archive_type->add($this->gettext('none'), '');
            $archive_type->add($this->gettext('archivetypeyear'), 'year');
            $archive_type->add($this->gettext('archivetypemonth'), 'month');
            $archive_type->add($this->gettext('archivetypesender'), 'sender');
            $archive_type->add($this->gettext('archivetypefolder'), 'folder');

            $args['blocks']['archive'] = array(
                'name' => rcube::Q($this->gettext('settingstitle')),
                'options' => array('archive_type' => array(
                        'title'   => $this->gettext('archivetype'),
                        'content' => $archive_type->show($type)
                    )
                )
            );
        }
        else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) {
            $chbox = new html_checkbox(array('name' => '_read_on_archive', 'id' => 'ff_read_on_archive', 'value' => 1));
            $args['blocks']['main']['options']['read_on_archive'] = array(
                'title'   => $this->gettext('readonarchive'),
                'content' => $chbox->show($rcmail->config->get('read_on_archive') ? 1 : 0)
            );
        }

        return $args;
    }
780113
def AnalizarRemito(self, ret, archivo=None):
        ""
        if ret:
            self.CodRemito = ret.get("codRemito")
            self.TipoComprobante = ret.get("tipoComprobante")
            self.PuntoEmision = ret.get("puntoEmision")
            datos_aut = ret.get('datosAutorizacion')
            if datos_aut:
                self.NroRemito = datos_aut.get('nroRemito')
                self.CodAutorizacion = datos_aut.get('codAutorizacion')
                self.FechaEmision = datos_aut.get('fechaEmision')
                self.FechaVencimiento = datos_aut.get('fechaVencimiento')
            self.Estado = ret.get('estado')
            self.Resultado = ret.get('resultado')
            self.QR = ret.get('qr') or ""
            if archivo:
                qr = base64.b64decode(self.QR)
                f = open(archivo, "wb")
                f.write(qr)
                f.close()
1234241
function(nombre, controlador, tags, opciones) {
    // Se establecen los objetos comunes a todos los dispositivos
    this.info = Object();
    this.info.nombre = nombre;
    this.conectado = false;
    this.noErrores = true;
    this.cola = new objCola();
    this.funciones = new funciones(this);
    this.log = new log(this.info.nombre);
    this.tags = tags;
    this.tiposMB = {
        BYTE: {bits: 8, funcion: 'Int8', endian: false},
        INT: {bits: 16, funcion: 'Int16', endian: true},
        UINT: {bits: 16, funcion: 'UInt16', endian: true},
        DINT: {bits: 32, funcion: 'Int32', endian: true},
        UDINT: {bits: 32, funcion: 'UInt32', endian: true}, 
        FLOAT: {bits: 32, funcion: 'Float', endian: true},
        DOUBLE: {bits: 64, funcion: 'Double', endian: true}
    }
    new require('./drivers/'+controlador+'/driver') (this); // Se integran las funciones del driver con el dispositivo actual
    utilidades.mezclarObjetos(opciones, this.info); // Se establecen los objetos particulares de cada dispositivo
    
    this.conectarRecursiva(); // Se conecta el dispositivo
    
    
    
    
    /*
     * Se establecen los eventos o Listeners que serán ejecutados en TODOS los dispositivos, sean del driver que sea
     */
    utilidades.eventos(this, {
        conexion: function() {
            this.conectado = true;
            this.comenzarCiclo();
            this.comprobarConexion();
            
            this.log.info("Conectado");
            this.emit("conectado");
        },
        desconexion: function() {
            if (this.conectado) {
                this.conectado = false;
               
                this.cola.vaciar();
                
                this.log.error("Desconectado");
                this.emit("desconectado");
                this.conectarRecursiva();
            }
        },
        datosRecibidos: function(datos) {
            var buffer = utilidades.extractorBuffer(datos, this.estructuraCabecera, this.tiposMB, this.bytesPorPosicion, this.endian, this.noErrores);   
            if (typeof this.cola.operaciones[buffer.operacion] === 'undefined') {
                this.cola.prepararCola();
                return false;
            }
            
            var numOperacion = buffer.operacion;
            var operacion = this.cola.operaciones[numOperacion];
            var numPaquete = operacion.paquete;
            var paquete = this.cola.paquetes[numPaquete];

            if ((paquete.operaciones.lastIndexOf(numOperacion) === -1) || (typeof this.funciones[paquete.funcion+"Callback"] === 'undefined')) {
                this.cola.prepararCola();
                return false;
            }
            
            var informacion = this.funciones[paquete.funcion+"Callback"](buffer, numOperacion, operacion, numPaquete, paquete);            
            if (paquete.operaciones.length == 1) {
                if (this.cola.quitarPaquete(numPaquete)) {
                    if (typeof paquete.callback == 'function') {
                        if (typeof informacion == 'object') {
                            var array = utilidades.obj2arr(informacion);
                        }

                        paquete.callback.apply(this, array);
                    }
                }
            } else {
                this.cola.quitarOperacion(numOperacion);
            }
            
            this.cola.prepararCola();
            return true;
        },
        error: function() {
            if (this.conectado) {
                this.log.error("Se ha producido un error. Reconectamos el dispositivo...");
                this.emit("desconexion");
            }
        }
    });

    // Alias para los eventos
    this.on("conectado", function() {
        this.emit("connected");
    });
    this.on("desconectado", function() {
        this.emit("disconnected");
    });
    
    
    events.call(this); // Función de llamada a los eventos personalizados
}
280043
public function onBeforeInsert()
	{
		if ($this->defaultArchiveValue === null || !empty($this->owner->{$this->archiveAttribute})) return;
		$this->owner->{$this->archiveAttribute} = $this->defaultArchiveValue;
	}
321315
function mf_save_post_data( $post_id ) {
    global $wpdb;

    //@todo hay que ponerle nonce a una de las metaboxes
    /*if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) ) ) {*/
      //return $post_id;
    /*}*/

    if ( !current_user_can( 'edit_post', $post_id ) )
      return $post_id;

     //just in case if the post_id is a post revision and not the post inself
    if ( $the_post = wp_is_post_revision( $post_id ) ) {
      $post_id = $the_post;
    }

    // Check if the post_type has page attributes
    // if is the case is necessary need save the page_template
    if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != 'page' && isset($_REQUEST['page_template'])) {
      add_post_meta($post_id, '_wp_mf_page_template', $_POST['page_template'], true) or update_post_meta($post_id, '_wp_mf_page_template', $_POST['page_template']);
    }

    if (!empty($_POST['magicfields'])) {

      $customfields = $_POST['magicfields'];

      /** Deleting the old values **/
      $sql_delete = $wpdb->prepare( "DELETE FROM ".MF_TABLE_POST_META." WHERE post_id = %s",$post_id );
      $wpdb->query($sql_delete);

      foreach ( $customfields as $field_name => $field ) {
        delete_post_meta($post_id, $field_name);
      }
      /** / Deleting the old values **/

      //creating the new values
      foreach( $customfields as $field_name => $groups ) {

        $group_count = 1;
        foreach( $groups as $fields ) {
          $field_count = 1;
          foreach( $fields as $value ) {
            //here if the value of the field needs a process before to be saved
            //should be trigger that method here
            //$value =  mf_process_value_by_type($field_name,$value);

            // Adding field value meta data
            add_post_meta($post_id, "{$field_name}", $value);

            $meta_id = $wpdb->insert_id;

            $sql_insert = $wpdb->prepare(
              "INSERT INTO " . MF_TABLE_POST_META .
              " ( meta_id, field_name, field_count, group_count, post_id ) " .
              " VALUES " .
              " (%s,'%s',%s,%s,%s) ",
              $meta_id,
              $field_name,
              $field_count,
              $group_count,
              $post_id
            );

            $wpdb->query($sql_insert);

            $field_count++;
          }
          $group_count++;
        }
      }
    }
  }
1075491
protected function SaveElement()
    {
        $this->articleList->SetArticlePage($this->articlePageSelector->GetPage());
        $archiveCat = explode('-', $this->Value('ArchiveCategory'));
        $this->CleanPageArticleLists();
        if (count($archiveCat) == 1) {
            $this->SaveArchivePage($archiveCat[0]);
        }
        else if (count($archiveCat) == 2) {
            $this->SaveCategoryPage($archiveCat[1]);
        }
        return $this->articleList;
    }
1038491
public function afficherHistorique($idEvenement)
    {
        //
        // affiche la liste des modifications faites sur un événement
        //
        $html = '';
        $formulaire = new formGenerator();
        $string = new stringObject();
        if ($formulaire->estChiffre($idEvenement)) {
            $sqlHistorique = 'SELECT titre, description, dateCreationEvenement, idHistoriqueEvenement FROM historiqueEvenement WHERE idEvenement='.$idEvenement.' ORDER BY dateCreationEvenement DESC';
            if ($rep = $this->connexionBdd->requete($sqlHistorique)) {
                $t = new Template('modules/archi/templates');
                $t->set_filenames(array('historiqueEvenement'=>'historiqueEvenement.tpl'));
                while ($res = mysql_fetch_object($rep)) {
                    $t->assign_block_vars('historique', array(
                            'titre'      => htmlspecialchars($res->titre),
                            'description'=> pia_substr($string->sansBalises($res->description), 0, 50),
                            'url'        => $this->creerUrl('', 'historiqueEvenementDetail', array('idHistoriqueEvenement'=>$res->idHistoriqueEvenement)),
                            'dateModif'  => $this->date->toFrench($res->dateCreationEvenement)));
                }
                ob_start();
                $t->pparse('historiqueEvenement');
                $html .= ob_get_contents();
                ob_end_clean();
            }
        } else {
            $html .= 'erreur chiffre';
        }

        return $html;
    }