Пример #1
0
    public static function generateLoadClass($realClazz, array $addOn, DevHelper_Config_Base $config)
    {
        $method = sprintf('load_class_%s', $realClazz);
        $existingContents = self::_getClassContents($addOn, $config);
        $existingMethods = DevHelper_Helper_Php::extractMethods($existingContents);
        if (in_array($method, $existingMethods, true)) {
            return false;
        }
        $ourClazz = sprintf('%s_%s', $config->getClassPrefix(), $realClazz);
        $methodCode = <<<EOF
public static function {$method}(\$class, array &\$extend)
{
    if (\$class === '{$realClazz}') {
        \$extend[] = '{$ourClazz}';
    }
}
EOF;
        $contents = DevHelper_Helper_Php::appendMethod($existingContents, $methodCode);
        if (!self::_write($addOn, $config, $contents)) {
            return false;
        }
        if (!DevHelper_Helper_Xfcp::generateXfcpClass($ourClazz, $realClazz, $config)) {
            return false;
        }
        if (!DevHelper_Helper_Xfcp::generateOurClass($ourClazz, $config)) {
            return false;
        }
        return $method;
    }
Пример #2
0
 public static function parsePhpForPhraseTracking($path, $contents)
 {
     if (self::$_lookingForPhraseTitles == false) {
         return;
     }
     if (strpos($path, 'library/DevHelper/') === 0) {
         return;
     }
     $offset = 0;
     $newXenForoPhrase = 'new XenForo_Phrase(';
     while (true) {
         $strPos = strpos($contents, $newXenForoPhrase, $offset);
         if ($strPos !== false) {
             $offset = $strPos + strlen($newXenForoPhrase);
             $phraseTitle = DevHelper_Helper_Php::extractString($contents, $offset);
             if (is_string($phraseTitle)) {
                 self::$_foundPhraseTitles[$phraseTitle][$path] = substr_count(substr($contents, 0, $offset), "\n");
             } else {
                 continue;
             }
         } else {
             break;
         }
     }
 }