Exemplo n.º 1
0
 public function getnahoWikiRevisionsJoinnahoWikiPage($criteria = null, $con = null)
 {
     include_once 'plugins/nahoWikiPlugin/lib/model/om/BasenahoWikiRevisionPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collnahoWikiRevisions === null) {
         if ($this->isNew()) {
             $this->collnahoWikiRevisions = array();
         } else {
             $criteria->add(nahoWikiRevisionPeer::CONTENT_ID, $this->getId());
             $this->collnahoWikiRevisions = nahoWikiRevisionPeer::doSelectJoinnahoWikiPage($criteria, $con);
         }
     } else {
         $criteria->add(nahoWikiRevisionPeer::CONTENT_ID, $this->getId());
         if (!isset($this->lastnahoWikiRevisionCriteria) || !$this->lastnahoWikiRevisionCriteria->equals($criteria)) {
             $this->collnahoWikiRevisions = nahoWikiRevisionPeer::doSelectJoinnahoWikiPage($criteria, $con);
         }
     }
     $this->lastnahoWikiRevisionCriteria = $criteria;
     return $this->collnahoWikiRevisions;
 }
Exemplo n.º 2
0
 public static function retrieveByPK($page_id, $revision, $content_id, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(nahoWikiRevisionPeer::PAGE_ID, $page_id);
     $criteria->add(nahoWikiRevisionPeer::REVISION, $revision);
     $criteria->add(nahoWikiRevisionPeer::CONTENT_ID, $content_id);
     $v = nahoWikiRevisionPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Exemplo n.º 3
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = nahoWikiRevisionPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setCreatedAt($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPageId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setRevision($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setUserName($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setComment($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setContentId($arr[$keys[5]]);
     }
 }
Exemplo n.º 4
0
 public static function retrieveByNamesJoinAll($names)
 {
     $c = new Criteria();
     $c->add(self::NAME, $names, Criteria::IN);
     return nahoWikiRevisionPeer::doSelectJoinAll($c);
 }
 public function executeDiff()
 {
     $this->setPage();
     // $this->revision is revision2
     $this->forward403Unless($this->canView);
     $this->forward404If($this->page->isNew());
     $this->forward404If($this->revision->isNew());
     // Source revision
     $c = new Criteria();
     $c->add(nahoWikiRevisionPeer::PAGE_ID, $this->page->getId());
     $c->add(nahoWikiRevisionPeer::REVISION, $this->getRequestParameter('oldRevision'));
     $this->revision1 = nahoWikiRevisionPeer::doSelectOne($c);
     $this->forward404Unless($this->revision1);
     // Dest revision
     $this->revision2 = $this->revision;
     // Make diff
     $lines1 = explode("\n", $this->revision1->getContent());
     $lines2 = explode("\n", $this->revision2->getContent());
     $diff = new Text_Diff('auto', array($lines1, $lines2));
     switch ($this->getRequestParameter('mode', 'inline')) {
         case 'unified':
             $renderer = new Text_Diff_Renderer_unified();
             break;
         case 'context':
             $renderer = new Text_Diff_Renderer_context();
             break;
         case 'inline':
         default:
             $renderer = new Text_Diff_Renderer_inline();
             break;
     }
     $this->diff = $renderer->render($diff);
     // Direct download
     if ($this->getRequestParameter('raw')) {
         $this->getResponse()->setContentType('text/plain');
         $this->renderText($this->diff);
         return sfView::NONE;
     }
     return sfView::SUCCESS;
 }
$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);
$t->ok(!$wiki_page instanceof nahoWikiPage, 'the wiki page was removed');
$wiki_revision = nahoWikiRevisionPeer::retrieveByPK($atto_page_id, $atto_revision_num, $atto_content_id);
$t->ok(!$wiki_revision instanceof nahoWikiRevision, 'the wiki revision was removed');
$wiki_content = nahoWikiContentPeer::retrieveByPK($atto_content_id);
$t->ok($wiki_content instanceof nahoWikiContent, 'the wiki content was NOT removed');
$t->diag('Remove the votation object');
$obj_votazione->delete();
$wiki_page = nahoWikiPagePeer::retrieveByPK($votazione_page_id);
$t->ok(!$wiki_page instanceof nahoWikiPage, 'the wiki page was removed');
$wiki_revision = nahoWikiRevisionPeer::retrieveByPK($votazione_page_id, $votazione_revision_num, $votazione_content_id);
$t->ok(!$wiki_revision instanceof nahoWikiRevision, 'the wiki revision was removed');
$wiki_content = nahoWikiContentPeer::retrieveByPK($votazione_content_id);
$t->ok($wiki_content instanceof nahoWikiContent, 'the wiki content was NOT removed');