コード例 #1
0
function link_to_post($post, $text = '', $postfix = null, $options = array())
{
    if (!$text) {
        $text = $post->getTitle();
    }
    return link_to($text, sfSimpleBlogTools::generatePostUri($post, $postfix), $options);
}
コード例 #2
0
function link_to_post($post, $text = '', $postfix = null, $options = array())
{
  $post = $post instanceof sfOutputEscaper ? $post->getRawValue() : $post;
  if(!$text)
  {
    $text = ($post instanceof BaseObject) ? $post->getTitle() : $post['Title'];
  }
  return link_to($text, sfSimpleBlogTools::generatePostUri($post, $postfix), $options);
}
コード例 #3
0
 public function getFeedLink()
 {
     return sfSimpleBlogTools::generatePostUri($this);
 }
 public function executeAddComment()
 {
     $this->forward404Unless(sfConfig::get('app_sfSimpleBlog_comment_enabled', true));
     $post = sfSimpleBlogPostPeer::retrieveByStrippedTitleAndDate($this->getRequestParameter('stripped_title'), $this->getRequestParameter('date'));
     $this->forward404Unless($post);
     $this->forward404Unless($post->allowComments());
     $comment = new sfSimpleBlogComment();
     $comment->setSfBlogPostId($post->getId());
     $automoderation = sfConfig::get('app_sfSimpleBlog_comment_automoderation', 'first_post');
     if ($automoderation === true || $automoderation == 'first_post' && !sfSimpleBlogCommentPeer::isAuthorApproved($this->getRequestParameter('name'), $this->getRequestParameter('mail'))) {
         $comment->setIsModerated(true);
         $this->setFlash('add_comment', 'moderated');
     } else {
         $this->setFlash('add_comment', 'normal');
     }
     $comment->setAuthorName($this->getRequestParameter('name'));
     $comment->setAuthorEmail($this->getRequestParameter('mail'));
     if ($url = $this->getRequestParameter('website', '')) {
         if (strpos($url, 'http://') !== 0) {
             $url = 'http://' . $url;
         }
         $comment->setAuthorUrl($url);
     }
     $comment->setContent(strip_tags($this->getRequestParameter('content')));
     $comment->save();
     $email_pref = sfConfig::get('app_sfSimpleBlog_comment_mail_alert', 1);
     if ($email_pref == 1 || $email_pref == 'moderated' && $comment->getIsModerated()) {
         $this->getRequest()->setAttribute('comment', $comment);
         $raw_email = $this->sendEmail('sfSimpleBlog', 'sendMailOnComment');
         $this->logMessage($raw_email, 'debug');
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->post = $post;
         $this->comments = $post->getComments();
         return 'Ajax';
     } else {
         $this->redirect(sfSimpleBlogTools::generatePostUri($post));
     }
 }
コード例 #5
0
<?php use_helper('I18N', 'sfSimpleBlog') ?>
<?php slot('title') ?>
  <?php echo sfConfig::get('app_sfSimpleBlog_title', 'sfSimpleBlog').' | '.$post->getTitle() ?>
<?php end_slot() ?>

<?php if(sfConfig::get('app_sfSimpleBlog_use_feeds', true)): ?>
  <?php slot('auto_discovery_link_tag') ?>
    <?php echo auto_discovery_link_tag('rss', sfSimpleBlogTools::generateFeedUri($post, null, 'commentsForPostFeed').'&format=rss', array('title' => __('Comments on post "%1%" from %2%', array('%1%' => $post->getTitle(), '%2%' => sfConfig::get('app_sfSimpleBlog_title', 'sfSimpleBlog'))))) ?>
  <?php end_slot() ?>
<?php endif; ?>

<span class="sfSimpleBlog">
  <?php include_partial('sfSimpleBlog/post', array('post' => $post, 'in_list' => false)) ?>
  <?php include_component('sfNestedComment', 'showComments', array('object' => $post)) ?>
</span>

<?php $link_prev = link_to_previous_post($post) ?>
<?php $link_next = link_to_next_post($post) ?>
<?php if ($link_prev || $link_next): ?>
<div id="nav-below" class="navigation">
  <?php if($link_prev): ?>
    <div class="nav-previous">
      <span class="meta-nav">&larr;</span><?php echo $link_prev ?>
    </div>
  <?php endif; ?>
  <?php if($link_next): ?>
    <div class="nav-next">
      <?php echo $link_next ?><span class="meta-nav">&rarr;</span>
    </div>
  <?php endif; ?>
