/** * testFindByProjectId method * * @return void */ public function testFindByProjectId() { $data = $this->Wiki->findByProjectId(1); $this->assertEqual($data['Wiki']['id'], 1); foreach ($data['WikiPage'] as $row) { $this->assertEqual($row['wiki_id'], 1); } //$this->assertEqual($data['WikiPage'][1]['title'], "日本語ページ"); }
function _replaceWikiLinks($already_matched) { /* Wiki links * Examples: * [[mypage]] * [[mypage|mytext]] * wiki links can refer other project wikis, using project name or identifier: * [[project:]] -> wiki starting page * [[project:|mytext]] * [[project:mypage]] * [[project:mypage|mytext]] */ $view = $this->_View; $link_project = isset($view->viewVars['main_project']) ? $view->viewVars['main_project'] : null; list(, $esc, $all, $page, $title) = $already_matched; $result = $all; if ($esc === "") { if (preg_match('/^([^\\:]+)\\:(.*)$/', $page, $matches)) { list(, $project_name, $page) = $matches; App::import('Model', 'Project'); $project_model = new Project(); $project_model->recursive = -1; $link_project = $project_model->findByName($project_name); if (empty($link_project)) { $link_project = $project_model->findByIdentifier($project_name); } if ($title === "" && $page === "") { $title = $project_name; } } App::import('Model', 'Wiki'); $wiki_model = new Wiki(); $wiki_model->recursive = -1; $link_project_wiki = $wiki_model->findByProjectId($link_project['Project']['id']); if ($link_project && $link_project_wiki) { // extract anchor $anchor = ""; if (preg_match('/^(.+?)\\#(.+)$/', $page, $matches)) { list(, $page, $anchor) = $matches; } // check if page exists $wiki_page = null; $wiki_model->id = $link_project_wiki['Wiki']['id']; $wiki_page = $wiki_model->find_page($page); $class = 'wiki-page'; if (!$wiki_page) { $class .= ' new'; } $result = $this->Html->link($title !== "" ? $title : $page, array('controller' => 'wiki', 'action' => 'index', 'project_id' => $link_project['Project']['identifier'], 'wikipage' => $page), array('class' => $class)); } else { if ($title !== "") { $result = $title; } else { $result = $page; } } } else { $result = $all; } return $result; }