0% found this document useful (0 votes)
8 views20 pages

SRC 3

Uploaded by

samyakmehta1234
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views20 pages

SRC 3

Uploaded by

samyakmehta1234
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

lectures/3/src/mvc/7/html/index.

php
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.

<?php
require_once('../includes/[Link]');
// determine which page to render
if (isset($_GET['page']))
$page = $_GET['page'];
else
$page = 'index';
// show page
switch ($page)
{
case 'index':
render('templates/header', array('title' => 'CSCI S-75'));
render('index');
render('templates/footer');
break;
case 'lectures':
render('templates/header', array('title' => 'Lectures'));
render('lectures');
render('templates/footer');
break;
case 'lecture':
if (isset($_GET['n']))
{
render('templates/header', array('title' => 'Lecture ' . $_GET['n']));
render('lecture', array('n' => $_GET['n']));
render('templates/footer');
}
break;
}
?>

lectures/3/src/mvc/7/includes/[Link]
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.

<?php
/**
* Renders template.
*
* @param array $data
*/
function render($template, $data = array())
{
$path = __DIR__ . '/../views/' . $template . '.php';
if (file_exists($path))
{
extract($data);
require($path);
}
}
?>

lectures/3/src/mvc/7/README
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.

mvc/7/README
David J. Malan
malan@[Link]
Improves upon mvc/6 by introducing search engine-friendly URLs via mod_rewrite.
html/
[Link] - controller
includes/
[Link] - helper functions
views/
[Link] - homepage for the course
[Link] - a lecture
[Link] - a list of lectures
templates/
[Link] - pages' footer
[Link] - pages' header

lectures/3/src/mvc/7/views/[Link]
1. <ul>
2.
<li><a href="lectures">Lectures</a></li>
3.
<li><a href="[Link]
4. </ul>

lectures/3/src/mvc/7/views/[Link]
1. <ul>
2.
<li><a href="[Link] echo $n ?>/slides<?php echo $n ?>.pdf">Slides</a></li>
3.
<li><a href="[Link] echo $n ?>/lecture<?php echo $n ?>.mp4">Video</a></li>
4. </ul>

lectures/3/src/mvc/7/views/[Link]
1. <ul>
2.
<li><a href="lecture/0">Lecture 0</a></li>
3.
<li><a href="lecture/1">Lecture 1</a></li>
4. </ul>

lectures/3/src/mvc/7/views/templates/[Link]
1.
</body>
2. </html>

lectures/3/src/mvc/7/views/templates/[Link]
1. <!DOCTYPE html>
2.
3. <html>
4.
<head>
5.
<meta name="viewport" content="width=device-width">
6.
<title><?php echo htmlspecialchars($title) ?></title>
7.
</head>
8.
<body>
9.
<h1><?php echo htmlspecialchars($title) ?></h1>

lectures/3/src/mvc/8/application/controllers/[Link]
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.

<?php
class Homepage extends CI_Controller {
public function index()
{
$this->load->view('templates/header', array('title' => 'CS164'));
$this->load->view('homepage/index');
$this->load->view('templates/footer');
}
public function lectures()
{
$this->load->view('templates/header', array('title' => 'Lectures'));
$this->load->view('homepage/lectures');
$this->load->view('templates/footer');
}
public function lecture($n)
{
$this->load->view('templates/header', array('title' => 'Lecture ' . $n));
$this->load->view('homepage/lecture', array('n' => $n));
$this->load->view('templates/footer');
}
}
?>

lectures/3/src/mvc/8/application/views/homepage/[Link]
1. <ul>
2.
<li><a href="lectures">Lectures</a></li>
3.
<li><a href="[Link]
4. </ul>

lectures/3/src/mvc/8/application/views/homepage/[Link]
1. <ul>
2.
<li><a href="[Link] echo $n ?>/slides<?php echo $n ?>.pdf">Slides</a></li>
3.
<li><a href="[Link] echo $n ?>/lecture<?php echo $n ?>.mp4">Video</a></li>
4. </ul>

lectures/3/src/mvc/8/application/views/homepage/[Link]
1. <ul>
2.
<li><a href="lecture/0">Lecture 0</a></li>
3.
<li><a href="lecture/1">Lecture 1</a></li>
4. </ul>

lectures/3/src/mvc/8/application/views/templates/[Link]
1.
</body>
2. </html>

