Skip to content

Commit

Permalink
Implemtation of excluding page from navigation [#15 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
olafgleba committed Sep 29, 2011
1 parent eb1a42c commit c79d582
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 11 deletions.
14 changes: 12 additions & 2 deletions welcompose/admin/content/pages_add.php
Expand Up @@ -249,11 +249,20 @@
$FORM->addRule('protect', gettext('The field protect accepts only 0 or 1'),
'regex', WCOM_REGEX_ZERO_OR_ONE);

// checkbox for draft
$FORM->addElement('checkbox', 'draft', gettext('Draft'), null,
array('id' => 'page_draft', 'class' => 'chbx'));
$FORM->applyFilter('draft', 'trim');
$FORM->applyFilter('draft', 'strip_tags');
$FORM->addRule('draft', gettext('The field whether to apply text macros accepts only 0 or 1'),
$FORM->addRule('draft', gettext('The field draft accepts only 0 or 1'),
'regex', WCOM_REGEX_ZERO_OR_ONE);

// checkbox for exclude
$FORM->addElement('checkbox', 'exclude', gettext('Exclude'), null,
array('id' => 'page_exclude', 'class' => 'chbx'));
$FORM->applyFilter('exclude', 'trim');
$FORM->applyFilter('exclude', 'strip_tags');
$FORM->addRule('exclude', gettext('The field exclude accepts only 0 or 1'),
'regex', WCOM_REGEX_ZERO_OR_ONE);

// checkbox for nofollow
Expand Down Expand Up @@ -379,7 +388,7 @@
$name_url = $FORM->exportValue('name_url');
if (!$PAGE->testForUniqueUrlName($name_url)) {
$name_url = $name_url.'-'.$page_id;
}
}

// prepare sql data for page create
$sqlData = array();
Expand All @@ -395,6 +404,7 @@
$sqlData['index_page'] = $FORM->exportValue('index_page');
$sqlData['protect'] = $FORM->exportValue('protect');
$sqlData['draft'] = (string)intval($FORM->exportValue('draft'));
$sqlData['exclude'] = $FORM->exportValue('exclude');
$sqlData['no_follow'] = $FORM->exportValue('no_follow');
$sqlData['sitemap_changefreq'] = $FORM->exportValue('sitemap_changefreq');
$sqlData['sitemap_priority'] = $FORM->exportValue('sitemap_priority');
Expand Down
14 changes: 12 additions & 2 deletions welcompose/admin/content/pages_edit.php
Expand Up @@ -216,15 +216,23 @@
array('id' => 'page_draft', 'class' => 'chbx'));
$FORM->applyFilter('draft', 'trim');
$FORM->applyFilter('draft', 'strip_tags');
$FORM->addRule('draft', gettext('The field whether to apply text macros accepts only 0 or 1'),
$FORM->addRule('draft', gettext('The field draft accepts only 0 or 1'),
'regex', WCOM_REGEX_ZERO_OR_ONE);

// checkbox for exclude
$FORM->addElement('checkbox', 'exclude', gettext('Exclude'), null,
array('id' => 'page_exclude', 'class' => 'chbx'));
$FORM->applyFilter('exclude', 'trim');
$FORM->applyFilter('exclude', 'strip_tags');
$FORM->addRule('exclude', gettext('The field exclude accepts only 0 or 1'),
'regex', WCOM_REGEX_ZERO_OR_ONE);

// checkbox for nofollow
$FORM->addElement('checkbox', 'no_follow', gettext('No Follow'), null,
array('id' => 'page_no_follow', 'class' => 'chbx'));
$FORM->applyFilter('no_follow', 'trim');
$FORM->applyFilter('no_follow', 'strip_tags');
$FORM->addRule('no_follow', gettext('The field protect accepts only 0 or 1'),
$FORM->addRule('no_follow', gettext('The field no_follow accepts only 0 or 1'),
'regex', WCOM_REGEX_ZERO_OR_ONE);

// multi select for rights
Expand Down Expand Up @@ -269,6 +277,7 @@
'template_set' => Base_Cnc::ifsetor($page['template_set'], null),
'index_page' => Base_Cnc::ifsetor($page['index_page'], null),
'protect' => Base_Cnc::ifsetor($page['protect'], null),
'exclude' => Base_Cnc::ifsetor($page['exclude'], null),
'draft' => Base_Cnc::ifsetor($page['draft'], null),
'no_follow' => Base_Cnc::ifsetor($page['no_follow'], null),
'groups' => $selected_groups,
Expand Down Expand Up @@ -356,6 +365,7 @@
$sqlData['index_page'] = $FORM->exportValue('index_page');
$sqlData['protect'] = $FORM->exportValue('protect');
$sqlData['draft'] = (string)intval($FORM->exportValue('draft'));
$sqlData['exclude'] = $FORM->exportValue('exclude');
$sqlData['no_follow'] = $FORM->exportValue('no_follow');
$sqlData['sitemap_changefreq'] = $FORM->exportValue('sitemap_changefreq');
$sqlData['sitemap_priority'] = $FORM->exportValue('sitemap_priority');
Expand Down
3 changes: 3 additions & 0 deletions welcompose/admin/smarty/templates/content/pages_add.html
Expand Up @@ -125,6 +125,9 @@ <h1>{i18n Your input was successfully saved!}</h1>
<label class="cont chbx" for="page_draft"><span class="bez">{$form.draft.label}<span class="iHelp"><a href="#" title="{i18n Show help on this topic}"><img src="../static/img/icons/help.gif" alt="" /></a></span></span>
{$form.draft.html}</label>

<label class="cont chbx" for="page_exclude"><span class="bez">{$form.exclude.label}<span class="iHelp"><a href="#" title="{i18n Show help on this topic}"><img src="../static/img/icons/help.gif" alt="" /></a></span></span>
{$form.exclude.html}</label>

<label class="cont chbx" for="page_no_follow"><span class="bez">{$form.no_follow.label}<span class="iHelp"><a href="#" title="{i18n Show help on this topic}"><img src="../static/img/icons/help.gif" alt="" /></a></span></span>
{$form.no_follow.html}</label>

Expand Down
3 changes: 3 additions & 0 deletions welcompose/admin/smarty/templates/content/pages_edit.html
Expand Up @@ -198,6 +198,9 @@ <h1>{i18n Your input was successfully saved!}</h1>
<label class="cont chbx" for="page_draft"><span class="bez">{$form.draft.label}<span class="iHelp"><a href="#" title="{i18n Show help on this topic}"><img src="../static/img/icons/help.gif" alt="" /></a></span></span>
{$form.draft.html}</label>

<label class="cont chbx" for="page_exclude"><span class="bez">{$form.exclude.label}<span class="iHelp"><a href="#" title="{i18n Show help on this topic}"><img src="../static/img/icons/help.gif" alt="" /></a></span></span>
{$form.exclude.html}</label>

<label class="cont chbx" for="page_no_follow"><span class="bez">{$form.no_follow.label}<span class="iHelp"><a href="#" title="{i18n Show help on this topic}"><img src="../static/img/icons/help.gif" alt="" /></a></span></span>
{$form.no_follow.html}</label>

Expand Down
Expand Up @@ -127,7 +127,7 @@ <h2>{$_navigation.name} <a class="toggleElemNavigation" href="#"><img title="{i1
{if count($page_arrays.$navigation_id) > 0}
{foreach from=$page_arrays.$navigation_id item=_page}
<tr>
<td class="page{if $_page.level > 1 && $_page.level < 6}{$_page.level}{elseif $_page.level >= 6}6{/if}{if $_page.draft > 0} draft{/if}" id="page{$_page.id|escape:"url"}">{$_page.name} {if $_page.index_page}<img src="../static/img/icons/index.gif" alt="{i18n Index page}" title="{i18n Index page}" />{/if} {if $_page.protect}<img src="../static/img/icons/lock.gif" alt="{i18n Protected page}" title="{i18n Protected page}" />{/if}</td>
<td class="page{if $_page.level > 1 && $_page.level < 6}{$_page.level}{elseif $_page.level >= 6}6{/if}{if $_page.draft > 0} draft{/if}" id="page{$_page.id|escape:"url"}">{$_page.name} {if $_page.index_page}<img src="../static/img/icons/index.gif" alt="{i18n Index page}" title="{i18n Index page}" />{/if} {if $_page.protect}<img src="../static/img/icons/lock.gif" alt="{i18n Protected page}" title="{i18n Protected page}" />{/if}{if $_page.exclude > 0}<img src="../static/img/icons/exclude.gif" alt="{i18n Excluded from navigation}" title="{i18n Excluded from navigation}" />{/if}</td>
<td><a class="down" href="pages_move.php?id={$_page.id|escape:"url"}&amp;direction=down#{$_page.id|escape:"url"}" title="{i18n Down}"></a></td>
<td><a class="up" href="pages_move.php?id={$_page.id|escape:"url"}&amp;direction=up#{$_page.id|escape:"url"}" title="{i18n Up}"></a></td>
<td><a class="edit" href="pages_content_edit.php?id={$_page.id|escape:"url"}" title="{i18n Edit page contents}"></a></td>
Expand Down
@@ -0,0 +1 @@
<p class="help">{i18n Check this box to spare the page from being visible within the frontend navigation}.</p>
Binary file added welcompose/admin/static/img/icons/exclude.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion welcompose/core/application_classes/sitemap.class.php
Expand Up @@ -122,7 +122,8 @@ public function generateSitemap ($compress)
// with protect is set we spare protected pages out
$select_params = array(
'draft' => null,
'protect' => 1
'protect' => 1,
'exclude' => 1
);

// get all pages without status protect and draft and cache them
Expand Down
24 changes: 19 additions & 5 deletions welcompose/core/content_classes/page.class.php
Expand Up @@ -94,14 +94,18 @@ public function addPage ($sqlData)
throw new Content_PageException('Input for parameter sqlData is not an array');
}

$sqlData['project'] = WCOM_CURRENT_PROJECT;
if (!isset($sqlData['project'])) {
$sqlData['project'] = WCOM_CURRENT_PROJECT;
}

// insert row
$this->base->db->insert(WCOM_DB_CONTENT_PAGES, $sqlData);

// test if page belongs to current project/user
if (!$this->pageBelongsToCurrentUser($sqlData['id'])) {
throw new Content_PageException('Given page does not belong to current project');
if (!isset($sqlData['project'])) {
// test if page belongs to current project/user
if (!$this->pageBelongsToCurrentUser($sqlData['id'])) {
throw new Content_PageException('Given page does not belong to current project');
}
}

return (int)$sqlData['id'];
Expand Down Expand Up @@ -233,6 +237,7 @@ public function selectPage ($id)
`content_pages`.`optional_text` AS `optional_text`,
`content_pages`.`url` AS `url`,
`content_pages`.`protect` AS `protect`,
`content_pages`.`exclude` AS `exclude`,
`content_pages`.`index_page` AS `index_page`,
`content_pages`.`no_follow` AS `no_follow`,
`content_pages`.`draft` AS `draft`,
Expand Down Expand Up @@ -285,6 +290,7 @@ public function selectPage ($id)
* <li>type, int, optional: Page type id</li>
* <li>start, int, optional: row offset</li>
* <li>limit, int, optional: amount of rows to return</li>
* <li>exclude, int, optional: if set exclude page from navigation</li>
* <li>draft, int, optional: if set include pages with param draft</li>
* <li>protect, int, optional: if set exclude protected pages</li>
* </ul>
Expand All @@ -311,6 +317,7 @@ public function selectPages ($params = array())
$start = null;
$limit = null;
$draft = null;
$exclude = null;
$protect = null;
$bind_params = array();

Expand All @@ -330,6 +337,7 @@ public function selectPages ($params = array())
case 'type':
case 'start':
case 'limit':
case 'exclude':
case 'protect':
$$_key = (int)$_value;
break;
Expand Down Expand Up @@ -365,6 +373,7 @@ public function selectPages ($params = array())
`content_pages`.`optional_text` AS `optional_text`,
`content_pages`.`url` AS `url`,
`content_pages`.`protect` AS `protect`,
`content_pages`.`exclude` AS `exclude`,
`content_pages`.`index_page` AS `index_page`,
`content_pages`.`no_follow` AS `no_follow`,
`content_pages`.`draft` AS `draft`,
Expand Down Expand Up @@ -427,7 +436,12 @@ public function selectPages ($params = array())
// Include only unprotected pages
if (!empty($protect) && is_numeric($protect)) {
$sql .= " AND `content_pages`.`protect` IS NULL ";
}
}
// Include only visible pages
if (!empty($exclude) && is_numeric($exclude)) {
$sql .= " AND `content_pages`.`exclude` IS NULL ";
}

// Include only result rows without drafts
if (is_null($draft) ) {
$sql .= " AND `content_pages`.`draft` = '0' ";
Expand Down

0 comments on commit c79d582

Please sign in to comment.