mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-25 22:33:18 +09:00
Finish News module updates
This commit is contained in:
commit
73bc66c1e2
5 files changed
+30
-25
No files matched your search
@@ -31,7 +31,7 @@ class Admin extends \Api_Abstract
|
||||
$pager = $this->di['pager']->getSimpleResultSet($sql, $params, $per_page);
|
||||
foreach ($pager['list'] as $key => $item) {
|
||||
$post = $this->di['db']->getExistingModelById('Post', $item['id'], 'Post not found');
|
||||
$pager['list'][$key] = $this->getService()->toApiArray($post);
|
||||
$pager['list'][$key] = $this->getService()->toApiArray($post, 'admin');
|
||||
}
|
||||
|
||||
return $pager;
|
||||
|
||||
@@ -37,8 +37,7 @@ class Service
|
||||
|
||||
public function getSearchQuery($data)
|
||||
{
|
||||
$sql='SELECT *,
|
||||
SUBSTRING( content, 1, LOCATE( "<!--more-->", content ) -1 ) AS excerpt
|
||||
$sql='SELECT *
|
||||
FROM post
|
||||
WHERE 1 ';
|
||||
|
||||
@@ -64,32 +63,35 @@ class Service
|
||||
|
||||
public function toApiArray($row, $role = 'guest', $deep = true)
|
||||
{
|
||||
$admin = $this->di['db']->getRow('SELECT name, email FROM admin WHERE id=:id', array('id'=>$row->admin_id));
|
||||
|
||||
$admin = $this->di['db']->getRow('SELECT name, email FROM admin WHERE id=:id', array('id' => $row->admin_id));
|
||||
|
||||
$pos = strpos($row->content, '<!--more-->');
|
||||
$excerpt = ($pos) ? substr($row->content, 0, $pos) : null;
|
||||
|
||||
$data = array(
|
||||
'id' => $row->id,
|
||||
'title' => $row->title,
|
||||
'content' => $row->content,
|
||||
'slug' => $row->slug,
|
||||
'image' => $row->image,
|
||||
'section' => $row->section,
|
||||
'publish_at' => $row->publish_at,
|
||||
'published_at' => $row->published_at,
|
||||
'expires_at' => $row->expires_at,
|
||||
'created_at' => $row->created_at,
|
||||
'updated_at' => $row->updated_at,
|
||||
'author' => array(
|
||||
'name' => $admin['name'],
|
||||
'email' => $admin['email'],
|
||||
'id' => $row->id,
|
||||
'title' => $row->title,
|
||||
'content' => $row->content,
|
||||
'slug' => $row->slug,
|
||||
'image' => $row->image,
|
||||
'section' => $row->section,
|
||||
'publish_at' => $row->publish_at,
|
||||
'published_at' => $row->published_at,
|
||||
'expires_at' => $row->expires_at,
|
||||
'created_at' => $row->created_at,
|
||||
'updated_at' => $row->updated_at,
|
||||
'author' => array(
|
||||
'name' => $admin['name'],
|
||||
'email' => $admin['email'],
|
||||
),
|
||||
'excerpt' => $row->excerpt,
|
||||
'excerpt' => $excerpt,
|
||||
//'tags' => array('foo', 'bar', 'bas'), //@todo
|
||||
);
|
||||
|
||||
if($role == 'admin') {
|
||||
|
||||
if ($role == 'admin') {
|
||||
$data['status'] = $row->status;
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<td style="width: 2%"><input type="checkbox" class="batch-delete-master-checkbox"/></td>
|
||||
<td>#</td>
|
||||
<td colspan="2">{% trans 'Title' %}</td>
|
||||
<td>{% trans 'Active' %}</td>
|
||||
<td>{% trans 'Date' %}</td>
|
||||
@@ -80,6 +79,8 @@
|
||||
<div class="rowElem">
|
||||
<label>{% trans 'Content' %}</label>
|
||||
<div class="formRight">
|
||||
<p>If the text is very long you can use <strong><!--more--></strong> tag. Inserting this tag within the post will create and excerpt of text (before the tag) to be displayed in posts list. Users will be able to see whole content when they click on "Read more" button.</p>
|
||||
<br/>
|
||||
<textarea name="content" cols="5" rows="10" class="bb-textarea">{{ request.content }}</textarea>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
<form method="post" action="{{ 'api/admin/news/update'|link }}" class="mainForm save api-form" data-api-msg="{% trans 'Post updated' %}">
|
||||
<fieldset>
|
||||
<p>If the text is very long you can use <strong><!--more--></strong> tag. Inserting this tag within the post will create and excerpt of text (before the tag) to be displayed in posts list. Users will be able to see whole content when they click on "Read more" button.</p>
|
||||
<br/>
|
||||
<textarea name="content" cols="5" rows="20" class="bb-textarea">{{ post.content }}</textarea>
|
||||
<input type="submit" value="{% trans 'Update' %}" class="greyishBtn submitForm" />
|
||||
<input type="hidden" name="id" value="{{ post.id }}"/>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block meta_title %}{{post.title}}{% endblock %}
|
||||
{% block breadcrumb %}
|
||||
<li><a href="{{ 'blog' | link}}">{% trans 'Blog' %}</a><span class="divider">/</span></li>
|
||||
<li><a href="{{ 'news' | link}}">{% trans 'Blog' %}</a><span class="divider">/</span></li>
|
||||
<li class="active">{{post.title}}</li>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
Reference in new issue
Block a user