-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from myconcretelab/add-a-page-picker-to-form-item
Add a link picker + filest
- Loading branch information
Showing
32 changed files
with
619 additions
and
177 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
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 |
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,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())); | ||
} | ||
|
||
} |
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,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> |
Loading
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
Oops, something went wrong.