Skip to content

Instantly share code, notes, and snippets.

@listenrightmeow
Created May 1, 2012 20:38
Show Gist options
  • Save listenrightmeow/2571175 to your computer and use it in GitHub Desktop.
Save listenrightmeow/2571175 to your computer and use it in GitHub Desktop.
List module
<?php defined('SYSPATH') or die('No direct access allowed.');
/*
* Author : Mike Dyer
* @Anchor.php
*
* @params :
* uri : anchor location
* title : anchor text
* attrs : valid anchor attributes
*
*/
if(!isset($item) && !empty($item)) return 0;
$links = I18n::load('en-links');
$messages = I18n::load('en-us');
$attrs = isset($attributes) ? HTML::attributes($attrs) : NULL;
echo HTML::anchor($links[$item], $messages[$item], $attrs);
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8"/>
<title>Wendy's Fresh Pic'd Summer</title>
<link rel="stylesheet" href="" />
<script src="" type="text/javascript"></script>
</head>
<body>
<header>
<?= HTML::anchor($links['logo'], 'LOGO') ?>
<h1><?php echo $messages['site.title']; ?></h1>
<nav>
<?php
echo View::factory('modules/list', array(
'items' => array( 'nav.create', 'nav.find', 'nav.help', 'nav.home' ),
'list_id' => 'primary',
'list_class' => 'UTL',
'render' => array(
'path' => 'modules/anchor',
'attrs' => array(
'data-href' => '#test',
),
)
))->render();
echo View::factory('modules/list', array(
'items' => array( 'nav.invite', 'nav.share' ),
'list_id' => 'social',
'list_class' => 'UTL',
'render' => array(
'path' => 'modules/anchor',
)
))->render();
?>
</nav>
</header>
<?php
/*
* Author : Mike Dyer
* @List.php
*
* @params :
* list_type : Defaults to UL if not provided
* list_class : List class
* list_id : List id
* list_attributes : Iterate over associative array for valid element attributes
*
*/
if(!isset($items) && !empty($items)) return 0;
$item_class = isset($item_class) ? ' class="'.$item_class.'"' : '';
$list_type = isset($list_type) ? $list_type : 'ul';
$list_class = isset($list_class) ? ' class="'.$list_class.'"' : '';
$list_id = isset($list_id) ? ' id="'.$list_id.'"' : '';
$list_attr = '';
if(isset($list_attributes)) {
foreach ($list_attributes as $key => $attr) {
$list_attr .= ' '. $key . '="' . $attr .'"';
}
}
if(isset($render)) {
$attrs = isset($render['attrs']) ? $render['attrs'] : NULL;
}
?>
<?php
echo '<' . $list_type . $list_class . $list_id . $list_attr . '>';
foreach ($items as $key => $item) {
if(isset($render)){
$data = View::factory($render['path'], array(
'item' => $item,
'attrs' => $attrs,
));
$item = $data->render();
}
echo '<li' . $item_class . '>'. $item .'</li>';
}
echo '</' . $list_type . '>';
?>
<?php defined('SYSPATH') or die('No direct access allowed.');
return array(
'nav.create' => 'Create',
'nav.find' => 'Find a Wendy&#39;s&#42;',
'nav.help' => 'Help',
'nav.home' => 'Home',
'nav.invite' => 'Invite a friend',
'nav.share' => 'Share',
'site.title' => 'Fresh Pic&#39;d Summer',
)
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment