diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c65f31b
--- /dev/null
+++ b/.gitignore
@@ -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
diff --git a/attributes/page_selector/controller.php b/attributes/page_selector/controller.php
new file mode 100644
index 0000000..d1afaa7
--- /dev/null
+++ b/attributes/page_selector/controller.php
@@ -0,0 +1,77 @@
+ '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 '' . $c->getCollectionName() . '';
+ }
+ }
+ 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()));
+ }
+
+}
diff --git a/attributes/page_selector/db.xml b/attributes/page_selector/db.xml
new file mode 100644
index 0000000..a039c2f
--- /dev/null
+++ b/attributes/page_selector/db.xml
@@ -0,0 +1,14 @@
+
+
+
+
\ No newline at end of file
diff --git a/attributes/page_selector/icon.png b/attributes/page_selector/icon.png
new file mode 100755
index 0000000..063dcf0
Binary files /dev/null and b/attributes/page_selector/icon.png differ
diff --git a/blocks/easy_image_gallery/composer.php b/blocks/easy_image_gallery/composer.php
index 17760d9..ba799a4 100644
--- a/blocks/easy_image_gallery/composer.php
+++ b/blocks/easy_image_gallery/composer.php
@@ -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
));
?>
@@ -17,4 +17,4 @@
.easy-image-toolbar .ccm-inline-toolbar-button-cancel {
display: none;
}
-
\ No newline at end of file
+
diff --git a/blocks/easy_image_gallery/controller.php b/blocks/easy_image_gallery/controller.php
index b921f18..6b70536 100644
--- a/blocks/easy_image_gallery/controller.php
+++ b/blocks/easy_image_gallery/controller.php
@@ -9,6 +9,7 @@
use Concrete\Core\Asset\AssetList;
use \Concrete\Core\Http\ResponseAssetGroup;
use Permissions;
+use Page;
use File;
use FileSet;
@@ -32,7 +33,7 @@ class Controller extends BlockController
protected $btCacheBlockOutputForRegisteredUsers = false;
protected $btSupportsInlineEdit = true;
protected $btSupportsInlineAdd = true;
- protected $btDefaultSet = 'multimedia';
+ protected $btDefaultSet = 'multimedia';
public function getBlockTypeDescription()
{
@@ -44,29 +45,29 @@ public function getBlockTypeName()
return t("Easy Images Gallery");
}
-
public function add() {
$this->setAssetEdit();
-
$this->set('fileSets', $this->getFileSetList());
- $this->set('options', $this->getOptionsJson());
+ $this->set('options', $this->getOptionsJson());
+ $this->set('selectedFilesets',array());
}
public function edit()
{
$this->setAssetEdit();
- $fIDs = $this->getFilesIds();
-
$this->set('fileSets', $this->getFileSetList());
+ $this->set('selectedFilesets', $this->getSelectedFilesets());
$this->set('options', $this->getOptionsJson());
- $this->set('fIDs', $fIDs);
- $this->set('fDetails',$this->getFilesDetails($fIDs));
+ $this->set('fDetails',$this->getFilesDetails());
}
- function getFilesIds () { return explode(',', $this->fIDs); }
-
- function getOptionsJson () {
+ function getSelectedFilesets() {
+ $options = json_decode($this->options,true);
+ return (is_array($options['fsIDs']) && count($options['fsIDs'])) ? $options['fsIDs'] : array();
+ }
+
+ function getOptionsJson () {
// Cette fonction retourne un objet option
// SI le block n'existe pas encore, ces options sont préréglées
// Si il existe on transfome la chaine de charactère en json
@@ -92,20 +93,52 @@ function getOptionsJson () {
if(!$options->hoverTitleColor) $options->hoverTitleColor = '#333333';
if(!$options->dateFormat) $options->dateFormat = 'm - Y';
// end legacy
- return $options ;
+ return $options ;
endif;
}
- // For Edit / ADD
- function getFilesDetails ($fIDs) {
- $tools = new EasyImageGalleryTools();
- $fDetails = array();
- foreach ($fIDs as $key => $fID) {
- $f = File::getByID($fID);
- if (is_object($f)) $fDetails[] = $tools->getFileDetails($f);
- }
+
+
+ function getFilesDetails ($fIDs = false, $details = true) {
+ $tools = new EasyImageGalleryTools();
+ $db = Loader::db();
+
+ if (!$fIDs)
+ $fIDs = explode(',', $this->fIDs);
+ $_fIDs = array();
+ $fDetails = array();
+
+ foreach ($fIDs as $key => $value) :
+ if(strpos($value,'fsID') === 0 ): // Le fID commence par "fsID" DOnc on va extraire les images
+ $fsID = substr($value,4);
+ $r = $db->query('SELECT fID FROM FileSetFiles WHERE fsID = ? ORDER BY fsDisplayOrder ASC', array($fsID));
+ while ($row = $r->FetchRow()) {
+ $_fIDs[$row['fID']] = 'fsID' . $fsID;
+ }
+ else:
+ $_fIDs[$value] = 'file';
+ endif;
+ endforeach;
+ $fIDs = $_fIDs;
+
+ // Si on ne veut pas de details,
+ // On retourne un tableau avec les fID
+ if (!$details) return array_keys($fIDs);
+
+ // Maintenant on extriait les details de chaque images
+ foreach ($fIDs as $fID => $type) {
+ $f = File::getByID($fID);
+ if (is_object($f)):
+ $origin = "file";
+ // Si le fichier fait partie d'un FS, son origine sera numerique
+ // Et représentera le fsID
+ if(strpos($type,'fsID') === 0 ) $origin = substr($type,4);
+ $fDetails[] = $tools->getFileDetails($f,$origin);
+ endif;
+ }
return $fDetails;
}
+
// For view
function getFileFromFileID ($fID) {
if ($fID) :
@@ -116,25 +149,27 @@ function getFileFromFileID ($fID) {
public function registerViewAssets()
{
- $this->requireAsset('css','easy-gallery-view');
+ $this->requireAsset('css','easy-gallery-view');
$this->requireAsset('javascript', 'jquery');
$this->requireAsset('javascript', 'imagesloaded');
$this->requireAsset('javascript', 'masonry');
$this->requireAsset('javascript', 'isotope');
$this->requireAsset('javascript', 'lazyload');
-
+
}
public function view() {
- $time_start = microtime(true);
+ $time_start = microtime(true);
$options = $this->getOptionsJson();
// Files
- $files = array_filter(array_map(array($this,'getFileFromFileID') , explode(',', $this->fIDs)));
- $this->set('fIDs', explode(',', $this->fIDs));
+ $fIDs = $this->getFilesDetails(false,false);
+ $files = array_filter(array_map(array($this,'getFileFromFileID') , $fIDs));
+ $this->set('fIDs', $fIDs);
+ $this->set('selectedFilesets', $this->getSelectedFilesets());
$this->set('files',$files );
$this->set('options', $options );
-
+ // print_r($files); exit();
$this->generatePlaceHolderFromArray($files);
// Lightbox
@@ -160,10 +195,10 @@ public function view() {
if (!$avID) continue;
$query = $db->GetAll("
- SELECT opt.value
- FROM atSelectOptions opt,
+ SELECT opt.value
+ FROM atSelectOptions opt,
atSelectOptionsSelected sel
-
+
WHERE sel.avID = ?
AND sel.atSelectOptionID = opt.ID",$avID);
@@ -182,7 +217,6 @@ public function view() {
}
-
public function getFileSetList () {
$fs = new FileSetList();
return $fs->get();
@@ -195,7 +229,7 @@ public function composer() {
public function isValueEmpty() {
if ($this->fIDs)
return false;
- else
+ else
return true;
}
@@ -210,6 +244,9 @@ public function setAssetEdit () {
$this->requireAsset('javascript', 'bootstrap/popover');
$this->requireAsset('javascript', 'jquery/ui');
$this->requireAsset('javascript', 'core/events');
+ $this->requireAsset('core/file-manager');
+ $this->requireAsset('core/sitemap');
+ $this->requireAsset('select2');
$this->requireAsset('javascript', 'underscore');
$this->requireAsset('javascript', 'core/app');
$this->requireAsset('javascript', 'bootstrap-editable');
@@ -224,15 +261,67 @@ public function save($args)
{
$options = $args;
unset($options['fID']);
+ unset($options['internal_link_cid']);
+
+ // Vu que je n'arrive pas encore a sauver en ajax l'attribut cID du lien
+ // (meme si dans le filemanager la fenetre attribut y arrive)
+ // je boucle et sauve pour chaque fichier
+ // var_dump($args['fsIDs']);die();
+ if(is_array($args['internal_link_cid'])) :
+ $ak = FileAttributeKey::getByHandle('internal_link_cid');
+ if (is_object($ak)) :
+ foreach ($args['internal_link_cid'] as $fID => $valueArray) :
+ $f = File::getByID($fID);
+ if(is_object($f)) :
+ $fv = $f->getVersionToModify();
+ $ak->setAttribute($fv,$valueArray[0]);
+ endif;
+ endforeach;
+ endif;
+ endif;
+
+
+ $fsIDs = array();
+ if (is_array($args['fID'])):
+ $args['fIDs'] = implode(',', array_unique($args['fID']));
+ // Now extract Filset ID and save it in Options
+ foreach ($args['fID'] as $value) :
+ if(strpos($value,'fsID') === 0 ):
+ $fsIDs[] = (int)substr($value,4);
+ endif;
+ endforeach;
+ $options['fsIDs'] = array_values(array_unique($fsIDs));
+ endif;
+
if (!is_numeric($options['fancyOverlayAlpha']) || $options['fancyOverlayAlpha'] > 1 || $options['fancyOverlayAlpha'] < 0) $options['fancyOverlayAlpha'] = .9;
$args['options'] = json_encode($options);
- if(is_array($args['fID'])) :
- $args['fIDs'] = implode(',', $args['fID']);
- $this->generatePlaceHolderFromArray ($args['fID']);
- endif;
parent::save($args);
}
+ function getImageLink($f,$options) {
+ if (!$options->lightbox) :
+ if ($f->getAttribute('link_type')):
+ $link_type = str_replace('
', '', $f->getAttribute('link_type','display'));
+ switch ($link_type) {
+ case 'Page':
+ $internal_link = Page::getByID($f->getAttribute('internal_link_cid'), 'ACTIVE');
+ $fullUrl = (is_object($internal_link) && $internal_link->getCollectionID()) ? $internal_link->getCollectionLink() : false;
+ break;
+ case 'URL':
+ $external_link_url = $f->getAttribute('external_link_url');
+ $fullUrl = $external_link_url ? $external_link_url : false;
+ break;
+ default:
+ $fullUrl = false;
+ }
+ endif;
+ else :
+ $fullUrl = $f->getRelativePath();
+ endif;
+
+ return $fullUrl;
+ }
+
function hex2rgb($hex) {
$hex = str_replace("#", "", $hex);
@@ -248,17 +337,17 @@ function hex2rgb($hex) {
$rgb = array($r, $g, $b);
return implode(",", $rgb); // returns the rgb values separated by commas
// return $rgb; // returns an array with the rgb values
- }
+ }
function generatePlaceHolderFromArray ($array) {
$placeholderMaxSize = 600;
if (!is_object($array[0])) :
- $files = array_map(array($this,'getFileFromFileID') ,$array);
+ $files = $this->getFilesDetails($array);
else :
$files = $array;
- endif;
+ endif;
foreach ($files as $key => $f) :
if(!is_object($f)) continue;
@@ -269,18 +358,18 @@ function generatePlaceHolderFromArray ($array) {
$placeholderFile = __DIR__ . "/images/placeholders/placeholder-$w-$h.png";
if (file_exists($placeholderFile)) continue;
- $img = imagecreatetruecolor($new_width,$new_height);
- imagesavealpha($img, true);
+ $img = imagecreatetruecolor($new_width,$new_height);
+ imagesavealpha($img, true);
- // Fill the image with transparent color
- $color = imagecolorallocatealpha($img,0x00,0x00,0x00,110);
- imagefill($img, 0, 0, $color);
+ // Fill the image with transparent color
+ $color = imagecolorallocatealpha($img,0x00,0x00,0x00,110);
+ imagefill($img, 0, 0, $color);
- // Save the image to file.png
- imagepng($img,$placeholderFile);
+ // Save the image to file.png
+ imagepng($img,$placeholderFile);
- // Destroy image
+ // Destroy image
imagedestroy($img);
endforeach;
}
-}
\ No newline at end of file
+}
diff --git a/blocks/easy_image_gallery/form_setup_html.php b/blocks/easy_image_gallery/form_setup_html.php
index fec48e4..412230d 100644
--- a/blocks/easy_image_gallery/form_setup_html.php
+++ b/blocks/easy_image_gallery/form_setup_html.php
@@ -2,15 +2,13 @@
$fp = FilePermissions::getGlobal();
$tp = new TaskPermission();
?>
-