From fda110004e1beeb0497ee0c0f436a1cf9d8683b8 Mon Sep 17 00:00:00 2001 From: Filip Penkava Date: Thu, 22 Jun 2017 13:32:48 +0200 Subject: [PATCH] sprint 5 --- admin/admin.php | 136 +++++++++++++++++++++++++++++++++++++----------- autoload.php | 44 +++++++++++++--- 2 files changed, 143 insertions(+), 37 deletions(-) diff --git a/admin/admin.php b/admin/admin.php index 58a5e2f..d2a737c 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -51,7 +51,6 @@ function superdesk_admin() { 'author-byline' => $_POST['author-byline'], 'byline-words' => $_POST['byline-words'], 'display-copyright' => $_POST['display-copyright'], - 'convert-keywords' => $_POST['convert-keywords'], 'import-keywords' => $_POST['import-keywords'], 'convert-services' => $_POST['convert-services'], 'subject-type' => $_POST['subject-type'], @@ -67,6 +66,11 @@ function superdesk_admin() { 'download-images' => $_POST['download-images'], 'post-formats' => $_POST['download-images'], 'post-formats-table' => $resultArray, + 'location-modifier' => $_POST['location-modifier'], + 'update-log-option' => $_POST['update-log-option'], + 'update-log-date-format' => $_POST['update-log-date-format'], + 'update-log-text' => $_POST['update-log-text'], + 'update-log-position' => $_POST['update-log-position'], ); update_option('superdesk_settings', $settings); } else if (get_option('superdesk_settings')) { @@ -82,7 +86,6 @@ function superdesk_admin() { 'author-byline' => '', 'byline-words' => '', 'display-copyright' => '', - 'convert-keywords' => '', 'import-keywords' => '', 'convert-services' => '', 'subject-type' => '', @@ -98,6 +101,11 @@ function superdesk_admin() { 'download-images' => '', 'post-formats' => '', 'post-formats-table' => array(), + 'location-modifier' => 'standard', + 'update-log-option' => 'off', + 'update-log-date-format' => 'Y-m-d H:i', + 'update-log-text' => 'This article was updated at', + 'update-log-position' => 'off' ); } $statuses = array( @@ -175,7 +183,7 @@ function superdesk_admin() { - Status of the ingested articles/posts + Default status of ingested articles/posts
@@ -252,30 +260,6 @@ function superdesk_admin() {
- - - Convert slugline keywords into WP tags - - -
- -
- -
- - Import SD keywords as WP tags @@ -380,7 +364,7 @@ function superdesk_admin() { - Display the copyrightholder image + Display the image copyright holder in the caption
@@ -404,7 +388,7 @@ function superdesk_admin() { - Display the copyrightnotice image + Display the image copyright notice in the caption
@@ -434,6 +418,30 @@ function superdesk_admin() { + + + Display location as + + +
+ +
+ +
+ + Convert slugline keywords into WP tags @@ -518,7 +526,75 @@ function superdesk_admin() {
- + + + + Add update logs to articles + + +
+ +
+ +
+ + + + + Update log position in article + + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + . + + Match Superdesk Content Profiles with Wordpress Post Formats diff --git a/autoload.php b/autoload.php index ac1dc4b..e02c8c0 100644 --- a/autoload.php +++ b/autoload.php @@ -14,12 +14,44 @@ if ($obj['type'] == 'text') { $settings = get_option('superdesk_settings'); if ($obj['pubstatus'] == 'usable') { + if (isset($obj['evolvedfrom'])) { + $guid = wp_strip_all_tags($obj['evolvedfrom']); + } else { + $guid = wp_strip_all_tags($obj['guid']); + } + + $sync = $wpdb->get_row("SELECT post_id FROM " . $wpdb->prefix . DB_TABLE_SYNC_POST . " WHERE guid = '" . $guid . "'"); + + $append = false; + $prepend = false; + $updateText = ''; + if($sync && $settings['update-log-option'] == 'on'){ + $updateText = $settings['update-log-text'] . ' '. date( $settings['update-log-date-format']). '.'; + if($settings['update-log-position'] == 'on'){ + $prepend = true; + }else{ + $append = true; + } + } + if (!empty($obj['located'])) { + if($settings['location-modifier'] == 'all-caps'){ + $obj['located'] = mb_strtoupper($obj['located']); + } $content = $obj['description_html'] . ""; - $content .= '

' . wp_strip_all_tags($obj['located']) . $settings['separator-located']; + $content .= '

'; + if($prepend){ + $content .= $updateText .'
'; + } + $content .= wp_strip_all_tags($obj['located']) . $settings['separator-located']; $content .= mb_substr($obj['body_html'], mb_strpos($obj['body_html'], '>') + 1, mb_strlen($obj['body_html'])); } else { - $content = $obj['description_html'] . "" . $obj['body_html']; + $content = $obj['description_html'] . ""; + $content .= '

'; + if($prepend){ + $content .= $updateText .'
'; + } + $content .= mb_substr($obj['body_html'], mb_strpos($obj['body_html'], '>') + 1, mb_strlen($obj['body_html'])); } /* if ($settings['display-copyright'] == "on" && isset($obj['associations']['featuremedia']['copyrightnotice'])) { @@ -30,10 +62,8 @@ if ($obj['type'] == 'text') { $content .= "

Editors Note: " . wp_strip_all_tags($obj['ednote']) . "

"; } - if (isset($obj['evolvedfrom'])) { - $guid = wp_strip_all_tags($obj['evolvedfrom']); - } else { - $guid = wp_strip_all_tags($obj['guid']); + if($append){ + $content .= "

".$updateText."

"; } if ($settings['import-keywords'] && $settings['import-keywords'] == 'on') { @@ -126,7 +156,7 @@ if ($obj['type'] == 'text') { $content = embed_images($content, $image); } - $sync = $wpdb->get_row("SELECT post_id FROM " . $wpdb->prefix . DB_TABLE_SYNC_POST . " WHERE guid = '" . $guid . "'"); + if ($sync) { $post_ID = $sync->post_id;