This commit is contained in:
Filip Penkava
2017-06-22 13:32:48 +02:00
parent 3bbcde1760
commit fda110004e
2 changed files with 143 additions and 37 deletions

View File

@@ -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() {
</tr>
<tr>
<th scope="row">
Status of the ingested articles/posts
Default status of ingested articles/posts
</th>
<td>
<fieldset>
@@ -252,30 +260,6 @@ function superdesk_admin() {
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
Convert slugline keywords into WP tags
</th>
<td>
<fieldset>
<label for="off">
<input type="radio" name="convert-keywords" id="off" value="off"<?php
if ($settings['convert-keywords'] == 'off') {
echo(' checked');
}
?>> off
</label>
<br>
<label for="on">
<input type="radio" name="convert-keywords" id="on" value="on"<?php
if ($settings['convert-keywords'] == 'on') {
echo(' checked');
}
?>> on
</label>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
Import SD keywords as WP tags
@@ -380,7 +364,7 @@ function superdesk_admin() {
</tr>
<tr>
<th scope="row">
Display the copyrightholder image
Display the image copyright holder in the caption
</th>
<td>
<fieldset>
@@ -404,7 +388,7 @@ function superdesk_admin() {
</tr>
<tr>
<th scope="row">
Display the copyrightnotice image
Display the image copyright notice in the caption
</th>
<td>
<fieldset>
@@ -434,6 +418,30 @@ function superdesk_admin() {
<input type="text" name="separator-located" id="separator-located" class="regular-text" value="<?php echo($settings['separator-located']); ?>">
</td>
</tr>
<tr>
<th scope="row">
Display location as
</th>
<td>
<fieldset>
<label for="location-modifier-all-caps">
<input type="radio" name="location-modifier" id="location-modifier-all-caps" value="all-caps"<?php
if ($settings['location-modifier'] == 'all-caps') {
echo(' checked');
}
?>> ALL CAPS
</label>
<br>
<label for="location-modifier-standard">
<input type="radio" name="location-modifier" id="location-modifier-standard" value="standard"<?php
if (!isset($settings['location-modifier']) || $settings['location-modifier'] != 'all-caps') {
echo(' checked');
}
?>> Standard case
</label>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
Convert slugline keywords into WP tags
@@ -519,6 +527,74 @@ function superdesk_admin() {
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
Add update logs to articles
</th>
<td>
<fieldset>
<label for="update-log-option-off">
<input type="radio" name="update-log-option" id="update-log-option-off" value="off"<?php
if (!isset($settings['update-log-option']) || $settings['update-log-option'] == 'off') {
echo(' checked');
}
?>> off
</label>
<br>
<label for="update-log-option-on">
<input type="radio" name="update-log-option" id="update-log-option-on" value="on"<?php
if ($settings['update-log-option'] == 'on') {
echo(' checked');
}
?>> on
</label>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
Update log position in article
</th>
<td>
<fieldset>
<label for="update-log-position-off">
<input type="radio" name="update-log-position" id="update-log-position-off" value="off"<?php
if (!isset($settings['update-log-position']) || $settings['update-log-position'] == 'off') {
echo(' checked');
}
?>> append
</label>
<br>
<label for="update-log-position-on">
<input type="radio" name="update-log-position" id="update-log-position-on" value="on"<?php
if ($settings['update-log-option'] == 'on') {
echo(' checked');
}
?>> prepend
</label>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
<label for="update-log-date-format">Update log date format</label>
</th>
<td>
<input type="text" name="update-log-date-format" id="update-log-date-format" class="regular-text" value="<?php echo($settings['update-log-date-format']); ?>">
</td>
</tr>
<tr>
<th scope="row">
<label for="update-log-text">Update log date text</label>
</th>
<td>
<input type="text" name="update-log-text" id="update-log-text" class="regular-text" value="<?php echo(!isset($settings['update-log-text']) ? 'This article was updated at' : $settings['update-log-text']); ?>">
<?php
echo date(!empty($settings['update-log-date-format']) ? $settings['update-log-date-format'] : 'Y-m-d H:i'); ?>.
</td>
</tr>
<tr>
<th scope="row">
Match Superdesk Content Profiles with Wordpress Post Formats

View File

@@ -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'] . "<!--more-->";
$content .= '<p>' . wp_strip_all_tags($obj['located']) . $settings['separator-located'];
$content .= '<p>';
if($prepend){
$content .= $updateText .'<br>';
}
$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'] . "<!--more-->" . $obj['body_html'];
$content = $obj['description_html'] . "<!--more-->";
$content .= '<p>';
if($prepend){
$content .= $updateText .'<br>';
}
$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 .= "<p>Editors Note: " . wp_strip_all_tags($obj['ednote']) . "</p>";
}
if (isset($obj['evolvedfrom'])) {
$guid = wp_strip_all_tags($obj['evolvedfrom']);
} else {
$guid = wp_strip_all_tags($obj['guid']);
if($append){
$content .= "<p>".$updateText."</p>";
}
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;