Recursively add toc

@param Toc $toc
@param string $src
@param array $headers
192653
private function recursiveToc(Toc &$toc, $src, array $headers){
		foreach( $headers as $id => $header ){
			$child = $toc->addChild($header['content'], $src.'#'.$id);
			if( $header['children'] ){
				$this->recursiveToc($child, $src, $header['children']);
			}
		}
	}
32048
public function addHeader($header, $value, array $opts = array())
    {
        /* Existing header? Add to that object. */
        $header = trim($header);
        if ($hdr = $this[$header]) {
            $hdr->setValue($value);
            return;
        }

        $classname = $this->_getHeaderClassName($header);

        try {
            $ob = new $classname($header, $value);
        } catch (InvalidArgumentException $e) {
            /* Ignore an invalid header. */
            return;
        } catch (Horde_Mime_Exception $e) {
            return;
        }

        switch ($classname) {
        case 'Horde_Mime_Headers_ContentParam_ContentDisposition':
        case 'Horde_Mime_Headers_ContentParam_ContentType':
            /* BC */
            if (!empty($opts['params'])) {
                foreach ($opts['params'] as $key => $val) {
                    $ob[$key] = $val;
                }
            }
            break;
        }

        $this->_headers[$ob->name] = $ob;
    }
1187907
public function addMultiple(array $headers): HeaderCollection
    {
        foreach ($headers as $key => $value) {
            $key = $this->getKey($key, true);
            \sndsgd\Arr::addValue($this->headers, $key, $value);
        }
        return $this;
    }
214557
function addHeader( $text, $level = 1, $paragraphArray = array() )
    {
        $headerContents = array();
        $headerContents['Text'] = $text;
        foreach ( $paragraphArray as $paragraphElement )
        {
            switch ( $paragraphElement[0] )
            {
                case self::TEXT:
                {
                    $tagContent = $paragraphElement[1];

                    $tagContent = str_replace( "&", "&amp;", $tagContent );
                    $tagContent = str_replace( ">", "&gt;", $tagContent );
                    $tagContent = str_replace( "<", "&lt;", $tagContent );
                    $tagContent = str_replace( "'", "&apos;", $tagContent );
                    $tagContent = str_replace( '"', "&quot;", $tagContent );


                    $headerContents['Element'][] = array( 'Type' => 'text', "Content" => $tagContent );
                }break;

                case self::LINK:
                {
                    $headerContents['Element'][] = array( 'Type' => 'link',
                                                          "Content" => $content = $paragraphElement[2],
                                                          "HREF" => $paragraphElement[1] );
                }break;

                case self::LINE:
                {
                    $headerContents['Element'][] = array( 'Type' => 'line',
                                                          "Content" => '');
                }break;

                default:
                {
                    eZDebug::writeError( "Unknown paragraph element." );
                }break;
            }
        }
        $this->DocumentArray[] = array( 'Type' => 'header',
                                        'Content' => $headerContents,
                                        'Level' => $level);
    }
1106260
private function digToc($id, array $header, array &$headers){
		$keys = array_keys($headers);
		krsort($keys);
		$done = false;
		foreach( $keys as $key ){
			if( $headers[$key]['level'] < $header['level'] ){
				if( !$this->digToc($id, $header, $headers[$key]['children']) ){
					$headers[$key]['children'][$id] = $header;
				}
				return true;
			}
		}
		return false;
	}
931232
public function setHeader(array $header_cols){
      $this->header = new TableHeader($header_cols);

      $this->updateMaxRowLength($this->header);
   }
1201285
public function addHeaderToRequest($header, $value)
    {
        $this->request = $this->request->withHeader($header, $value);
    }
193615
public function addList($items=array(),$header=NULL){
		if(!$this->content instanceof HtmlGrid){
			$this->content=new HtmlGrid("Grid-".$this->identifier,0);
		}
		$grid=$this->content;

		$colCount=$grid->colCount();
		$colCount++;
		$grid->setColsCount($colCount);

		$list=new HtmlList("",$items);
		$list->asLink();
		if(isset($header)){
			$list->addHeader(4,$header);
		}
		$grid->getCell(0,$colCount-1)->setContent($list);
		$grid->setDivided()->setRelaxed(true);
		return $list;
	}
