Example #1
0
function v1()
{
    global $basedir, $namespace, $action, $jsonp;
    // ...
    extractParams();
    // ...
    return $basedir . $namespace . $action . $jsonp;
}
Example #2
0
function convertFile($src, $dst)
{
    $text = file_get_contents($src);
    $params = extractParams($text);
    $params['text'] = \Michelf\MarkdownExtra::defaultTransform($text);
    $html = loadTemplate($params['template'], $params);
    $dst = str_replace(array('.txt', '.md'), '.html', $dst);
    file_put_contents($dst, $html);
}
Example #3
0
function parseUri($route)
{
    // example: /products/cat1/detail/123/computer-case => matched: /products/cat1/detail
    global $arr_mapping, $ext_mapping;
    $rt = removeFirst('/', $route);
    $rt = removeLast('/', $rt);
    $arr = explode('/', $rt);
    for ($i = count($arr) - 1; $i >= 0; $i--) {
        $path = '';
        for ($j = 0; $j < $i; $j++) {
            $path .= '/' . $arr[$j];
        }
        $testCtlName = formatControllerName($arr[$j]);
        $testCtlPath = $path;
        $testCtlFullPath = BASECTL . $testCtlPath . '/' . $testCtlName . '.php';
        //echo $testCtlFullPath.'<p/>';
        $path .= '/' . $arr[$j];
        if (file_exists($testCtlFullPath)) {
            //echo 'Controller.php exists!'
            return array('controller' . $testCtlPath, $testCtlName, extractParams($path, $route));
        } else {
            if (isset($arr_mapping[$path])) {
                //echo 'Controller Mapping matched!';
                $retArr = $arr_mapping[$path];
                if (isset($retArr[2])) {
                    return $retArr;
                } else {
                    return array($retArr[0], $retArr[1], extractParams($path, $route));
                }
            } else {
                if (isset($ext_mapping[$path])) {
                    //echo 'Extension Mapping Matched!';
                    $retArr = $ext_mapping[$path];
                    if (isset($retArr[2])) {
                        return $retArr;
                    } else {
                        return array($retArr[0], $retArr[1], extractParams($path, $route));
                    }
                }
            }
        }
    }
    return null;
}
Example #4
0
}
if (!($configUrl = extractParams('--config', $dirs))) {
    $configUrl = 'https://raw.githubusercontent.com/sutunam/mage-patch/master/config.json';
}
$patch = new PatchMage($configUrl);
if ($su = extractParams('--su', $dirs)) {
    $patch->setSuUser($su);
}
if ($sudo = extractParams('--sudo', $dirs)) {
    $patch->setSudoUser($sudo);
}
if ($patches = extractParams('--patches', $dirs)) {
    $patch->setAllowedPatches($patches);
}
if ($continueOnError = extractParams('--continueOnError', $dirs)) {
    $patch->setContinueOnError($continueOnError);
}
if ($dryRun = extractParams('--dryRun', $dirs)) {
    $patch->setDryRun($dryRun);
}
if ($kdp = extractParams('--keepDownloadedPatch', $dirs)) {
    $patch->setKeepDownloadedPatch($kdp);
}
if ($quiet = extractParams('--quiet', $dirs)) {
    $patch->setQuiet($quiet);
}
if (!count($dirs)) {
    $patch->help();
} else {
    $patch->multiPatch($dirs);
}