Skip to content
This repository has been archived by the owner on Feb 28, 2018. It is now read-only.

Commit

Permalink
educational paths removed from the views
Browse files Browse the repository at this point in the history
This removes:

* the mandatory/optional sections
* cursus' news
* educational paths (from the views, they're still in the DB)
* old /profile/* URLs
* old (2012) courses URLs
  • Loading branch information
bfontaine committed Nov 29, 2014
1 parent d86c26d commit a7d8cba
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 410 deletions.
203 changes: 10 additions & 193 deletions controllers/cursus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,31 @@ function display_cursus() {
)
);

if ($cursus->countEducationalPaths() > 1) {
return display_cursus_with_multiple_educational_paths($cursus, $msg_str, $msg_type, $base_uri, $breadcrumb);
}

$path = $cursus->getEducationalPath();

if (!$path) {
return display_empty_cursus($cursus, $base_uri, $breadcrumb);
}

$courses = array(
's1' => array(
'mandatory' => array(),
'optional' => array()
),
's2' => array(
'mandatory' => array(),
'optional' => array()
)
's1' => array(),
's2' => array()
);

foreach ($path->getOptionalCourses() as $c) {

if ( $c->isDeleted()) {
continue;
}

$courses['s'.$c->getSemester()]['optional'] []= array(
'href' => $base_uri.$c->getShortName(),
'title' => $c->getShortName(),
'name' => $c->getName()
);
}

foreach ($path->getMandatoryCourses() as $c) {
foreach ($cursus->getCourses() as $c) {

if ( $c->isDeleted()) {
continue;
}

$courses['s'.$c->getSemester()]['mandatory'] []= array(
$courses['s'.$c->getSemester()] []= array(
'href' => $base_uri.$c->getShortName(),
'title' => $c->getShortName(),
'name' => $c->getName()
);
}

// sort courses (#302)
uasort($courses['s1']['optional'], 'cmpTitles');
uasort($courses['s1']['mandatory'], 'cmpTitles');
uasort($courses['s2']['optional'], 'cmpTitles');
uasort($courses['s2']['mandatory'], 'cmpTitles');

$news = get_news($cursus);
uasort($courses['s1'], 'cmpTitles');
uasort($courses['s2'], 'cmpTitles');

$other_links = array();

$moderation_bar = array();
$add_news = false;

$is_page_admin = (is_connected() && user()->isAdmin());

Expand All @@ -93,28 +59,21 @@ function display_cursus() {
'breadcrumbs' => $breadcrumb,

'keywords' => array(
$cursus->getName(), $cursus->getShortName(),
$path->getName(), $path->getShortName()
$cursus->getName(), $cursus->getShortName()
),
'description' => truncate_string($path->getDescription()),

'news' => tpl_news($news),
'description' => truncate_string($cursus->getDescription()),

'cursus' => array(
'id' => $cursus->getId(),
'name' => $cursus->getName(),
'introduction' => $cursus->getDescription(),

'path_name' => $path->getName(),

'courses' => $courses,
'news' => $news,
'other_links' => $other_links
),

// moderation
'moderation_bar' => $moderation_bar,
'add_news_button' => $add_news,

'scripts' => array(
array( 'href' => js_url( ($is_page_admin ? 'admin' : 'simple') . '-cursus') )
Expand All @@ -130,150 +89,8 @@ function display_cursus() {
return tpl_render('cursus/base.html', $tpl_cursus);
}

function display_cursus_with_multiple_educational_paths($cursus, $msg_str, $msg_type, $base_uri, $breadcrumb) {

$paths = $cursus->getEducationalPaths();
$tpl_paths = array();

foreach ($paths as $p) {

if ($p->isDeleted()) {
continue;
}

$tpl_paths []= array(
'name' => $p->getName(),
'title' => $p->getShortName(),
'href' => $base_uri.'parcours/'.$p->getShortName()
);
}

return tpl_render('cursus/multiple_paths.html', array(
'page' => array(
'title' => $cursus->getName(),
'breadcrumb' => $breadcrumb,
'message' => $msg_str,
'message_type' => $msg_type,

'keywords' => array( $cursus->getName(), $cursus->getShortName() ),
'description' => truncate_string($cursus->getDescription()),

'news' => false,

'cursus' => array(
'id' => $cursus->getId(),
'name' => $cursus->getName(),
'introduction' => $cursus->getDescription(),

'educational_paths' => $tpl_paths
),

'feeds' => array(
'atom' => $base_uri . 'flux.atom',
'rss2' => $base_uri . 'flux.rss'
)
)
));
}

function display_empty_cursus($cursus, $base_uri, $breadcrumb) {
return tpl_render('cursus/empty.html', array(
'page' => array(
'title' => $cursus->getName(),
'breadcrumb' => $breadcrumb,

'keywords' => array( $cursus->getName(), $cursus->getShortName() ),
'description' => truncate_string($cursus->getDescription()),

'cursus' => array(
'id' => $cursus->getId(),
'name' => $cursus->getName(),
'introduction' => $cursus->getDescription(),
),

'message' => 'Ce cursus n\'est lié à aucun parcours pédagogique.',
'message_type' => 'error',

'feeds' => array(
'atom' => $base_uri . 'flux.atom',
'rss2' => $base_uri . 'flux.rss'
)

)
));
}

// deprecated -> redirect to course page
function display_cursus_courses() {
$name = params('name');

$cursus = CursusQuery::create()->findOneByShortName($name);

if ($cursus == null) {
halt(NOT_FOUND);
}

$cursus_uri = cursus_url($cursus);

$breadcrumbs = array(
1 => array(
'href' => $cursus_uri,
'title' => $cursus->getName()
),
2 => array(
'href' => url(),
'title' => 'Matières'
)
);

$tpl_courses = array(
's1' => array(),
's2' => array()
);

$courses = CourseQuery::create()
->filterByDeleted(0)
->filterByCursus($cursus)
->find();

foreach ($courses as $c) {

$s = $c->getSemester();

if ($s !== 1 && $s !== 2) {
continue;
}

$tpl_courses['s'.$s] []= array(
'href' => course_url($cursus, $c),
'title' => $c->getName() . ' (' . $c->getShortName() . ')'
);

}

// natural sorting
uasort($tpl_courses['s1'], 'cmpTitles');
uasort($tpl_courses['s2'], 'cmpTitles');

$tpl_cursus = array(
'page' => array(
'title' => 'Matières ' . Lang\de($cursus->getName()),

'breadcrumbs' => $breadcrumbs,

'keywords' => array(
$cursus->getName(), $cursus->getShortName(), 'matières'
),
'description' => '',

'cursus' => array(
'id' => $cursus->getId(),
'href' => $cursus_uri,
'name' => $cursus->getName(),

'courses' => $tpl_courses
)
)
);

return tpl_render('cursus/courses.html', $tpl_cursus);
return redirect_to(cursus_url($name));
}
Loading

0 comments on commit a7d8cba

Please sign in to comment.