예제 #1
0
파일: shouts.php 프로젝트: anqh/anqh
    /**
     * Render content.
     *
     * @return  string
     */
    public function content()
    {
        $shouts = array();
        foreach (Model_Shout::find_latest($this->limit) as $shout) {
            $shouts[] = array('created' => $shout->created, 'user_id' => $shout->author_id, 'shout' => $shout->shout);
        }
        if ($shouts) {
            ob_start();
            ?>

<ul class="list-unstyled">

	<?php 
            foreach (array_reverse($shouts) as $shout) {
                ?>
	<li>
		<?php 
                echo HTML::time(Date::format('HHMM', $shout['created']), array('datetime' => $shout['created'], 'class' => 'muted'));
                ?>
		<?php 
                echo HTML::user($shout['user_id']);
                ?>
:
		<?php 
                echo Text::smileys(Text::auto_link_urls(HTML::chars($shout['shout'])));
                ?>
	</li>
	<?php 
            }
            ?>

</ul>

<?php 
            if ($this->_can_shout) {
                ?>
<form <?php 
                echo $this->aside ? 'class="ajaxify"' : '';
                ?>
 action="<?php 
                echo Route::url('shouts', array('action' => 'shout'));
                ?>
" method="post">
	<input class="form-control" type="text" name="shout" maxlength="300" placeholder="<?php 
                echo __('Shout, and ye shall be heard..');
                ?>
" />
	<?php 
                echo Form::CSRF();
                ?>
</form>
<?php 
            }
            return ob_get_clean();
        }
        return '';
    }
예제 #2
0
파일: galleries.php 프로젝트: anqh/anqh
 /**
  * Get notification as HTML.
  *
  * @static
  * @param   Model_Notification
  * @return  string
  */
 public static function get(Model_Notification $notification)
 {
     $text = '';
     switch ($notification->type) {
         case self::TYPE_IMAGE_COMMENT:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user commented your :photo: <em>:comment</em>', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable')), ':comment' => Text::smileys(Text::auto_link_urls(HTML::chars($notification->text)))));
             } else {
                 $notification->delete();
             }
             break;
         case self::TYPE_IMAGE_NOTE:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user tagged you to a :photo', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable'))));
             } else {
                 $notification->delete();
             }
             break;
         case self::TYPE_IMAGE_REPORT:
             $user = Model_User::find_user($notification->user_id);
             $image = Model_Image::factory($notification->data_id);
             if ($user->loaded() && $image->loaded()) {
                 $gallery = $image->gallery();
                 $text = __(':user reported a :photo: <em>:reason</em>', array(':user' => HTML::user($user), ':photo' => HTML::anchor(Route::url('gallery_image', array('gallery_id' => Route::model_id($gallery), 'id' => $image->id, 'action' => '')), __('photo'), array('class' => 'hoverable')), ':reason' => $notification->text ? HTML::chars($notification->text) : __('No reason')));
             } else {
                 $notification->delete();
             }
             break;
     }
     return $text;
 }
예제 #3
0
 /**
  * Tests Text::auto_link()
  *
  * @test
  * @dataProvider provider_auto_link
  */
 public function test_auto_link($text, $urls = array(), $emails = array())
 {
     $linked_text = Text::auto_link($text);
     if ($urls === FALSE) {
         $this->assertNotContains('http://', $linked_text);
     } elseif (count($urls)) {
         foreach ($urls as $url) {
             // Assert that all the urls have been caught by text auto_link_urls()
             $this->assertContains(Text::auto_link_urls($url), $linked_text);
         }
     }
     foreach ($emails as $email) {
         $this->assertContains('&#109;&#097;&#105;&#108;&#116;&#111;&#058;' . $email, $linked_text);
     }
 }
예제 #4
0
파일: text.php 프로젝트: Normull/core
 /**
  * Converts text email addresses and anchors into links.
  *
  * @param   string   text to auto link
  * @return  string
  */
 public static function auto_link($text)
 {
     // Auto link emails first to prevent problems with "*****@*****.**"
     return Text::auto_link_urls(Text::auto_link_emails($text));
 }
예제 #5
0
파일: comments.php 프로젝트: anqh/anqh
    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        // Comment form
        echo $this->form();
        // Pagination
        if ($this->pagination) {
            echo $this->pagination->render();
        }
        ?>

