Removed Smarty Functions

* Smarty is no longer the default templating engine for PICKLES, so I decided to remove the custom functions.

 * Most of the good functions are available at http://github.com/joshtronic/smarty-functions

 * May re-add these to another location and port them over to be functions that can be used outside of Smarty.
This commit is contained in:
Josh Sherman 2010-03-11 20:15:33 -05:00
parent 38e0479ee8
commit aefeb1dca5
6 changed files with 0 additions and 252 deletions

View file

@ -1,25 +0,0 @@
<?php
function smarty_function_age($params, &$smarty) {
if (empty($params['dob'])) {
$smarty->trigger_error('assign: missing \'dob\' parameter');
}
else {
// Breaks the date apart
list($dob_year, $dob_month, $dob_day) = split('-', $params['dob'], 3);
// Determines the age regardless of the day
$age = date('Y') - $dob_year;
// If today's month day is less than the dob decrement
if (date('md') < $dob_month . $dob_day) {
$age--;
}
return $age;
}
}
?>

View file

@ -1,21 +0,0 @@
<?php
function smarty_function_contact_form($params, &$smarty) {
$form = '
<form action="/contact/send" method="post" class="contact_form">
Email:<br />
<input name="email" title="required" class="contact_input" /><br /><br />
Subject:<br />
<input name="subject" title="required" class="contact_input" /><br /><br />
Message:<br />
<textarea name="message" title="required" class="contact_textarea"></textarea><br /><br />
<div class="contact_button">
<input type="button" value="Send Message" onclick="ajaxRequest(this.parentNode.parentNode); return false;" />
</div>
</form>
';
return $form;
}
?>

View file

@ -1,107 +0,0 @@
<?php
/**
* Smarty State Drop Down for PICKLES
*
* PICKLES is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* PICKLES is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with PICKLES. If not, see
* <http://www.gnu.org/licenses/>.
*
* @author Joshua John Sherman <josh@phpwithpickles.org>
* @copyright Copyright 2009 Joshua John Sherman
* @link http://phpwithpickles.org
* @license http://www.gnu.org/copyleft/lesser.html
* @package PICKLES
*/
/**
* Smarty function: html_select_state
*
* Allows you to add a state drop down easily in Smarty (in the vein of the
* built-in functions html_select_time and html_select_date). Includes the
* 50 states and the District of Columbia. Eventually there may be an
* enhanced version that includes Puerto Rico and the Canadian provinces.
*
* @param array Parameters array
* @param object Smarty object
* @usage <code>{html_select_state prefix="user_"}</code>
*/
function smarty_function_html_select_state($params, &$smarty) {
// Sets up the prefix and title (optionally passed in)
$prefix = (isset($params['prefix']) ? $params['prefix'] : null) . 'state';
$title = (isset($params['title']) ? $params['title'] : null);
// Puts together the dropdown
$select = '
<select id="' . $prefix . '" name="' . $prefix . '" title="' . $title . '">
<option value="">-- Select a State --</option>
<option value="AK">Alaska</option>
<option value="AL">Alabama</option>
<option value="AR">Arkansas</option>
<option value="AZ">Arizona</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DC">District of Columbia</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="IA">Iowa</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="MA">Massachusetts</option>
<option value="MD">Maryland</option>
<option value="ME">Maine</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MO">Missouri</option>
<option value="MS">Mississippi</option>
<option value="MT">Montana</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="NE">Nebraska</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NV">Nevada</option>
<option value="NY">New York</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VA">Virginia</option>
<option value="VT">Vermont</option>
<option value="WA">Washington</option>
<option value="WI">Wisconsin</option>
<option value="WV">West Virginia</option>
<option value="WY">Wyoming</option>
</select>
';
// Returns the dropdown to Smarty
return $select;
}
?>

View file

@ -1,66 +0,0 @@
<?php
function smarty_function_pagination($params, &$smarty) {
if (empty($params['current'])) {
$smarty->trigger_error('assign: missing \'current\' parameter');
}
else if (empty($params['total'])) {
$smarty->trigger_error('assign: missing \'total\' parameter');
}
else if (empty($params['section'])) {
$smarty->trigger_error('assign: missing \'section\' parameter');
}
else {
$current =& $params['current'];
$total =& $params['total'];
$section =& $params['section'];
$start = 1;
$end = $total;
if ($total > 10) {
if ($current - 5 >= 0) {
$start = $current - 5;
}
if ($current + 5 <= $total) {
$end = $current + 5;
}
}
$pagination = null;
// &laquo = double
// &lsaquo = single
$first = '&laquo; First';
$last = 'Last &raquo;';
$prev = '&laquo; Previous';
$next = 'Next &raquo;';
/*
$pagination .= ' <span class="pagination">';
$pagination .= $current != $total ? '<a href="/blog/first">' . $first . '</a>' : $first;
$pagination .= '</span>';
*/
$pagination .= $current != 1 ? '<a href="/' . $section . '/' . ($current - 1) . '">' . $prev . '</a>' : '<span class="prev">' . $prev . '</span>';
for ($i = $start; $i <= $end; $i++) {
$pagination .= $i != $current ? '<a href="/' . $section . '/' . $i . '">' . $i . '</a>' : '<span class="current">' . $i . '</span>';
}
$pagination .= $current != $total ? '<a href="/' . $section . '/' . ($current + 1) . '">' . $next . '</a>' : '<span class="next">' . $next . '</span>';
/*
$pagination .= ' <span class="pagination">';
$pagination .= $current != 1 ? '<a href="/blog/last">' . $last . '</a>' : $last;
$pagination .= '</span> ';
*/
return '<div id="pagination">' . $pagination . '</div>';
}
}
?>

View file

@ -1,33 +0,0 @@
<?php
function smarty_function_var_dump($params, &$smarty) {
//$hidden = array('SCRIPT_NAME', 'navigation', 'section', 'model', 'action', 'event', 'admin', 'session', 'template');
$hidden = array();
$all_variables = $smarty->_tpl_vars;
$variables = array();
if (is_array($all_variables)) {
foreach ($all_variables as $name => $value) {
if (!in_array($name, $hidden)) {
$variables['$' . $name] = $value;
}
}
}
// @todo
require_once '/home/josh/3rd-party-stuff/dBug-1.2/dBug.php';
echo "
<style>
table, tr, td {
margin: 2px;
padding: 2px;
border: 1px solid black;
}
</style>
";
new dBug($variables);
}
?>