constructor(); } # OTHER METHODS function constructor() { $this->file = '/webroot/cat/thinker/includes/structure.xml'; $this->holder['depth'] = 0; $this->holder['link'] = Array(); $this->holder['top_count'] = 1; # Count top levels # $this->currentSection = $_SERVER['PHP_SELF']; # If URL ends in .php, snip it off if (ereg('.php',$this->currentSection)): $this->currentSection = substr($this->currentSection,0,-4); endif; # If URL ends in index, snip it off if (ereg('index',$this->currentSection)): $this->currentSection = substr($this->currentSection,0,-5); endif; # Remove any trailing / if (substr($this->currentSection,-1) == '/'): $this->currentSection = substr($this->currentSection,0,-1); endif; $temp_array = explode('/', $this->currentSection); foreach ($temp_array as $key => $value): if ($value != ''): $this->currentSectionArray[] = $value; endif; endforeach; # Remove first item /thinker/ from array array_shift($this->currentSectionArray); $this->titles = Array(); # Initialize array $this->siteMap = Array(); # Initialize array $this->drillDown = Array(); # Initialize array $this->drillDown[0] = 'Thinker'; # Create XML parser $this->parser = xml_parser_create(); xml_set_object($this->parser, &$this); xml_set_element_handler($this->parser, 'startElement', 'endElement'); } function parse() { # Open file if (!($fp = fopen($this->file, 'r'))): die('could not open XML input'); endif; while ($data = fread($fp, 4096)) { if (!xml_parse($this->parser, $data, feof($fp))): die(sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser))); endif; } # Free result from memory xml_parser_free($this->parser); if (!$this->sectionNumber): $this->titles['mainSection'] = '???'; $this->titles['section'] = ''; $this->titles['prevSection'] = ''; endif; $this->titles['parentSection'] = array_pop($this->parentSectionTitleTemp); $this->titles['parentSectionURL'] = array_pop($this->parentSectionURLTemp); } function startElement($parser, $name, $attrs) { # Skip wrapper element if ($name != 'THINKER'): # Add name to link placeholder $this->holder['link'][] = $attrs[URL_TITLE]; # Get current and placeholder names for matching purposes $match1 = $this->currentSectionArray[($this->holder['depth']-2)]; $match2 = $this->holder['link'][($this->holder['depth']-2)]; $count = count($this->currentSectionArray)-1; $match3 = $this->currentSectionArray[$count]; $count = count($this->holder['link'])-1; $match4 = $this->holder['link'][$count]; /* echo '
'; */ /* echo '1:'; */ /* print_r($match1); */ /* echo '
'; */ /* echo ' 2:'; */ /* print_r($match2); */ /* echo '
'; */ /* echo ' 3:'; */ /* print_r($match3); */ /* echo '
'; */ /* echo ' 4:'; */ /* print_r($match4); */ /* echo '
'; */ /* echo '
'; */ /* echo '
'; */ # Create link from array $url = '/thinker/'.implode('/',$this->holder['link']); # If node has children, append a / becuz this will reference a directory, not a file /* if (node has kids): $url .= '/'; endif; */ # If subsection property is not yet set if (!$this->titles['section'] && $url != $this->currentSection): # Set previous section property $this->titles['prevSection'] = $attrs[PAGE_TITLE]; $this->titles['prevSectionURL'] = $url; endif; # If next section property is not yet set but subsection property is if (!$this->titles['nextSection'] && $this->titles['section']): # Set next section property $this->titles['nextSection'] = $attrs[PAGE_TITLE]; $this->titles['nextSectionURL'] = $url; $this->holder['nextSectionSet'] = TRUE; endif; # Special case for first level -- always display if ($this->holder['depth'] == 1): # If this section corresponds to current section, set main title property if ($this->currentSectionArray[0] == $this->holder['link'][0]): $this->titles['mainSection'] = $attrs[PAGE_TITLE]; $this->titles['mainLong'] = $attrs[PAGE_TITLE]; $this->sectionNumber = $this->holder['top_count']; # Store linked title for drilldown $drilldown_tmp = ' '.htmlentities($attrs[PAGE_TITLE]).' '; # Add temp string to drilldown array $this->drillDown[$this->holder['depth']] = $drilldown_tmp; $this->parentSectionTitleTemp[$this->holder['depth']] = $attrs[PAGE_TITLE]; $this->parentSectionURLTemp[$this->holder['depth']] = $url; endif; if ($url == $this->currentSection): # Set subsection title property $this->titles['section'] = $attrs[PAGE_TITLE]; $this->level = 1; # Store non-linked title for sitemap $sitemap_tmp = ' '.htmlentities($attrs[PAGE_TITLE]).' '; # Store non-linked title for drilldown $drilldown_tmp = ' '.htmlentities($attrs[PAGE_TITLE]).' '; # Add temp string to drilldown array $this->drillDown[$this->holder['depth']] = $drilldown_tmp; $this->drillDownComplete = TRUE; unset($this->parentSectionTitleTemp[$this->holder['depth']]); unset($this->parentSectionURLTemp[$this->holder['depth']]); else: # Store linked title for sitemap $sitemap_tmp = ' '.htmlentities($attrs[PAGE_TITLE]).' '; endif; # Add temp string to site map array $this->siteMap[] = $sitemap_tmp; # Increment counter $this->holder['top_count']++; # Only display higher levels that match the current position elseif ($match1 == $match2): if ($match3 == $match4): # Store non-linked title for drilldown $drilldown_tmp = ' '.htmlentities($attrs[PAGE_TITLE]).' '; # Add temp string to drilldown array $this->drillDown[$this->holder['depth']] = $drilldown_tmp; $this->drillDownComplete = TRUE; unset($this->parentSectionTitleTemp[$this->holder['depth']]); unset($this->parentSectionURLTemp[$this->holder['depth']]); endif; if (!$this->drillDownComplete): # Store linked title for drilldown $drilldown_tmp = ' '.htmlentities($attrs[PAGE_TITLE]).' '; $this->drillDown[$this->holder['depth']] = $drilldown_tmp; $this->parentSectionTitleTemp[$this->holder['depth']] = $attrs[PAGE_TITLE]; $this->parentSectionURLTemp[$this->holder['depth']] = $url; endif; $nav_item = 'nav_item'.$this->holder['depth']; # If this subsection corresponds to current subsection if ($url == $this->currentSection): # Set subsection title property $this->titles['section'] = $attrs[PAGE_TITLE]; $this->level = $this->holder['depth']; $sitemap_tmp .= ""; $sitemap_tmp .= htmlentities($attrs[PAGE_TITLE]); $sitemap_tmp .= ''; else: $sitemap_tmp .= ""; $sitemap_tmp .= htmlentities($attrs[PAGE_TITLE]); $sitemap_tmp .= ''; if ($this->holder['depth'] > $this->level && $this->level > 0): $ic_tmp .= "
  • ".htmlentities($attrs[PAGE_TITLE]).'
  • '; endif; endif; $sitemap_tmp .= "\n"; # Add temp string to site map array $this->siteMap[] = $sitemap_tmp; # Add temp string to immediate children array $this->immediateChildren[] = $ic_tmp; endif; endif; # Increment depth counter $this->holder['depth']++; } function endElement($parser, $name) { # Decrement depth counter $this->holder['depth']--; # Remove element from link holder array_pop($this->holder['link']); } function printSiteMap() { echo(implode('',$this->siteMap)); } function printDrillDown() { echo(implode(' > ',$this->drillDown)); } function printImmediateChildren() { echo(''); } } ?>
    ( ! ) Fatal error: Class 'SiteStructure' not found in /var/www/cat/thinker/includes/page_start.inc on line 4
    Call Stack
    #TimeMemoryFunctionLocation
    10.0000227376{main}( )../index.php:0
    20.0001228064include( '/var/www/cat/thinker/includes/page_start.inc' )../index.php:1