/**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return ProjectLinks 
  */
 function manager()
 {
     if (!instance_of($this->manager, 'Wiki')) {
         $this->manager = Wiki::instance();
     }
     return $this->manager;
 }
Exemple #2
0
function wiki_replace_link_callback($matches)
{
    if (count($matches) < 2) {
        return null;
    }
    if ($matches[1] == 'wiki') {
        $rev = Revisions::instance()->getTableName(true);
        $page = Wiki::instance()->getTableName(true);
        $where1 = 'WHERE page_id = ' . $matches[2] . ' AND project_id = ' . active_project()->getId();
        $where2 = 'WHERE id = ' . $matches[2] . ' AND project_id = ' . active_project()->getId();
        $sql = "SELECT page_id, name FROM {$rev} {$where1} ";
        $sql .= "AND revision = ( select revision from {$page} {$where2} )";
        //echo $sql;
        $row = DB::executeOne($sql);
        if (!count($row)) {
            return null;
        }
        $url = get_url($matches[1], 'view', array('id' => $matches[2]));
        $url = str_replace('&amp;', '&', $url);
        return '"' . $row['name'] . '(' . $row['page_id'] . ')":' . $url;
    }
    $user = Users::instance()->getTableName(true);
    $where1 = 'WHERE id = ' . $matches[2];
    $sql = "SELECT id, display_name FROM {$user} {$where1} ";
    echo $sql;
    $row = DB::executeOne($sql);
    if (!count($row)) {
        return null;
    }
    $url = get_url($matches[1], 'card', array('id' => $matches[2]));
    $url = str_replace('&amp;', '&', $url);
    return '"' . $row['display_name'] . '(' . $row['id'] . ')":' . $url;
}
Exemple #3
0
 /**
  * Get a list of pages for a project
  * 
  * @param mixed $project
  * @return
  */
 function getPagesList(Project $project)
 {
     $sql = 'SELECT p.id, r.name FROM ' . Wiki::instance()->getTableName(true) . ' AS p, ' . Revisions::instance()->getTableName(true) . ' AS r WHERE p.project_id = ' . $project->getId() . ' AND p.id = r.page_id AND r.revision = p.revision AND p.project_sidebar = 0 ORDER BY 2';
     $return = array();
     foreach ((array) DB::executeAll($sql) as $page) {
         $return[] = array('name' => $page['name'], 'view_url' => get_url('wiki', 'view', array('id' => $page['id'])));
     }
     return $return;
 }
Exemple #4
0
/**
 * Replaces wiki links in format [wiki:{PAGE_ID}] with a textile link to the page
 * 
 * @param mixed $content
 * @return
 */
function wiki_replace_link_callback($matches)
{
    //print_r($matches);
    if (count($matches) >= 2) {
        if (is_numeric($matches[1])) {
            $object_id = $matches[1];
            $object = Wiki::instance()->findById($object_id);
            if ($object instanceof WikiPage) {
                if ($matches[2] == ',content') {
                    $revision = $object->getLatestRevision();
                    return do_textile(plugin_manager()->apply_filters('wiki_text', $revision->getContent()));
                }
                return '<a href="' . externalUrl($object->getViewUrl()) . '" title="' . lang('wiki page') . "({$object_id})" . '">' . $object->getObjectName() . '</a>';
            }
        }
    }
    return '<del>' . lang('invalid reference', $matches[0]) . '</del>';
}
Exemple #5
0
    define('USE_WIKITTEN_LOGO', true);
}
if (!defined('USE_DARK_THEME')) {
    define('USE_DARK_THEME', false);
}
if (!defined('USE_PAGE_METADATA')) {
    define('USE_PAGE_METADATA', true);
}
if (!defined('ENABLE_EDITING')) {
    define('ENABLE_EDITING', false);
}
define('PLUGINS', __DIR__ . DIRECTORY_SEPARATOR . 'plugins');
$request_uri = parse_url($_SERVER['REQUEST_URI']);
$request_uri = explode("/", $request_uri['path']);
$script_name = explode("/", dirname($_SERVER['SCRIPT_NAME']));
$app_dir = array();
foreach ($request_uri as $key => $value) {
    if (isset($script_name[$key]) && $script_name[$key] == $value) {
        $app_dir[] = $script_name[$key];
    }
}
define('APP_DIR', rtrim(implode('/', $app_dir), "/"));
$https = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
    $https = true;
}
define('BASE_URL', "http" . ($https ? "s" : "") . "://" . $_SERVER['HTTP_HOST'] . APP_DIR);
unset($config_file, $request_uri, $script_name, $app_dir, $https);
require_once __DIR__ . DIRECTORY_SEPARATOR . 'wiki.php';
Wiki::instance()->dispatch();
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'Wiki')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return Wiki::instance()->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }