public static function generate()
 {
     $c = new Criteria();
     $c->add(SnippetPeer::DRAFT, false);
     $snippets = SnippetPeer::doSelect($c);
     $urls = array();
     foreach ($snippets as $snippet) {
         $urls[] = new sitemapURL("snippet/show?id=" . $snippet->getFriendlyUrl(), date('Y-m-d\\TH:i:s\\Z', strtotime($snippet->getUpdatedAt())), 'weekly', 1.0);
     }
     return $urls;
 }
 public function executeViewProfile()
 {
     $username = $this->getRequestParameter('username');
     $this->user = sfGuardUserPeer::retrieveByUsername($username);
     $c = new Criteria();
     $c->add(SnippetPeer::USER_ID, $this->user->getId());
     $c->add(SnippetPeer::DRAFT, false);
     $this->snippet_count = SnippetPeer::doCount($c);
     $this->pager = new sfPropelPager('Snippet', sfConfig::get('app_pager', 10));
     $this->pager->setCriteria($c);
     $this->pager->setPage($this->getRequestParameter('page', 1));
     $this->pager->init();
 }
 public function executeAdd()
 {
     $comment = new Comment();
     $comment->setSnippet(SnippetPeer::retrieveByPk($this->getRequestParameter('id')));
     if ($this->getUser()->isAuthenticated()) {
         $comment->setUserId($this->getUser()->getGuardUser()->getId());
     } else {
         $comment->setName($this->getRequestParameter('name'));
         $comment->setEmail($this->getRequestParameter('email'));
     }
     $comment->setRawBody($this->getRequestParameter('raw_body'));
     $comment->save();
     $this->comment = $comment;
 }
 public function executeMost()
 {
     $most = $this->getRequestParameter('most');
     $this->logMessage('Umut: ' . $most, 'debug');
     if (!$most || $most == 'new') {
         $this->snippets = SnippetPeer::getNewCodes($this->getUser()->getPreference('box_snippets_size'));
     } else {
         if ($most == 'high') {
             $this->snippets = SnippetPeer::getPopularCodes($this->getUser()->getPreference('box_snippets_size'));
         } else {
             if ($most == 'disc') {
                 $this->snippets = SnippetPeer::getMostDiscussedCodes($this->getUser()->getPreference('box_snippets_size'));
             } else {
                 $this->snippets = SnippetPeer::getNewCodes();
             }
         }
     }
 }
 public function executeNewCodes()
 {
     $feed = new sfAtom1Feed();
     $feed->setTitle('Hoydaa Snippets');
     $feed->setLink('http://codesnippet.hoydaa.org');
     $feed->setAuthorEmail('*****@*****.**');
     $feed->setAuthorName('Hoydaa Snippets');
     $codes = SnippetPeer::getNewCodes();
     foreach ($codes as $code) {
         $item = new sfFeedItem();
         $item->setTitle($code->getTitle());
         $item->setLink('snippet/show?id=' . $code->getFriendlyUrl());
         $item->setAuthorName($code->getSfGuardUser() ? $code->getSfGuardUser()->getProfile()->getFullName() : $code->getName());
         $item->setAuthorEmail($code->getSfGuardUser() ? $code->getSfGuardUser()->getProfile()->getEmail() : $code->getEmail());
         $item->setPubdate($code->getCreatedAt('U'));
         $item->setUniqueId($code->getId());
         $item->setDescription($code->getSummary());
         $feed->addItem($item);
     }
     $this->feed = $feed;
     $this->setTemplate('feed');
 }
<?php

define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..'));
define('SF_APP', 'frontend');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', true);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
// initialize database manager
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$snippets = SnippetPeer::doSelect(new Criteria());
foreach ($snippets as $snippet) {
    echo "Saving snippet#" . $snippet->getId() . ":" . $snippet->getTitle() . "\n";
    $snippet->save();
    echo "     Stripped title: " . $snippet->getFriendlyUrl() . "\n";
}
 public static function countUserSnippets($user_id)
 {
     $c = new Criteria();
     $c->add(SnippetPeer::USER_ID, $user_id);
     return SnippetPeer::doCount($c);
 }
 public function executeIndex()
 {
     $this->snippets = SnippetPeer::getNewCodes(5);
 }
 public function executeDelete()
 {
     $id = $this->getRequestParameter('id');
     $this->forward404Unless($id);
     $snippet = SnippetPeer::retrieveByPk($id);
     $this->forward404Unless($snippet);
     if ($snippet->getUserId() != $this->getUser()->getGuardUser()->getId()) {
         $this->forward('default', 'secure');
     }
     $snippet->delete();
     $this->setFlash('info', 'Snippet is completely removed from the system.');
     $this->forward('site', 'message');
 }
 public function executeShow()
 {
     $this->pager = SnippetPeer::getByTag($this->getRequestParameter('tag'), $this->getRequestParameter('page', 1), $this->getUser()->getPreference('search_size'));
     $this->tag = $this->getRequestParameter('tag');
 }
 public function executeBox()
 {
     $user_id = $this->getUser()->getId();
     $this->user_code_count = SnippetPeer::countUserSnippets($user_id);
     $this->user_comment_count = CommentPeer::countUserComments($user_id);
 }