-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
302 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php defined('C5_EXECUTE') or die("Access Denied."); | ||
$this->inc('form.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
namespace Concrete\Block\RelatedPages; | ||
defined('C5_EXECUTE') or die("Access Denied."); | ||
use Concrete\Core\Attribute\Key\CollectionKey; | ||
use Concrete\Core\Block\BlockController; | ||
use Concrete\Core\Page\PageList; | ||
use Concrete\Core\Page\Type\Type; | ||
use Concrete\Core\Tree\Tree; | ||
use Concrete\Core\Tree\Type\Topic as TopicTree; | ||
use Concrete\Core\Tree\Type\Topic; | ||
use Core; | ||
use Loader; | ||
|
||
class Controller extends BlockController | ||
{ | ||
|
||
public $helpers = array('form'); | ||
|
||
protected $btInterfaceWidth = 400; | ||
protected $btCacheBlockOutput = true; | ||
protected $btCacheBlockOutputOnPost = true; | ||
protected $btCacheBlockOutputForRegisteredUsers = true; | ||
protected $btInterfaceHeight = 300; | ||
protected $btTable = 'btRelatedPages'; | ||
|
||
public function getBlockTypeDescription() | ||
{ | ||
return t("Displays a list of pages related to this page. Uses the topic attribute for relation."); | ||
} | ||
|
||
public function getBlockTypeName() | ||
{ | ||
return t("Related Pages"); | ||
} | ||
|
||
public function add() | ||
{ | ||
$this->edit(); | ||
$this->set('maxResults', 3); | ||
$this->set('title', t('Related Pages')); | ||
} | ||
|
||
public function edit() | ||
{ | ||
$keys = CollectionKey::getList(); | ||
foreach($keys as $ak) { | ||
if ($ak->getAttributeTypeHandle() == 'topics') { | ||
$attributeKeys[] = $ak; | ||
} | ||
} | ||
$types = Type::getList(); | ||
$this->set('pagetypes', $types); | ||
$this->set('attributeKeys', $attributeKeys); | ||
} | ||
|
||
public function view() | ||
{ | ||
$ak = CollectionKey::getByHandle($this->topicAttributeKeyHandle); | ||
$pages = array(); | ||
$c = \Page::getCurrentPage(); | ||
if (is_object($ak)) { | ||
$topics = $c->getAttribute($ak->getAttributeKeyHandle()); | ||
if (count($topics)) { | ||
$pl = new PageList(); | ||
$pl->setItemsPerPage($this->maxResults); | ||
if ($this->ptID) { | ||
$pl->filterByPageTypeID($this->ptID); | ||
} | ||
if ($this->cParentID) { | ||
$pl->filterByParentID($this->cParentID); | ||
} | ||
$pl->filter('p.cID', $c->getCollectionID(), '<>'); | ||
$topic = $topics[array_rand($topics)]; | ||
$pl->filterByTopic($topic); | ||
$pl->sortBy('rand()'); | ||
$pages = $pl->getPagination()->getCurrentPageResults(); | ||
} | ||
} | ||
$this->set('pages', $pages); | ||
} | ||
|
||
public function save($data) | ||
{ | ||
$data['maxResults'] = intval($data['maxResults']); | ||
parent::save($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0"?> | ||
<schema version="0.3"> | ||
<table name="btRelatedPages"> | ||
<field name="bID" type="I"> | ||
<key /> | ||
<unsigned /> | ||
</field> | ||
<field name="topicAttributeKeyHandle" type="C" size="255"> | ||
<notnull /> | ||
<default value="" /> | ||
</field> | ||
<field name="title" type="C" size="255"> | ||
<notnull /> | ||
<default value="" /> | ||
</field> | ||
<field name="maxResults" type="I"> | ||
<unsigned /> | ||
<default value="3" /> | ||
</field> | ||
<field name="cParentID" type="I"> | ||
<unsigned /> | ||
<notnull /> | ||
<default value="0" /> | ||
</field> | ||
<field name="ptID" type="I2"> | ||
<unsigned /> | ||
</field> | ||
</table> | ||
</schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php defined('C5_EXECUTE') or die("Access Denied."); | ||
$this->inc('form.php'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> | ||
<fieldset> | ||
<div class="form-group" data-row="mode-page"> | ||
<label class="control-label" for="attributeKeySelect"><?=t('Topic Attribute to Use For Relation')?></label> | ||
<select class="form-control" name="topicAttributeKeyHandle" id="attributeKeySelect"> | ||
<? foreach($attributeKeys as $attributeKey) { ?> | ||
<option value="<?=$attributeKey->getAttributeKeyHandle()?>" <? if ($attributeKey->getAttributeKeyHandle() == $topicAttributeKeyHandle) { ?>selected<? } ?>><?=$attributeKey->getAttributeKeyDisplayName()?></option> | ||
<? } ?> | ||
</select> | ||
</div> | ||
|
||
<div class='form-group'> | ||
<label for='title' style="margin-bottom: 0px;"><?=t('Parent Page')?>:</label> | ||
<div class="checkbox"> | ||
<label> | ||
<input <? if (intval($cParentID) > 0) { ?>checked<? } ?> name="filterByParent" type="checkbox" value="1" /> | ||
<?=t('Filter by Parent Page')?> | ||
</label> | ||
</div> | ||
<div id="ccm-block-related-pages-parent-page"> | ||
<? | ||
print Loader::helper('form/page_selector')->selectPage('cParentID', $cParentID); | ||
?> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label class="control-label"><?= t('Filter by Page Type') ?></label> | ||
<?php ?> | ||
<select class="form-control" name="ptID" id="selectPTID"> | ||
<option value="0">** <?php echo t('All') ?> **</option> | ||
<?php | ||
foreach ($pagetypes as $ct) { | ||
?> | ||
<option | ||
value="<?= $ct->getPageTypeID() ?>" <? if ($ptID == $ct->getPageTypeID()) { ?> selected <? } ?>> | ||
<?= $ct->getPageTypeName() ?> | ||
</option> | ||
<?php | ||
} | ||
?> | ||
</select> | ||
<?php ?> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label class="control-label" for="maxResults"><?=t('Number of Pages to Display')?></label> | ||
<input class="form-control" name="maxResults" id="maxResults" value="<?=$maxResults?>" /> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label class="control-label" for="title"><?=t('Title')?></label> | ||
<input class="form-control" name="title" id="title" value="<?=$title?>" /> | ||
</div> | ||
|
||
</fieldset> | ||
|
||
|
||
<script type="text/javascript"> | ||
$(function() { | ||
$("input[name=filterByParent]").on('change', function() { | ||
if ($(this).is(":checked")) { | ||
$('#ccm-block-related-pages-parent-page').show(); | ||
} else { | ||
$('#ccm-block-related-pages-parent-page').hide(); | ||
} | ||
}).trigger('change'); | ||
}); | ||
</script> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> | ||
<? if (count($pages) > 0): ?> | ||
|
||
<div class="ccm-block-related-pages-wrapper"> | ||
|
||
<div class="ccm-block-related-pages-header"> | ||
<h5><?=$title?></h5> | ||
</div> | ||
|
||
<? foreach($pages as $page) { ?> | ||
|
||
<div class="ccm-block-related-pages-page"> | ||
<a href="<?=$page->getCollectionLink()?>"><?=$page->getCollectionName()?></a> | ||
</div> | ||
|
||
<? } ?> | ||
|
||
</div> | ||
|
||
|
||
<? endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ul.list-inline { | ||
display: inline-block; | ||
margin: 0px; | ||
padding: 0px; | ||
} | ||
|
||
ul.list-inline li { | ||
padding: 0px; | ||
list-style-type: none; | ||
margin-right: 10px; | ||
display: inline-block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?php | ||
defined('C5_EXECUTE') or die("Access Denied."); | ||
foreach($selected as $service) { ?> | ||
|
||
<a href="<?=$service->getServiceLink()?>"><?=$service->getServiceIconHTML()?></a> | ||
|
||
<? | ||
} | ||
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> | ||
|
||
<div class="ccm-block-share-this-page"> | ||
<ul class="list-inline"> | ||
<? foreach($selected as $service) { ?> | ||
<li><a href="<?=$service->getServiceLink()?>"><?=$service->getServiceIconHTML()?></a></li> | ||
<? } ?> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.