Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
87e7c79
Resolução do exercio #17
acidiney Oct 20, 2017
dd3e676
Resolução do exercio #17
acidiney Oct 20, 2017
b186fef
Fixed StyleCI Error
acidiney Oct 20, 2017
0e36c6b
Fixed StyleCI Error
acidiney Oct 20, 2017
56a063e
Fixed StyledCI API
acidiney Oct 20, 2017
6dc8534
Fixed StyledCI API
acidiney Oct 20, 2017
bf9e843
Fixed StyledCI API
acidiney Oct 20, 2017
ca1e557
Clear Bugs in ArrayInformationAPI
acidiney Oct 20, 2017
d8ff9aa
TestFix
acidiney Oct 20, 2017
e42eb56
Clear Bugs in ArrayInformationAPI
acidiney Oct 20, 2017
f86a705
Resolução do exercicio #16
acidiney Oct 22, 2017
ce624e9
Corrigindo StyleCI no exercicio #16
acidiney Oct 22, 2017
20f458d
Resolve StyleCI
acidiney Oct 22, 2017
ffca46f
PHPunit fixed -> Using Github Url
acidiney Oct 22, 2017
21b157c
Enviando Correções do Controller
acidiney Oct 22, 2017
783795a
PHPunit fixed -> Using Github Url
acidiney Oct 22, 2017
eee03db
initial
acidiney Oct 22, 2017
37026dd
Merge branch 'desafios' into desafios
JoseCage Oct 28, 2017
1214824
Merge branch 'desafios' into desafios
JoseCage Oct 28, 2017
54ec617
Novas alterações
acidiney Oct 28, 2017
6231266
merge
acidiney Nov 17, 2017
7c8591a
Clear Conflites
acidiney Nov 17, 2017
1397291
Exercicio feito2
acidiney Nov 17, 2017
2a0aa95
merge
acidiney Nov 17, 2017
846ec52
merge
acidiney Nov 17, 2017
911f0d7
styleCI
acidiney Nov 17, 2017
7ed697d
styleCI
acidiney Nov 17, 2017
b8fbf6e
Add Link
acidiney Nov 17, 2017
7504ed3
Adicionado index a pasta app, para listar os arquivos
acidiney Nov 17, 2017
50746ff
index modify
acidiney Nov 17, 2017
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
11 changes: 4 additions & 7 deletions app/ConvertjsonToArray/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
.container
{
box-sizing: border-box;
padding-top:5%;

padding-top:5%;
}
.panel
{
Expand All @@ -31,14 +30,13 @@
}
</style>
</head>
<body onload="carregar();">
<div class="container">
<body onload="carregar();">
<div class="container">
<div class="panel panel-warning">
<div class="panel-heading">
<h3 class="panel-title"><b>Caminho do arquivo: </b> data/codingdojo.json</h3>
</div>
<div class="panel-body" id="carregamento">

</div>
</div>
<h3> Lista de membros </h3>
Expand All @@ -57,7 +55,6 @@ <h4 class="text-center" style="color: #ccc">Criado Por Acidiney Dias</h4>
$.ajax({
url:"controller.php",
type:"POST",
data:{'date': data, 'opt' : 1},
dataType: 'json',
success: function(data){
$('#carregamento').html(data.app);
Expand All @@ -67,4 +64,4 @@ <h4 class="text-center" style="color: #ccc">Criado Por Acidiney Dias</h4>
}
</script>
</body>
</html>
</html>
19 changes: 19 additions & 0 deletions app/UpdateFileJson/controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

require '../../vendor/autoload.php';
use DojoPHP\UpdateFileJson\UpdateFileJsonAPI;

// Preenchendo dados padrão

$data = [
'nome' => addslashes($_POST['name']),
'cargo' => addslashes($_POST['function']),
'avatar' => '',
];
$source = '../../data/codingdojo.json';
$key = 'membros';

// Instaciando Classe UpdateFileJsonAPI
$new = new UpdateFileJsonAPI($data, $source, $key);
$msg = $new->UpdateFile();
echo json_encode($msg);
75 changes: 75 additions & 0 deletions app/UpdateFileJson/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Atualizando ficheiro do dojo</title>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">
<style>
*{
font-family:'Inconsolata', monospace;
font-size: 14pt;
}
body{
color:#555;
}
h3{
padding-bottom: 12px;
border-bottom: 1px solid #f0f0f0;
}
.red{
background: transparent !important;
color: #F44336;
}
#avatar
{
font-size: 12pt !important;
font-weight: lighter;
}
.btn{
background-color: #81d4fa;
}
</style>
</head>
<body class="white">
<div class="">
<h3 class="center-align truncate"> Adicionando novos dados ao arquivo json </h3>

<div class="container">
<p class="red">* Preencha os campos </p>
<label for="name">*Nome</label>
<input type="text" class="form-control" name="name" id="name" placeholder=" Eg. Acidiney Dias "/>
<label for="function">*Função</label>
<input type="text" class="form-control" name="function" id="function" placeholder=" Eg. Desenvolvedor PHP "/>
<button onclick="onSubmit()" class="btn">Carregar novo registro</button>
<p class="red"> Status de retorno </p>
<div id="return"></div>
<hr />
<p class="red"> * PREVIEW</p>
</div>
<iframe src="http://dojo-php.herokuapp.com/ConvertjsonToArray/" width="100%" height="600" style="border:0px"></iframe>
</div>
<script id="frame" src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>

function onSubmit(){
$.ajax({
url:"controller.php",
type:"POST",
dataType: 'json',
data: {
"name": $("#name").val(),
"function": $("#function").val(),
},
success: function(data){
$('#return').html(data);
document.getElementById('frame').contentDocument.location.reload(true);
}
});
}
</script>
</body>
</html>
42 changes: 42 additions & 0 deletions app/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Dojo PHP -> Projects</title>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<style>
*{
font-family: "Inconsolata";
padding:6px;
}
p{
width:100%;
padding-top:6px !important;
border-bottom:1px solid #eee;
}
</style>
</head>
<body class="container-fluid">
<h3>Lista diretórios <?php echo getcwd();?><br /></h3>
<p></p>
<div class="container">
<?php
$path = "./";
$diretorio = dir($path);
while(($arquivo = $diretorio -> read()) !== false){
if(is_dir($arquivo)){
echo "<i class='fa fa-folder-o' aria-hidden='true'></i>
<a href='".$path.$arquivo."'>".$arquivo.'</a><br />';
}
}
$diretorio -> close();
?>
</div>
<p class="center-align">@acidiney_dias</p>
</body>
</html>
68 changes: 1 addition & 67 deletions data/codingdojo.json
Original file line number Diff line number Diff line change
@@ -1,67 +1 @@
{
"app": "Coding Dojo Angola",
"url": "http://codingdojoangola.com",
"email": "geral@codingdojoangola.com",
"membros": [
{
"nome": "Lucius Curado",
"cargo": "Moderador e Organizador",
"avatar": ""
},
{
"nome": "José Cage",
"cargo": "Moderador e instrutor",
"avatar": ""
},
{
"nome": "Doriel Fonseca",
"cargo": "Instrutor #dojojavascript",
"avatar": ""
},
{
"nome": "Pedro Massango",
"cargo": "Desenvolvedor Java",
"avatar": ""
},
{
"nome": "Eleandro Duzentos",
"cargo": "Desenvolvedor PHP e .Net",
"avatar": ""
},
{
"nome": "Renato Martins",
"cargo": "Desenvolvedor Java e PHP",
"avatar": ""
},
{
"nome": "Victor Kiffen",
"cargo": "Desenvolvedor Java",
"avatar": ""
},
{
"nome": "Jetro Domingos",
"cargo": "Desenvolvedor Java",
"avatar": ""
},
{
"nome": "Acidiney Dias",
"cargo": "Desenvolvedor PHP",
"avatar": ""
},
{
"nome": "Nelson Júnior",
"cargo": "Desenvolvedor PHP",
"avatar": ""
},
{
"nome": "Masiry Link",
"cargo": "Desenvolvedor PHP",
"avatar": ""
},
{
"nome": "Aleixo Jeronimo",
"cargo": "",
"avatar": ""
}
]
}
{"app":"Coding Dojo Angola","url":"http:\/\/codingdojoangola.com","email":"geral@codingdojoangola.com","membros":[{"nome":"Lucius Curado","cargo":"Moderador e Organizador","avatar":""},{"nome":"Jos\u00e9 Cage","cargo":"Moderador e instrutor","avatar":""},{"nome":"Doriel Fonseca","cargo":"Instrutor #dojojavascript","avatar":""},{"nome":"Pedro Massango","cargo":"Desenvolvedor Java","avatar":""},{"nome":"Eleandro Duzentos","cargo":"Desenvolvedor PHP e .Net","avatar":""},{"nome":"Renato Martins","cargo":"Desenvolvedor Java e PHP","avatar":""},{"nome":"Victor Kiffen","cargo":"Desenvolvedor Java","avatar":""},{"nome":"Jetro Domingos","cargo":"Desenvolvedor Java","avatar":""},{"nome":"Acidiney Dias","cargo":"Desenvolvedor PHP","avatar":""},{"nome":"Nelson J\u00fanior","cargo":"Desenvolvedor PHP","avatar":""},{"nome":"Masiry Link","cargo":"Desenvolvedor PHP","avatar":""},{"nome":"Aleixo Jeronimo","cargo":"","avatar":""}]}
8 changes: 4 additions & 4 deletions src/ArrayDeInformacoes/ArrayInformationsAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public function CreateArrayWithInformation()
{
$this->data =
[
'E-mail' => $this->email,
'Name' => $this->name,
'Telefone' => $this->telephone,
];
'E-mail' => $this->email,
'Name' => $this->name,
'Telefone' => $this->telephone,
];

return $this->data;
}
Expand Down
25 changes: 13 additions & 12 deletions src/ConvertJsonToArray/ConvertJsonForArrayAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
*/
class ConvertJsonForArrayAPI
{
public $source;
public $data;
public $source;
public $data;

public function __construct($source)
{
$this->source = $source;
$this->data = file_get_contents($source);
}
public function __construct($source)
{
$this->source = $source;
}

public function Itera()
{
return json_decode($this->data, true);
}
}
public function Itera()
{
$this->data = file_get_contents($this->source);

return json_decode($this->data, true);
}
}
50 changes: 50 additions & 0 deletions src/UpdateFileJson/UpdateFileJsonAPI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace DojoPHP\UpdateFileJson;