<ul class="media-list">

<?php 
        $new_comments = isset($new_comments) ? (int) $new_comments : 0;
        foreach ($this->comments as $comment) {
            /** @var  Model_Comment  $comment */
            $author = $comment->author();
            // Ignore
            if (Visitor::$user && Visitor::$user->is_ignored($author)) {
                continue;
            }
            $classes = array('media');
            // Private comment?
            if ($comment->private) {
                $classes[] = 'private';
            }
            // Viewer's post
            if (Visitor::$user && $author['id'] == Visitor::$user->id) {
                $classes[] = 'my';
            }
            // Topic author's post
            if ($author['id'] == $comment->user_id) {
                $classes[] = 'owner';
            }
            // New comment?
            if ($new_comments-- > 0) {
                $classes[] = 'new';
            }
            ?>

	<li class="<?php 
            echo implode(' ', $classes);
            ?>
" id="comment-<?php 
            echo $comment->id;
            ?>
">
		<div class="pull-left">
			<?php 
            echo HTML::avatar($author['avatar'], $author['username']);
            ?>
		</div>
		<div class="arrow"></div>
		<div class="media-body">
			<small class="pull-right">
				<?php 
            if (Visitor::$user && $comment->user_id == Visitor::$user->id || in_array('my', $classes)) {
                if ($this->private && !$comment->private) {
                    echo HTML::anchor(sprintf($this->private, $comment->id), __('Set as private'), array('class' => 'comment-private')) . ' &bull; ';
                }
                if ($this->delete) {
                    echo HTML::anchor(sprintf($this->delete, $comment->id), __('Delete'), array('class' => 'comment-delete')) . ' &bull; ';
                }
            }
            ?>

				<?php 
            echo in_array('new', $classes) ? __('New') : '';
            ?>
 <?php 
            echo HTML::time(Date::short_span($comment->created, true, true), $comment->created);
            ?>
			</small>
			<?php 
            echo HTML::user($author);
            ?>
<br />
			<?php 
            echo $comment->private ? '<span class="label label-special" title="' . __('Private comment') . '">' . __('Priv') . '</span>: ' : '';
            ?>
			<?php 
            echo Text::smileys(Text::auto_link_urls(HTML::chars($comment->comment)));
            ?>
		</div>
	</li>

	<?php 
        }
        ?>

</ul>

<?php 
        // Pagination
        if ($this->pagination) {
            echo $this->pagination->render();
        }
        return ob_get_clean();
    }
예제 #6
0
파일: comments.php 프로젝트: anqh/core
        ?>
	<nav class="actions inline">
		<?php 
        if ($private && !$comment->private) {
            ?>
		<?php 
            echo HTML::anchor(sprintf($private, $comment->id), __('Set as private'), array('class' => 'action small comment-private'));
            ?>
		<?php 
        }
        ?>
		<?php 
        echo HTML::anchor(sprintf($delete, $comment->id), __('Delete'), array('class' => 'action small comment-delete'));
        ?>
	</nav>
	<?php 
    }
    ?>

	<p>
		<?php 
    echo $comment->private ? '<abbr title="' . __('Private comment') . '">' . __('Priv') . '</abbr>: ' : '';
    ?>
		<?php 
    echo Text::smileys(Text::auto_link_urls(HTML::chars($comment->comment)));
    ?>
	</p>
</article>

<?php 
}
예제 #7
0
<br/>

<?php 
echo Text::similar(array('Help', 'Helium', 'Herman'));
?>

<br>

<?php 
echo Text::auto_link('My email is someone@somewhere.ca and my web site is www.kohanaphp.com');
?>
<br>

<?php 
echo Text::auto_link_urls('My email is someone@somewhere.ca and my web site is www.kohanaphp.com');
?>
<br>

<?php 
echo Text::auto_link_emails('My email is someone@somewhere.ca and my web site is www.kohanaphp.com');
?>

<br/>

<?php 
$string = "This is a block of\ntext that has\n\nSome line breaks in it.";
echo Text::auto_p($string);
?>

<br/>
예제 #8
0
 public static function auto_link_urls($string)
 {
     return Text::auto_link_urls($string);
 }