</div>
コード例 #6
0
if (sfConfig::get('app_sfSimpleBlog_use_ajax', true)) {
    ?>
  <?php 
    use_javascript(sfConfig::get('sf_prototype_web_dir') . '/js/prototype.js');
}
$sf_context->getResponse()->setTitle(sfConfig::get('app_sfSimpleBlog_title', 'How is life on earth?') . ' > ' . $post->getTitle());
?>

<?php 
if (sfConfig::get('app_sfSimpleBlog_use_feeds', true)) {
    ?>
  <?php 
    slot('auto_discovery_link_tag');
    ?>
    <?php 
    echo auto_discovery_link_tag('rss', sfSimpleBlogTools::generatePostUri($post, null, 'commentsForPostFeed'), array('title' => __('Comments on post "%1%" from %2%', array('%1%' => $post->getTitle(), '%2%' => sfConfig::get('app_sfSimpleBlog_title', 'How is life on earth?')))));
    ?>
  <?php 
    end_slot();
}
?>

<span class="sfSimpleBlog">

  <?php 
include_partial('sfSimpleBlog/post', array('post' => $post, 'in_list' => false));
?>
  
  <div class="comments" id="comments">

    <?php 
コード例 #7
0
 public function executeCommentsFeed()
 {
     sfLoader::loadHelpers(array('I18N', 'Tag', 'Url'));
     $comments = sfSimpleBlogCommentPeer::getRecent($this->getRequestParameter('nb', sfConfig::get('app_sfSimpleBlog_feed_count', 5)));
     $feed = new sfRss2ExtendedFeed();
     $feed->initialize(array('title' => __('Comments from %1%', array('%1%' => sfConfig::get('app_sfSimpleBlog_title', ''))), 'link' => $this->getController()->genUrl('sfSimpleBlog/index'), 'siteUrl' => 'http://' . sfConfig::get('sf_site_url'), 'image' => 'http://' . sfConfig::get('sf_site_url') . '/images/logo-openparlamento.png', 'feedUrl' => $this->getRequest()->getURI(), 'language' => 'it', 'copyright' => "Licenza Creative Commons 'Attribuzione-Non commerciale-Non opere derivate 2.5 Generico'", 'authorEmail' => '*****@*****.**', 'authorName' => 'Openparlamento', 'description' => "Openparlamento.it - il progetto Openpolis per la trasparenza del Parlamento", 'ttl' => 1440, 'sy_updatePeriod' => 'daily', 'sy_updateFrequency' => '4', 'sy_updateBase' => '2000-01-01T12:00+00:00'));
     foreach ($comments as $comment) {
         $post = $comment->getsfSimpleBlogPost();
         $item = new sfRss2ExtendedItem();
         $item->initialize(array('title' => "Commento sul post: " . $post->getTitle(), 'link' => sfSimpleBlogTools::generatePostUri($post, null), 'authorEmail' => '*****@*****.**', 'authorName' => 'Openparlamento', 'pubDate' => $comment->getCreatedAt('U'), 'permalink' => url_for('@blog_article?stripped_title=' . $post->getStrippedTitle(), true) . "#" . $comment->getId(), 'description' => $comment->getContent()));
         $feed->addItem($item);
     }
     $this->setLayout(false);
     $this->response->setContentType('text/xml');
     $this->response->setContent($feed->asXml());
     return sfView::NONE;
 }
コード例 #8
0
    <abbr class="published">
      <?php echo format_date(strtotime($post->getPublishedAt()), 'P') ?>
      <?php if ($sf_user->isAuthenticated()): ?>
        <?php $user_id = $sf_user->getAttribute('user_id', null, 'sfGuardSecurityUser') ?>
        <?php if (null !== $user_id && $post->getAuthorId() == $user_id): ?>
          <a href="<?php echo cross_app_url_for('backend', '@sf_simple_blog_post_edit?id='.$post->getId()) ?>">(<?php echo __('Edit') ?>)</a>
        <?php endif; ?>
      <?php endif; ?>
    </abbr>
  </div>
  <div class="entry-content">
    <?php echo $post->getContent(ESC_RAW)?>
  </div>
  <?php $shareOn = sfConfig::get('app_sfSimpleBlog_share_on', false) ?>
  <?php if ($shareOn): ?>
    <?php $url = url_for(sfSimpleBlogTools::generatePostUri($post), true) ?>
    <div id="social_bookmark">
      <h3>Share this post</h3>
      <ul>
      <?php if ($shareOn === 'all'): ?>
        <?php echo link_to_all_social_bookmarking($url, $post->getTitle()) ?>
      <?php else: ?>
        <?php echo link_to_social_bookmarking($shareOn, $url, $post->getTitle()) ?>
      <?php endif; ?>
      </ul>
    </div>
  <?php endif; ?>

  <div class="entry-meta">
    <span class="entry-category">
      <?php echo __('Posted in ') ?>&rsaquo;