lectures/3/src/mvc/8/application/views/templates/[Link]
1. <!DOCTYPE html>
2.
3. <html>
4.
<head>
5.
<meta name="viewport" content="width=device-width">
6.
<title><?php echo htmlspecialchars($title) ?></title>
7.
</head>
8.
<body>
9.
<h1><?php echo htmlspecialchars($title) ?></h1>

lectures/3/src/mvc/8/README
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.

mvc/9/README
David J. Malan
malan@[Link]
Improves upon mvc/8 by introducing a framework (CodeIgniter).
application/
config/
[Link] - CodeIgniter's configuration
[Link] - default routes
...
controllers/
[Link] - application controller
views/
homepage/
[Link] - a homepage for the course
[Link] - a lecture
[Link] - a list of lectures
templates/
[Link] - pages' footer
[Link] - pages' header
[Link] - front controller
system/
...

lectures/3/src/xml/[Link]
1. <!DOCTYPE html>
2.
3. <html>
4.
<head>
5.
<title>My Lecture Reader</title>
6.
</head>
7.
<body>
8.
<h1>CSCI S-75</h1>
9.
<ul>
10.
<?
11.
12.
$dom = simplexml_load_file("[Link]");
13.
foreach ($dom->xpath("/lectures/lecture") as $lecture)
14.
{
15.
print "<li>";
16.
print $lecture->title;
17.
print "</li>";
18.
}
19.
20.
?>
21.
</ul>
22.
</body>
23. </html>

lectures/3/src/xml/[Link]
1. <?xml version="1.0"?>
2. <lectures>
3.
<lecture number="0">
4.
<title>HTTP</title>
5.
<dates>Mon 6/25</dates>
6.
<resources>
7.
<resource name="Slides">
8.
<format path="[Link] label="PDF" />
9.
</resource>
10.
<resource name="Syllabus">
11.
<format path="[Link] label="PDF" />
12.
</resource>
13.
</resources>
14.
</lecture>
15.
<lecture number="1">
16.
<title>PHP</title>
17.
<dates>Wed 6/27</dates>
18.
<resources>
19.
<resource name="Slides">
20.
<format path="[Link] label="PDF" />
21.
</resource>
22.
<resource name="Source Code">
23.
<format path="[Link] label="index" />
24.
<format path="[Link] label="PDF" />
25.
<format path="[Link] label="ZIP" />
26.
</resource>
27.
</resources>
28.
</lecture>
29.
<lecture number="2">
30.
<title>PHP, Continued</title>
31.
<dates>Mon 7/2</dates>
32.
<resources>
33.
<resource name="Slides">
34.
<format path="[Link] label="PDF" />
35.
</resource>
36.
<resource name="Source Code">
37.
<format path="[Link] label="index" />
38.
<format path="[Link] label="PDF" />
39.
<format path="[Link] label="ZIP" />
40.
</resource>
41.
</resources>
42.
</lecture>
43.
<lecture number="3">
44.
<title>XML</title>
45.
<dates>Mon 7/9</dates>
46.
<resources>
47.
<resource name="Slides">
48.
<format path="[Link] label="PDF" />

lectures/3/src/xml/[Link]
49.
</resource>
50.
</resources>
51.
</lecture>
52. </lectures>

lectures/3/src/xml/[Link]
1. <!DOCTYPE html>
2.
3. <html>
4.
<head>
5.
<title>My RSS Reader</title>
6.
</head>
7.
<body>
8.
<h1>New York Times Technology</h1>
9.
<ul>
10.
<?
11.
12.
$dom = simplexml_load_file("[Link]
13.
foreach ($dom->channel->item as $item)
14.
{
15.
print "<li>";
16.
print "<a href='{$item->link}'>";
17.
print $item->title;
18.
print "</a>";
19.
print "</li>";
20.
}
21.
22.
?>
23.
</ul>
24.
</body>
25. </html>

lectures/3/src/xml/[Link]
1. <!DOCTYPE html>
2.
3. <html>
4.
<head>
5.
<title>My RSS Reader</title>
6.
</head>
7.
<body>
8.
<h1>New York Times Technology</h1>
9.
<ul>
10.
<?
11.
12.
$dom = simplexml_load_file("[Link]
13.
foreach ($dom->channel->item as $item)
14.
{
15.
$time = strtotime($item->pubDate);
16.
$date = date("M j, Y", $time);
17.
print "<li>";
18.
print "<a href='{$item->link}'>";
19.
print $item->title;
20.
print "</a>";
21.
print " (" . $date . ")";
22.
print "</li>";
23.
}
24.
25.
?>
26.
</ul>
27.
</body>
28. </html>

You might also like