Skip to content

Commit

Permalink
Dev: Rename from 'object' to 'module'
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Oct 17, 2016
1 parent 13367f1 commit 19137cd
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 45 deletions.
4 changes: 2 additions & 2 deletions application/config/internal.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
// 'newDirMode'=>0777,
),
// TODO: Include modules dynamically
'ArrayQuestionObject' => array(
'class' => 'questions\ArrayQuestionObject\ArrayQuestionObjectModule',
'ArrayQuestionModule' => array(
'class' => 'questions\ArrayQuestionModule\ArrayQuestionModule',
),
),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace questions\ArrayQuestionModule;

// TODO: Auto-include
\Yii::import('application.core.questions.common.*');

/**
*
*/
class ArrayQuestionModule extends \QuestionModule
{
/**
* @todo Init automatically
* @var string
*/
public $controllerNamespace = 'questions\ArrayQuestionModule';

/**
*
* @return
*/
public function init()
{
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Array question module",
"name": "ArrayQuestionModule",
"description": "Some description of question module",
"version": "1.0.0",

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace questions\ArrayQuestionObject;
namespace questions\ArrayQuestionModule;

// TODO: Auto-include
\Yii::import('application.core.questions.common.controllers.*');
Expand All @@ -15,10 +15,22 @@ class AdminController extends \AdminBaseController
* @param int $surveyId
* @param int $qid
* @param int $gid
* @return
* @return void
*/
public function actionView($surveyId, $gid, $qid)
{
$this->renderSidebody($surveyId, $gid, $qid);
}

/**
* Edit question view
* @param int $surveyId
* @param int $qid
* @param int $gid
* @return void
*/
public function actionEdit($surveyId, $gid, $qid)
{
echo 'here';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Yii::import('application.core.questions.QuestionObjectBase', true);

/**
* Basic array question type
* Basic array question model
* @since 2016-10-06
* @author Olle Haerstedt
*/
class ArrayQuestionObject extends QuestionObjectBase
class ArrayQuestion extends QuestionObjectBase
{
/**
* @return
Expand Down Expand Up @@ -39,7 +39,7 @@ public function getFieldMap($fieldname)
'other' => 'N',
'help' => 'question help',
'type' => '?',
'extended_type' => 'ArrayQuestionObject',
'extended_type' => 'ArrayQuestionModule',
'database' => 'string(5)'
);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ public function renderSidebody($surveyId, $gid, $qid, $content = null)
$aData['showEditDefaultAnswers'] = $config->haveDefaultAnswers;
$aData['questionTypeDescription'] = $config->description;

// Reflection class needed to get module name
$r = new ReflectionClass($this->module);
$aData['editUrl'] = $this->createUrl(
$r->getShortName() . '/admin/edit',
array(
'surveyId' => $surveyId,
'gid' => $gid,
'qid' => $qid
)
);

$qshowstyle = "";

$aData['qshowstyle'] = $qshowstyle;
Expand Down
9 changes: 6 additions & 3 deletions application/helpers/QuestionObjectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public static function getAttributeNames($extendedType)
*/
private static function getInstance($extendedType)
{
$file = '/core/questions/' . $extendedType . '/' . $extendedType . '.php';
$modelFile = str_replace('Module', '', $extendedType);
$file = '/core/questions/' . $extendedType . '/models/' . $modelFile . '.php';
$fullFilePath = \Yii::app()->basePath . $file;

$fileExists = file_exists($fullFilePath);
Expand All @@ -120,7 +121,7 @@ private static function getInstance($extendedType)

require_once(\Yii::app()->basePath . $file);

$m = new \ReflectionMethod($extendedType, 'getInstance');
$m = new \ReflectionMethod($modelFile, 'getInstance');
return $m->invoke(null);
}

Expand Down Expand Up @@ -151,9 +152,11 @@ public static function redirectQuestionView($surveyId, \Question $question)
*/
public static function updateControllerMap(\CWebApplication $app)
{
/*
$app->controllerMap = array(
'ArrayQuestionObjectAdminController' => 'application.core.questions.ArrayQuestionObject.ArrayQuestionObjectAdminController',
'ArrayQuestionObjectAdminController' => 'application.core.questions.ArrayQuestionModule.ArrayQuestionObjectAdminController',
'TestQuestionObjectAdminController' => 'application.core.questions.TestQuestionObject.TestQuestionObjectAdminController'
);
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

<!-- Edit button -->
<?php if(Permission::model()->hasSurveyPermission($surveyid,'surveycontent','update')): ?>
<a class="btn btn-default" href='<?php echo $this->createUrl("/admin/questions/sa/editquestion/surveyid/".$surveyid."/gid/".$gid."/qid/".$qid); ?>' role="button">
<a class="btn btn-default" href='<?php echo $editUrl; ?>' role="button">
<span class="icon-edit"></span>
<?php eT("Edit");?>
</a>
Expand Down

0 comments on commit 19137cd

Please sign in to comment.