/**
  * Build notification list as array
  */
 public function make()
 {
     // check if records is not empty
     if ($this->_records === null) {
         return;
     }
     // list records and build response
     foreach ($this->_records as $record) {
         /** @var UserNotification $record */
         $vars = null;
         if (!Str::likeEmpty($record->vars)) {
             $vars = $record->vars;
         }
         if (!$vars !== null && isset($vars['snippet'])) {
             $vars['snippet'] = Url::standaloneLink($vars['snippet'], $record->uri, App::$Request->getLanguage());
         }
         $text = App::$Translate->get('Profile', $record->msg, $vars);
         $this->items[] = ['text' => $text, 'date' => Date::humanize($record->created_at), 'new' => (bool) $record->readed === false];
     }
 }
示例#2
0
<?php

/** @var object $records */
use Ffcms\Core\Helper\Date;
use Ffcms\Core\Helper\Text;
use Ffcms\Core\Helper\Type\Str;
foreach ($records as $record) {
    $title = \App::$Translate->getLocaleText($record->title);
    if (Str::likeEmpty($title)) {
        continue;
    }
    $title = Text::snippet($title, 50);
    $date = Date::humanize($record->created_at);
    $categoryUrl = \App::$Alias->baseUrl . '/content/list/' . $record->cpath;
    $categoryLink = '<a href="' . $categoryUrl . '">' . \App::$Translate->getLocaleText($record->ctitle) . '</a>';
    $newsLink = \App::$Alias->baseUrl . '/content/read/' . $record->cpath;
    $newsLink = rtrim($newsLink, '/') . '/' . $record->path;
    echo '<div class="row"><div class="col-md-12">';
    echo '<a href="' . $newsLink . '">&rarr; ' . $title . '</a><br />';
    echo '<small class="pull-left">' . $categoryLink . '</small>';
    echo '<small class="pull-right">' . $date . '</small>';
    echo '</div></div>';
    echo '<hr class="pretty" />';
}
示例#3
0
文件: show.php 项目: phpffcms/ffcms
        echo $referNickname;
        ?>
"
                             src="<?php 
        echo $referObject->getProfile()->getAvatarUrl('small');
        ?>
" />
                        </div>
                    </div>
                    <div class="col-xs-8 col-md-10">
                        <h5 style="margin-top: 0;">
                            <i class="fa fa-pencil"></i> <?php 
        echo Url::link(['profile/show', $post->sender_id], $referNickname);
        ?>
                            <small class="pull-right"><?php 
        echo Date::humanize($post->updated_at);
        ?>
</small>
                        </h5>
                        <div class="object-text">
                            <?php 
        echo $post->message;
        ?>
                        </div>
                        <hr style="margin: 5px;" />
                        <div><i class="fa fa-comment-o"></i>
                            <a href="#wall-post-<?php 
        echo $post->id;
        ?>
" id="wall-post-response-<?php 
        echo $post->id;
