Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > dca483b59ba61f3fa092de932ddd570e > files > 253

nuface-2.0.14-2mdv2009.1.i586.rpm

<?php
# Copyright(C) 2004-2007 INL
# Written by Eric Leblond <regit@inl.fr>
#            Vincent Deffontaines <gryzor@inl.fr>
#            Jean Gillaux <jean@inl.fr>
#            Damien Boucard <damien.boucard AT inl.fr>
#
# $Id: order.class.php 17927 2009-02-16 13:16:09Z haypo $
#
# 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, version 3 of the License.
#
#  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, see <http://www.gnu.org/licenses/>.

require_once('elt.class.php');

class order_elt extends set {
    var $from;
    var $to;
    var $order;
    var $ID;

    function xmldump($xml,$curelt){
        $node=$xml->create_element( 'elt' );
        $curelt->append_child($node);
        $node->set_attribute('from',$this->from);
        $node->set_attribute('to',$this->to);
        $node->set_attribute('order',$this->order);
        $node->set_attribute('ID',$this->ID);
    }

    function order_elt($ress,$type='xml',$id=0){
      if ($type != 'xml')
      {
        if ($id==0){
          log_error("Must be passed a valid ID!");
          return(-1);
        }
        $this->ID=$id;
        $this->order=$ress['order'];
        $this->from=$ress['from'];
        $this->to=$ress['to'];
      }else{
        $this->ID=$ress->get_attribute('ID');
        $this->from=$ress->get_attribute('from');
        $this->to=$ress->get_attribute('to');
        $this->order=$ress->get_attribute('order');
      }
    }
    function modify_param($param,$value){
        if ($param == 'ID'){
          return(-1);
        }
        if (($param=='from') or ($param=='to') or ($param=='order')){
          $this->$param=$value;
          return(0);
        }
        return(-1);
    }

    function get_id(){
      return($this->ID);
    }

    function get_max_elt_id(){
        $max=0;
        foreach ($this->elts as $elt){
            $local=$elt->get_id();
            if ($local>$max)
              $max=$local;
        }
        return $max;
    }

    function get_obj()
    {
      foreach ($this as $key=>$obj)
      {
        // Skip elts, that contains stuff from subelements
        if ($key=='elts')
          continue;
        $result{$key}=$obj;
      }
      return $result;
    }
}

class descsort extends set {
  var $ID;
    function descsort($ress,$type='xml',$id=0){
        $this->elts=array();
        if ($type != 'xml')
        {
          $this->ID=$id;
          if (is_array($ress['elts']))
              $this->elts=$ress['elts'];
        } else {
          $this->ID=$ress->get_attribute('ID');
          xml_read_elements($this, $ress, "elt", "order_elt");
        }
        if (!$this->ID) {
            throw new Exception(sprintf(
                _("%s consistency error: %s!"),
                "descsort", _("Invalid identifier")));
        }
    }
    function get_id(){
      return($this->ID);
    }
    function xmldump($xml,$node){
        $descsort_n = $xml->create_element('descsort');
        $descsort_n->set_attribute('ID',$this->ID);
        $node->append_child($descsort_n);
        foreach ($this->elts as $elt){
                $elt->xmldump($xml,$descsort_n);
        }
    }
    function get_max_id()
    {
      $max=0;
      foreach ($this->elts as $elt)
      {
        if ($elt->ID>$max)
          $max=$elt->ID;
      }
      return($max);
    }

    function get_order($from,$to)
    {
      $elt = $this->get_elt($from, $to);
      if($elt == null){
          return 0;
      }
      return $elt->order;
    }
    function get_elt($from, $to)
    {
      if (is_array($this->elts))
      {
        foreach ($this->elts as $elt)
        {
          if (($elt->from == $from) and ($elt->to == $to))
            return($elt);
        }
        return(null);
      }
    }

}

?>