protected function setPage($page_name = null) { // Get page from request if not given as parameter (default behaviour) if (is_null($page_name)) { $page_name = $this->getRequestParameter('page', $this->startPage); } // Handle case insensitivity $page_name = strtolower($page_name); // Support default page if not specified in namespace if (substr($page_name, -1) == ':') { if ($this->getRequestParameter('wiki') == null) { die('wiki not specified'); } $page_name .= $this->startPage; } // Retrieve the page, or start a new one if cannot be found $this->page = nahoWikiPagePeer::retrieveByName($page_name); if (!$this->page) { $this->initNewPage($page_name); } // Retrieve the revision $revision = $this->getRequestParameter('revision', $this->page->getLatestRevision()); $this->revision = $this->page->getRevision($revision); if (!$this->revision) { $this->initNewRevision(); } // Generate the URI parameters to keep trace of the requested page $this->uriParams = 'page=' . $this->page->getName(); if ($this->revision->getRevision() != $this->page->getLatestRevision()) { $this->uriParams .= '&revision=' . $this->revision->getRevision(); } // Permissions management $this->canView = $this->page->canView($this->getUser()); $this->canEdit = $this->page->canEdit($this->getUser()); }
/** * remove the page related to the object (and all the revisione in cascade) * * @return void * @author Guglielmo Celata **/ public function preDelete($object, $con) { $prefix = sfConfig::get(sprintf('propel_behavior_wikifiableBehavior_%s_prefix', get_class($object))); $wiki_page = nahoWikiPagePeer::retrieveByName($prefix . "_" . $object->getId()); if (!is_null($wiki_page)) { $wiki_page->delete(); } }
public function executeShowContent() { // store the referer in the user's session $referer = $this->getRequest()->getUri(); $this->getUser()->setAttribute('referer', $referer); // Retrieve page and revision $this->page = nahoWikiPagePeer::retrieveByName($this->page_name); if ($this->page) { $this->revision = $this->page->getRevision(); } }
protected function setPage($page_name = null) { // Get page from request if not given as parameter (default behaviour) if (is_null($page_name)) { $page_name = $this->getRequestParameter('page', $this->startPage); } // Handle case insensitivity $page_name = strtolower($page_name); // Support default page if not specified in namespace if (substr($page_name, -1) == ':') { $page_name .= $this->startPage; } // Retrieve the page, or start a new one if cannot be found $this->page = nahoWikiPagePeer::retrieveByName($page_name); if (!$this->page) { return; } // Retrieve the revision $revision = $this->getRequestParameter('revision', $this->page->getLatestRevision()); $this->revision = $this->page->getRevision($revision); if (!$this->revision) { $this->initNewRevision(); } // Generate the URI parameters to keep trace of the requested page $this->uriParams = 'page=' . $this->page->getName(); if ($this->revision->getRevision() != $this->page->getLatestRevision()) { $this->uriParams .= '&revision=' . $this->revision->getRevision(); } // Permissions management $this->canView = $this->page->canView($this->getUser()); $this->canEdit = $this->page->canEdit($this->getUser()); // Retriev item name and type of item (tab and breadcrumbs) list($tipo, $id) = split("_", $this->page->getName()); switch ($tipo) { case 'atto': $this->item = OppAttoPeer::retrieveByPK($id); $this->item_name = Text::denominazioneAttoShort($this->item); break; case 'votazione': $this->item = OppVotazionePeer::retrieveByPK($id); $this->item_name = $this->item->getTitolo(); break; case 'emendamento': $this->item = OppEmendamentoPeer::retrieveByPK($id); $attoPortante = $this->item->getAttoPortante(); $this->item_name = "Emendamento " . $this->item->getTitolo() . " relativo a " . Text::denominazioneAttoShort($attoPortante) . " - " . $attoPortante->getTitolo(); break; } $this->item_type = $tipo; }
public function executeContent() { if (!isset($this->hide_toc)) { $this->hide_toc = !sfConfig::get('app_nahoWikiPlugin_include_toc', true); } $start = sfConfig::get('app_nahoWikiPlugin_start_page', 'index'); if (!($page_name = $this->pagename)) { $page_name = $start; } // Support default page if not specified in namespace if (substr($page_name, -1) == ':') { $page_name .= $start; } // Retrieve the page, or start a new one if cannot be found $this->page = nahoWikiPagePeer::retrieveByName($page_name); // Build page object if (!$this->page) { $this->page = new nahoWikiPage(); $this->revision = null; } else { // Retrieve the revision if (!($revision = $this->revision)) { $revision = $this->page->getLatestRevision(); } $this->revision = $this->page->getRevision($revision); } // Buil revision object if (!$this->revision) { $this->revision = new nahoWikiRevision(); $this->revision->setnahoWikiPage($this->page); } // Generate the URI parameters to keep trace of the requested page $this->uriParams = 'page=' . urlencode($this->page->getName()); if ($this->revision->getRevision() != $this->page->getLatestRevision()) { $this->uriParams .= '&revision=' . urlencode($this->revision->getRevision()); } // Permissions $this->canView = $this->page->canView($this->getUser()); $this->canEdit = $this->page->canEdit($this->getUser()); }
public function getHasDescrizioneWiki() { $prefix = sfConfig::get(sprintf('propel_behavior_wikifiableBehavior_%s_prefix', get_class($this))); $default_description = sfConfig::get(sprintf('propel_behavior_wikifiableBehavior_%s_default_description', get_class($this)), 'Descrizione di default'); $wiki_page = nahoWikiPagePeer::retrieveByName($prefix . "_" . $this->getId()); if ($wiki_page) { $desc = $wiki_page->getRevision()->getContent(); if ($desc != $default_description) { return "true"; } } return "false"; }
$t->ok(count($wiki_revisions) == 1 && $wiki_revision instanceof nahoWikiRevision, 'a wiki revision was added'); $wiki_content = $wiki_revision->getnahoWikiContent(); $t->ok($wiki_content instanceof nahoWikiContent, 'a wiki content was also added'); $t->ok($wiki_revision->getComment() == 'Creazione Automatica' && $wiki_revision->getContent() == 'Descrizione wiki, a cura degli utenti.', 'comment and content were correctly inserted'); $atto_page_id = $wiki_page->getId(); $atto_revision_num = $wiki_revision->getRevision(); $atto_content_id = $wiki_content->getId(); $t->diag('Create the votation object'); $obj_votazione = new OppVotazione(); $obj_votazione->setSedutaId(2950); $obj_votazione->setNumeroVotazione(999999); $obj_votazione->setTitolo('Una votazione di test'); $obj_votazione->save(); $prefix = sfConfig::get(sprintf('propel_behavior_wikifiableBehavior_%s_prefix', get_class($obj_votazione))); $t->ok($prefix == 'votazione', 'The prefix was correctly read from the behavior configuration'); $wiki_page = nahoWikiPagePeer::retrieveByName($prefix . "_" . $obj_votazione->getId()); $t->ok($wiki_page instanceof nahoWikiPage, 'a wiki page was just created for this object'); $c = new Criteria(); $c->add(nahoWikiRevisionPeer::REVISION, 1); $wiki_revisions = $wiki_page->getRevisions($c); $wiki_revision = $wiki_revisions[0]; $t->ok(count($wiki_revisions) == 1 && $wiki_revision instanceof nahoWikiRevision, 'a wiki revision was added'); $wiki_content = $wiki_revision->getnahoWikiContent(); $t->ok($wiki_content instanceof nahoWikiContent, 'a wiki content was also added'); $t->ok($wiki_revision->getComment() == 'Creazione Automatica' && $wiki_revision->getContent() == 'Descrizione wiki, a cura degli utenti.', 'comment and content were correctly inserted'); $votazione_page_id = $wiki_page->getId(); $votazione_revision_num = $wiki_revision->getRevision(); $votazione_content_id = $wiki_content->getId(); $t->diag('Remove the act object'); $obj_atto->delete(); $wiki_page = nahoWikiPagePeer::retrieveByPK($atto_page_id);