!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/uploads/script/vendor/league/commonmark/src/Extension/HeadingPermalink/   drwxr-xr-x
Free 13.12 GB of 57.97 GB (22.64%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     HeadingPermalinkProcessor.php (4.86 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of the league/commonmark package.
 *
 * (c) Colin O'Dell <colinodell@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace League\CommonMark\Extension\HeadingPermalink;

use 
League\CommonMark\Block\Element\Document;
use 
League\CommonMark\Block\Element\Heading;
use 
League\CommonMark\Event\DocumentParsedEvent;
use 
League\CommonMark\Exception\InvalidOptionException;
use 
League\CommonMark\Extension\HeadingPermalink\Slug\SlugGeneratorInterface as DeprecatedSlugGeneratorInterface;
use 
League\CommonMark\Inline\Element\Code;
use 
League\CommonMark\Inline\Element\Text;
use 
League\CommonMark\Node\Node;
use 
League\CommonMark\Normalizer\SlugNormalizer;
use 
League\CommonMark\Normalizer\TextNormalizerInterface;
use 
League\CommonMark\Util\ConfigurationAwareInterface;
use 
League\CommonMark\Util\ConfigurationInterface;

/**
 * Searches the Document for Heading elements and adds HeadingPermalinks to each one
 */
final class HeadingPermalinkProcessor implements ConfigurationAwareInterface
{
    const 
INSERT_BEFORE 'before';
    const 
INSERT_AFTER 'after';

    
/** @var TextNormalizerInterface|DeprecatedSlugGeneratorInterface */
    
private $slugNormalizer;

    
/** @var ConfigurationInterface */
    
private $config;

    
/**
     * @param TextNormalizerInterface|DeprecatedSlugGeneratorInterface|null $slugNormalizer
     */
    
public function __construct($slugNormalizer null)
    {
        if (
$slugNormalizer instanceof DeprecatedSlugGeneratorInterface) {
            @
trigger_error(sprintf('Passing a %s into the %s constructor is deprecated; use a %s instead'DeprecatedSlugGeneratorInterface::class, self::class, TextNormalizerInterface::class), E_USER_DEPRECATED);
        }

        
$this->slugNormalizer $slugNormalizer ?? new SlugNormalizer();
    }

    public function 
setConfiguration(ConfigurationInterface $configuration)
    {
        
$this->config $configuration;
    }

    public function 
__invoke(DocumentParsedEvent $e): void
    
{
        
$this->useNormalizerFromConfigurationIfProvided();

        
$walker $e->getDocument()->walker();

        while (
$event $walker->next()) {
            
$node $event->getNode();
            if (
$node instanceof Heading && $event->isEntering()) {
                
$this->addHeadingLink($node$e->getDocument());
            }
        }
    }

    private function 
useNormalizerFromConfigurationIfProvided(): void
    
{
        
$generator $this->config->get('heading_permalink/slug_normalizer');
        if (
$generator === null) {
            return;
        }

        if (!(
$generator instanceof DeprecatedSlugGeneratorInterface || $generator instanceof TextNormalizerInterface)) {
            throw new 
InvalidOptionException('The heading_permalink/slug_normalizer option must be an instance of ' TextNormalizerInterface::class);
        }

        
$this->slugNormalizer $generator;
    }

    private function 
addHeadingLink(Heading $headingDocument $document): void
    
{
        
$text $this->getChildText($heading);
        if (
$this->slugNormalizer instanceof DeprecatedSlugGeneratorInterface) {
            
$slug $this->slugNormalizer->createSlug($text);
        } else {
            
$slug $this->slugNormalizer->normalize($text$heading);
        }

        
$slug $this->ensureUnique($slug$document);

        
$headingLinkAnchor = new HeadingPermalink($slug);

        switch (
$this->config->get('heading_permalink/insert''before')) {
            case 
self::INSERT_BEFORE:
                
$heading->prependChild($headingLinkAnchor);

                return;
            case 
self::INSERT_AFTER:
                
$heading->appendChild($headingLinkAnchor);

                return;
            default:
                throw new 
\RuntimeException("Invalid configuration value for heading_permalink/insert; expected 'before' or 'after'");
        }
    }

    
/**
     * @deprecated Not needed in 2.0
     */
    
private function getChildText(Node $node): string
    
{
        
$text '';

        
$walker $node->walker();
        while (
$event $walker->next()) {
            if (
$event->isEntering() && (($child $event->getNode()) instanceof Text || $child instanceof Code)) {
                
$text .= $child->getContent();
            }
        }

        return 
$text;
    }

    private function 
ensureUnique(string $proposedDocument $document): string
    
{
        
// Quick path, it's a unique ID
        
if (!isset($document->data['heading_ids'][$proposed])) {
            
$document->data['heading_ids'][$proposed] = true;

            return 
$proposed;
        }

        
$extension 0;
        do {
            ++
$extension;
        } while (isset(
$document->data['heading_ids']["$proposed-$extension"]));

        
$document->data['heading_ids']["$proposed-$extension"] = true;

        return 
"$proposed-$extension";
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0122 ]--