diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 934b69b..e8234c0 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -63,10 +63,49 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -113,17 +152,17 @@
-
-
-
+
+
+
@@ -1074,20 +1113,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1097,20 +1122,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1153,9 +1164,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/www/protected/components/ProgramHelper.php b/www/protected/components/ProgramHelper.php
index aff1463..3e92aab 100644
--- a/www/protected/components/ProgramHelper.php
+++ b/www/protected/components/ProgramHelper.php
@@ -67,7 +67,7 @@ class ProgramHelper {
if (is_null($row))
$progDropDown[] = TbHtml::menuDivider();
else
- $progDropDown[] = array('label' => $row->attributes['Name'], 'url' => '/programs/' . $row->attributes['Name']);
+ $progDropDown[] = array('label' => $row->attributes['Name'], 'url' => '/programs/view/' . $row->attributes['Name']);
}
return $progDropDown;
}
diff --git a/www/protected/config/main.php b/www/protected/config/main.php
index 8d834d7..6a6fd14 100644
--- a/www/protected/config/main.php
+++ b/www/protected/config/main.php
@@ -65,8 +65,11 @@ return ArrayX::merge(
'rules' =>
[
'programs/' => 'programs/index',
- 'downloads/' => 'programs/', // Compatibility
+ 'programs/view/' => 'programs/view',
+
+ 'downloads/details.php' => 'programs/index', // Compatibility
'downloads/downloads.php' => 'programs/index', // Compatibility
+ 'downloads/' => 'programs/view', // Compatibility
'' => 'site/index',
diff --git a/www/protected/controllers/ProgramsController.php b/www/protected/controllers/ProgramsController.php
index a82cf64..f43f65e 100644
--- a/www/protected/controllers/ProgramsController.php
+++ b/www/protected/controllers/ProgramsController.php
@@ -50,8 +50,17 @@ class ProgramsController extends Controller
*/
public function actionView($id)
{
+ if (is_string($id))
+ {
+ $model = $this->loadModelByName($id);
+ }
+ else
+ {
+ $model = $this->loadModelByID($id);
+ }
+
$this->render('view',array(
- 'model'=>$this->loadModel($id),
+ 'model'=>$model,
));
}
@@ -156,7 +165,7 @@ class ProgramsController extends Controller
* @return Program the loaded model
* @throws CHttpException
*/
- public function loadModel($id)
+ public function loadModelByID($id)
{
$model=Program::model()->findByPk($id);
if ($model===null) {
@@ -165,6 +174,22 @@ class ProgramsController extends Controller
return $model;
}
+ /**
+ * Returns the data model based on the name of Program
+ * If the data model is not found, an HTTP exception will be raised.
+ * @param string $name the ID of the model to be loaded
+ * @return Program the loaded model
+ * @throws CHttpException
+ */
+ public function loadModelByName($name)
+ {
+ $model=Program::model()->findByAttributes(['Name' => $name]);
+ if ($model===null) {
+ throw new CHttpException(404,'The requested page does not exist.');
+ }
+ return $model;
+ }
+
/**
* Performs the AJAX validation.
* @param Program $model the model to be validated