Ejemplo n.º 1
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $this->user = sfGuardUserPeer::retrieveByPK($request->getParameter('id'));
     $this->forward404Unless($this->user, 'User Not Found');
     $this->statusActions = StatusActionPeer::getStatusActionsForBoard($this->user->getId());
     $this->commentBoards = CommentPeer::getCommentsForBoard($this->user->getId());
 }
Ejemplo n.º 2
0
 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($comment = CommentPeer::retrieveByPk($request->getParameter('id')), sprintf('Object comment does not exist (%s).', $request->getParameter('id')));
     $comment->delete();
     $this->redirect('comment/index');
 }
Ejemplo n.º 3
0
 static function getComments($id)
 {
     $c = new Criteria();
     // $c->addByColumn('created_at');
     $c->add(CommentPeer::ARTICLE_ID, $id);
     return CommentPeer::doSelect($c);
 }
Ejemplo n.º 4
0
 public function execute($request)
 {
     $repositories = RepositoryQuery::create()->find();
     $this->repositories = array();
     foreach ($repositories as &$repository) {
         $branchesCount = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByIsBlacklisted(0)->count();
         $this->repositories[] = array_merge($repository->toArray(), array('NbBranches' => $branchesCount));
     }
     $this->statusActions = StatusActionPeer::getStatusActionsForBoard();
     $this->commentBoards = CommentPeer::getCommentsForBoard();
 }
Ejemplo n.º 5
0
 /**
  * @param sfWebRequest $request
  * @return void
  */
 public function execute($request)
 {
     $this->branch = null;
     if ($request->hasParameter('name') && $request->hasParameter('repository')) {
         $repository = RepositoryQuery::create()->filterByName($request->getParameter('repository'))->findOne();
         $this->forward404Unless($repository, "Repository not found");
         $this->branch = BranchQuery::create()->filterByName($request->getParameter('name'))->filterByRepository($repository)->findOne();
         // Dirty hack to make the breadcrumb work /!\
         if ($this->branch) {
             $this->redirect('default/fileList?branch=' . $this->branch->getId());
         }
     } elseif ($request->hasParameter('branch')) {
         $this->branch = BranchPeer::retrieveByPK($request->getParameter('branch'));
     }
     $this->forward404Unless($this->branch, "Branch not found");
     $this->getResponse()->setTitle($this->branch->getName());
     $this->repository = RepositoryPeer::retrieveByPK($this->branch->getRepositoryId());
     $this->forward404Unless($this->repository, "Repository not found");
     $files = FileQuery::create()->filterByBranchId($this->branch->getId())->find();
     $this->files = array();
     foreach ($files as $file) {
         $fileCommentsCount = CommentQuery::create()->filterByFileId($file->getId())->filterByType(CommentPeer::TYPE_FILE)->count();
         $fileCommentsCountNotChecked = CommentQuery::create()->filterByFileId($file->getId())->filterByType(CommentPeer::TYPE_FILE)->filterByCheckUserId(null)->count();
         $lineCommentsCount = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->count();
         $lineCommentsCountNotChecked = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->filterByType(CommentPeer::TYPE_LINE)->filterByCheckUserId(null)->count();
         $lastCommentId = 0;
         if ($fileCommentsCount || $lineCommentsCount) {
             $lastComment = CommentQuery::create()->filterByFileId($file->getId())->filterByCommit($file->getLastChangeCommit())->_or()->filterByType(CommentPeer::TYPE_FILE)->orderById(Criteria::DESC)->findOne();
             if ($lastComment) {
                 $lastCommentId = $lastComment->getId();
             }
         }
         $this->files[] = array_merge($file->toArray(), array('NbFileComments' => $fileCommentsCount + $lineCommentsCount, 'NbFileCommentsNotChecked' => $fileCommentsCountNotChecked + $lineCommentsCountNotChecked, 'LastCommentId' => $lastCommentId));
     }
     usort($this->files, array('self', 'sortPath'));
     $this->statusActions = StatusActionPeer::getStatusActionsForBoard(null, $this->repository->getId(), $this->branch->getId());
     $this->commentBoards = CommentPeer::getCommentsForBoard(null, $this->repository->getId(), $this->branch->getId());
 }
Ejemplo n.º 6
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(CommentPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(CommentPeer::DATABASE_NAME);
         $criteria->add(CommentPeer::ID, $pks, Criteria::IN);
         $objs = CommentPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 7
0
 /**
  * Filter the query on the type column
  *
  * @param     mixed $type The value to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    CommentQuery The current query, for fluid interface
  */
 public function filterByType($type = null, $comparison = null)
 {
     $valueSet = CommentPeer::getValueSet(CommentPeer::TYPE);
     if (is_scalar($type)) {
         if (!in_array($type, $valueSet)) {
             throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $type));
         }
         $type = array_search($type, $valueSet);
     } elseif (is_array($type)) {
         $convertedValues = array();
         foreach ($type as $value) {
             if (!in_array($value, $valueSet)) {
                 throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $value));
             }
             $convertedValues[] = array_search($value, $valueSet);
         }
         $type = $convertedValues;
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
     }
     return $this->addUsingAlias(CommentPeer::TYPE, $type, $comparison);
 }
