Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php final class CelerityManagementSyntaxWorkflow extends CelerityManagementWorkflow {..

Decoded Output download

<?php

final class CelerityManagementSyntaxWorkflow
  extends CelerityManagementWorkflow {

  protected function didConstruct() {
    $this
      ->setName('syntax')
      ->setExamples('**syntax** [options]')
      ->setSynopsis(pht('Rebuild syntax highlighting CSS.'))
      ->setArguments(
        array());
  }

  public function execute(PhutilArgumentParser $args) {
    $styles = PhabricatorSyntaxStyle::getAllStyles();

    $root = dirname(phutil_get_library_root('phabricator'));
    $root = $root.'/webroot/rsrc/css/syntax/';

    foreach ($styles as $key => $style) {
      $content = $this->generateCSS($style);
      $path = $root.'/syntax-'.$key.'.css';
      Filesystem::writeFile($path, $content);

      echo tsprintf(
        "%s
",
        pht(
          'Rebuilt "%s" syntax CSS.',
          basename($path)));
    }

    return 0;
  }

  private function generateCSS(PhabricatorSyntaxStyle $style) {
    $key = $style->getSyntaxStyleKey();
    $provides = "syntax-{$key}-css";
    $generated = 'generated';

    $header =
      "/**
".
      " * @provides {$provides}
".
      " * @{$generated}
".
      " */

";

    $groups = array();
    $map = $style->getStyleMap();
    ksort($map);
    foreach ($map as $key => $value) {
      $groups[$value][] = $key;
    }

    $rules = array();
    foreach ($groups as $body => $classes) {
      $parts = array();
      foreach ($classes as $class) {
        $parts[] = ".remarkup-code .{$class}";
      }
      $rules[] = implode(",
", $parts)." {
  {$body}
}";
    }
    $rules = implode("

", $rules);

    return $header.$rules."
";
  }

}
 ?>

Did this file decode correctly?

Original Code

<?php

final class CelerityManagementSyntaxWorkflow
  extends CelerityManagementWorkflow {

  protected function didConstruct() {
    $this
      ->setName('syntax')
      ->setExamples('**syntax** [options]')
      ->setSynopsis(pht('Rebuild syntax highlighting CSS.'))
      ->setArguments(
        array());
  }

  public function execute(PhutilArgumentParser $args) {
    $styles = PhabricatorSyntaxStyle::getAllStyles();

    $root = dirname(phutil_get_library_root('phabricator'));
    $root = $root.'/webroot/rsrc/css/syntax/';

    foreach ($styles as $key => $style) {
      $content = $this->generateCSS($style);
      $path = $root.'/syntax-'.$key.'.css';
      Filesystem::writeFile($path, $content);

      echo tsprintf(
        "%s\n",
        pht(
          'Rebuilt "%s" syntax CSS.',
          basename($path)));
    }

    return 0;
  }

  private function generateCSS(PhabricatorSyntaxStyle $style) {
    $key = $style->getSyntaxStyleKey();
    $provides = "syntax-{$key}-css";
    $generated = 'generated';

    $header =
      "/**\n".
      " * @provides {$provides}\n".
      " * @{$generated}\n".
      " */\n\n";

    $groups = array();
    $map = $style->getStyleMap();
    ksort($map);
    foreach ($map as $key => $value) {
      $groups[$value][] = $key;
    }

    $rules = array();
    foreach ($groups as $body => $classes) {
      $parts = array();
      foreach ($classes as $class) {
        $parts[] = ".remarkup-code .{$class}";
      }
      $rules[] = implode(",\n", $parts)." {\n  {$body}\n}";
    }
    $rules = implode("\n\n", $rules);

    return $header.$rules."\n";
  }

}

Function Calls

None

Variables

None

Stats

MD5 18434d92d5efac506fde71f319971d7a
Eval Count 0
Decode Time 113 ms