Skip to content

Commit

Permalink
SQL and PHP cases
Browse files Browse the repository at this point in the history
PHP true,false,null in lowercase
SQL keywords uppercase
  • Loading branch information
Alexandra Nantel committed Aug 24, 2017
1 parent 57bb1a9 commit 48c5e1a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/*
* Subscribe to delegates
*/

public function getSubscribedDelegates() {
return array(
array(
Expand All @@ -15,22 +15,22 @@ public function getSubscribedDelegates() {
),
);
}

/*********** DELEGATES ***********************/

/*
* Appends resource (js/css) files references into the head, if needed
* @param array $context
*/

public function appendResources() {

// store callback array locally
$c = Administration::instance()->getPageCallback();

// publish page, new or edit
if(in_array($c['context']['page'], array('index', 'new', 'edit'))){

$page = Administration::instance()->Page;

$page->addScriptToHead(URL.'/extensions/color_chooser_field/assets/jquery.farbtastic.js', 3001);
Expand All @@ -41,31 +41,31 @@ public function appendResources() {
return;
}
}

/*
* Delegate fired when the extension is installed
*/

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,
`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;");
}

/*
* Delegate fired when the extension is uninstalled
* Cleans settings and Database
*/

public function uninstall() {
try {
Symphony::Database()->query("DROP TABLE `tbl_fields_colorchooser`");
} catch( Exception $e ){}
return true;
}
}
}

?>
22 changes: 11 additions & 11 deletions fields/field.colorchooser.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,42 +74,42 @@ function groupRecords($records){
return $groups;
}

function displaySettingsPanel(XMLElement &$wrapper, $errors = NULL){
function displaySettingsPanel(XMLElement &$wrapper, $errors = null){

parent::displaySettingsPanel($wrapper, $errors);

/* Option Group */
$optgroup = new XMLElement('div', NULL, array('class' => 'two columns'));
$optgroup = new XMLElement('div', null, array('class' => 'two columns'));
$this->appendRequiredCheckbox($optgroup);
$this->appendShowColumnCheckbox($optgroup);
$wrapper->appendChild($optgroup);

}

function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL, $entry_id = NULL){
function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null){

$value = $data['value'];
$label = Widget::Label($this->get('label'));
$label->setAttribute('class', 'color-chooser');
if( $this->get('required') != 'yes' ) $label->appendChild(new XMLElement('i', 'Optional'));
$label->appendChild(Widget::Input('fields'.$fieldnamePrefix.'['.$this->get('element_name').']'.$fieldnamePostfix, (strlen($value) != 0 ? $value : '#')));

if( $flagWithError != NULL ) $wrapper->appendChild(Widget::Error($label, $flagWithError));
if( $flagWithError != null ) $wrapper->appendChild(Widget::Error($label, $flagWithError));
else $wrapper->appendChild($label);
}

public function displayDatasourceFilterPanel(XMLElement &$wrapper, $data = NULL, $errors = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL){
public function displayDatasourceFilterPanel(XMLElement &$wrapper, $data = null, $errors = null, $fieldnamePrefix = null, $fieldnamePostfix = null){
$wrapper->appendChild(new XMLElement('h4', $this->get('label').' <i>'.$this->Name().'</i>'));
$label = Widget::Label('Value');
$label->appendChild(Widget::Input('fields[filter]'.($fieldnamePrefix ? '['.$fieldnamePrefix.']' : '').'['.$this->get('id').']'.($fieldnamePostfix ? '['.$fieldnamePostfix.']' : ''), ($data ? General::sanitize($data) : NULL)));
$label->appendChild(Widget::Input('fields[filter]'.($fieldnamePrefix ? '['.$fieldnamePrefix.']' : '').'['.$this->get('id').']'.($fieldnamePostfix ? '['.$fieldnamePostfix.']' : ''), ($data ? General::sanitize($data) : null)));
$wrapper->appendChild($label);

$wrapper->appendChild(new XMLElement('p', 'Accepts a 6 character color hex value beginning with \'#\'.', array('class' => 'help')));
}
public function checkPostFieldData($data, &$message, $entry_id = NULL){
$message = NULL;
public function checkPostFieldData($data, &$message, $entry_id = null){
$message = null;
if( $this->get('required') == 'yes' && strlen($data) == 0 ){
$message = "This is a required field.";
Expand Down Expand Up @@ -196,9 +196,9 @@ 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,
`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`)
Expand Down

0 comments on commit 48c5e1a

Please sign in to comment.