Path: blob/master/src/applications/config/check/PhabricatorPygmentSetupCheck.php
12262 views
<?php12final class PhabricatorPygmentSetupCheck extends PhabricatorSetupCheck {34public function getDefaultGroup() {5return self::GROUP_OTHER;6}78protected function executeChecks() {9$pygment = PhabricatorEnv::getEnvConfig('pygments.enabled');1011if ($pygment) {12if (!Filesystem::binaryExists('pygmentize')) {13$summary = pht(14'You enabled pygments but the %s script is not '.15'actually available, your %s is probably broken.',16'pygmentize',17'$PATH');1819$message = pht(20'The environmental variable %s does not contain %s. '.21'You have enabled pygments, which requires '.22'%s to be available in your %s variable.',23'$PATH',24'pygmentize',25'pygmentize',26'$PATH');2728$this29->newIssue('pygments.enabled')30->setName(pht('%s Not Found', 'pygmentize'))31->setSummary($summary)32->setMessage($message)33->addRelatedPhabricatorConfig('pygments.enabled')34->addPhabricatorConfig('environment.append-paths');35} else {36list($err) = exec_manual('pygmentize -h');37if ($err) {38$summary = pht(39'You have enabled pygments and the %s script is '.40'available, but does not seem to work.',41'pygmentize');4243$message = pht(44'This server has %s available in %s, but the binary '.45'exited with an error code when run as %s. Check that it is '.46'installed correctly.',47phutil_tag('tt', array(), 'pygmentize'),48phutil_tag('tt', array(), '$PATH'),49phutil_tag('tt', array(), 'pygmentize -h'));5051$this52->newIssue('pygments.failed')53->setName(pht('%s Not Working', 'pygmentize'))54->setSummary($summary)55->setMessage($message)56->addRelatedPhabricatorConfig('pygments.enabled')57->addPhabricatorConfig('environment.append-paths');58}59}60} else {61$summary = pht(62'Pygments should be installed and enabled '.63'to provide advanced syntax highlighting.');6465$message = pht(66'This software can highlight a few languages by default, '.67'but installing and enabling Pygments (a third-party highlighting '.68"tool) will add syntax highlighting for many more languages. \n\n".69'For instructions on installing and enabling Pygments, see the '.70'%s configuration option.'."\n\n".71'If you do not want to install Pygments, you can ignore this issue.',72phutil_tag('tt', array(), 'pygments.enabled'));7374$this75->newIssue('pygments.noenabled')76->setName(pht('Install Pygments to Improve Syntax Highlighting'))77->setSummary($summary)78->setMessage($message)79->addRelatedPhabricatorConfig('pygments.enabled');80}81}82}838485