Exemplo n.º 1
0
function wikiGetPageData($title)
{
    global $snoopy;
    global $wikiapi_url;
    if (!wikiLogin()) {
        I2CE::raiseError("Could not login to wiki");
        return false;
    }
    $post = array('action' => 'query', 'titles' => $title, 'prop' => 'revisions', 'rvprop' => 'ids|flags|timestamp|user|size|comment|content', 'format' => 'php');
    if (!$snoopy->submit($wikiapi_url, $post)) {
        I2CE::raiseError("Could not test for {$title}");
        return false;
    }
    $res = unserialize($snoopy->results);
    if (array_key_exists('error', $res)) {
        I2CE::raiseError("Could not find token:\n" . print_r($res['error'], true));
        return false;
    }
    $res = $res['query'];
    if (!is_array($res)) {
        I2CE::raiseError("Invalid token 0:\n" . print_r($res, true));
        return false;
    }
    if (!array_key_exists('pages', $res)) {
        return false;
    }
    $res = $res['pages'];
    if (!is_array($res) || count($res) != 1) {
        I2CE::raiseError("Invalid token 2:\n" . print_r($res, true));
        return false;
    }
    reset($res);
    if (key($res) < 0) {
        //key == -1 means the page does not exist
        return false;
    }
    $res = current($res);
    return $res;
}
Exemplo n.º 2
0
/**
 * Translate Templates
 *
 * @package I2CE
 * @subpackage Core
 * @author Carl Leitner <*****@*****.**>
 * @copyright Copyright &copy; 2008, 2008 IntraHealth International, Inc. 
 * @version 1.0
 */
$templates_dir = "." . DIRECTORY_SEPARATOR . "translations" . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
$package_dir = getcwd();
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'base.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'wiki_base.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'translate_base.php';
require_once dirname(__FILE__) . '/../lib/I2CE_Date.php';
wikiLogin();
//colors from http://meta.wikimedia.org/wiki/Wiki_color_formatting_help
$packages = array('i2ce' => array('pkg_name' => 'i2ce', 'top_module' => 'I2CE', 'name' => 'I2CE', 'color' => 'FireBrick'), 'manage' => array('pkg_name' => 'ihris-manage', 'top_module' => 'ihris-manage', 'name' => 'iHRIS Manage', 'color' => 'DarkGreen'), 'common' => array('pkg_name' => 'ihris-common', 'top_module' => 'ihris-common', 'name' => 'iHRIS Common', 'color' => 'SaddleBrown'), 'qualify' => array('pkg_name' => 'qualify', 'top_module' => 'ihris-qualify', 'name' => 'iHRIS Qualify', 'color' => 'Teal'), 'textlayout' => array('pkg_name' => 'textlayout', 'top_module' => 'textlayout', 'name' => 'TextLayout Tools', 'color' => 'Indigo'));
$search_dirs = array();
foreach (glob($package_dir . "/*", GLOB_ONLYDIR) as $dir) {
    $ldir = strtolower(basename($dir));
    foreach ($packages as $pkg => &$info) {
        if (strpos($ldir, $pkg) !== false) {
            $dir = realpath($dir);
            $search_dirs[$pkg] = $dir;
            $info['dir'] = $dir;
            break;
        }
    }
    unset($info);
    //deference this so we can use it