<?php
// Dans un controller
+
namespace App\Controller;
use App\Controller\AppController;
use Cake\Network\Http\Client;
+class ProjectController extends AppController {
-class ProjectController extends AppController
-{
- public function index($id = null)
- {
- try {
+ public function index($id = null) {
+ try {
$http = new Client();
- $response = $http->get(MANIVELLE_URL."request/".$this->request->query('id'),[],['type'=>'json']);
- $software = $response->body('json_decode');
- }catch (Exception $exception){
- $this->log(var_export($exception,true),"debug");
- }
- $this->set('project',$software->software);
- }
-
- public function request(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
-
- public function alternative(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
-
- public function works(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
-
- public function reviews(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
- public function users(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
-
- public function creator(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
- public function providers(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
-
- public function screens(array $data)
- {
- //$data contains forge name, forge api url, project name,
- }
-}
\ No newline at end of file
+ $response = $http->get(MANIVELLE_URL . "request/" . $this->request->query('id'), [], ['type' => 'json']);
+
+ $softwareAndRelationshipUsersOf = $response->body('json_decode');
+ $RelationshipsUsersOf = $softwareAndRelationshipUsersOf->RelationshipsUsersOf;
+ $software = $softwareAndRelationshipUsersOf->software;
+ } catch (Exception $exception) {
+ $this->log(var_export($exception, true), "debug");
+ }
+
+ $this->set('project',$software);
+ $this->set('usersOf', $RelationshipsUsersOf);
+ }
+
+ public function request(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+ public function alternative(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+ public function works(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+ public function reviews(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+ public function users(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+ public function creator(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+ public function providers(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+ public function screens(array $data) {
+ //$data contains forge name, forge api url, project name,
+ }
+
+}
</div>
<?php endif;?>
-<?php if (!isset($entity) ) : ?>
+
+
+<?php if (isset($user) ) : ?>
<ul class="list-unstyled">
<li>
<div id="minimal-entity" class="col-sm-9 col-md-3">
- <h3>
- <?= $this->Html->link( __("Montepllier"),
- ['controller' => 'Entity', 'action' => 'index','?' => ['name' => '$entity->name', 'description' => '$entity->description']],
- ['escape' => false] ) ?>
- </h3>
- <?= $this->Html->link( $this->Html->image("logos/entity.png",["alt"=>"[entityName]","class"=>"img-responsive"]),
- ['controller' => 'Entity', 'action' => 'i','?' => ['name' => '$entity->name', 'description' => '$entity->description']],
- ['escape' => false] ) ?>
-
- </div>
- </li>
- <li>
- <div id="minimal-entity" class="col-sm-9 col-md-3">
-
- <h3>
- <?= $this->Html->link( __("Montepllier"),
- ['controller' => 'Entity', 'action' => 'index','?' => ['name' => '$entity->name', 'description' => '$entity->description']],
- ['escape' => false] ) ?>
- </h3>
- <?= $this->Html->link( $this->Html->image("logos/entity.png",["alt"=>"[entityName]","class"=>"img-responsive"]),
- ['controller' => 'Entity', 'action' => 'i','?' => ['name' => '$entity->name', 'description' => '$entity->description']],
- ['escape' => false] ) ?>
+ <h3>
+ <?= $this->Html->link( __($user->username),
+ ['controller' => 'Entity', 'action' => 'index','?' => ['name' => $user->username, 'description' => $user->description]],
+ ['escape' => false] ) ?>
+ </h3>
+ <?= $this->Html->link( $this->Html->image("logos/entity.png",["alt"=>$user->username,"class"=>"img-responsive"]),
+ ['controller' => 'Entity', 'action' => 'i','?' => ['name' => $user->username, 'description' => $user->description]],
+ ['escape' => false] ) ?>
-
- </div>
+ </div>
</li>
</ul>
?>
-<section class="row">
+<?php if (!empty( $project->relationships ) ): ?>
+<section class="row">
<h2>
- <?= __("Alternative to ")?> <?= __("[ProjectName]")?>
+ <?= __("Alternative to ")?> <?= __($project->softwarename)?>
</h2>
-
-
- <ul class="list-unstyled">
- <li>
- <?= $this->element("ProjectPage/softwareSummary")?>
- </li>
- <li>
- <?= $this->element("ProjectPage/softwareSummary")?>
- </li>
-
+ <ul class=" list-unstyled ">
+ <?php foreach ($project->relationships as $screenshot) : ?>
+ <?php if ($screenshot->cd =='AlternativeTo') : ?>:
+ <li>
+ <?php echo $this->cell('SoftwareSummary',[$screenshot->_joinData->recipient_id])->render('../../Element/ProjectPage/softwareSummary')?>
+ </li>
+ <?php endif ;?>
+ <?php endforeach; ?>
</ul>
-
-
-
-</section>
\ No newline at end of file
+</section>
+<?php endif; ?>
\ No newline at end of file
</section>
<?php endif; ?>
+<?php if (!empty( $project->reviews ) ): ?>
+<section class="row">
+ <div class="col-md-5">
+
+ <ol class=" list-unstyled">
+ <?php foreach ($project->reviews as $review) : ?>
+ <h3> <?php echo $review->title ;?> </h3>
+
+ <p>
+ <h3> <?php echo $review->comment ;?> </h3>
+ </p>
+ <?php endforeach; ?>
+
+ <li>
+ Mr. TITI
+ </li>
+ <li>
+ Today ?
+ </li>
+ <li>
+ <div class="ratingStar">
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
+ <span class="glyphicon glyphicon-star" aria-hidden="true"></span>
+ </div>
+ </li>
+ </ol>
+
+ <p class="comment">
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+ </p>
+ </div>
+</section>
+<?php endif; ?>
\ No newline at end of file
*/
?>
-
-<section class="row">
+<?php if (!empty( $project->screenshots ) ) : ?>
+<section class="row">
<h2>
- <?= __("Screens of ")?> <?= __("[ProjectName]")?>
+ <?= __("Screens of ")?> <?= __($project->softwarename)?>
</h2>
-
-
- <ul class=" list-unstyled ">
- <li>
- <div id="screenShot" class="col-sm-9 col-md-2">
- <?= $this->Html->image('logos/screenshot.png', ['alt' => 'screenshot [ProjectName]','class' => 'img-responsive']) ?>
- </div>
- </li>
- <li>
- <div id="screenShot" class="col-sm-9 col-md-2">
- <?= $this->Html->image('logos/screenshot.png', ['alt' => 'screenshot [ProjectName]','class' => 'img-responsive']) ?>
- </div>
- </li>
+ <ul class=" list-unstyled ">
+ <?php foreach ($project->screenshots as $screenshot): ?>
<li>
<div id="screenShot" class="col-sm-9 col-md-2">
- <?= $this->Html->image('logos/screenshot.png', ['alt' => 'screenshot [ProjectName]','class' => 'img-responsive']) ?>
+ <?= $this->Html->image(WEBROOT_SERVER.$project->logo_directory.DS.$project->photo, ['alt' => $screenshot->photo,'class' => 'img-responsive']) ?>
</div>
</li>
+ <?php endforeach; ?>
</ul>
-
-
-
-</section>
\ No newline at end of file
+</section>
+<?php endif; ?>
\ No newline at end of file
* and open the template in the editor.
*/
?>
-<div class="row">
+<?php if (!empty( $serviceProviders ) ): ?>
+<section class="row">
<h2>
- <?= __("Service providers for ")?> <?= __("[ProjectName]")?>
+ <?= __("Users of ")?> <?= __($project->softwarename)?>
</h2>
- <ul class="list-unstyled">
+ <ul class=" list-unstyled ">
+ <?php foreach ($serviceProviders as $serviceProvider) : ?>
+
<li>
- <?= $this->element("Entity/entitySummary") ?>
- </li>
+ <?php echo $this->cell('UserSummary',[$user->user_id])->render('../../Element/Entity/entitySummary')?>
+ </li>
+
+ <?php endforeach; ?>
</ul>
-
-</div>
\ No newline at end of file
+</section>
+<?php endif; ?>
\ No newline at end of file
?>
-<div class="row">
+<?php if (!empty( $usersOf ) ): ?>
+<section class="row">
<h2>
- <?= __("Users of ")?> <?= __("[ProjectName]")?>
+ <?= __("Users of ")?> <?= __($project->softwarename)?>
</h2>
-
- <?= $this->element("Entity/entitySummary") ?>
-
-
-</div>
\ No newline at end of file
+ <ul class=" list-unstyled ">
+ <?php foreach ($usersOf as $user) : ?>
+
+ <li>
+ <?php echo $this->cell('UserSummary',[$user->user_id])->render('../../Element/Entity/entitySummary')?>
+ </li>
+
+ <?php endforeach; ?>
+ </ul>
+</section>
+<?php endif; ?>
\ No newline at end of file
*/
?>
-
-<section class="row">
+<?php if (!empty( $project->relationships ) ): ?>
+<section class="row">
<h2>
- <?= __("Works well with ")?> <?= __("[ProjectName]")?>
+ <?= __("Works well with ")?> <?= __($project->softwarename)?>
</h2>
-
-
- <ul class="list-unstyled">
- <li>
- <?= $this->element("ProjectPage/softwareSummary")?>
- </li>
- <li>
- <?= $this->element("ProjectPage/softwareSummary")?>
- </li>
- <li>
- <?= $this->element("ProjectPage/softwareSummary")?>
- </li>
-
+ <ul class=" list-unstyled ">
+ <?php foreach ($project->relationships as $screenshot) : ?>
+ <?php if ($screenshot->cd =='WorksWellWith') : ?>
+ <li>
+ <?php echo $this->cell('SoftwareSummary',[$screenshot->_joinData->recipient_id])->render('../../Element/ProjectPage/softwareSummary')?>
+ </li>
+ <?php endif ;?>
+ <?php endforeach; ?>
</ul>
-
-
-
-</section>
\ No newline at end of file
+</section>
+<?php endif; ?>
\ No newline at end of file
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-1 main">
<div class="row">
- <?= $this->element("ProjectPage/overview") ?>
+ <?= $this->element("ProjectPage/overview",['project' => $project]) ?>
</div>
<div class="row">
</div>
<div class="row">
- <?= $this->element("ProjectPage/screenShotsList")?>
- <?= $this->Html->link( "All screenshots of [ProjectName]",
- ['controller' => 'Project', 'action' => 'screens','?' => ['id' => '']],
+ <?= $this->element("ProjectPage/screenShotsList" , ['project' => $project])?>
+ <?= $this->Html->link( "All screenshots of ".$project->softwarename,
+ ['controller' => 'Project', 'action' => 'screens','?' => ['id' => $project->id]],
['escape' => false] ) ?>
</div>
<div class="row">
- <?= $this->element("ProjectPage/reviews")?>
- <?= $this->Html->link( "All reviews of [ProjectName]",
+ <?= $this->element("ProjectPage/reviews" , ['project' => $project])?>
+ <?= $this->Html->link( "All reviews of $project->softwarename",
['controller' => 'Project', 'action' => 'reviews','?' => ['id' => '']],
['escape' => false] ) ?>
</div>
<div class="row">
- <?= $this->element("ProjectPage/serviceProviders")?>
- <?= $this->Html->link( "All service providers of [ProjectName]",
- ['controller' => 'Project', 'action' => 'providers','?' => ['id' => '']],
+ <?= $this->element("ProjectPage/serviceProviders" , ['serviceProviders'=>$serviceProviders,'project' => $project])?>
+ <?= $this->Html->link( "All service providers of $project->softwarename",
+ ['controller' => 'Project', 'action' => 'providers','?' => ['id' => $project->id]],
['escape' => false] ) ?>
</div>
<div class="row">
- <?= $this->element("ProjectPage/usersOfProject")?>
- <?= $this->Html->link( "All users of [ProjectName]",
- ['controller' => 'Project', 'action' => 'users','?' => ['id' => '']],
+ <?= $this->element("ProjectPage/usersOfProject" , ['userOf' => $usersOf,'project' => $project])?>
+ <?= $this->Html->link( "All users of $project->softwarename",
+ ['controller' => 'Project', 'action' => 'users','?' => ['id' => $project->id]],
['escape' => false] ) ?>
</div>
<div class="row">
- <?= $this->element("ProjectPage/alternativeTo")?>
+ <?= $this->element("ProjectPage/alternativeTo" , ['project' => $project])?>
<?= $this->Html->link( "All alternatives to [ProjectName]",
- ['controller' => 'Project', 'action' => 'alternative','?' => ['id' => '']],
+ ['controller' => 'Project', 'action' => 'alternative','?' => ['id' => $project->id]],
['escape' => false] ) ?>
</div>
<div class="row">
- <?= $this->element("ProjectPage/worksWellWith")?>
- <?= $this->Html->link( "All softwares works well with [ProjectName]",
- ['controller' => 'Project', 'action' => 'works','?' => ['id' => '']],
+ <?= $this->element("ProjectPage/worksWellWith" , ['project' => $project])?>
+ <?= $this->Html->link( "All softwares works well with $project->softwarename",
+ ['controller' => 'Project', 'action' => 'works','?' => ['id' => $project->id]],
['escape' => false] ) ?>
</div>
--- /dev/null
+<?php
+namespace App\View\Cell;
+use Cake\Network\Http\Client;
+
+use Cake\View\Cell;
+
+/**
+ * SoftwareSummary cell
+ */
+class SoftwareSummaryCell extends Cell
+{
+
+ /**
+ * List of valid options that can be passed into this
+ * cell's constructor.
+ *
+ * @var array
+ */
+ protected $_validCellOptions = [];
+
+ /**
+ * Default display method.
+ *
+ * @return void
+ */
+ public function display($id=null)
+ {
+ try {
+ $http = new Client();
+ $response = $http->get(MANIVELLE_URL."request/".$id,[],['type'=>'json']);
+ $softwareAndRelationshipUsersOf = $response->body('json_decode');
+ $RelationshipsUsersOf = $softwareAndRelationshipUsersOf->RelationshipsUsersOf;
+ $software = $softwareAndRelationshipUsersOf->software;
+ }catch (Exception $exception){
+ $this->log(var_export($exception,true),"debug");
+ }
+ $this->set('project',$software);
+ $this->set('usersOf', $RelationshipsUsersOf);
+ }
+}
--- /dev/null
+<?php
+namespace App\View\Cell;
+
+use Cake\View\Cell;
+use Cake\Network\Http\Client;
+
+/**
+ * UserSummary cell
+ */
+class UserSummaryCell extends Cell
+{
+
+ /**
+ * List of valid options that can be passed into this
+ * cell's constructor.
+ *
+ * @var array
+ */
+ protected $_validCellOptions = [];
+
+ /**
+ * Default display method.
+ *
+ * @return void
+ */
+ public function display($id)
+ {
+ try {
+ $http = new Client();
+ $response = $http->get(MANIVELLE_URL."users/view/".$id,[],['type'=>'json']);
+ $user = $response->body('json_decode');
+ }catch (Exception $exception){
+ $this->log(var_export($exception,true),"debug");
+ }
+ $this->set('user',$user->user);
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\View\Cell;
+
+use App\View\Cell\SoftwareSummaryCell;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\View\Cell\SoftwareSummaryCell Test Case
+ */
+class SoftwareSummaryCellTest extends TestCase
+{
+
+ /**
+ * Request mock
+ *
+ * @var \Cake\Network\Request|\PHPUnit_Framework_MockObject_MockObject
+ */
+ public $request;
+
+ /**
+ * Response mock
+ *
+ * @var \Cake\Network\Response|\PHPUnit_Framework_MockObject_MockObject
+ */
+ public $response;
+
+ /**
+ * Test subject
+ *
+ * @var \App\View\Cell\SoftwareSummaryCell
+ */
+ public $SoftwareSummary;
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $this->request = $this->getMock('Cake\Network\Request');
+ $this->response = $this->getMock('Cake\Network\Response');
+ $this->SoftwareSummary = new SoftwareSummaryCell($this->request, $this->response);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->SoftwareSummary);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test display method
+ *
+ * @return void
+ */
+ public function testDisplay()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\View\Cell;
+
+use App\View\Cell\UserSummaryCell;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\View\Cell\UserSummaryCell Test Case
+ */
+class UserSummaryCellTest extends TestCase
+{
+
+ /**
+ * Request mock
+ *
+ * @var \Cake\Network\Request|\PHPUnit_Framework_MockObject_MockObject
+ */
+ public $request;
+
+ /**
+ * Response mock
+ *
+ * @var \Cake\Network\Response|\PHPUnit_Framework_MockObject_MockObject
+ */
+ public $response;
+
+ /**
+ * Test subject
+ *
+ * @var \App\View\Cell\UserSummaryCell
+ */
+ public $UserSummary;
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $this->request = $this->getMock('Cake\Network\Request');
+ $this->response = $this->getMock('Cake\Network\Response');
+ $this->UserSummary = new UserSummaryCell($this->request, $this->response);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->UserSummary);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test display method
+ *
+ * @return void
+ */
+ public function testDisplay()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}