Added config for PHP formatting (PSR2)
I needed some consistent php formatting, so I plugged in a php fixer config and then reformatted all PHP files so it's all consistent. Fixed an ID issue with the page-edit template that was causing page editing to fail.pull/84/head
parent
d9c9f7744e
commit
63eaba08e2
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return (new PhpCsFixer\Config())
|
||||||
|
->setRules([
|
||||||
|
'@PSR2' => true,
|
||||||
|
'array_indentation' => true,
|
||||||
|
'array_syntax' => [
|
||||||
|
'syntax' => 'short',
|
||||||
|
],
|
||||||
|
'combine_consecutive_unsets' => true,
|
||||||
|
'method_chaining_indentation' => true,
|
||||||
|
'class_attributes_separation' => [
|
||||||
|
'elements' => [
|
||||||
|
'method' => 'none',
|
||||||
|
'trait_import' => 'none'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'multiline_whitespace_before_semicolons' => [
|
||||||
|
'strategy' => 'no_multi_line',
|
||||||
|
],
|
||||||
|
'single_quote' => true,
|
||||||
|
|
||||||
|
'binary_operator_spaces' => [
|
||||||
|
'default' => 'single_space',
|
||||||
|
'operators' => [
|
||||||
|
'=' => 'align_single_space_minimal',
|
||||||
|
'=>' => 'align_single_space_minimal',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'braces' => [
|
||||||
|
'allow_single_line_closure' => true,
|
||||||
|
],
|
||||||
|
'concat_space' => [
|
||||||
|
'spacing' => 'one',
|
||||||
|
],
|
||||||
|
'declare_equal_normalize' => true,
|
||||||
|
'function_typehint_space' => true,
|
||||||
|
'single_line_comment_style' => [
|
||||||
|
'comment_types' => [
|
||||||
|
'hash',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'include' => true,
|
||||||
|
'lowercase_cast' => true,
|
||||||
|
'no_extra_blank_lines' => [
|
||||||
|
'tokens' => [
|
||||||
|
'use',
|
||||||
|
'curly_brace_block',
|
||||||
|
'extra',
|
||||||
|
'parenthesis_brace_block',
|
||||||
|
'throw',
|
||||||
|
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'no_multiline_whitespace_around_double_arrow' => true,
|
||||||
|
'no_spaces_around_offset' => true,
|
||||||
|
'no_unused_imports' => true,
|
||||||
|
'no_whitespace_before_comma_in_array' => true,
|
||||||
|
'no_whitespace_in_blank_line' => true,
|
||||||
|
'object_operator_without_whitespace' => true,
|
||||||
|
'single_blank_line_before_namespace' => true,
|
||||||
|
'ternary_operator_spaces' => true,
|
||||||
|
'trim_array_spaces' => true,
|
||||||
|
'unary_operator_spaces' => true,
|
||||||
|
'whitespace_after_comma_in_array' => true,
|
||||||
|
'single_line_after_imports' => true,
|
||||||
|
'ordered_imports' => [
|
||||||
|
'sort_algorithm' => 'none',
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->setLineEnding("\n");
|
@ -1,93 +1,95 @@
|
|||||||
import StringUtils from '../utils/StringUtils';
|
import StringUtils from '../utils/StringUtils';
|
||||||
export default class PostActions {
|
export default class PostActions {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {}
|
constructor() {}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
collectInfo(files) {
|
collectInfo(files) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let pageInfo = new FormData();
|
let pageInfo = new FormData();
|
||||||
let txt = document.createElement('textarea');
|
let txt = document.createElement('textarea');
|
||||||
txt.innerHTML = document.getElementById('highlight-content').innerHTML;
|
txt.innerHTML = document.getElementById('highlight-content').innerHTML;
|
||||||
let html = txt.value;
|
let html = txt.value;
|
||||||
html = html.replace(/<\/?span[^>]*>/g, ''); //removes prism styling
|
html = html.replace(/<\/?span[^>]*>/g, ''); //removes prism styling
|
||||||
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage
|
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage
|
||||||
pageInfo.append(
|
pageInfo.append(
|
||||||
'id',
|
'id',
|
||||||
document.getElementById('post-edit-index').getAttribute('data-index')
|
document.getElementById('post-edit-index').getAttribute('data-index')
|
||||||
);
|
);
|
||||||
pageInfo.append(
|
pageInfo.append(
|
||||||
'uuid',
|
'uuid',
|
||||||
document.getElementById('post-edit-index').getAttribute('data-uuid')
|
document.getElementById('post-edit-index').getAttribute('data-uuid')
|
||||||
);
|
);
|
||||||
pageInfo.append(
|
pageInfo.append(
|
||||||
'layout',
|
'layout',
|
||||||
document.getElementById('post-edit-index').getAttribute('data-layout')
|
document.getElementById('post-edit-index').getAttribute('data-layout')
|
||||||
);
|
);
|
||||||
pageInfo.append(
|
pageInfo.append(
|
||||||
'current_title',
|
'current_title',
|
||||||
document.getElementById('post-edit-index').getAttribute('data-slug')
|
document.getElementById('post-edit-index').getAttribute('data-slug')
|
||||||
);
|
);
|
||||||
pageInfo.append('content', html);
|
pageInfo.append('content', html);
|
||||||
pageInfo.append('title', document.getElementById('post_title').value);
|
pageInfo.append('title', document.getElementById('post-title-text').value);
|
||||||
pageInfo.append(
|
pageInfo.append(
|
||||||
'created',
|
'created',
|
||||||
document.getElementById('post-date').getAttribute('data-raw')
|
document.getElementById('post-date').getAttribute('data-raw')
|
||||||
);
|
);
|
||||||
pageInfo.append(
|
pageInfo.append(
|
||||||
'slug',
|
'slug',
|
||||||
new StringUtils().cleanString(document.getElementById('post_title').value)
|
new StringUtils().cleanString(
|
||||||
);
|
document.getElementById('post-title-text').value
|
||||||
pageInfo.append('tags', document.getElementById('post_tags').value);
|
)
|
||||||
pageInfo.append(
|
);
|
||||||
'menu',
|
pageInfo.append('tags', document.getElementById('post-tags').value);
|
||||||
document.getElementById('option-menu-pin').getAttribute('data-active')
|
pageInfo.append(
|
||||||
);
|
'menu',
|
||||||
pageInfo.append(
|
document.getElementById('option-menu-pin').getAttribute('data-active')
|
||||||
'featured',
|
);
|
||||||
document.getElementById('option-feature').getAttribute('data-active')
|
pageInfo.append(
|
||||||
);
|
'featured',
|
||||||
pageInfo.append(
|
document.getElementById('option-feature').getAttribute('data-active')
|
||||||
'published',
|
);
|
||||||
document.getElementById('option-published').getAttribute('data-active')
|
pageInfo.append(
|
||||||
);
|
'published',
|
||||||
pageInfo.append('layout', document.getElementById('page-templates').value);
|
document.getElementById('option-published').getAttribute('data-active')
|
||||||
pageInfo.append('form_token', document.getElementById('form_token').value);
|
);
|
||||||
if (files.length > 0 && files != null) {
|
pageInfo.append('layout', document.getElementById('page-templates').value);
|
||||||
for (var i = 0; i < files.length; i++) {
|
pageInfo.append('form_token', document.getElementById('form_token').value);
|
||||||
var file = files[i];
|
if (files.length > 0 && files != null) {
|
||||||
if (
|
for (var i = 0; i < files.length; i++) {
|
||||||
file.type.match('image.*') ||
|
var file = files[i];
|
||||||
file.type.match('video.mp4') ||
|
if (
|
||||||
file.type.match('audio.mpeg') ||
|
file.type.match('image.*') ||
|
||||||
file.type.match('application.pdf') ||
|
file.type.match('video.mp4') ||
|
||||||
file.type.match('text.plain') ||
|
file.type.match('audio.mpeg') ||
|
||||||
file.type.match('text.rtf')
|
file.type.match('application.pdf') ||
|
||||||
) {
|
file.type.match('text.plain') ||
|
||||||
pageInfo.append('page_files[]', file, file.name);
|
file.type.match('text.rtf')
|
||||||
} else {
|
) {
|
||||||
reject('Not an image file');
|
pageInfo.append('page_files[]', file, file.name);
|
||||||
}
|
} else {
|
||||||
}
|
reject('Not an image file');
|
||||||
} else {
|
}
|
||||||
//check to see if image exists
|
}
|
||||||
if (document.getElementById('featured-image')) {
|
} else {
|
||||||
var imageURL = document.getElementById('featured-image').src;
|
//check to see if image exists
|
||||||
imageURL != null || imageURL != undefined
|
if (document.getElementById('featured-image')) {
|
||||||
? pageInfo.append('feature_image', imageURL)
|
var imageURL = document.getElementById('featured-image').src;
|
||||||
: pageInfo.append('feature_image', null);
|
imageURL != null || imageURL != undefined
|
||||||
} else {
|
? pageInfo.append('feature_image', imageURL)
|
||||||
//pageInfo.append("feature_image", null);
|
: pageInfo.append('feature_image', null);
|
||||||
}
|
} else {
|
||||||
}
|
//pageInfo.append("feature_image", null);
|
||||||
//console.log("FILES", files);
|
}
|
||||||
resolve(pageInfo);
|
}
|
||||||
});
|
//console.log("FILES", files);
|
||||||
}
|
resolve(pageInfo);
|
||||||
//--------------------------
|
});
|
||||||
// event handlers
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
// event handlers
|
||||||
|
//--------------------------
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue