Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ config/database.yml
config/config.yml
tmp/logs.txt
*~

/vendor/
app/models/Base
app/models/Map
20 changes: 13 additions & 7 deletions app/controllers/IssueController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class IssueController extends ApplicationController {
use Base\IssueQuery;

class IssueController extends ApplicationController {

public function newAction() {
$entity = new Issue();
Expand All @@ -16,9 +18,8 @@ public function editAction() {
}

public function showAction() {
$id = $this->request->getParam("id");
$ent = load_issue($id);
$this->render(array("entity" => $ent));
$issue = IssueQuery::create()->findOneById($this->request->getParam("id"));
$this->render(array("entity" => $issue));
}

public function createAction() {
Expand All @@ -30,8 +31,13 @@ public function indexAction() {
$project_id = $this->request->getParam("pid");
$per_page = 5;
$init = $page * $per_page;
$items = list_issue("num desc", $init . "," . $per_page, "project_id = " . $project_id);
$total_results = count_issue("project_id = " . $project_id);
$items = IssueQuery::create()
->orderByNum(IssueQuery::DESC)
->offset($init)
->limit($per_page)
->filterByProjectId($project_id)
->find();
$total_results = IssueQuery::create()->filterByProjectId($project_id)->count();
$total_pages = ceil($total_results / $per_page);
$this->render(array("issues" => $items,
"pid" => $project_id,
Expand All @@ -41,4 +47,4 @@ public function indexAction() {
}

}
?>
?>
49 changes: 25 additions & 24 deletions app/controllers/ProjectController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

class ProjectController extends ApplicationController {
use Base\DeveloperQuery;
use Base\ProjectQuery;

class ProjectController extends ApplicationController {
private $per_page = 12;

public function searchAction() {
Expand Down Expand Up @@ -104,45 +107,43 @@ public function publishAction() {
}

public function createAction() {
$entity = new Project();
$project = new Project();
$proj = $this->request->getParam("project");

$dev = load_developer_where('name = "' . $this->request->getParam("owner_name").'"');
$dev = DeveloperQuery::create()->findOneByName($this->request->getParam("owner_name"));

if($dev == null) { //Create the developer if it's not on our database already
$dev = new Developer();
$dev->name = $this->request->getParam("owner_name");
$dev->avatar_url = $this->request->getParam("owner_avatar");
save_developer($dev);
$dev->setName($this->request->getParam("owner_name"));
$dev->setAvatarUrl($this->request->getParam("owner_avatar"));
$dev->save();
} else { //Update the avatar if it changed
if ( $dev->avatar_url != $this->request->getParam("owner_avatar")) {
$dev->avatar_url = $this->request->getParam("owner_avatar");
save_developer($dev);
if ( $dev->getAvatarUrl() != $this->request->getParam("owner_avatar")) {
$dev->setAvatarUrl($this->request->getParam("owner_avatar"));
$dev->save();
}
}

if(!load_project_where("name = '".$proj['name']."' and owner_id = ".$dev->id)) {

$proj['url'] = str_replace("https", "", $proj['url']);
$proj['url'] = str_replace("http", "", $proj['url']);
$proj['url'] = str_replace("://", "", $proj['url']);
$proj['url'] = "http://" . $proj['url'];
if(!ProjectQuery::create()->filterByName($proj['name'])->findOneByOwnerId($dev->getId())) {
$projectUrl = $proj['url'];
$projectUrl = str_replace("https", "", $projectUrl);
$projectUrl = str_replace("http", "", $projectUrl);
$projectUrl = str_replace("://", "", $projectUrl);
$projectUrl = "http://" . $projectUrl;

$proj['owner_id'] = $dev->id;
$proj['published'] = 1;
$entity->load_from_array($proj);
if(save_project($entity)) {
$project->setUrl($projectUrl)->setDeveloper($dev)->setPublished(true);
if($project->save()) {
//Create the first set of stats
$entity->saveInitStats();
$entity->grabHistoricData();
$project->saveInitStats();
$project->grabHistoricData();
$this->flash->setSuccess("The project was added correctly, thanks!");
$this->redirect_to(project_show_path($entity));
$this->redirect_to(project_show_path($project));
} else {
$this->render(array("entity" => $entity), "new");
$this->render(array("entity" => $project), "new");
}
} else {
$this->flash->setError("This project has already been submited");
$this->render(array("entity" => $entity), "new");
$this->render(array("entity" => $project), "new");
}
}

Expand Down
26 changes: 14 additions & 12 deletions app/controllers/WebSiteMessageController.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
<?php

class WebSiteMessageController extends ApplicationController {
use Propel\Runtime\Exception\PropelException;

class WebSiteMessageController extends ApplicationController {

public function newAction() {
$entity = new WebSiteMessage();
$this->render(array("entity" => $entity));
}

public function deleteAction() {
delete_web_site_message($this->request->getParam("id"));
WebSiteMessageQuery::create()->findOneById($this->request->getParam("id"))->delete();
$this->flash->success("Delete successfull!");
$this->redirect_to(web_site_message_list_path());
}

public function editAction() {
$tb = load_web_site_message($this->request->getParam("id"));
$webSiteMessage = WebSiteMessageQuery::create()->findOneById($this->request->getParam("id"));

$this->render(array("entity" => $tb));
$this->render(array("entity" => $webSiteMessage));
}

public function showAction() {
$id = $this->request->getParam("id");
$ent = load_web_site_message($id);
$this->render(array("entity" => $ent));
$webSiteMessage = WebSiteMessageQuery::create()->findOneById($this->request->getParam("id"))
$this->render(array("entity" => $webSiteMessage));
}

public function createAction() {
$entity = new WebSiteMessage();
$entity->load_from_array($this->request->getParam("web_site_message"));
if(save_web_site_message($entity)) {
$this->flash->setSuccess("Message sent! Thanks for getting in touch!");
$this->redirect_to(home_root_path_path());
} else {
$entity->fromArray($this->request->getParam("web_site_message"));
try {
$entity->save();
$this->flash->setSuccess("Message sent! Thanks for getting in touch!");
$this->redirect_to(home_root_path_path());
} catch (PropelException $e) {
$this->flash->setError("Both fields are required, make sure you fill them! And the email must be valid one.");
$this->redirect_to(home_root_path_path());
}
Expand Down
51 changes: 51 additions & 0 deletions app/models/Developer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

use Base\Developer as BaseDeveloper;


/**
* Skeleton subclass for representing a row from the 'developer' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class Developer extends BaseDeveloper
{
public function avatar()
{
if ($this->getAvatarUrl() == "") {
return "/img/no-avatar.png";
} else {
return $this->getAvatarUrl();
}
}

public function gatherStats()
{
$db_projects = $this->getProjects(true);
$langs = array();
$projects = array();
foreach ($db_projects as $project) {
$projects[] = array(
"language" => $project->language,
"name" => $project->name,
"commits" => $project->countCommits(),
"pr_acceptance_rate" => intval($project->pr_acceptance_rate),
"stars" => intval($project->stars),
"forks" => intval($project->forks),
"faq_count" => count($project->getQuestions()),
"total_pull_requests" => $project->getTotalPullRequests()
);
}
$stats = array(
"owned_projects" => $projects,
"contributed_projects" => $this->getMyContributions()
);

return $stats;
}
}
19 changes: 19 additions & 0 deletions app/models/DeveloperQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Base\DeveloperQuery as BaseDeveloperQuery;


/**
* Skeleton subclass for performing query and update operations on the 'developer' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class DeveloperQuery extends BaseDeveloperQuery
{

} // DeveloperQuery
19 changes: 19 additions & 0 deletions app/models/Faq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Base\Faq as BaseFaq;


/**
* Skeleton subclass for representing a row from the 'faq' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class Faq extends BaseFaq
{

}
19 changes: 19 additions & 0 deletions app/models/FaqQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Base\FaqQuery as BaseFaqQuery;


/**
* Skeleton subclass for performing query and update operations on the 'faq' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class FaqQuery extends BaseFaqQuery
{

} // FaqQuery
19 changes: 19 additions & 0 deletions app/models/Issue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Base\Issue as BaseIssue;


/**
* Skeleton subclass for representing a row from the 'issue' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class Issue extends BaseIssue
{

}
19 changes: 19 additions & 0 deletions app/models/IssueQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use Base\IssueQuery as BaseIssueQuery;


/**
* Skeleton subclass for performing query and update operations on the 'issue' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class IssueQuery extends BaseIssueQuery
{

} // IssueQuery
Loading