/**
* @author Acidiney Dias
* @desc this class expected three parameters [$dataInput(is Array), $source and a $key]
* @return json with a message with status the return
*/
class UpdateFileJsonAPI
{

public $source;
public $data = [];
public $openFile;
public $alterFile;
public $key;

public function __construct($dataInputs = [], $source, $key)
{
$this->source = $source;
$this->data = $dataInputs;
$this->key = $key;
}

public function UpdateFile()
{

// var_dump($this->data); echo "<br />";
// I'm open file Json passed
$this->openFile = file_get_contents($this->source);

// Transform "temporary" he in array for php understand
$this->alterFile = json_decode($this->openFile, true);

// Now I'm used a method the PHP for add the new data in my collection data,
//using array push

array_push($this->alterFile["$this->key"], $this->data);

// So I'm encode again the file for json formatter
$this->alterFile = json_encode($this->alterFile);

// In the end, I'm add the new data in my file original
if(file_put_contents($this->source, $this->alterFile)):
return json_encode(["message" => "File updated with success!"], 201); else:
return json_encode(["message" => "File was not updated!"], 400);
endif;
}
}
31 changes: 17 additions & 14 deletions tests/ConvertJsonToArray/ConvertJsonForArrayTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

use DojoPHP\ConvertJsonToArray\ConvertJsonForArrayAPI;
use PHPUnit\Framework\TestCase;
use DojoPHP\ConvertJsonToArray\ConvertJsonForArrayAPI;
use PHPUnit\Framework\TestCase;

/**


/**
*@author Acidiney Dias
*
*@link https://www.github.com/acidiney
Expand All @@ -12,18 +14,19 @@
*/
class ConvertJsonForArrayTest extends TestCase
{
public $url;
public $instance;
public $url;
public $instance;

public function testGetData()
{
$this->url = 'https://github.com/codingdojoangola/dojophp/raw/desafios/data/codingdojo.json';
$this->instance = new ConvertJsonForArrayAPI($this->url);
public function testGetData()
{
$this->url = './data/codingdojo.json';
$this->instance = new ConvertJsonForArrayAPI($this->url);

$data = $this->instance->Itera();
$data = $this->instance->Itera();

$this->assertNotEmpty($data);
$this->assertInternalType('array', $data);
$this->assertArrayHasKey('membros', $data);
}
$this->assertNotEmpty($data);
$this->assertInternalType('array', $data);
$this->assertArrayHasKey('membros', $data);
}
}

Loading