示例#4
0
 /**
  * Build content data to model properties
  * @param $records
  * @throws ForbiddenException
  * @throws NotFoundException
  */
 private function buildContent($records)
 {
     $nullItems = 0;
     foreach ($records as $row) {
         /** @var Content $row */
         // check title length on current language locale
         $localeTitle = $row->getLocaled('title');
         if (Str::likeEmpty($localeTitle)) {
             ++$nullItems;
             continue;
         }
         // get snippet from full text for current locale
         $text = Text::snippet($row->getLocaled('text'));
         $itemPath = $this->categories[$row->category_id]->path;
         if (!Str::likeEmpty($itemPath)) {
             $itemPath .= '/';
         }
         $itemPath .= $row->path;
         // prepare tags data
         $tags = $row->getLocaled('meta_keywords');
         if (!Str::likeEmpty($tags)) {
             $tags = explode(',', $tags);
         } else {
             $tags = null;
         }
         $owner = App::$User->identity($row->author_id);
         // make a fake if user is not exist over id
         if ($owner === null) {
             $owner = new User();
         }
         // check if current user can rate item
         $ignoredRate = App::$Session->get('content.rate.ignore');
         $canRate = true;
         if (Obj::isArray($ignoredRate) && Arr::in((string) $row->id, $ignoredRate)) {
             $canRate = false;
         }
         if (!App::$User->isAuth()) {
             $canRate = false;
         } elseif ($owner->getId() === App::$User->identity()->getId()) {
             // own item
             $canRate = false;
         }
         // build result array
         $this->items[] = ['id' => $row->id, 'title' => $localeTitle, 'text' => $text, 'date' => Date::humanize($row->created_at), 'updated' => $row->updated_at, 'author' => $owner, 'poster' => $row->getPosterUri(), 'thumb' => $row->getPosterThumbUri(), 'thumbSize' => File::size($row->getPosterThumbUri()), 'views' => (int) $row->views, 'rating' => (int) $row->rating, 'canRate' => $canRate, 'category' => $this->categories[$row->category_id], 'uri' => '/content/read/' . $itemPath, 'tags' => $tags];
     }
     if ($nullItems === $this->_contentCount) {
         throw new NotFoundException(__('Content is not founded'));
     }
 }
示例#5
0
 /**
  * Prepare model attributes from passed objects
  * @throws ForbiddenException
  */
 public function before()
 {
     $this->id = $this->_content->id;
     $this->title = $this->_content->getLocaled('title');
     $this->text = $this->_content->getLocaled('text');
     // check if title and text are exists
     if (Str::length($this->title) < 1 || Str::length($this->text) < 1) {
         throw new ForbiddenException();
     }
     // get meta data
     $this->metaTitle = $this->_content->getLocaled('meta_title');
     if (Str::likeEmpty($this->metaTitle)) {
         $this->metaTitle = $this->title;
     }
     $this->metaDescription = $this->_content->getLocaled('meta_description');
     $tmpKeywords = $this->_content->getLocaled('meta_keywords');
     $this->metaKeywords = explode(',', $tmpKeywords);
     // set content date, category data
     $this->createDate = Date::humanize($this->_content->created_at);
     $this->catName = $this->_category->getLocaled('title');
     $this->catPath = $this->_category->path;
     // set user data
     if (App::$User->isExist($this->_content->author_id)) {
         $this->authorId = $this->_content->author_id;
         $profile = App::$User->identity($this->authorId)->getProfile();
         $this->authorName = $profile->getNickname();
     }
     $this->source = $this->_content->source;
     $this->views = $this->_content->views + 1;
     // check for dependence, add '' for general cat, ex: general/depend1/depend2/.../depend-n
     $catNestingArray = Arr::merge([0 => ''], explode('/', $this->catPath));
     if ($catNestingArray > 1) {
         // latest element its a current nesting level, lets cleanup it
         array_pop($catNestingArray);
         $catNestingPath = null;
         foreach ($catNestingArray as $cPath) {
             $catNestingPath .= $cPath;
             // try to find category by path in db
             $record = ContentCategory::getByPath($catNestingPath);
             if ($record !== null && $record->count() > 0) {
                 // if founded - add to nesting data
                 $this->catNesting[] = ['name' => $record->getLocaled('title'), 'path' => $record->path];
             }
             if (!Str::likeEmpty($catNestingPath)) {
                 $catNestingPath .= '/';
             }
         }
     }
     // build array of category nesting level
     $this->catNesting[] = ['name' => $this->catName, 'path' => $this->catPath];
     // get gallery images and poster data
     $galleryPath = '/upload/gallery/' . $this->_content->id;
     // check if gallery folder is exist
     if (Directory::exist($galleryPath)) {
         $originImages = File::listFiles($galleryPath . '/orig/', ['.jpg', '.png', '.gif', '.jpeg', '.bmp', '.webp'], true);
         // generate poster data
         if (Arr::in($this->_content->poster, $originImages)) {
             // original poster
             $posterName = $this->_content->poster;
             $this->posterFull = $galleryPath . '/orig/' . $posterName;
             if (!File::exist($this->posterFull)) {
                 $this->posterFull = null;
             }
             // thumb poster
             $posterSplit = explode('.', $posterName);
             array_pop($posterSplit);
             $posterCleanName = implode('.', $posterSplit);
             $this->posterThumb = $galleryPath . '/thumb/' . $posterCleanName . '.jpg';
             if (!File::exist($this->posterThumb)) {
                 $this->posterThumb = null;
             }
         }
         // generate full gallery
         foreach ($originImages as $image) {
             $imageSplit = explode('.', $image);
             array_pop($imageSplit);
             $imageClearName = implode('.', $imageSplit);
             // skip image used in poster
             if (Str::startsWith($imageClearName, $this->_content->poster)) {
                 continue;
             }
             $thumbPath = $galleryPath . '/thumb/' . $imageClearName . '.jpg';
             if (File::exist($thumbPath)) {
                 $this->galleryItems[$thumbPath] = $galleryPath . '/orig/' . $image;
             }
         }
     }
     // set rating data
     $this->rating = $this->_content->rating;
     $ignoredRate = App::$Session->get('content.rate.ignore');
     $this->canRate = true;
     if (Obj::isArray($ignoredRate) && Arr::in((string) $this->id, $ignoredRate)) {
         $this->canRate = false;
     }
     if (!App::$User->isAuth()) {
         $this->canRate = false;
     } elseif ($this->authorId === App::$User->identity()->getId()) {
         $this->canRate = false;
     }
     // update views count
     $this->_content->views += 1;
     $this->_content->save();
 }