Ejemplo n.º 8
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = CommentPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setPostId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setMessage($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
 }
    propel:
      article:
        id:          ~
        title:       varchar(255)

Beware that the tables for these models will be emptied by the tests, so use a test database connection.
*/

include dirname(__FILE__).'/../../bootstrap.php';

$con = Propel::getConnection();

// cleanup database
AuthorPeer::doDeleteAll();
CommentPeer::doDeleteAll();
CategoryPeer::doDeleteAll();
ArticlePeer::doDeleteAll();

$t = new lime_test(33, new lime_output_color());

$article1 = new Article();
$article1->setTitle('tt1');
$article1->save();
$article2 = new Article();
$article2->setTitle('tt2');
$article2->save();
$article3 = new Article();
$article3->setTitle('tt3');
$article3->save();
$article4 = new Article();
Ejemplo n.º 10
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = FilePeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Comment objects
         $criteria = new Criteria(CommentPeer::DATABASE_NAME);
         $criteria->add(CommentPeer::FILE_ID, $obj->getId());
         $affectedRows += CommentPeer::doDelete($criteria, $con);
         // delete related StatusAction objects
         $criteria = new Criteria(StatusActionPeer::DATABASE_NAME);
         $criteria->add(StatusActionPeer::FILE_ID, $obj->getId());
         $affectedRows += StatusActionPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
Ejemplo n.º 11
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = CommentPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setArticleId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setAuthor($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setContent($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
 }
Ejemplo n.º 12
0
 public static function countUserComments($user_id)
 {
     $c = new Criteria();
     $c->add(CommentPeer::USER_ID, $user_id);
     return CommentPeer::doCount($c);
 }
Ejemplo n.º 13
0
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
//$data = new sfPropelData();
//$data->loadData(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures');
//$code = CodePeer::retrieveByPK(1);
//$code->setRating(4, 1);
//$code->save();
//$tag = new Tag();
//$tag->setTag('Hede');
//$tag->setTagNormalized(Tag::normalize('Hede'));
//$tag->save();
//$soap = new SoapClient("http://localhost:8080/axis2/services/CodesnippetService?wsdl");
//print_r($soap);
//$func = $soap->__getFunctions();
//print_r($func);
//$rtn = $soap->highlight(array("language"=>"c", "code"=>"deneme"));
//print_r($rtn);
//echo $rtn->return;
$languages = CodeLanguagePeer::doSelect(new Criteria());
foreach ($languages as $language) {
    $c = new Criteria();
    //$c->add(CommentPeer::ID, 8);
    $comments = CommentPeer::doSelect($c);
    foreach ($comments as $comment) {
        echo '<' . $language->getTag() . '\\-code>(.|\\r|\\n)+<\\/' . $language->getTag() . '\\-code>' . "\n";
        $arr = array();
        preg_match_all("/<" . $language->getTag() . "\\-code>(.+)<\\/" . $language->getTag() . "\\-code>/isU", $comment->getComment(), $arr, PREG_SET_ORDER);
        print_r($arr);
    }
}
print_r(myUtils::highlightSnippet('deneme'));
Ejemplo n.º 14
0
 /**
  * Returns the number of related Comment objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related Comment objects.
  * @throws     PropelException
  */
 public function countComments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ArticlePeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collComments === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(CommentPeer::ARTICLE_ID, $this->id);
             $count = CommentPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(CommentPeer::ARTICLE_ID, $this->id);
             if (!isset($this->lastCommentCriteria) || !$this->lastCommentCriteria->equals($criteria)) {
                 $count = CommentPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collComments);
             }
         } else {
             $count = count($this->collComments);
         }
     }
     return $count;
 }
Ejemplo n.º 15
0
 public function executeBox()
 {
     $user_id = $this->getUser()->getId();
     $this->user_code_count = SnippetPeer::countUserSnippets($user_id);
     $this->user_comment_count = CommentPeer::countUserComments($user_id);
 }
Ejemplo n.º 16
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = CommentPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setBranchId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setFileId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setPosition($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setLine($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setType($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setCommit($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setValue($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setRootCommentId($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setCheckUserId($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setCheckedAt($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setCreatedAt($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setUpdatedAt($arr[$keys[13]]);
     }
 }