-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
877 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.question-list { | ||
margin-top: 15px; | ||
} | ||
|
||
.question-single { | ||
padding-bottom: 5px; | ||
margin-bottom: 5px; | ||
border-bottom: 1px solid #ddd; | ||
} | ||
|
||
.question-single .question-single-title h3 { | ||
padding: 5px 0; | ||
margin: 0; | ||
} | ||
|
||
.question-single .question-single-time {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* Pi Engine (http://pialog.org) | ||
* | ||
* @link http://code.pialog.org for the Pi Engine source repository | ||
* @copyright Copyright (c) Pi Engine http://pialog.org | ||
* @license http://pialog.org/license.txt New BSD License | ||
*/ | ||
|
||
/** | ||
* @author Hossein Azizabadi <[email protected]> | ||
*/ | ||
namespace Module\Ask\Api; | ||
|
||
use Pi; | ||
use Pi\Application\Api\AbstractApi; | ||
|
||
/* | ||
* Pi::api('project', 'ask')->getProject($parameter, $type); | ||
* Pi::api('project', 'ask')->getProjectList(); | ||
* Pi::api('project', 'ask')->canonizeProject($project); | ||
*/ | ||
|
||
class Project extends AbstractApi | ||
{ | ||
public function getProject($parameter, $type = 'id') | ||
{ | ||
// Get project | ||
$project = Pi::model('project', $this->getModule())->find($parameter, $type); | ||
$project = $this->canonizeProject($project); | ||
return $project; | ||
} | ||
|
||
public function getProjectList() | ||
{ | ||
$list = array(); | ||
$where = array('status' => 1); | ||
$order = array('time_create DESC', 'id DESC'); | ||
$select = Pi::model('project', $this->getModule())->select()->where($where)->order($order); | ||
$rowset = Pi::model('project', $this->getModule())->selectWith($select); | ||
foreach ($rowset as $row) { | ||
$list[$row->id] = $this->canonizeProject($row); | ||
} | ||
return $list; | ||
} | ||
|
||
public function canonizeProject($project) | ||
{ | ||
// Check | ||
if (empty($project)) { | ||
return ''; | ||
} | ||
// boject to array | ||
$project = $project->toArray(); | ||
// Set times | ||
$project['time_create_view'] = _date($project['time_create']); | ||
$project['time_update_view'] = _date($project['time_update']); | ||
// Set text_description | ||
$project['text_description'] = Pi::service('markup')->render($project['text_description'], 'html', 'html'); | ||
// Set question url | ||
$project['projectUrl'] = Pi::url(Pi::service('url')->assemble('ask', array( | ||
'module' => $this->getModule(), | ||
'controller' => 'project', | ||
'slug' => $project['slug'], | ||
))); | ||
// return question | ||
return $project; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Pi Engine (http://pialog.org) | ||
* | ||
* @link http://code.pialog.org for the Pi Engine source repository | ||
* @copyright Copyright (c) Pi Engine http://pialog.org | ||
* @license http://pialog.org/license.txt New BSD License | ||
*/ | ||
|
||
/** | ||
* @author Hossein Azizabadi <[email protected]> | ||
*/ | ||
namespace Module\Ask\Controller\Front; | ||
|
||
use Pi; | ||
use Pi\Mvc\Controller\ActionController; | ||
use Pi\Paginator\Paginator; | ||
use Zend\Db\Sql\Predicate\Expression; | ||
|
||
class ProjectController extends IndexController | ||
{ | ||
public function indexAction() | ||
{ | ||
// Get info from url | ||
$module = $this->params('module'); | ||
$slug = $this->params('slug'); | ||
// Get config | ||
$config = Pi::service('registry')->config->read($module); | ||
// Get topic information from model | ||
$project = Pi::api('project', 'ask')->getProject($slug, 'slug'); | ||
// Check slug set | ||
if (empty($project) || $project['status'] != 1) { | ||
$this->getResponse()->setStatusCode(404); | ||
$this->terminate(__('Project not set.'), '', 'error-404'); | ||
$this->view()->setLayout('layout-simple'); | ||
return; | ||
} | ||
// Set question info | ||
$where = array('status' => 1, 'type' => 'Q', 'project_id' => $project['id']); | ||
// Set paginator info | ||
$template = array( | ||
'controller' => 'index', | ||
'action' => 'index', | ||
); | ||
// Get question List | ||
$questions = $this->askList($where); | ||
// Get paginator | ||
$paginator = $this->askPaginator($template, $where); | ||
// Set view | ||
$this->view()->setTemplate('question-list'); | ||
$this->view()->assign('questions', $questions); | ||
$this->view()->assign('paginator', $paginator); | ||
$this->view()->assign('project', $project); | ||
$this->view()->assign('config', $config); | ||
$this->view()->assign('title', __('List of all questions')); | ||
|
||
} | ||
} |
Oops, something went wrong.