Skip to content

Commit

Permalink
Merge pull request #1 from myconcretelab/add-a-page-picker-to-form-item
Browse files Browse the repository at this point in the history
Add a link picker + filest
  • Loading branch information
myconcretelab committed Oct 1, 2015
2 parents b460e47 + a47efef commit a16a040
Show file tree
Hide file tree
Showing 32 changed files with 619 additions and 177 deletions.
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Package #
###################
placeholders/

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
77 changes: 77 additions & 0 deletions attributes/page_selector/controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
namespace Concrete\Package\EasyImageGallery\Attribute\PageSelector;

use Page;
use Loader;
defined('C5_EXECUTE') or die("Access Denied.");

class Controller extends \Concrete\Core\Attribute\Controller {

protected $searchIndexFieldDefinition = array('type' => 'integer', 'options' => array('default' => 0, 'notnull' => false));

public function getValue() {
$db = Loader::db();
$value = $db->GetOne("select value from atPageSelector where avID = ?", array($this->getAttributeValueID()));
return $value;
}
public function getDisplayValue()
{
$c = Page::getByID($this->getValue());
if (is_object($c)) {
return '<a href="' . $c->getCollectionLink() . '">' . $c->getCollectionName() . '</a>';
}
}
public function getDisplaySanitizedValue()
{
return $this->getDisplayValue();
}
public function searchForm($list) {
$PagecID = $this->request('value');
$list->filterByAttribute($this->attributeKey->getAttributeKeyHandle(), $PagecID, '=');
return $list;
}

public function search() {
$form_selector = Loader::helper('form/page_selector');
print $form_selector->selectPage($this->field('value'), $this->request('value'), false);
}

public function form() {
if (is_object($this->attributeValue)) {
$value = $this->getAttributeValue()->getValue();
}
$form_selector = Loader::helper('form/page_selector');
print $form_selector->selectPage($this->field('value'), $value);
}

public function validateForm($p) {
return $p['value'] != 0;
}

public function saveValue($value) {
$db = Loader::db();
if(!intval($value)) {
$value = 0;
}
$db->Replace('atPageSelector', array('avID' => $this->getAttributeValueID(), 'value' => $value), 'avID', true);
}

public function deleteKey() {
$db = Loader::db();
$arr = $this->attributeKey->getAttributeValueIDList();
foreach($arr as $id) {
$db->Execute('delete from atPageSelector where avID = ?', array($id));
}
}

public function saveForm($data) {
$db = Loader::db();
$this->saveValue($data['value']);
}

public function deleteValue() {
$db = Loader::db();
$db->Execute('delete from atPageSelector where avID = ?', array($this->getAttributeValueID()));
}

}
14 changes: 14 additions & 0 deletions attributes/page_selector/db.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<schema version="0.3">
<table name="atPageSelector">
<field name="avID" type="I" size="10">
<KEY/>
<DEFAULT value="0"/>
<UNSIGNED/>
</field>
<field name="value" type="I">
<NOTNULL/>
<DEFAULT value="0"/>
</field>
</table>
</schema>
Binary file added attributes/page_selector/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions blocks/easy_image_gallery/composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
defined('C5_EXECUTE') or die("Access Denied.");

$this->inc('form_setup_html.php', array('view' => $view,
'fIDs' => $controller->getFilesIds(),
'fDetails' => $controller->getFilesDetails($controller->getFilesIds()),
'fDetails' => $controller->getFilesDetails(false, true),
'fileSets' => $controller->getFileSetList(),
'selectedFilesets' => $controller->getSelectedFilesets(),
'isComposer' => true
));
?>
Expand All @@ -17,4 +17,4 @@
.easy-image-toolbar .ccm-inline-toolbar-button-cancel {
display: none;
}
</style>
</style>
Loading

0 comments on commit a16a040

Please sign in to comment.