示例#6
0
/** @var \Apps\ActiveRecord\CommentPost $records */
/** @var object $this */
/** @var int $snippet */
?>

<?php 
foreach ($records as $comment) {
    /** @var array $data */
    $data = (new EntityCommentData($comment, false))->make();
    ?>

<ul class="media-list">
	<li class="media">
		<ul class="list-inline list-info">
			<li><i class="fa fa-calendar"></i> <?php 
    echo Date::humanize($data['date']);
    ?>
</li>
			<li><i class="fa fa-user"></i>
			<?php 
    if ((int) $data['user']['id'] > 0) {
        ?>
				<?php 
        echo Url::link(['profile/show', $data['user']['id']], $data['user']['name']);
        ?>
			<?php 
    } else {
        ?>
				<?php 
        echo $data['user']['name'];
        ?>
示例#7
0
 /**
  * Set item date
  * @param string $value
  */
 public function setDate($value)
 {
     $this->date = Date::humanize($value);
 }
示例#8
0
 /**
  * Show all answers for this post id
  * @param int $postId
  * @return string
  * @throws NativeException
  * @return string
  */
 public function actionShowwallanswers($postId)
 {
     // check input post id num
     if (!Obj::isLikeInt($postId) || $postId < 1) {
         throw new NativeException('Wrong input data');
     }
     // try to find this post
     $object = WallPost::find($postId);
     if ($object === null || $object === false) {
         throw new NativeException('Wrong input data');
     }
     $result = $object->getAnswer()->orderBy('id', 'DESC')->take(200)->get();
     $response = [];
     foreach ($result as $answer) {
         // get user object and profile
         $user = $answer->getUser();
         $profile = $user->getProfile();
         // check if user exist
         if ($user === null || $user->id < 1) {
             continue;
         }
         // generate response array
         $response[] = ['answer_id' => $answer->id, 'user_id' => $answer->user_id, 'user_nick' => $profile->getNickname(), 'user_avatar' => $profile->getAvatarUrl('small'), 'answer_message' => $answer->message, 'answer_date' => Date::humanize($answer->created_at)];
     }
     return json_encode(['status' => 1, 'data' => $response]);
 }