Permalink
Browse files

fixed formatting and .travis.yml

  • Loading branch information...
1 parent a4b8020 commit 40a9dc37e21889bfd54af4785f48d50fa9e5880e @NewFuture NewFuture committed Oct 7, 2016
View
@@ -0,0 +1,27 @@
+# EditorConfig is awesome: http://EditorConfig.org
+# top-most EditorConfig file
+root = true
+
+# Unix-style newlines with a newline ending every file
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+
+# Matches multiple files with brace expansion notation
+# Set default charset
+[*.{js,php}]
+charset = utf-8
+indent_style = space
+indent_size = 4
+
+# 4 space indentation
+[*.min.js]
+indent_style = space
+indent_size = 0
+
+
+# Matches the exact files either package.json or .travis.yml
+[{composer.json,.travis.yml,build.xml}]
+indent_style = space
+indent_size = 2
View
@@ -5,13 +5,23 @@ php:
- 5.4
- 5.5
- 5.6
+ - 7.0
env:
- - RUN=vendor/bin/phing
+ global:
+ # Naming conventions and Namespace are not compatible current and LineLength
+ - CS_EXCLUDE: "PSR1.Classes.ClassDeclaration,PSR1.Methods.CamelCapsMethodName,Squiz.Classes.ValidClassName,Generic.NamingConventions.UpperCaseConstantName,Generic.Files.LineLength,PSR1.Files.SideEffects"
+ - CS_INGNORE: "dialog.php"
-script: ${RUN}
-
-before_script:
- - composer selfupdate
- - composer --version
+#install dependence
+install:
- composer install --prefer-dist --verbose
+
+# check formatting and Syntax
+script:
+ - ./vendor/bin/phpcs components
+ --standard=PSR2
+ --exclude="$CS_EXCLUDE"
+ --ignore="$CS_INGNORE"
+ --colors
+ --extensions=php
@@ -8,7 +8,8 @@
require_once('../../common.php');
-class Active extends Common {
+class Active extends Common
+{
//////////////////////////////////////////////////////////////////
// PROPERTIES
@@ -29,56 +30,59 @@ class Active extends Common {
// Construct
//////////////////////////////////////////////////////////////////
- public function __construct(){
+ public function __construct()
+ {
$this->actives = getJSON('active.php');
}
//////////////////////////////////////////////////////////////////
// List User's Active Files
//////////////////////////////////////////////////////////////////
- public function ListActive(){
+ public function ListActive()
+ {
$active_list = array();
- $tainted = FALSE;
+ $tainted = false;
$root = WORKSPACE;
- if($this->actives){
- foreach($this->actives as $active=>$data){
- if(is_array($data) && isset($data['username']) && $data['username']==$this->username){
- if($this->isAbsPath($data['path'])) {
- $root = "";
- } else {
- $root = $root.'/';
+ if ($this->actives) {
+ foreach ($this->actives as $active => $data) {
+ if (is_array($data) && isset($data['username']) && $data['username']==$this->username) {
+ if ($this->isAbsPath($data['path'])) {
+ $root = "";
+ } else {
+ $root = $root.'/';
+ }
+ if (file_exists($root.$data['path'])) {
+ $focused = isset($data['focused']) ? $data['focused'] : false;
+ $active_list[] = array('path'=>$data['path'], 'focused'=>$focused);
+ } else {
+ unset($this->actives[$active]);
+ $tainted = true;
+ }
}
- if (file_exists($root.$data['path'])) {
- $focused = isset($data['focused']) ? $data['focused'] : false;
- $active_list[] = array('path'=>$data['path'], 'focused'=>$focused);
- } else {
- unset($this->actives[$active]);
- $tainted = TRUE;
- }
- }
}
}
- if ($tainted){
- saveJSON('active.php',$this->actives);
+ if ($tainted) {
+ saveJSON('active.php', $this->actives);
}
- echo formatJSEND("success",$active_list);
+ echo formatJSEND("success", $active_list);
}
//////////////////////////////////////////////////////////////////
// Check File
//////////////////////////////////////////////////////////////////
- public function Check(){
+ public function Check()
+ {
$cur_users = array();
- foreach($this->actives as $active=>$data){
- if(is_array($data) && isset($data['username']) && $data['username']!=$this->username && $data['path']==$this->path){
+ foreach ($this->actives as $active => $data) {
+ if (is_array($data) && isset($data['username']) && $data['username']!=$this->username && $data['path']==$this->path) {
$cur_users[] = $data['username'];
}
}
- if(count($cur_users)!=0){
- echo formatJSEND("error","Warning: File ".substr($this->path,strrpos($this->path,"/")+1)." Currently Opened By: " . implode(", ",$cur_users));
- }else{
+ if (count($cur_users)!=0) {
+ echo formatJSEND("error", "Warning: File ".substr($this->path, strrpos($this->path, "/")+1)." Currently Opened By: " . implode(", ", $cur_users));
+ } else {
echo formatJSEND("success");
}
}
@@ -87,16 +91,17 @@ public function Check(){
// Add File
//////////////////////////////////////////////////////////////////
- public function Add(){
+ public function Add()
+ {
$process_add = true;
- foreach($this->actives as $active=>$data){
- if(is_array($data) && isset($data['username']) && $data['username']==$this->username && $data['path']==$this->path){
+ foreach ($this->actives as $active => $data) {
+ if (is_array($data) && isset($data['username']) && $data['username']==$this->username && $data['path']==$this->path) {
$process_add = false;
}
}
- if($process_add){
+ if ($process_add) {
$this->actives[] = array("username"=>$this->username,"path"=>$this->path);
- saveJSON('active.php',$this->actives);
+ saveJSON('active.php', $this->actives);
echo formatJSEND("success");
}
}
@@ -105,61 +110,64 @@ public function Add(){
// Rename File
//////////////////////////////////////////////////////////////////
- public function Rename(){
+ public function Rename()
+ {
$revised_actives = array();
- foreach($this->actives as $active=>$data){
- if(is_array($data) && isset($data['username'])){
- $revised_actives[] = array("username"=>$data['username'],"path"=>str_replace($this->path,$this->new_path,$data['path']));
- }
+ foreach ($this->actives as $active => $data) {
+ if (is_array($data) && isset($data['username'])) {
+ $revised_actives[] = array("username"=>$data['username'],"path"=>str_replace($this->path, $this->new_path, $data['path']));
+ }
}
- saveJSON('active.php',$revised_actives);
+ saveJSON('active.php', $revised_actives);
echo formatJSEND("success");
}
//////////////////////////////////////////////////////////////////
// Remove File
//////////////////////////////////////////////////////////////////
- public function Remove(){
- foreach($this->actives as $active=>$data){
- if(is_array($data) && isset($data['username']) && $this->username==$data['username'] && $this->path==$data['path']){
+ public function Remove()
+ {
+ foreach ($this->actives as $active => $data) {
+ if (is_array($data) && isset($data['username']) && $this->username==$data['username'] && $this->path==$data['path']) {
unset($this->actives[$active]);
}
}
- saveJSON('active.php',$this->actives);
+ saveJSON('active.php', $this->actives);
echo formatJSEND("success");
}
//////////////////////////////////////////////////////////////////
// Remove All Files
//////////////////////////////////////////////////////////////////
- public function RemoveAll(){
- foreach($this->actives as $active=>$data){
- if(is_array($data) && isset($data['username']) && $this->username==$data['username']){
+ public function RemoveAll()
+ {
+ foreach ($this->actives as $active => $data) {
+ if (is_array($data) && isset($data['username']) && $this->username==$data['username']) {
unset($this->actives[$active]);
}
}
- saveJSON('active.php',$this->actives);
+ saveJSON('active.php', $this->actives);
echo formatJSEND("success");
}
//////////////////////////////////////////////////////////////////
- // Mark File As Focused
+ // Mark File As Focused
// All other files will be marked as non-focused.
//////////////////////////////////////////////////////////////////
- public function MarkFileAsFocused(){
- foreach($this->actives as $active=>$data){
- if(is_array($data) && isset($data['username']) && $this->username==$data['username']){
+ public function MarkFileAsFocused()
+ {
+ foreach ($this->actives as $active => $data) {
+ if (is_array($data) && isset($data['username']) && $this->username==$data['username']) {
$this->actives[$active]['focused']=false;
- if($this->path==$data['path']){
+ if ($this->path==$data['path']) {
$this->actives[$active]['focused']=true;
}
}
}
- saveJSON('active.php',$this->actives);
+ saveJSON('active.php', $this->actives);
echo formatJSEND("success");
}
-
}
@@ -21,69 +21,67 @@
// Get user's active files
//////////////////////////////////////////////////////////////////
- if($_GET['action']=='list'){
- $Active->username = $_SESSION['user'];
- $Active->ListActive();
- }
+if ($_GET['action']=='list') {
+ $Active->username = $_SESSION['user'];
+ $Active->ListActive();
+}
//////////////////////////////////////////////////////////////////
// Add active record
//////////////////////////////////////////////////////////////////
- if($_GET['action']=='add'){
- $Active->username = $_SESSION['user'];
- $Active->path = $_GET['path'];
- $Active->Add();
- }
+if ($_GET['action']=='add') {
+ $Active->username = $_SESSION['user'];
+ $Active->path = $_GET['path'];
+ $Active->Add();
+}
//////////////////////////////////////////////////////////////////
// Rename
//////////////////////////////////////////////////////////////////
- if($_GET['action']=='rename'){
- $Active->username = $_SESSION['user'];
- $Active->path = $_GET['old_path'];
- $Active->new_path = $_GET['new_path'];
- $Active->Rename();
- }
+if ($_GET['action']=='rename') {
+ $Active->username = $_SESSION['user'];
+ $Active->path = $_GET['old_path'];
+ $Active->new_path = $_GET['new_path'];
+ $Active->Rename();
+}
//////////////////////////////////////////////////////////////////
// Check if file is active
//////////////////////////////////////////////////////////////////
- if($_GET['action']=='check'){
- $Active->username = $_SESSION['user'];
- $Active->path = $_GET['path'];
- $Active->Check();
- }
+if ($_GET['action']=='check') {
+ $Active->username = $_SESSION['user'];
+ $Active->path = $_GET['path'];
+ $Active->Check();
+}
//////////////////////////////////////////////////////////////////
// Remove active record
//////////////////////////////////////////////////////////////////
- if($_GET['action']=='remove'){
- $Active->username = $_SESSION['user'];
- $Active->path = $_GET['path'];
- $Active->Remove();
- }
+if ($_GET['action']=='remove') {
+ $Active->username = $_SESSION['user'];
+ $Active->path = $_GET['path'];
+ $Active->Remove();
+}
//////////////////////////////////////////////////////////////////
// Remove all active record
//////////////////////////////////////////////////////////////////
- if($_GET['action']=='removeall'){
- $Active->username = $_SESSION['user'];
- $Active->RemoveAll();
- }
+if ($_GET['action']=='removeall') {
+ $Active->username = $_SESSION['user'];
+ $Active->RemoveAll();
+}
//////////////////////////////////////////////////////////////////
// Mark file as focused
//////////////////////////////////////////////////////////////////
- if($_GET['action']=='focused'){
- $Active->username = $_SESSION['user'];
- $Active->path = $_GET['path'];
- $Active->MarkFileAsFocused();
- }
-
-?>
+if ($_GET['action']=='focused') {
+ $Active->username = $_SESSION['user'];
+ $Active->path = $_GET['path'];
+ $Active->MarkFileAsFocused();
+}
Oops, something went wrong.

0 comments on commit 40a9dc3

Please sign in to comment.