706896
def refresh_toc(self, refresh_done_callback, toc_cache):
        """"""

        self._useV2 = self.cf.platform.get_protocol_version() >= 4

        self._toc_cache = toc_cache
        self._refresh_callback = refresh_done_callback
        self.toc = None

        pk = CRTPPacket()
        pk.set_header(CRTPPort.LOGGING, CHAN_SETTINGS)
        pk.data = (CMD_RESET_LOGGING,)
        self.cf.send_packet(pk, expected_reply=(CMD_RESET_LOGGING,))
205873
public function AddHeader($header_name, &$content, $subdir="includes")
    {
        if($subdir)
        {
            $subdir = trim($subdir, "\\/") . "/";
            
            if(!file_exists($this->output_path . $subdir))
                \Peg\Lib\Utilities\FileSystem::MakeDir(
                    $this->output_path . $subdir, 
                    0755, 
                    true
                );
        }
        
        $header = $this->output_path 
            . $subdir
            . $this->GetHeaderNamePHP($header_name)
        ;
        
        \Peg\Lib\Utilities\FileSystem::WriteFileIfDifferent($header, $content);
    }
1161665
public function addHeaders (array $headers)
    {
        if ($this->_sent) {
            throw new CAS_OutOfSequenceException(
                'Request has already been sent cannot '.__METHOD__
            );
        }

        $this->headers = array_merge($this->headers, $headers);
    }
559859
protected function container(Table $table, array $rows, array $headers, array $footers)
	{
		$html = '<table';
		$this->addAttributes($html, $table->getAttributes());
		$html .= '><thead>';
		$html .= implode("\n", $headers);
		$html .= '</thead><tbody>';
		$html .= implode("\n", $rows);
		$html .= '</tbody><tfoot>';
		$html .= implode("\n", $footers);
		$html .= '</tfoot></table>';

		return $html;
	}
842068
function headerIndex( $page, $level )
    {
        $headerIndex = 0;
        foreach ( array_keys( $this->TOC ) as $key )
        {
            $header = $this->TOC[$key];
            if ( $header['pageNumber'] > $page )
                return ( $headerIndex != 0 ? $headerIndex : '' );

            if ( $header['level'] == $level )
            {
                $headerIndex++;
            }
            else if ( $header['level'] < $level )
            {
                $headerLabel = 0;
            }
        }

        return ( $headerIndex != 0 ? $headerIndex : '' );
    }
1172157
public function addHeader($key, $value = null, $toLower = true)
    {
        if (is_array($key)) {
            foreach ($key as $k => $v) {
                $this->addHeader($k, $v);
            }
        } else {
            if ($value !== null) {
                if ($toLower === true) {
                    $key = strtolower($key);
                }
                if (!isset($this->_headers[$key])) {
                    $this->_headers[$key] = $value;
                } else {
                    if (is_array($this->_headers[$key])) {
                        $this->_headers[$key][] = $value;
                    } else {
                        $this->_headers[$key] = [$this->_headers[$key], $value];
                    }
                }
            }
        }
    }
1057725
public function addGlobalHeaders($headers)
    {
        if (current($headers) instanceof Header) {
            foreach ($headers as $header) {
                $this->addGlobalHeader($header);
            }
        } else {
            foreach ($headers as $key => $value) {
                $this->addGlobalHeader($key, $value);
            }
        }
    }
918494
public function addHeader($header, $value)
    {
        $header = strtolower($header);
        $this->headers[$header] = $value;
        return $this;
    }
313951
def write_toc(self, args):
        """"""
        # FIXME: Can this logic be moved into the create_parser function?
        ordered = False
        if args.ordered_list_marker is not None:
            list_marker = args.ordered_list_marker
            ordered = True
        elif args.unordered_list_marker is not None:
            list_marker = args.unordered_list_marker
        else:
            list_marker = md_parser[
                args.parser]['list']['unordered']['default_marker']

        toc_struct = build_multiple_tocs(
            filenames=args.filename,
            ordered=ordered,
            no_links=args.no_links,
            no_indentation=args.no_indentation,
            no_list_coherence=args.no_list_coherence,
            keep_header_levels=int(args.header_levels),
            parser=args.parser,
            list_marker=list_marker)
        if args.in_place:
            write_strings_on_files_between_markers(
                filenames=args.filename,
                strings=toc_struct,
                marker=args.toc_marker)
        else:
            for toc in toc_struct:
                print(toc, end='')