Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Symphony 4.x #11

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/color_wheel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 109 additions & 31 deletions assets/farbtastic.css
Original file line number Diff line number Diff line change
@@ -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;
}
31 changes: 21 additions & 10 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/*
Expand All @@ -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();
}
}

Expand Down
4 changes: 4 additions & 0 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
</item>
</media>
<releases>
<release version="2.0.0" date="TBA" min="4.0.0" max="4.x.x" php-min="5.6.x" php-max="7.x.x">
* Update for Symphony 4.x
* Code refactoring for Database and EQFA
</release>
<release version="1.7.2" date="2017-11-06" min="2.4" max="2.x.x">
* PHP 7 Support
</release>
Expand Down
50 changes: 34 additions & 16 deletions fields/field.colorchooser.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function __construct(){
parent::__construct();
$this->_name = 'Color Chooser';
$this->_required = true;
$this->entryQueryFieldAdapter = new EntryQueryFieldAdapter($this);
$this->set('required', 'yes');
}

Expand Down Expand Up @@ -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){
Expand All @@ -68,7 +77,6 @@ function groupRecords($records){
}

$groups[$this->get('element_name')][$value]['records'][] = $r;

}

return $groups;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

}
Expand Down