Jump to content

different results from different servers


wolves

Recommended Posts

<?php

class defaultItemMenu {    
  var $obj,$name,$link;

  function __construct($name,$link,$image,$args) {
    $img = ($image) ? image($image) : '';
    $this->name = $name;
  
if($link) {
  $link = ($args) ? _link(array(
     'href' => '#',
	 'onclick' => "javascript:open_win('".$link."','".$args[0]."','".$args[1]."')"),$this->getName()) :
    _link(array('href' => $link),$this->getName());
} else
  $link = '';
  
if($link)
      $this->obj =  '<li>' . $img . $link. '</li>';
    elseif(!$this->getName())
      $this->obj =  '<li></li>';
    else
      $this->obj =  '<li>'.$this->getName().'</li>';

    $this->link = $link;
  }	
  
  function getName() {
    //não é um menu comum
    if(strstr($this->name,'<div'))
      return $this->name;
    else
  	  return str_replace('_','',$this->name);
  }
  
  function getLink() {
    return $this->link;
  }

  function toString() {
    return $this->obj;
  }
}

class rootItemMenu {   
  var $childs = array();    
  var $name,$image;
  
  function __construct($name,$image) {
    $this->name = $name;
    $this->image = $image;
  }
  
  function addDefaultItem($name = null,$link = null,$image = null,$arg = array()) {
    $this->childs[$this->name][] = &new defaultItemMenu($name,$link,$image,$arg);
  }
  
  function addRootItem($name = null,$image = null) {
    $obj = &new rootItemMenu($name,$image);
$this->childs[$this->name][] = $obj;
return $obj;
  }
  
}

class rootMenu {			
  var $defaultItens,$rootItens,$objects = array();
  var $name,$link;
  
  function __construct($name,$link) {
    $this->name = $name;
    $this->link = $link;
  }
  
  function addRootItem($name,$image=null) {
    $this->rootItens[$name] = $obj = &new rootItemMenu($name,$image);
    $this->objects[] = $obj;
    return $obj;
  }
  
  function addDefaultItem($name =null,$link = null,$image = null,$arg = array()) {
   $this->defaultItens[] = $obj = &new defaultItemMenu($name,$link,$image,$arg);
   $this->objects[] = $obj;
  }
  
  function addSeparator() {
    $this->addDefaultItem();
  }
}

class Menu {  

  var $objects;
   
  function addRoot($name,$link = null) {
    $this->objects[] = $obj = &new rootMenu($name,$link);
    return $obj;
  }  

  function toString() {
    $output = '';
    foreach($this->objects as  $objects) {
      $link = ($objects->link) ? _link(array('href' => $objects->link),$objects->name) : $objects->name;
      $output .= "<li> $link";
      if($objects->objects)
        $output .= '<ul>';
      foreach($objects->objects as $rootItem) {        
        $output .= self::buildRoots($rootItem);
      }
      if($objects->objects)
        $output.= '</ul>';        

     $output.= '</li>';
    }
return '<ul id="_settimainmenu" style="display:none">' . $output . '</ul>';   
  }   

  private function buildRoots($object) {
    $output = '';
if(is_a($object,'rootItemMenu')) {
      $output .= '<li> ';                    
      $output .= ($object->image) ? image($object->image) . $object->name : $object->name;
  	  $output .= '<ul>';
      foreach($object->childs as $rootChilds) {
        foreach($rootChilds as $child)
          $output .= self::buildRoots($child);
    }
      $output.= '</ul></li>';
      return $output;
} elseif(is_a($object,'defaultItemMenu'))
  return $object->toString();
  }

  public static function parseString($str) {
    
    $str = str_replace(array(
  ' ',
  '_',
  '/'
),array('','',''),$str);
    return retiraAcentos('item_'.strtolower($str));
  }
}

?>

 

using this:

 

<?php
  $menu = new Menu();
  $root = $menu->addRoot('Section 1');
  $a = $root->addDefaultItem('Section 1.1');

  print '<pre>';
  print_r($menu);
  print '</pre>';
?>

 

I'm getting 2 different results...

 

localhost:

 

<pre>Menu Object
(
    [objects] => Array
        (
            [0] => rootMenu Object
                (
                    [defaultItens] => Array
                        (
                            [0] => defaultItemMenu Object
                                (
                                    [obj] => <li>Section 1.1</li>
                                    [name] => Section 1.1
                                    [link] => 
                                )

                        )

                    [rootItens] => 
                    [objects] => Array
                        (
                            [0] => defaultItemMenu Object
                                (
                                    [obj] => <li>Section 1.1</li>
                                    [name] => Section 1.1
                                    [link] => 
                                )

                        )

                    [name] => Section 1
                    [link] => 
                )

        )

)
</pre>

 

 

other server

 

(
    [objects] => Array
        (
            [0] => rootMenu Object
                (
                    [defaultItens] => 
                    [rootItens] => 
                    [objects] => Array
                        (
                        )

                    [name] => Section 1
                    [link] => 
                )

        )

)

 

I Can't fix it... what can be?

 

tks...

Link to comment
https://forums.phpfreaks.com/topic/65983-different-results-from-different-servers/
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.