Skip to content

Commit

Permalink
You can now set an individual staticpage to appear in the search resu…
Browse files Browse the repository at this point in the history
…lts or not

For issue #1016
  • Loading branch information
eSilverStrike committed Mar 18, 2020
1 parent 25fb628 commit 8794596
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 56 deletions.
26 changes: 16 additions & 10 deletions plugins/staticpages/functions.inc
Expand Up @@ -980,21 +980,21 @@ function plugin_dopluginsearch_staticpages($query, $datestart, $dateend, $topic,
}
}

if ($_SP_CONF['includesearchcenterblocks'] == 0) {
$sql .= 'AND sp_centerblock = 0 ';
// Search 0 = Excluded, 1 = Default, 2 = Included
// SQL Default for regular pages
$searchsql = '(search = 1 AND sp_centerblock = 0 AND sp_php = 0 AND template_id = "")';
if ($_SP_CONF['includesearchcenterblocks']) {
$searchsql .= ' OR (sp_centerblock = 1 AND search = 1)';
}

if ($_SP_CONF['includesearchphp'] == 0) {
$sql .= 'AND sp_php = 0 ';
if ($_SP_CONF['includesearchphp']) {
$searchsql .= 'OR (sp_php > 0 AND search = 1)';
}

if ($_SP_CONF['includesearchtemplate'] == 0) {
if ($_DB_dbms === 'pgsql') {
$sql .= 'AND ((CASE coalesce (template_id, \'\') WHEN \'\' THEN 0 ELSE 1 END) <> 0) ';
} else {
$sql .= 'AND template_id = "" ';
}
if ($_SP_CONF['includesearchtemplate']) {
$searchsql .= 'OR (template_id != "" AND search = 1)';
}
$sql .= " AND (search = 2 OR ($searchsql)) ";

$search_p = new SearchCriteria('staticpages', $LANG_STATIC['pages']);

Expand Down Expand Up @@ -1744,6 +1744,12 @@ function plugin_upgrade_staticpages()
break;

case '1.7.1':
if (isset($_UPDATES[$current_version])) {
$_SQL = $_UPDATES[$current_version];
foreach ($_SQL as $sql) {
DB_query($sql);
}
}
staticpages_update_ConfValues_1_7_2();

$current_version = '1.7.2';
Expand Down
10 changes: 9 additions & 1 deletion plugins/staticpages/language/english.php
Expand Up @@ -135,7 +135,9 @@
'next_page' => 'Next page',
'parent_page' => 'Parent page',
'page_desc' => 'Setting a previous and/or next page will indicate the relationship between pages in a paginated series. Actual page navigation links are not added to the page. You have to add these yourself. NOTE: Parent page is currently not being used.',
'num_pages' => '%s Page(s)'
'num_pages' => '%s Page(s)',
'search' => 'Search',
'search_desc' => 'Control if page appears in search. Default depends on setting in Configuration and depends on page type (if it is a Center Block, Uses a Template, or Uses PHP).'
);

$PLG_staticpages_MESSAGE15 = 'Your comment has been submitted for review and will be published when approved by a moderator.';
Expand All @@ -148,6 +150,12 @@
$PLG_staticpages_MESSAGE3001 = 'Plugin upgrade not supported.';
$PLG_staticpages_MESSAGE3002 = $LANG32[9];

// Search options for pages
$LANG_staticpages_search = array(
0 => 'Excluded',
1 => 'Use Default',
2 => 'Included'
);

// Localization of the Admin Configuration UI
$LANG_configsections['staticpages'] = array(
Expand Down
10 changes: 9 additions & 1 deletion plugins/staticpages/language/english_utf-8.php
Expand Up @@ -135,7 +135,9 @@
'next_page' => 'Next page',
'parent_page' => 'Parent page',
'page_desc' => 'Setting a previous and/or next page will indicate the relationship between pages in a paginated series. Actual page navigation links are not added to the page. You have to add these yourself. NOTE: Parent page is currently not being used.',
'num_pages' => '%s Page(s)'
'num_pages' => '%s Page(s)',
'search' => 'Search',
'search_desc' => 'Control if page appears in search. Default depends on setting in Configuration and depends on page type (if it is a Center Block, Uses a Template, or Uses PHP).'
);

$PLG_staticpages_MESSAGE15 = 'Your comment has been submitted for review and will be published when approved by a moderator.';
Expand All @@ -148,6 +150,12 @@
$PLG_staticpages_MESSAGE3001 = 'Plugin upgrade not supported.';
$PLG_staticpages_MESSAGE3002 = $LANG32[9];

// Search options for pages
$LANG_staticpages_search = array(
0 => 'Excluded',
1 => 'Use Default',
2 => 'Included'
);

// Localization of the Admin Configuration UI
$LANG_configsections['staticpages'] = array(
Expand Down
11 changes: 10 additions & 1 deletion plugins/staticpages/language/japanese_utf-8.php
Expand Up @@ -141,7 +141,9 @@
'next_page' => '次のページ',
'parent_page' => '親ページ',
'page_desc' => '「前のページ」や「次のページ」を指定すると、HTMLのヘッダーに rel=”next” と rel=”prev” を追加します。表示用のナビゲーションは別に追加してください。注意: 「親ページ」は現在、使用されていません。',
'num_pages' => '%s ページ'
'num_pages' => '%s ページ',
'search' => 'Search',
'search_desc' => 'Control if page appears in search. Default depends on setting in Configuration and depends on page type (if it is a Center Block, Uses a Template, or Uses PHP).'
);

$PLG_staticpages_MESSAGE15 = 'あなたのコメントは投稿スタッフによる承認待ちとなっていて、承認が済むとサイトに表示します。';
Expand All @@ -154,6 +156,13 @@
$PLG_staticpages_MESSAGE3001 = 'プラグインはアップグレードをサポートしていません。';
$PLG_staticpages_MESSAGE3002 = $LANG32[9];

// Search options for pages
$LANG_staticpages_search = array(
0 => 'Excluded',
1 => 'Use Default',
2 => 'Included'
);

// Localization of the Admin Configuration UI
$LANG_configsections['staticpages'] = array(
'label' => '静的ページ',
Expand Down
24 changes: 16 additions & 8 deletions plugins/staticpages/services.inc.php
Expand Up @@ -179,6 +179,10 @@ function service_submit_staticpages($args, &$output, &$svc_msg)
$args['commentcode'] = $_SP_CONF['comment_code'];
}

if (($args['search'] < 0) || ($args['search'] > 2)) {
$args['search'] = 1; // Default setting
}

// Only Core Structured Data Types supported
if (!isset($LANG_structureddatatypes[$args['structured_data_type']])) {
if ($_SP_CONF['structured_data_type_default'] != 'none') {
Expand Down Expand Up @@ -320,6 +324,7 @@ function service_submit_staticpages($args, &$output, &$svc_msg)
$sp_old_id = $args['sp_old_id'];
$sp_centerblock = $args['sp_centerblock'];
$draft_flag = $args['draft_flag'];
$search = $args['search'];
$cache_time = $args['cache_time'];
$template_flag = $args['template_flag'];
$template_id = $args['template_id'];
Expand Down Expand Up @@ -544,6 +549,7 @@ function service_submit_staticpages($args, &$output, &$svc_msg)
$meta_description = "";
$meta_keywords = "";
$structured_data_type = "";
$search = 0; // Disabled but shouldn't happen anyways

// Switch sp_content to page_data since template
$page_data = $sp_content;
Expand Down Expand Up @@ -624,9 +630,9 @@ function service_submit_staticpages($args, &$output, &$svc_msg)
$dateCreated = date('Y-m-d H:i:s');
}

DB_save($_TABLES['staticpage'], 'sp_id,sp_title,sp_page_title, sp_content,created,modified,sp_hits,sp_format,sp_onmenu,sp_onhits,sp_onlastupdate,sp_label,commentcode,structured_data_type,meta_description,meta_keywords,template_flag,template_id,page_data,draft_flag,cache_time'
DB_save($_TABLES['staticpage'], 'sp_id,sp_title,sp_page_title, sp_content,created,modified,sp_hits,sp_format,sp_onmenu,sp_onhits,sp_onlastupdate,sp_label,commentcode,structured_data_type,meta_description,meta_keywords,template_flag,template_id,page_data,draft_flag,search,cache_time'
. ',owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,sp_php,sp_nf,sp_centerblock,sp_help,sp_where,sp_inblock,postmode,sp_prev,sp_next,sp_parent',
"'$sp_id','$sp_title','$sp_page_title','$sp_content','$dateCreated',NOW(),$sp_hits,'$sp_format',$sp_onmenu,$sp_onhits,$sp_onlastupdate,'$sp_label','$commentcode','$structured_data_type','$meta_description','$meta_keywords',$template_flag,'$template_id','$page_data',$draft_flag,$cache_time,$owner_id,$group_id,"
"'$sp_id','$sp_title','$sp_page_title','$sp_content','$dateCreated',NOW(),$sp_hits,'$sp_format',$sp_onmenu,$sp_onhits,$sp_onlastupdate,'$sp_label','$commentcode','$structured_data_type','$meta_description','$meta_keywords',$template_flag,'$template_id','$page_data',$draft_flag,$search,$cache_time,$owner_id,$group_id,"
. "$perm_owner,$perm_group,$perm_members,$perm_anon,'$sp_php','$sp_nf',$sp_centerblock,'$sp_help',$sp_where,"
. "'$sp_inblock','$postmode', '{$sp_prev}', '{$sp_next}', '{$sp_parent}'");
TOPIC_saveTopicSelectionControl('staticpages', $sp_id);
Expand Down Expand Up @@ -693,8 +699,9 @@ function service_submit_staticpages($args, &$output, &$svc_msg)

// If uses a template or PHP then save cache copy in DB used for search (needs to be done after save)
// Currently generating page view based on current user. Should really be saving at lowest viewable user permission but currently not possible
if (!$draft_flag) {
if ($template_id != '' OR $sp_php) {
// Only if search not excluded
if (!$draft_flag AND $search > 0) {
if ($template_id != '' OR $sp_php > 0) {
// Return whatever an autotag would return and cache it in content column
$search_sp_content = SP_returnStaticpage($sp_id, 'autotag');
$search_sp_content = DB_escapeString($search_sp_content);
Expand Down Expand Up @@ -826,6 +833,7 @@ function service_get_staticpages($args, &$output, &$svc_msg)
'sp_onlastupdate',
'sp_format',
'draft_flag',
'search',
'cache_time',
'owner_id',
'group_id',
Expand Down Expand Up @@ -904,12 +912,12 @@ function service_get_staticpages($args, &$output, &$svc_msg)
}
$topic_perms .= " GROUP BY sp_id, sp_title, sp_page_title, sp_content, sp_onhits, sp_onlastupdate, sp_hits, "
. "created, modified, sp_format, commentcode, structured_data_type, meta_description, meta_keywords, template_flag, template_id, page_data, "
. "draft_flag, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon, sp_help, sp_php, "
. "draft_flag, search, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon, sp_help, sp_php, "
. "sp_inblock,cache_time";

$sql = <<<SQL
SELECT sp_id, sp_title, sp_page_title, sp_content, sp_onhits, sp_onlastupdate, sp_hits, created, modified, sp_format,
commentcode, structured_data_type, meta_description, meta_keywords, template_flag, template_id, page_data, draft_flag,
commentcode, structured_data_type, meta_description, meta_keywords, template_flag, template_id, page_data, draft_flag, search,
owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon,
sp_help, sp_php, sp_inblock, cache_time, sp_prev, sp_next, sp_parent
FROM {$_TABLES['staticpage']}, {$_TABLES['topic_assignments']} ta
Expand Down Expand Up @@ -1041,10 +1049,10 @@ function service_get_staticpages($args, &$output, &$svc_msg)
$limit = " LIMIT $offset, $max_items";
$order = " ORDER BY modified DESC";
$sql = array();
$sql['mysql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,page_data,draft_flag,owner_id,"
$sql['mysql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,page_data,draft_flag,search,owner_id,"
. "group_id,perm_owner,perm_group,perm_members,perm_anon,sp_help,sp_php,sp_inblock,cache_time,structured_data_type "
. " FROM {$_TABLES['staticpage']}" . $perms . $order . $limit;
$sql['pgsql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,page_data,draft_flag,owner_id,"
$sql['pgsql'] = "SELECT sp_id,sp_title,sp_page_title,sp_content,sp_hits,created,modified,sp_format,meta_description,meta_keywords,template_flag,template_id,page_data,draft_flag,search,owner_id,"
. "group_id,perm_owner,perm_group,perm_members,perm_anon,sp_help,sp_php,sp_inblock,cache_time,structured_data_type "
. "FROM {$_TABLES['staticpage']}" . $perms . $order . $limit;
$result = DB_query($sql);
Expand Down
1 change: 1 addition & 0 deletions plugins/staticpages/sql/mysql_install.php
Expand Up @@ -58,6 +58,7 @@
template_id varchar(40) NOT NULL default '',
cache_time INT NOT NULL DEFAULT '0',
draft_flag tinyint(1) unsigned default '0',
search tinyint(1) NOT NULL default '1',
owner_id mediumint(8) unsigned NOT NULL default '1',
group_id mediumint(8) unsigned NOT NULL default '1',
perm_owner tinyint(1) unsigned NOT NULL default '3',
Expand Down
3 changes: 3 additions & 0 deletions plugins/staticpages/sql/mysql_updates.php
Expand Up @@ -89,6 +89,9 @@
"ALTER TABLE {$_TABLES['staticpage']} ADD `structured_data_type` varchar(40) NOT NULL DEFAULT '' AFTER `commentcode`",
"ALTER TABLE {$_TABLES['staticpage']} ADD page_data TEXT DEFAULT NULL AFTER sp_content"
),
'1.7.1' => array(
"ALTER TABLE {$_TABLES['staticpage']} ADD `search` TINYINT(1) NOT NULL DEFAULT '1' AFTER `draft_flag`;"
),
);

/**
Expand Down
1 change: 1 addition & 0 deletions plugins/staticpages/sql/pgsql_install.php
Expand Up @@ -56,6 +56,7 @@
template_id varchar(40) NOT NULL default '',
cache_time INT NOT NULL DEFAULT '0',
draft_flag int default '0',
search int default '1',
owner_id int NOT NULL default '1',
group_id int NOT NULL default '1',
perm_owner int NOT NULL default '3',
Expand Down
3 changes: 3 additions & 0 deletions plugins/staticpages/sql/pgsql_updates.php
Expand Up @@ -66,6 +66,9 @@
"ALTER TABLE {$_TABLES['staticpage']} ADD `structured_data_type` varchar(40) NOT NULL DEFAULT '' AFTER `commentcode`",
"ALTER TABLE {$_TABLES['staticpage']} ADD page_data TEXT DEFAULT NULL AFTER sp_content"
),
'1.7.1' => array(
"ALTER TABLE {$_TABLES['staticpage']} ADD `search` int NOT NULL DEFAULT '1' AFTER `draft_flag`;"
),
);

/**
Expand Down
18 changes: 12 additions & 6 deletions plugins/staticpages/templates/default/admin/editor.thtml
Expand Up @@ -37,11 +37,11 @@
<dd><select name="commentcode" id="sp-editor-commentcode">
{comment_options}
</select></dd>

<dt><label for="sp-editor-structureddata">{lang_structured_data_type}</label></dt>
<dd><select name="structured_data_type" id="sp-editor-structureddata">
{structured_data_options}
</select></dd>
</select></dd>

<dt{hide_meta}><label for="sp-editor-meta_description">{lang_metadescription}</label></dt>
<dd{hide_meta}><textarea name="meta_description" cols="45" rows="2" id="sp-editor-meta_description" class="wide">{meta_description}</textarea></dd>
Expand All @@ -55,23 +55,29 @@
<dt><label for="sp-editor-draft_flag">{lang_draft}</label></dt>
<dd><input type="checkbox" name="draft_flag" id="sp-editor-draft_flag" {draft_flag_checked}{xhtml}></dd>

<dt><label for="sp-editor-search">{lang_search}</label></dt>
<dd><select name="search" id="sp-editor-search">
{search_options}
</select></dd>
<dd class="description">{lang_search_desc}</dd>

<dt><label for="sp-editor-cache_time">{lang_cache_time}</label></dt>
<dd><input type="text" size="8" value="{cache_time}" name="cache_time" id="sp-editor-cachetime" class="text"{xhtml}></dd>
<dd class="description">{lang_cache_time_desc}</dd>

<dt><label for="sp-editor-sp_onlastupdate">{lang_lastupdated}</label></dt>
<dd class="controls_text">
{sp_formateddate}
{sp_formateddate}
(<input type="checkbox" name="sp_onlastupdate" id="sp-editor-sp_onlastupdate" {onlastupdate_checked}{xhtml}> {lang_show_on_page})
{!if lang_show_on_page_date_disabled}<dd class="description">{lang_show_on_page_date_disabled}</dd>{!endif}
</dd>

<dt><label for="sp-editor-sp_onhits">{lang_hits}</label></dt>
<dd class="controls_text">
<input type="hidden" name="sp_hits" value="{sp_hits}"{xhtml}>{sp_hits_formatted}
<input type="hidden" name="sp_hits" value="{sp_hits}"{xhtml}>{sp_hits_formatted}
(<input type="checkbox" name="sp_onhits" id="sp-editor-sp_onhits" {onhits_checked}{xhtml}> {lang_show_on_page})
{!if lang_show_on_page_hits_disabled}<dd class="description">{lang_show_on_page_hits_disabled}</dd>{!endif}
</dd>
</dd>

<dt><label>{lang_comments}</label></dt>
<dd>{sp_comments}</dd>
Expand Down Expand Up @@ -145,7 +151,7 @@
<input type="submit" value="{lang_cancel}" name="mode" class="submit"{xhtml}>
{!if allow_delete}
<input type="submit" value="{lang_delete}" name="mode" class="submit" onclick="return confirm('{confirm_message}');"{xhtml}>
{!endif}
{!endif}
<input type="hidden" name="sp_old_id" value="{sp_old_id}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
</div>
Expand Down
18 changes: 12 additions & 6 deletions plugins/staticpages/templates/default/admin/editor_advanced.thtml
Expand Up @@ -39,11 +39,11 @@
<dd><select name="commentcode" id="sp-advanced_editor-commentcode">
{comment_options}
</select></dd>

<dt><label for="sp-advanced_editor-structureddata">{lang_structured_data_type}</label></dt>
<dd><select name="structured_data_type" id="sp-advanced_editor-structureddata">
{structured_data_options}
</select></dd>
</select></dd>

<dt><label for="sel_editmode">{lang_postmode}</label></dt>
<dd><select name="postmode" id="sel_editmode" {change_editormode}>
Expand Down Expand Up @@ -88,23 +88,29 @@
<dt><label for="sp-advanced_editor-draft_flag">{lang_draft}</label></dt>
<dd><input type="checkbox" name="draft_flag" id="sp-advanced_editor-draft_flag" {draft_flag_checked}{xhtml}></dd>

<dt><label for="sp-advanced_editor-search">{lang_search}</label></dt>
<dd><select name="search" id="sp-advanced_editor-search">
{search_options}
</select></dd>
<dd class="description">{lang_search_desc}</dd>

<dt><label for="sp-advanced_editor-cache_time">{lang_cache_time}</label></dt>
<dd><input type="text" size="8" value="{cache_time}" name="cache_time" id="sp-advanced_editor-cachetime" class="text"{xhtml}></dd>
<dd class="description">{lang_cache_time_desc}</dd>

<dt><label for="sp-editor-sp_onlastupdate">{lang_lastupdated}</label></dt>
<dd class="controls_text">
{sp_formateddate}
{sp_formateddate}
(<input type="checkbox" name="sp_onlastupdate" id="sp-editor-sp_onlastupdate" {onlastupdate_checked}{xhtml}> {lang_show_on_page})
{!if lang_show_on_page_date_disabled}<dd class="description">{lang_show_on_page_date_disabled}</dd>{!endif}
</dd>

<dt><label for="sp-editor-sp_onhits">{lang_hits}</label></dt>
<dd class="controls_text">
<input type="hidden" name="sp_hits" value="{sp_hits}"{xhtml}>{sp_hits_formatted}
<input type="hidden" name="sp_hits" value="{sp_hits}"{xhtml}>{sp_hits_formatted}
(<input type="checkbox" name="sp_onhits" id="sp-editor-sp_onhits" {onhits_checked}{xhtml}> {lang_show_on_page})
{!if lang_show_on_page_hits_disabled}<dd class="description">{lang_show_on_page_hits_disabled}</dd>{!endif}
</dd>
</dd>

<dt><label>{lang_comments}</label></dt>
<dd>{sp_comments}</dd>
Expand Down Expand Up @@ -178,7 +184,7 @@
<input type="submit" value="{lang_cancel}" name="mode" class="submit"{xhtml}>
{!if allow_delete}
<input type="submit" value="{lang_delete}" name="mode" class="submit" onclick="return confirm('{confirm_message}');"{xhtml}>
{!endif}
{!endif}
{delete_option}
<input type="hidden" name="sp_old_id" value="{sp_old_id}"{xhtml}>
<input type="hidden" name="{gltoken_name}" value="{gltoken}"{xhtml}>
Expand Down

0 comments on commit 8794596

Please sign in to comment.