diff --git a/assets/color_wheel.png b/assets/color_wheel.png index acf926e..1ce70d4 100644 Binary files a/assets/color_wheel.png and b/assets/color_wheel.png differ diff --git a/assets/farbtastic.css b/assets/farbtastic.css index e22a7cc..0e97ff7 100644 --- a/assets/farbtastic.css +++ b/assets/farbtastic.css @@ -1,36 +1,114 @@ -.farbtastic { position:relative; } -.farbtastic * { position:absolute; cursor:crosshair; } -.farbtastic, .farbtastic .wheel { width:195px; height:195px; } -.farbtastic .color, .farbtastic .overlay { top:47px; left:47px; width:101px; height:101px; } -.farbtastic .wheel { background:url(wheel.png) no-repeat; width:195px; height:195px; } -.farbtastic .overlay { background:url(mask.png) no-repeat; } -.farbtastic .marker { width:17px; height:17px; margin:-8px 0 0 -8px; overflow:hidden; background:url(marker.png) no-repeat; } - -#picker-container { z-index:100; width:197px; height:197px; position:absolute; background-color: transparent; } -#picker { padding:20px; background-color:#353530; width:197px; height:197px; - -moz-border-radius: 10px; -webkit-border-radius: 10px; -moz-box-shadow: 2px 2px 10px #444; -webkit-box-shadow: 2px 2px 10px #444; } -#picker-top { height:16px; background:transparent url(arrow.png) 7px 0 no-repeat; } -#picker-bottom { display:none; } -.color-chooser-container { margin-left:23px; position:relative; } -.color-icon { width:20px; height:22px; background:transparent url(color_wheel.png) center center no-repeat; margin:2px 0 0 -24px; display:block; float:left; } -#picker-container.top { margin-top:-5.3em; } -#picker-container.top #picker-top { display:none; } -#picker-container.top #picker-bottom { display:block; height:16px; background:transparent url(arrow-dn.png) 7px -2px no-repeat; } - - -.field-colorchooser input {background: none;} +/** + * Color Chooser Field + */ + +.farbtastic { + position:relative; +} + +.farbtastic * { + position: absolute; + cursor: crosshair; +} + +.farbtastic, .farbtastic .wheel { + width: 195px; + height: 195px; +} + +.farbtastic .color, .farbtastic .overlay { + top: 47px; + left: 47px; + width: 101px; + height: 101px; +} + +.farbtastic .wheel { + background: url(wheel.png) no-repeat; + width: 195px; + height: 195px; +} + +.farbtastic .overlay { + background: url(mask.png) no-repeat; +} + +.farbtastic .marker { + width: 17px; + height: 17px; + margin: -8px 0 0 -8px; + overflow: hidden; + background: url(marker.png) no-repeat; +} + + +#picker-container { + z-index: 100; + width: 197px; + height: 197px; + position: absolute; + background-color: transparent; +} + +#picker { + padding: 20px; + background-color: #353530; + width: 197px; + height: 197px; + -moz-border-radius: 10px; + -webkit-border-radius: 10px; + -moz-box-shadow: 2px 2px 10px #444; + -webkit-box-shadow: 2px 2px 10px #444; +} + +#picker-top { + height: 16px; + background: transparent url(arrow.png) 7px 0 no-repeat; +} + +#picker-bottom { + display: none; +} + +.color-chooser-container { + margin-left: 23px; + position: relative; +} + +.color-icon { + width: 20px; + height: 20px; + background: transparent url(color_wheel.png) center center no-repeat; + background-size: 100%; + margin: 2px 0 0 -24px; + display: block; + float: left; +} + +#picker-container.top { + margin-top: -5.3em; +} + +#picker-container.top #picker-top { + display: none; +} + +#picker-container.top #picker-bottom { + display: block; + height: 16px; + background: transparent url(arrow-dn.png) 7px -2px no-repeat; +} + +.field-colorchooser input { + transition-duration: 0s; +} .colorchooser-index-preview { - display: inline-block; + border-radius: 100%; + display: block; position: relative; - top: .3rem; - margin-top: -.1rem; - padding-top: 0; - height: 1rem; - width: 1rem; - border: .1rem solid black; + height: 1.5rem; + width: 1.5rem; + border: 1px solid #d3dce2; color: black; } -.colorchooser-index-preview:hover { - border-color: currentColor; -} \ No newline at end of file diff --git a/extension.driver.php b/extension.driver.php index 44d7a46..6c91d48 100644 --- a/extension.driver.php +++ b/extension.driver.php @@ -47,12 +47,22 @@ public function appendResources() { */ public function install(){ - return Symphony::Database()->query("CREATE TABLE `tbl_fields_colorchooser` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `field_id` INT(11) UNSIGNED NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `field_id` (`field_id`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); + return Symphony::Database() + ->create('tbl_fields_colorchooser') + ->ifNotExists() + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'field_id' => 'int(11)', + ]) + ->keys([ + 'id' => 'primary', + 'field_id' => 'unique', + ]) + ->execute() + ->success(); } /* @@ -61,10 +71,11 @@ public function install(){ */ public function uninstall() { - try { - Symphony::Database()->query("DROP TABLE `tbl_fields_colorchooser`"); - } catch( Exception $e ){} - return true; + return Symphony::Database() + ->drop('tbl_fields_colorchooser') + ->ifExists() + ->execute() + ->success(); } } diff --git a/extension.meta.xml b/extension.meta.xml index f19ab98..8043e56 100644 --- a/extension.meta.xml +++ b/extension.meta.xml @@ -35,6 +35,10 @@ + + * Update for Symphony 4.x + * Code refactoring for Database and EQFA + * PHP 7 Support diff --git a/fields/field.colorchooser.php b/fields/field.colorchooser.php index a86ba4f..7752985 100644 --- a/fields/field.colorchooser.php +++ b/fields/field.colorchooser.php @@ -11,6 +11,7 @@ function __construct(){ parent::__construct(); $this->_name = 'Color Chooser'; $this->_required = true; + $this->entryQueryFieldAdapter = new EntryQueryFieldAdapter($this); $this->set('required', 'yes'); } @@ -46,9 +47,17 @@ function commit(){ $fields['field_id'] = $id; - Symphony::Database()->query("DELETE FROM `tbl_fields_".$this->handle()."` WHERE `field_id` = '$id' LIMIT 1"); - return Symphony::Database()->insert($fields, 'tbl_fields_'.$this->handle()); - + Symphony::Database() + ->delete('tbl_fields_' . $this->handle()) + ->where(['field_id' => $id]) + ->limit(1) + ->execute() + ->success(); + return Symphony::Database() + ->insert('tbl_fields_' . $this->handle()) + ->values($fields) + ->execute() + ->success(); } function groupRecords($records){ @@ -68,7 +77,6 @@ function groupRecords($records){ } $groups[$this->get('element_name')][$value]['records'][] = $r; - } return $groups; @@ -147,7 +155,7 @@ public function rgb2brightness($r,$g,$b) { $brightness = round( (.2126 * $r + .7152 * $g + .0722 * $b) / 255 * 100 ); return $brightness; } - + public function rgb2cmyk($r,$g,$b) { $r = $r / 255; @@ -231,17 +239,27 @@ public function prepareTextValue($data, $entry_id = null) { } public function createTable(){ - return Symphony::Database()->query( - "CREATE TABLE IF NOT EXISTS `tbl_entries_data_".$this->get('id')."` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `entry_id` INT(11) UNSIGNED NOT NULL, - `value` VARCHAR(32) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `entry_id` (`entry_id`), - KEY `value` (`value`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;" - - ); + return Symphony::Database() + ->create('tbl_entries_data_' . $this->get('id')) + ->ifNotExists() + ->fields([ + 'id' => [ + 'type' => 'int(11)', + 'auto' => true, + ], + 'entry_id' => 'int(11)', + 'value' => [ + 'type' => 'varchar(32)', + 'null' => true, + ], + ]) + ->keys([ + 'id' => 'primary', + 'entry_id' => 'key', + 'value' => 'key', + ]) + ->execute() + ->success(); } }