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 Jun 6, 2018
1 parent c803068 commit 5073d2b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public function install()
{
return Symphony::Database()->query(sprintf(
"CREATE TABLE `%s` (
`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,
`destination` VARCHAR(255) NOT NULL,
`validator` VARCHAR(255),
`unique` enum('yes','no') DEFAULT 'yes',
`default_main_lang` enum('yes','no') NOT NULL DEFAULT 'no',
`unique` ENUM('yes','no') DEFAULT 'yes',
`default_main_lang` ENUM('yes','no') NOT NULL DEFAULT 'no',
`required_languages` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `field_id` (`field_id`)
Expand Down Expand Up @@ -200,10 +200,10 @@ public function dFLSavePreferences($context){
if( !in_array('file-'.$lc, $columns) )
Symphony::Database()->query(sprintf(
'ALTER TABLE `%1$s`
ADD COLUMN `file-%2$s` varchar(255) default NULL,
ADD COLUMN `size-%2$s` int(11) unsigned NULL,
ADD COLUMN `mimetype-%2$s` varchar(50) default NULL,
ADD COLUMN `meta-%2$s` varchar(255) default NULL;',
ADD COLUMN `file-%2$s` VARCHAR(255) DEFAULT NULL,
ADD COLUMN `size-%2$s` INT(11) UNSIGNED NULL,
ADD COLUMN `mimetype-%2$s` VARCHAR(50) DEFAULT NULL,
ADD COLUMN `meta-%2$s` VARCHAR(255) DEFAULT NULL;',
$entries_table, $lc
));
}
Expand Down
40 changes: 20 additions & 20 deletions fields/field.multilingual_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public function __construct(){
public function createTable(){
$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,
`file` varchar(255) default NULL,
`size` int(11) unsigned NULL,
`mimetype` varchar(50) default NULL,
`meta` varchar(255) default NULL,";
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`entry_id` INT(11) UNSIGNED NOT NULL,
`file` VARCHAR(255) DEFAULT NULL,
`size` INT(11) UNSIGNED NULL,
`mimetype` VARCHAR(50) DEFAULT NULL,
`meta` VARCHAR(255) DEFAULT NULL,";

foreach( FLang::getLangs() as $lc ){
$query .= sprintf('
`file-%1$s` varchar(255) default NULL,
`size-%1$s` int(11) unsigned NULL,
`mimetype-%1$s` varchar(50) default NULL,
`meta-%1$s` varchar(255) default NULL,',
`file-%1$s` VARCHAR(255) DEFAULT NULL,
`size-%1$s` INT(11) UNSIGNED NULL,
`mimetype-%1$s` VARCHAR(50) DEFAULT NULL,
`meta-%1$s` VARCHAR(255) DEFAULT NULL,',
$lc
);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ public function commit()
/* Publish */
/*------------------------------------------------------------------------------------------------*/

public function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL, $entry_id = NULL){
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null){
Extension_Frontend_Localisation::appendAssets();
Extension_Multilingual_Upload_Field::appendAssets();

Expand Down Expand Up @@ -287,8 +287,8 @@ public function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWit
/*------------------------------------------------------------------------------------------------*/

foreach ($langs as $lc) {
$div = new XMLElement('div', NULL, array('class' => 'file tab-panel tab-'.$lc));
$frame = new XMLElement('div', NULL, array('class' => 'frame'));
$div = new XMLElement('div', null, array('class' => 'file tab-panel tab-'.$lc));
$frame = new XMLElement('div', null, array('class' => 'frame'));

$file = 'file-'.$lc;

Expand Down Expand Up @@ -324,7 +324,7 @@ public function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWit
$flagWithError = __('Destination folder, <code>%s</code>, is not writable. Please check permissions.', array($this->get('destination')));
}

if ($flagWithError != NULL ) {
if ($flagWithError != null ) {
$wrapper->appendChild(Widget::Error($container, $flagWithError));
}
else {
Expand All @@ -338,7 +338,7 @@ public function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWit
/* Input */
/*------------------------------------------------------------------------------------------------*/

public function checkPostFieldData($data, &$message, $entry_id = NULL){
public function checkPostFieldData($data, &$message, $entry_id = null){
$error = self::__OK__;
$field_data = $data;
$all_langs = FLang::getAllLangs();
Expand Down Expand Up @@ -377,7 +377,7 @@ public function checkPostFieldData($data, &$message, $entry_id = NULL){
return $error;
}

public function processRawFieldData($data, &$status, &$message = NULL, $simulate = false, $entry_id = NULL){
public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null){
if(!is_array($data) || empty($data)) {
return parent::processRawFieldData($data, $status, $message, $simulate, $entry_id);
}
Expand Down Expand Up @@ -466,7 +466,7 @@ protected function getCurrentData($entry_id) {
/* Output */
/*------------------------------------------------------------------------------------------------*/

public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = NULL, $entry_id = NULL){
public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null){
$lang_code = $this->getLang($data);
$data['file'] = $data["file-$lang_code"];
$data['size'] = $data["size-$lang_code"];
Expand All @@ -476,7 +476,7 @@ public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = fa
}

// @todo: remove and fallback to default (Symphony 2.5 only?)
public function prepareTableValue($data, XMLElement $link = NULL, $entry_id = null){
public function prepareTableValue($data, XMLElement $link = null, $entry_id = null){
$lang_code = $this->getLang($data);
$data['file'] = $data["file-$lang_code"];
$data['size'] = $data["size-$lang_code"];
Expand All @@ -490,7 +490,7 @@ public function prepareTextValue($data, $entry_id = null) {
return strip_tags($data["file-$lc"]);
}

public function getParameterPoolValue(array $data, $entry_id = NULL) {
public function getParameterPoolValue(array $data, $entry_id = null) {
$lc = $this->getLang();
return $data["file-$lc"];
}
Expand All @@ -517,7 +517,7 @@ public function getExampleFormMarkup(){
/* Utilities */
/*------------------------------------------------------------------------------------------------*/

public function entryDataCleanup($entry_id, $data = NULL)
public function entryDataCleanup($entry_id, $data = null)
{
foreach( FLang::getLangs() as $lc ){
$file_location = WORKSPACE.'/'.ltrim($data['file-'.$lc], '/');
Expand Down

0 comments on commit 5073d2b

Please sign in to comment.