diff --git a/src/bb-modules/News/Api/Admin.php b/src/bb-modules/News/Api/Admin.php index ee4739a86..1cc740bc0 100644 --- a/src/bb-modules/News/Api/Admin.php +++ b/src/bb-modules/News/Api/Admin.php @@ -75,6 +75,7 @@ class Admin extends \Api_Abstract * @param int $id - news item ID * * @optional string $title - news item title + * @optional string $description - news item description * @optional string $slug - news item slug * @optional string $content - news item content * @optional string $status - news item status @@ -83,19 +84,24 @@ class Admin extends \Api_Abstract */ public function update($data) { + $service = $this->getService(); $required = array( - 'id' => 'Post id not passed', + 'id' => 'Post ID not passed', ); $this->di['validator']->checkRequiredParamsForArray($required, $data); $model = $this->di['db']->getExistingModelById('Post', $data['id'], 'News item not found'); - $model->content = $this->di['array_get']($data, 'content', $model->content); - $model->title = $this->di['array_get']($data, 'title', $model->title); - $model->slug = $this->di['array_get']($data, 'slug', $model->slug); - $model->image = $this->di['array_get']($data, 'image', $model->image); - $model->section = $this->di['array_get']($data, 'section', $model->section); - $model->status = $this->di['array_get']($data, 'status', $model->status); + $description = $this->di['array_get']($data, 'description', $model->description); + if (empty($description)) $description = $service->generateDescriptionFromContent($this->di['array_get']($data, 'content', $model->content)); + + $model->content = $this->di['array_get']($data, 'content', $model->content); + $model->title = $this->di['array_get']($data, 'title', $model->title); + $model->description = $description; + $model->slug = $this->di['array_get']($data, 'slug', $model->slug); + $model->image = $this->di['array_get']($data, 'image', $model->image); + $model->section = $this->di['array_get']($data, 'section', $model->section); + $model->status = $this->di['array_get']($data, 'status', $model->status); $publish_at = $this->di['array_get']($data, 'publish_at', 0); if ($publish_at) { @@ -130,7 +136,7 @@ class Admin extends \Api_Abstract } /** - * Creat new news item. + * Create new news item. * * @param string $title - news item title * @@ -141,19 +147,21 @@ class Admin extends \Api_Abstract */ public function create($data) { + $service = $this->getService(); $required = array( 'title' => 'Post title not passed', ); $this->di['validator']->checkRequiredParamsForArray($required, $data); - $model = $this->di['db']->dispense('Post'); - $model->admin_id = $this->getIdentity()->id; - $model->title = $data['title']; - $model->slug = $this->di['tools']->slug($data['title']); - $model->status = $this->di['array_get']($data, 'status', NULL); - $model->content = $this->di['array_get']($data, 'content', NULL); - $model->created_at = date('Y-m-d H:i:s'); - $model->updated_at = date('Y-m-d H:i:s'); + $model = $this->di['db']->dispense('Post'); + $model->admin_id = $this->getIdentity()->id; + $model->title = $data['title']; + $model->description = null; + $model->slug = $this->di['tools']->slug($data['title']); + $model->status = $this->di['array_get']($data, 'status', NULL); + $model->content = $this->di['array_get']($data, 'content', NULL); + $model->created_at = date('Y-m-d H:i:s'); + $model->updated_at = date('Y-m-d H:i:s'); $this->di['db']->store($model); $this->di['logger']->info('Created news item #%s', $model->id); diff --git a/src/bb-modules/News/Service.php b/src/bb-modules/News/Service.php index 8a7d39104..1d72db98b 100644 --- a/src/bb-modules/News/Service.php +++ b/src/bb-modules/News/Service.php @@ -35,6 +35,22 @@ class Service return $this->di['db']->findOne('Post', 'slug = :slug AND status = "active"', array('slug'=>$slug)); } + /** + * Generate a placeholder meta description from given string. + * + * @param string $content - string to generate description from + * + * @return string + */ + public function generateDescriptionFromContent($content) + { + $desc = utf8_encode($content); + $desc = strip_tags($desc); + $desc = str_replace(array("\n", "\r", "\t"), ' ', $desc); + $desc = substr($desc, 0, 125); + return $desc; + } + public function getSearchQuery($data) { $sql='SELECT * @@ -71,6 +87,7 @@ class Service $data = array( 'id' => $row->id, 'title' => $row->title, + 'description' => $row->description, 'content' => $row->content, 'slug' => $row->slug, 'image' => $row->image, diff --git a/src/bb-modules/News/html_admin/mod_news_post.phtml b/src/bb-modules/News/html_admin/mod_news_post.phtml index c31373db6..b2c088649 100644 --- a/src/bb-modules/News/html_admin/mod_news_post.phtml +++ b/src/bb-modules/News/html_admin/mod_news_post.phtml @@ -1,13 +1,13 @@ {% extends "layout_default.phtml" %} {% import "macro_functions.phtml" as mf %} -{% block meta_title %}{{ post.title}}{% endblock %} +{% block meta_title %}{{post.title}}{% endblock %} {% set active_menu = 'support' %} {% block breadcrumbs %} {% endblock %} @@ -15,13 +15,15 @@
-
{{ post.title}}
+
{{post.title}}
- +
+
Edit post
+

If the text is very long you can use <!--more--> 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.

+
+
-

If the text is very long you can use <!--more--> 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.

-
@@ -32,7 +34,7 @@
-
{{ post.title}}
+
{{post.title}}
@@ -45,6 +47,14 @@
+
+ +
+ +
+
+
+
@@ -91,4 +101,4 @@
{% endblock %} -{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %} \ No newline at end of file +{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %} diff --git a/src/bb-modules/News/html_client/mod_news_post.phtml b/src/bb-modules/News/html_client/mod_news_post.phtml index fca2db60f..d98e160a0 100644 --- a/src/bb-modules/News/html_client/mod_news_post.phtml +++ b/src/bb-modules/News/html_client/mod_news_post.phtml @@ -1,6 +1,8 @@ {% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %} -{% block meta_title %}{{post.title}}{% endblock %} +{% block meta_title %}{{ post.title }}{% endblock %} +{% block meta_description %}{{ post.description }}{% endblock %} + {% block breadcrumb %}
  • {% trans 'Blog' %}/
  • {{post.title}}
  • @@ -10,6 +12,7 @@ + diff --git a/src/bb-themes/admin_default/html/macro_functions.phtml b/src/bb-themes/admin_default/html/macro_functions.phtml index d1eaead2e..14a280bcf 100644 --- a/src/bb-themes/admin_default/html/macro_functions.phtml +++ b/src/bb-themes/admin_default/html/macro_functions.phtml @@ -130,4 +130,4 @@ {% else %} {% endif %} -{% endmacro %} +{% endmacro %} \ No newline at end of file diff --git a/src/bb-themes/bootstrap/html/mod_news_post.phtml b/src/bb-themes/bootstrap/html/mod_news_post.phtml index eceabcac4..fcf7d993c 100755 --- a/src/bb-themes/bootstrap/html/mod_news_post.phtml +++ b/src/bb-themes/bootstrap/html/mod_news_post.phtml @@ -1,11 +1,13 @@ {% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %} {% block meta_title %}{{post.title}}{% endblock %} +{% block meta_description %}{{ post.description }}{% endblock %} {% block opengraph %} + @@ -43,11 +45,9 @@

    - {{ post.content|bbmd }} + {{ post.content | bbmd }} {# if post.tags %}Tags: {{ post.tags|join(', ') }}{% endif #}

    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ducimus, vero, obcaecati, aut, error quam sapiente nemo saepe quibusdam sit excepturi nam quia corporis eligendi eos magni recusandae laborum minus inventore?

    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut, tenetur natus doloremque laborum quos iste ipsum rerum obcaecati impedit odit illo dolorum ab tempora nihil dicta earum fugiat. Temporibus, voluptatibus.


    diff --git a/src/bb-themes/boxbilling/html/mod_news_post.phtml b/src/bb-themes/boxbilling/html/mod_news_post.phtml index 7eda6690d..6031c0ac3 100644 --- a/src/bb-themes/boxbilling/html/mod_news_post.phtml +++ b/src/bb-themes/boxbilling/html/mod_news_post.phtml @@ -1,10 +1,12 @@ {% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %} {% block meta_title %}{{post.title}}{% endblock %} +{% block meta_description %}{{post.description}}{% endblock %} {% block opengraph %} + diff --git a/src/bb-update.php b/src/bb-update.php index 6dee7caa0..6db05b28a 100644 --- a/src/bb-update.php +++ b/src/bb-update.php @@ -18,6 +18,10 @@ class BBPatch_24 extends BBPatchAbstract { public function patch() { + // Initializing meta description support for announcements + $q = "ALTER TABLE `post` ADD `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER `title`"; + $this->execSql($q); + // Clearing leftovers from deleted payment adapters $q = "DELETE FROM `pay_gateway` WHERE `gateway` = 'AlertPay' OR `gateway` = 'WebToPay' OR `gateway` = 'Payza' OR `gateway` = 'SinglePay'"; $this->execSql($q); diff --git a/src/install/sql/content.sql b/src/install/sql/content.sql index db1a0d856..3ab0893dd 100644 --- a/src/install/sql/content.sql +++ b/src/install/sql/content.sql @@ -245,11 +245,11 @@ UNLOCK TABLES; LOCK TABLES `post` WRITE; /*!40000 ALTER TABLE `post` DISABLE KEYS */; -INSERT INTO `post` (`id`, `admin_id`, `title`, `content`, `slug`, `status`, `image`, `section`, `publish_at`, `published_at`, `expires_at`, `created_at`, `updated_at`) +INSERT INTO `post` (`id`, `admin_id`, `title`, `description`, `content`, `slug`, `status`, `image`, `section`, `publish_at`, `published_at`, `expires_at`, `created_at`, `updated_at`) VALUES - (1,1,'BoxBilling is the most affordable Billing Application Ever!','Just in case you weren''t already aware, BoxBilling is the most affordable client management application ever!\n\nTo learn more about it You can always visit [www.boxbilling.com](http://www.boxbilling.com/)\n','boxbilling-is-affordable-billing-system','active',NULL,NULL,NULL,NULL,NULL,'2020-01-01 12:00:00','2020-01-01 12:00:00'), - (2,1,'Check out great features of BoxBilling','* Supports automated billing, invoicing, product provisioning\n* Automatically create accounts as soon as the payment is received, suspend when account becomes overdue, terminate when a specified amount of time passes.\n* Boxbilling is perfectly created to sell shared and reseller hosting accounts, software licenses and downloadable products.\n* Integrated helpdesk, knowledgebase, news and announcements system.\n','great-features-of-boxbilling','active',NULL,NULL,NULL,NULL,NULL,'2020-01-01 12:00:00','2020-01-01 12:00:00'), - (3,1,'BoxBilling is customizable','* You can create your own simple or advanced hooks on BoxBilling events. For example, send notification via sms when new client signs up.\n* Create custom theme for your client interface\n','boxbilling-is-customizable','active',NULL,NULL,NULL,NULL,NULL,'2020-01-01 12:00:00','2020-01-01 12:00:00'); + (1,1,'BoxBilling is the most affordable Billing Application Ever!','Just in case you weren''t already aware, BoxBilling is the most affordable client management application ever!','Just in case you weren''t already aware, BoxBilling is the most affordable client management application ever!\n\nTo learn more about it You can always visit [www.boxbilling.com](http://www.boxbilling.com/)\n','boxbilling-is-affordable-billing-system','active',NULL,NULL,NULL,NULL,NULL,'2020-01-01 12:00:00','2020-01-01 12:00:00'), + (2,1,'Check out great features of BoxBilling','BoxBilling supports automated billing, invoicing, product provisioning', '* Supports automated billing, invoicing, product provisioning\n* Automatically create accounts as soon as the payment is received, suspend when account becomes overdue, terminate when a specified amount of time passes.\n* Boxbilling is perfectly created to sell shared and reseller hosting accounts, software licenses and downloadable products.\n* Integrated helpdesk, knowledgebase, news and announcements system.\n','great-features-of-boxbilling','active',NULL,NULL,NULL,NULL,NULL,'2020-01-01 12:00:00','2020-01-01 12:00:00'), + (3,1,'BoxBilling is customizable','You can create your own simple or advanced hooks on BoxBilling events.','* You can create your own simple or advanced hooks on BoxBilling events. For example, send notification via sms when new client signs up.\n* Create custom theme for your client interface\n','boxbilling-is-customizable','active',NULL,NULL,NULL,NULL,NULL,'2020-01-01 12:00:00','2020-01-01 12:00:00'); /*!40000 ALTER TABLE `post` ENABLE KEYS */; UNLOCK TABLES; diff --git a/src/install/sql/structure.sql b/src/install/sql/structure.sql index 95b102249..9a7211e79 100644 --- a/src/install/sql/structure.sql +++ b/src/install/sql/structure.sql @@ -775,6 +775,7 @@ CREATE TABLE `post` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `admin_id` bigint(20) DEFAULT NULL, `title` varchar(255) DEFAULT NULL, + `description` text DEFAULT NULL, `content` text, `slug` varchar(255) DEFAULT NULL, `status` varchar(30) DEFAULT 'draft' COMMENT 'active, draft',