Changes to AgileBill

This commit is contained in:
Deon George
2009-08-03 14:10:16 +10:00
parent 0a22cfe22c
commit 27aee719b0
1051 changed files with 219109 additions and 117219 deletions

View File

@@ -1,20 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.account.php
* Type: block
* Name: account
* Purpose: display an account field
* -------------------------------------------------------------
*/
function smarty_block_account($params, $resource, &$smarty)
{
$resource = trim($resource);
if ($resource != '')
{
global $C_list;
echo $C_list->account($resource);
}
}
?>

View File

@@ -1,38 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.group.php
* Type: block
* Name: group
* Purpose: display content to authenticated groups only
* -------------------------------------------------------------
*/
function smarty_block_group($params, $resource, &$smarty)
{
if(empty($resource)) return;
@$id = $params["id"];
$do = false;
$db = &DB();
$sql = 'SELECT status,group_avail FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
status = ' . $db->qstr('1') . ' AND
id = ' . $db->qstr($id);
@$result = $db->Execute($sql);
$do = false;
if(@$result->RecordCount() > 0) {
global $C_auth;
@$arr = unserialize($result->fields['group_avail']);
for($i=0; $i<count($arr); $i++)
if($do == false && $C_auth->auth_group_by_id($arr[$i]))
$do = true;
}
if($do) {
echo $resource;
} else {
echo @$params["msg"];
}
}
?>

View File

@@ -1,55 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.htmlarea.php
* Type: block
* Name: htmlarea
* Purpose: display a WYSIWYG html editor form
* -------------------------------------------------------------
*/
function smarty_block_htmlarea($params, $resource, &$smarty)
{
/* passed params:
field = name of the textarea field
width = width ie '100'
height = height ie '200'
*/
if(isset($resource))
{
if(empty($params['width']))
$width = '550';
else
$width = $params['width'];
if(empty($params['height']))
$height = '350';
else
$height = $params['height'];
echo '
<textarea id="'.$params['field'].'" name="'.$params['field'].'">'.$resource.'</textarea>
<script type="text/javascript" defer="1">
var config = new HTMLArea.Config();
config.width = \''.$width .'px\';
config.height = \''.$height .'px\';
config.toolbar = [
[ "fontname", "space",
"fontsize", "space",
"formatblock", "space",
"strikethrough", "subscript", "superscript", "separator",
"copy", "cut", "paste", "space", "undo", "redo" ],
[ "bold", "italic", "underline", "separator",
"justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
"insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
"forecolor", "hilitecolor", "textindicator", "separator",
"inserthorizontalrule", "createlink", "insertimage", "inserttable", "htmlmode"]
];
HTMLArea.replace("'.$params['field'].'", config);
</script>';
}
}
?>

View File

@@ -1,23 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.is_auth.php
* Type: block
* Name: is_auth
* Purpose: display content to authenticated groups based on module & method
* -------------------------------------------------------------
*/
function smarty_block_is_auth($params, $resource, &$smarty)
{
if(empty($resource)) return;
global $C_auth;
if(!is_object($C_auth)) return false;
if($C_auth->auth_method_by_name($params["module"], $params["method"]))
echo $resource;
else
echo $params["alt"];
}
?>

View File

@@ -1,25 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.is_auth_method.php
* Type: block
* Name: is_auth_method
* Purpose: display content to authenticated groups based on authentication to module/method
* -------------------------------------------------------------
*/
function smarty_block_is_auth_method($params, $resource, &$smarty)
{
if(empty($resource)) return;
if(!empty($params['logged']) && !SESS_LOGGED) return false;
global $C_auth;
if(!is_object($C_auth)) return false;
if($C_auth->auth_method_by_name($params["module"], $params["method"]))
echo $resource;
else if(!empty($params["alt"]))
echo $params["alt"];
}
?>

View File

@@ -1,39 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.panel.php
* Type: block
* Name: panel
* Purpose: Creates a div/span element around html / text
* -------------------------------------------------------------
*/
function smarty_block_panel($params, $resource, &$smarty)
{
$type = 'div';
$show = true;
$_ignore['show'] = true;
$_ignore['type'] = true;
$vals='';
foreach($params as $_key => $_val)
if(empty($_ignore["$_key"]))
$vals .= " $_key=\"$_val\"";
else
$$_key = $_val;
$pre = "<{$type}";
if(!$show)
$pre .= " style=\"display:none\"";
$pre .= $vals;
$pre .= ">\r\n";
$pre .= $resource;
$pre .= "\r\n</$type>";
return $pre;
}
?>

View File

@@ -1,38 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.translate.php
* Type: block
* Name: translate
* Purpose: translate a block of text
* -------------------------------------------------------------
*/
function smarty_block_translate($params, $resource, &$smarty)
{
global $C_translate;
if($params["module"] != '')
{
$module = $params["module"];
}
else
{
$module = 'CORE';
}
while(list ($key, $val) = each ($params))
{
$C_translate->value["$module"]["$key"] = $val;
}
$resource = trim($resource);
if ($resource != '') {
# strip whitespaces from the resouce identifier
echo $C_translate->translate($resource,$module,'');
}
}
?>

View File

@@ -1,19 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: ab_version
* Purpose: display current AB version
* -------------------------------------------------------------
*/
function smarty_function_ab_version($params, &$smarty)
{
include_once(PATH_CORE.'version.inc.php');
$ver = new CORE_version;
$ver->smarty();
}
?>

View File

@@ -1,30 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: assign
* Purpose: assign a value to a template variable
* -------------------------------------------------------------
*/
function smarty_function_assign($params, &$smarty)
{
extract($params);
if (empty($var)) {
$smarty->trigger_error("assign: missing 'var' parameter");
return;
}
if (!in_array('value', array_keys($params))) {
$smarty->trigger_error("assign: missing 'value' parameter");
return;
}
$smarty->assign($var, $value);
}
/* vim: set expandtab: */
?>

View File

@@ -1,29 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: block
* Purpose: display an agilebill block
* Usage: {block module=? block=?}
* -------------------------------------------------------------
*/
function smarty_function_block($params, &$this)
{
extract($params);
if($module == 'TEMPLATE') {
$this->display('file:' . PATH_THEMES . '' . THEME_NAME . '/' . $smarty->template_dir . '' . $block . '.tpl');
} else {
if(is_file(PATH_THEMES . '' . THEME_NAME . '/blocks/' . $module . '/' . $block . '.tpl'))
$this->display('file:'. PATH_THEMES . '' . THEME_NAME . '/blocks/' . $module . '/' . $block . '.tpl' );
elseif (is_file(PATH_THEMES . '' . DEF_THEME_N . '/blocks/' . $module . '/' . $block . '.tpl'))
$this->display('file:' . PATH_THEMES . '' . DEF_THEME_N . '/blocks/' . $module . '/' . $block . '.tpl');
elseif (is_file(PATH_THEMES . 'default/blocks/' . $module . '/' . $block . '.tpl'))
$this->display('file:' . PATH_THEMES . 'default/blocks/' . $module . '/' . $block . '.tpl');
else
$this->display('file:'. PATH_THEMES . '' . DEF_THEME_N . '/blocks/core/invalid_page.tpl');
}
}
?>

View File

@@ -1,16 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.date
* Type: function
* Name: date
* -------------------------------------------------------------
*/
function smarty_function_date($params, &$smarty)
{
extract($params);
echo date(UNIX_DATE_FORMAT,$date);
}
?>

View File

@@ -1,18 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.date_time
* Type: function
* Name: date_time
* -------------------------------------------------------------
*/
function smarty_function_date_time($params, &$smarty)
{
extract($params);
echo date(UNIX_DATE_FORMAT,$time);
echo " ";
echo date(DEFAULT_TIME_FORMAT,$time);
}
?>

View File

@@ -1,33 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: db_lookup
* Purpose: get a field value from the database for a given id
* -------------------------------------------------------------
*/
function smarty_function_db_lookup($params, &$smarty)
{
extract($params);
if (empty($id)) {
$smarty->trigger_error("db_lookup: attribute 'id' required");
return false;
}
if (empty($table)) {
$smarty->trigger_error("db_lookup: attribute 'table' required");
return false;
}
if (empty($field)) {
$smarty->trigger_error("db_lookup: attribute 'field' required");
return false;
}
$db =& DB();
$rs = $db->Execute(sqlSelect($db, $table, $field, "id=::".$id."::"));
return $rs->fields[0];
}
?>

View File

@@ -1,22 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.exe.php
* Type: function
* Name: exe
* -------------------------------------------------------------
*/
function smarty_function_exe($params, &$smarty)
{
extract($params);
include_once(PATH_CORE.'method.inc.php');
$m = new CORE_method;
if(!empty($noauth))
$m->exe_noauth($module,$method);
else
echo $m->exe($module,$method);
}
?>

View File

@@ -1,41 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: graph
* Purpose: displays a specific flash graph
* -------------------------------------------------------------
*/
function smarty_function_graph($params, &$this)
{
$width = 500;
$height = 300;
$color = "FFFFFF";
$transparency = true;
extract($params);
if(empty($module) || empty($method)) return false;
include_once (PATH_INCLUDES .'charts/charts.php');
if($title) {
global $C_translate;
$trans = $C_translate->translate($title,$module);
if(!empty($trans)) $title = $trans;
}
if($show === false) $display = 'style="display:none"';
global $VAR;
$vars = '';
foreach($VAR as $a => $b) $vars .= "&{$a}={$b}";
echo "<div id=\"{$id}\" class=\"graph\" $display>";
echo "<h3>$title</h3>";
echo InsertChart ( "includes/charts/charts.swf", "includes/charts/charts_library", URL."ajax.php?do[]={$module}:{$method}{$vars}", $width, $height, $color, $transparency);
echo "</div>";
}
?>

View File

@@ -1,20 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: grid_boo
* Purpose: Formats boolean fields to translated true/false value
* -------------------------------------------------------------
*/
function smarty_function_grid_bool($params, &$smarty)
{
extract($params);
if(!empty($bool))
echo translate('true');
else
echo translate('false');
}
?>

View File

@@ -1,31 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: grid_column_heading
* Purpose: display grid column heading
* -------------------------------------------------------------
*/
function smarty_function_grid_column_heading($params, &$smarty)
{
extract($params);
if($column == '_checkbox') {
echo '<input type="checkbox" id="'.$module.'_check_main" onclick="'.$module.'_grid.switchCheck(this.checked)" />';
return;
}
echo '<span style="float:right;display:none;overflow:hidden" id="'.$module.'_grid_'.$column.'_asc"><img src="images/asc.gif" alt="ASC" /></span>';
echo '<span style="float:right;display:none;overflow:hidden" id="'.$module.'_grid_'.$column.'_desc"><img src="images/desc.gif" alt="DESC" /></span>';
global $C_translate;
if($column == 'id')
echo '<span class="nobr"><?smarty:translate?>'.$C_translate->translate("id").'<?smarty:/translate?></span>';
else
echo '<span class="nobr"><?smarty:translate module='.$module.'?>'.$C_translate->translate("field_".$column,$module).'<?smarty:/translate?></span>';
}
?>

View File

@@ -1,26 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: grid_column_refine
* Purpose: display grid columns for refine search
* -------------------------------------------------------------
*/
function smarty_function_grid_column_refine($params, &$smarty)
{
extract($params);
if(empty($expr)) $expr = 'LIKE';
echo '<input type="hidden" name="'.$module.'[conditions]['.$column.'][exp][]" value="'.$expr.'" />';
echo '<input type="hidden" name="'.$module.'[conditions]['.$column.'][col][]" value="'.$column.'" />';
if($column == 'id')
echo '<input type="text" name="'.$module.'[conditions]['.$column.'][val][]" onclick="this.value=\'\'" size="4" />';
else
echo '<input type="text" name="'.$module.'[conditions]['.$column.'][val][]" onclick="this.value=\'\'" />';
}
?>

View File

@@ -1,28 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.html_bool
* Type: function
* Name: html_bool
* -------------------------------------------------------------
*/
function smarty_function_html_bool($params, &$smarty)
{
extract($params);
if(empty($id)) $id = $field;
if(empty($value)) $value = '1';
$extra=' ';
if(!empty($onclick)) $extra .= ' onClick="'.$onclick.'" ';
if($default == $value) $extra .= 'checked ';
$ret = '<input type="checkbox" name="'.$field.'" id="'.$id.'" value="'.$value.'"'.$extra.'/>';
return $ret;
}
?>

View File

@@ -1,58 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.html_button.php
* Type: function
* Name: html_checkboxes
* Version: 1.0
* -------------------------------------------------------------
*/
function smarty_function_html_button($params, &$smarty)
{
$allowdclick = true;
$name = 'submit';
$module = 'CORE';
foreach($params as $_key => $_val) $$_key = $_val;
# translate name
global $C_translate;
$trans = $C_translate->translate($name, $module);
if(!empty($trans)) $name = $trans;
# allow multiple clicks?
if(!$allowdclick) $action = "this.disabled=true; this.value='". $C_translate->translate('processing') ."';" . $action;
# change state(s)
$t = 0;
if($hide) {
$e = 'Fade';
if(ereg(',', $hide)) $hides = explode(',', $hide); else $hides = Array($hide);
foreach($hides as $element) {
if(ereg('\|', $element)) {
$el = explode('|', $element);
$action .= " new Effect.{$el[2]}('{$el[0]}', {duration: {$el[1]}}); ";
} else {
$action .= " $('{$element}').style.display='none'; ";
}
}
}
if($show) {
$e = 'Appear';
if(ereg(',', $show)) $shows = explode(',', $show); else $shows = Array($show);
foreach($shows as $element) {
if(ereg('\|', $element)) {
$el = explode('|', $element);
$action .= " new Effect.{$el[2]}('{$el[0]}', {duration: {$el[1]}}); ";
} else {
$action .= " $('{$element}').style.display='block'; ";
}
}
}
$html = "<input id=\"{$id}\" type=\"submit\" name=\"{$name}\" value=\"{$name}\" onclick=\"{$action} \">";
return $html;
}
?>

View File

@@ -1,28 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.html_date
* Type: function
* Name: html_date
* -------------------------------------------------------------
*/
function smarty_function_html_date($params, &$smarty)
{
extract($params);
if($disabled) return '<input type="text" id="'.$id.'" name="'.$field.'" value="'.$default.'" disabled />';
# set the date to current date if 'now' is set as default
if($default == 'now') $default = date(UNIX_DATE_FORMAT);
if(empty($id)) $id = $field;
if(empty($trigger)) $trigger = $id;
$ret = '<input type="text" id="'.$id.'" name="'.$field.'" value="'.$default.'" />';
$ret .= '<script type="text/javascript"> Calendar.setup({inputField: "'.$id.'", ifFormat: "'.DEFAULT_DATE_FORMAT.'", button: "'.$trigger.'"}); </script> ';
return $ret;
}
?>

View File

@@ -1,77 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.html_link.php
* Type: function
* Name: html_link
* Version: 1.0
* -------------------------------------------------------------
*/
function smarty_function_html_link($params, &$smarty)
{
$name = 'submit';
$module = 'CORE';
$_ignore['show'] = true;
$_ignore['hide'] = true;
$_ignore['name'] = true;
# Get the values passed...
$vals='';
foreach($params as $_key => $_val)
if(empty($_ignore["$_key"]))
$vals .= " $_key=\"$_val\"";
else
$$_key = $_val;
foreach($params as $_key => $_val) $$_key = $_val;
# change state(s) (hide)
$t = 0;
if($hide) {
$e = 'Fade';
if(ereg(',', $hide)) $hides = explode(',', $hide); else $hides = Array($hide);
foreach($hides as $element) {
if(ereg('\|', $element)) {
$el = explode('|', $element);
$action .= " new Effect.{$el[2]}('{$el[0]}', {duration: {$el[1]}}); ";
} else {
$action .= " $('{$element}').style.display='none'; ";
}
}
}
# change state(s) (show)
if($show) {
$e = 'Appear';
if(ereg(',', $show)) $shows = explode(',', $show); else $shows = Array($show);
foreach($shows as $element) {
if(ereg('\|', $element)) {
$el = explode('|', $element);
$action .= " new Effect.{$el[2]}('{$el[0]}', {duration: {$el[1]}}); ";
} else {
$action .= " $('{$element}').style.display='block'; ";
}
}
}
# translate name
global $C_translate;
$trans = $C_translate->translate($name, $module);
if(!empty($trans)) $name = $trans;
if(empty($link)) $link = "#";
$html = "<a href=\"$link\"";
$html .= $vals;
if($action) $html .= " onclick=\"{$action}\">";
$html .= $name;
$html .= "</a>";
return $html;
}
?>

View File

@@ -1,41 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_menu
* Purpose: Get creates a html menu for associated records
* -------------------------------------------------------------
*/
function smarty_function_html_menu($params, &$smarty)
{
$conditions='';
extract($params);
if(empty($field)) $field = $name;
if(empty($id)) $id = $field;
$db = &DB();
$rs = & $db->Execute( $sql = sqlSelect($db, $assoc_table, "id,".$assoc_field, $conditions, $assoc_field));
#echo $sql;
$return = '<select id="'.$id.'" name="'. $field .'">';
if($default == "all" || $blank) $return .= '<option value="" selected></option>';
if($rs && $rs->RecordCount() > 0)
{
while(!$rs->EOF)
{
$return .= '<option value="' . $rs->fields['id'] . '"';
if($default == $rs->fields['id']) $return .= "selected";
$return .= '>' . $rs->fields["$assoc_field"] . '</option>';
$rs->MoveNext();
}
} else {
if( $default != "all") $return .= '<option value=""></option>';
}
$return .= '</select>';
echo $return;
}
?>

View File

@@ -1,80 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_menu_files
* Purpose: Get list of files from the filesystem
* -------------------------------------------------------------
*/
function smarty_function_html_menu_files($params, &$smarty)
{
extract($params);
if(empty($field)) $field = $name;
if(empty($path)) $path = $dir;
if(empty($id)) $id = $field;
if($path == 'product_cat') { $path = PATH_THEMES . '' . DEF_THEME_N . '/blocks/product_cat/'; }
elseif($path == 'product') { $path = PATH_PLUGINS . '/product/'; }
elseif($path == 'theme') { $path = PATH_THEMES; }
elseif($path == 'static_template') { $path = PATH_THEMES . '/default/blocks/static_page/'; $ext = "_template.tpl"; $cap=1; }
elseif($path == 'language') { $path = PATH_LANGUAGE. '/core/'; $ext = "_core.xml"; $cap=1; }
elseif($path == 'whois_plugin') { $path = PATH_PLUGINS . '/whois/'; }
elseif($path == 'provision_plugin') { $path = PATH_PLUGINS . '/provision/'; }
elseif($path == 'affiliate_plugin') { $path = PATH_PLUGINS . '/affiliate/'; }
elseif($path == 'checkout_plugin') { $path = PATH_PLUGINS . '/checkout/'; }
elseif($path == 'voip_did') { $path = PATH_PLUGINS . '/voip_did/'; $ext = ".php"; }
elseif($path == 'invoice_pdf') { $path = PATH_INCLUDES. '/pdf/'; $ext = ".inc.php"; $pre = "pdf_invoice_"; }
$count = 0;
chdir($path);
$dir = opendir($path);
while ($file_name = readdir($dir))
{
$display = true;
if($file_name != '..' && $file_name != '.')
{
if(!empty($ext))
{
$cute = eregi_replace($ext.'$', "", $file_name);
if(!eregi($ext.'$', $file_name)) $display = false;
}
if(!empty($pre))
{
$cute = eregi_replace('^'.$pre, "", $cute);
if(!eregi('^'.$pre, $file_name)) $display = false;
}
if($display)
{
$arr[] = $cute;
$cute = eregi_replace("_"," ",$cute);
$cute = eregi_replace("-"," ",$cute);
if($cap==1) $cute = ucfirst(strtolower($cute));
elseif($cap==2) $cute = ucwords(strtolower($cute));
elseif($cap) $cute = strtoupper($cute);
$arrc[] = $cute;
$count++;
}
}
}
$return = '<select id="'.$id.'" name="'. $field .'" value="'.$default.'">';
if($default == "all")
$return .= '<option value="" selected></option>';
$i = 0;
for($i=0; $i<$count; $i++)
{
$return .= '<option value="' . $arr[$i] . '"';
if($default == $arr[$i])
$return .= "selected";
$return .= '>' . $arrc[$i] . '</option>';
}
if($count==0 && $default != 'all') $return .= '<option value=""></option>';
$return .= '</select>';
echo $return;
}
?>

View File

@@ -1,51 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_menu_multi
* Purpose: Get creates a html menu for associated records (multi-select)
* -------------------------------------------------------------
*/
function smarty_function_html_menu_multi($params, &$smarty)
{
$conditions='';
extract($params);
if(empty($field)) $field = $name;
if(empty($id)) $id = $field;
if(empty($size)) $size = '4';
$db = &DB();
$rs = & $db->Execute( $sql = sqlSelect($db, $assoc_table, "id,".$assoc_field, $conditions, $assoc_field));
if(empty($default)) $default = Array('');
elseif (is_array($default)) $default = $default;
elseif (is_numeric($default)) $default[] = $default;
elseif (is_string($default)) $default = unserialize($default);
else $default = Array('');
if($default == "all") $return .= '<option value="" selected></option>';
$i=0;
if($rs && $rs->RecordCount() > 0) {
while(!$rs->EOF) {
$return .= '<option value="' . $rs->fields['id'] . '"';
foreach($default as $def) { if($def == $rs->fields["id"]) $return .= " selected"; break; }
$return .= '>' . $rs->fields["$assoc_field"] . '</option>';
$i++;
$rs->MoveNext();
}
} else {
if( $default != "all") $return .= '<option value=""></option>';
}
$return .= '</select>';
if($i < $size) $size = $i++;
echo '<select id="'.$id.'" name="'. $field .'[]" size="'.$size.'" value="" multiple>' . $return;
}
?>

View File

@@ -1,41 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_menu_product_host
* Purpose: Autoselect for all active hosting plans
* -------------------------------------------------------------
*/
function smarty_function_html_menu_product_host($params, &$smarty)
{
$id = $params['id'];
$name = $params['name'];
$default = unserialize($params['default']);
$size = $params['size'];
$exclude = $params['exclude'];
if(empty($id)) $id = $name;
$db = &DB();
$p = AGILE_DB_PREFIX;
$q = "SELECT id,sku FROM {$p}product
WHERE host = 1
AND active = 1
AND price_type = 1
AND id != $exclude
AND site_id = " . DEFAULT_SITE;
$result = $db->Execute($q);
if($result && $result->RecordCount() > 0)
{
echo "<select id=\"$id\" name=\"{$name}[]\" size=\"$size\" multiple>";
while(!$result->EOF) {
$sel='';
foreach($default as $cur) if ($cur == $result->fields['id']) $sel = "selected";
echo "<option value=\"{$result->fields['id']}\"$sel>{$result->fields['sku']}</option>";
$result->MoveNext();
}
echo "</select>";
}
}
?>

View File

@@ -1,42 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_menu_product_subscription
* Purpose: Autoselect for all active non-hosting subscriptions
* -------------------------------------------------------------
*/
function smarty_function_html_menu_product_subscription($params, &$smarty)
{
$id = $params['id'];
$name = $params['name'];
$default = unserialize($params['default']);
$size = $params['size'];
$exclude = $params['exclude'];
if(empty($id)) $id = $name;
$db = &DB();
$p = AGILE_DB_PREFIX;
$q = "SELECT id,sku FROM {$p}product
WHERE
( host = 0 OR host IS NULL )
AND active = 1
AND price_type = 1
AND id != $exclude
AND site_id = " . DEFAULT_SITE;
$result = $db->Execute($q);
if($result && $result->RecordCount() > 0)
{
echo "<select id=\"$id\" name=\"{$name}[]\" size=\"$size\" multiple>";
while(!$result->EOF) {
$sel='';
foreach($default as $cur) if ($cur == $result->fields['id']) $sel = "selected";
echo "<option value=\"{$result->fields['id']}\"$sel>{$result->fields['sku']}</option>";
$result->MoveNext();
}
echo "</select>";
}
}
?>

View File

@@ -1,63 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_menu_search_expr
* Purpose: display search form expression menu
* -------------------------------------------------------------
*/
function smarty_function_html_menu_search_expr($params, &$smarty)
{
extract($params);
// Types: exact, date, dateex, number, fulltext, text (default)
switch($type) {
case 'exact':
$options = Array('EQ', 'NULL', 'NNULL');
break;
case 'date':
$options = Array('GTEQ', 'LTEQ', 'GT', 'LT');
break;
case 'dateex':
$options = Array('EQ', 'GTEQ', 'LTEQ', 'GT', 'LT');
break;
case 'number':
$options = Array('EQ', 'GTEQ', 'LTEQ', 'GT', 'LT', 'NULL', 'NNULL');
break;
case 'fulltext':
$options = Array('FT');
break;
case 'text':
$options = Array('LIKE','NLIKE', 'EQ', 'NOT', 'NULL', 'NNULL');
break;
}
if(empty($options)) $options = Array('LIKE','NLIKE', 'EQ', 'NOT', 'NULL', 'NNULL');
$optionsTxt["EQ"] = 'IS EXACT';
$optionsTxt["LIKE"] = 'IS LIKE';
$optionsTxt["NOT"] = 'IS NOT';
$optionsTxt["NLIKE"] = 'IS NOT LIKE';
$optionsTxt["GT"] = 'IS &gt;';
$optionsTxt["LT"] = 'IS &lt;';
$optionsTxt["GTEQ"] = 'IS &gt;=';
$optionsTxt["LTEQ"] = 'IS &lt;=';
$optionsTxt["NULL"] = 'IS NULL';
$optionsTxt["NNULL"] = 'IS NOT NULL';
$optionsTxt["FT"] = 'FULL TEXT';
echo '<select name="'.$module.'[conditions]['.$field.'][exp][]">';
foreach($options as $opt) echo '<option value="'.$opt.'">'.$optionsTxt["$opt"].'</option>';
echo '</select>';
echo '<input type="hidden" name="'.$module.'[conditions]['.$field.'][col][]" value="'.$field.'" />';
}
?>

View File

@@ -1,96 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_menu_sub
* Purpose: Creates a html menu for associated records w/sub-record support
* -------------------------------------------------------------
*/
function smarty_function_html_menu_sub($params, &$smarty)
{
$conditions='';
$actions='';
extract($params);
if(empty($field)) $field = $name;
if(empty($id)) $select_id = $field; else $select_id = $id;
if(empty($parent_id)) $parent_id = 'parent_id';
if(!empty($onchange)) $actions .= " onchange=\"$onchange\" ";
$db = &DB();
$result = $db->Execute( sqlSelect($db,$assoc_table,"id,$parent_id,".$assoc_field, $conditions, "$parent_id,$assoc_field"));
# Get current id
if(!empty($VAR['id'])) $cid = ereg_replace(",","", $VAR['id']); else $current = '';
# Loop and put in array
while(!$result->EOF) {
if($result->fields["$parent_id"] == "" || $result->fields["$parent_id"] == 0 || $result->fields["$parent_id"] == $result->fields['id']) {
$arr[0][] = $result->fields;
} else {
$arr["{$result->fields["$parent_id"]}"][] = $result->fields;
}
# get current parent_id
if($cid > 0 && $result->fields['id'] == $cid)
$current = $result->fields["$parent_id"];
$result->MoveNext();
}
$option = '';
$dirpre = ' \\ ';
for($i=0; $i<count($arr[0]); $i++) {
$id = $arr[0][$i]["id"];
if($id == $current) $sel = 'selected'; else $sel = '';
$dir = $dirpre.$dir.$arr[0][$i]["$assoc_field"];
$option .= '<option value="'.$id.'" '.$sel.'>'.$dir.'</option>';
# get the sub-records # (LEVEL 2)
if(isset($arr[$id])) {
for($ii=0; $ii<count($arr[$id]); $ii++) {
$idx = $arr[$id][$ii]["id"];
if($idx == $current) $sel = 'selected'; else $sel = '';
$dir .= $dirpre.$arr[$id][$ii]["$assoc_field"];
$option .= '<option value="'.$idx.'" '.$sel.'>'.$dir.'</option>';
}
# get the sub-records # (LEVEL 3)
if(isset($arr[$idx])) {
for($iii=0; $iii<count($arr[$idx]); $iii++) {
$idx2 = $arr[$idx][$iii]["id"];
if($idx2 == $current) $sel = 'selected'; else $sel = '';
$dir .= $dirpre.$arr[$idx][$iii]["$assoc_field"];
$option .= '<option value="'.$idx2.'" '.$sel.'>'.$dir.'</option>';
}
# get the sub-records # (LEVEL 4)
if(isset($arr[$idx2])) {
for($iiii=0; $iiii<count($arr[$idx2]); $iiii++) {
$idx3 = $arr[$idx2][$iiii]["id"];
if($idx3 == $current) $sel = 'selected'; else $sel = '';
$dir .= $dirpre.$arr[$idx2][$iiii]["$assoc_field"];
$option .= '<option value="'.$idx3.'" '.$sel.'>'.$dir.'</option>';
}
# get the sub-records # (LEVEL 5)
if(isset($arr[$idx3])) {
for($iiiii=0; $iiiii<count($arr[$idx3]); $iiiii++) {
$idx4 = $arr[$idx3][$iiiii]["id"];
if($idx4 == $current) $sel = 'selected'; else $sel = '';
$dir .= $dirpre.$arr[$idx3][$iiiii]["$assoc_field"];
$option .= '<option value="'.$idx4.'" '.$sel.'>'.$dir.'</option>';
}
}
}
}
}
}
echo "<select id=\"$select_id\" name=\"$field\"$actions\>";
echo "<option value=\"0\">\\</option>";
echo $option;
echo '</select>';
}
?>

View File

@@ -1,49 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_select_account
* Purpose: Autoselect for accounts in AgileBill
* -------------------------------------------------------------
*/
function smarty_function_html_select_account($params, &$smarty)
{
$id = $params['id'];
$name = $params['name'];
$default = $params['default'];
$type = $params['type'];
if(empty($id)) $id = $name."_id";
if(!empty($default)) {
$db = &DB();
$p = AGILE_DB_PREFIX;
$q = "SELECT id,first_name,middle_name,last_name FROM {$p}account
WHERE id = {$default}
AND site_id = " . DEFAULT_SITE;
$result = $db->Execute($q);
if($result->RecordCount() > 0)
$val = $result->fields['first_name'].' '.$result->fields['last_name'];
if(!empty($val)) {
# Get
}
} else {
$val = '';
}
if(empty($val)) {
echo '
<input type="hidden" id="'.$id.'_hidden" name="'.$name.'" value="'.$default.'" />
<input type="text" autocomplete="off" id="'.$id.'" name="account_search" size="35" value="'.$val.'" />
<div class="auto_complete" id="'.$id.'_auto_complete"></div>
<script type="text/javascript">new Ajax.Autocompleter("'.$id.'", "'.$id.'_auto_complete", "ajax.php?do[]=account_admin:autoselect", { })</script>
';
} else {
echo "<a href=\"#\" onClick=\"window.open('?_page=account_admin:view&id={$default}', 'mainFrame', '')\"><u>{$val}</u></a>";
echo "<input value=\"{$default}\" id=\"{$id}\" name=\"{$name}\" type=\"hidden\">";
}
}
?>

View File

@@ -1,56 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_select_affiliate
* Purpose: Autoselect for affiliate accounts in AgileBill
* -------------------------------------------------------------
*/
function smarty_function_html_select_affiliate($params, &$smarty)
{
$id = $params['id'];
$name = $params['name'];
$default = $params['default'];
$type = $params['type'];
if(empty($id)) $id = $name."_id";
if(!empty($default)) {
$db = &DB();
$p = AGILE_DB_PREFIX;
$q = "SELECT DISTINCT
{$p}affiliate.id,
{$p}account.first_name,
{$p}account.last_name,
{$p}account.username
FROM
{$p}account
LEFT JOIN
{$p}affiliate
ON
{$p}account.id = {$p}affiliate.account_id
WHERE
{$p}affiliate.id = '{$default}' AND
{$p}affiliate.site_id = " . DEFAULT_SITE . " AND
{$p}account.site_id = " . DEFAULT_SITE;
$result = $db->Execute($q);
if($result != false && $result->RecordCount() > 0) $val = $result->fields['first_name'].' '.$result->fields['last_name'];
} else {
$val = '';
}
echo '
<input type="hidden" id="'.$id.'_hidden" name="'.$name.'" value="'.$default.'" />
<input type="text" autocomplete="off" id="'.$id.'" name="affiliate_search" size="35" value="'.$val.'" />
<div class="auto_complete" id="'.$id.'_auto_complete"></div>
<script type="text/javascript">new Ajax.Autocompleter("'.$id.'", "'.$id.'_auto_complete", "ajax.php?do[]=affiliate:autoselect", { })</script>
';
if(!empty($val)) {
// display unselect option
echo '<a href="#" OnClick="document.getElementById(\''.$id.'\').value=\'\'; document.getElementById(\''.$id.'_hidden\').value=\'\'"> - </a>';
}
}
?>

View File

@@ -1,21 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.input_text.php
* Type: function
* Name: input_text
* Purpose: display a text form with the proper css & onchange settings
* -------------------------------------------------------------
*/
function smarty_function_input_text($params, &$this)
{
extract($params);
$c_class = $class ? $class : 'form_field';
$s_size = $size ? $size : '12';
$s_id = $id ? $id : $name;
echo "<input type=\"text\" name=\"{$name}\" id=\"{$id}\" class=\"{$c_class}\" value=\"{$value}\" size=\"{$s_size}\" onFocus=\"class_change(this.id,'form_field_focus')\" onBlur=\"class_change(this.id,'form_field')\">";
}
?>

View File

@@ -0,0 +1,445 @@
<?php
/**
* Smarty Open Source Billing Plugin
* -------------------------------------------------------------
* File: block.osb.php
* Type: block
* Name: osb
* Purpose: Hooks into OSB
* -------------------------------------------------------------
*/
function smarty_function_osb($params,&$smarty) {
if (! isset($params['f']) || ! ($f=$params['f'])) {
echo 'NO Function name used in call?';
return;
}
unset($params['f']);
$f = 'osb_'.$f;
if (! function_exists($f)) {
printf('Unknown Function [%s]?',$f);
return;
}
eval(sprintf('%s($params,$smarty);',$f));
}
function osb_html_select($val,$id,$name,$default,$module) {
if (! $val) {
printf('<input type="hidden" id="%s_hidden" name="id" value="%s"/>',$id,$default);
printf('<input type="text" id="%s" name="%s_search" size="35" value="%s" autocomplete="off"/>',$name,'account',$val);
printf('<div class="auto_complete" id="%s_auto_complete"></div>',$id);
printf('<script type="text/javascript">new Ajax.Autocompleter("%s","%s_auto_complete","ajax.php?do[]=%s:autoselect",{});</script>',$name,$id,$module);
} else {
printf('<div style="text-decoration: underline;"><a href="#" onclick="window.open(\'?_page=%s:view&amp;id=%s\',\'mainFrame\',\'\')">%s</a></div>',$module,$default,$val);
printf('<input type="hidden" id="%s" name="%s" value="%s"/>',$id,$name,$default);
}
}
/**
* HTML Account Selector
*
* If passed a default ID (and it exists), that will be rendered, otherwise a javascript selection box is rendered.
*/
function osb_html_select_account($params,&$smarty) {
if (! $params['name']) {
printf('MISSING name:%s',__METHOD__);
return;
}
$module = isset($params['module']) ? $params['module'] : 'account';
$default = isset($params['default']) ? $params['default'] : '';
$id = isset($params['id']) ? $params['id'] : sprintf('%s_id',$params['name']);
$val = '';
if ($default) {
$db = &DB();
$result = $db->Execute(sqlSelect($db,'account','first_name,last_name',array('id'=>$default)));
if ($result->RecordCount() > 0)
$val = sprintf('%s %s',$result->fields['first_name'],$result->fields['last_name']);
}
return osb_html_select($val,$id,$params['name'],$default,$module);
}
/**
* HTML Affiliate Selector
*
* If passed a default ID (and it exists), that will be rendered, otherwise a javascript selection box is rendered.
* @todo need to create autoselect();
*/
function osb_html_select_affiliate($params,&$smarty) {
if (! $params['name']) {
printf('MISSING name:%s',__METHOD__);
return;
}
$module = isset($params['module']) ? $params['module'] : 'affiliate';
$default = isset($params['default']) ? $params['default'] : '';
$id = isset($params['id']) ? $params['id'] : sprintf('%s_id',$params['name']);
$val = '';
if ($default) {
$db = &DB();
$sql = sprintf('SELECT DISTINCT {p}affiliate.id,{p}account.first_name,{p}account.last_name,{p}account.username
FROM {p}account LEFT JOIN {p}affiliate ON {p}account.id={p}affiliate.account_id
WHERE {p}affiliate.id=%s AND {p}affiliate.site_id=%s AND {p}account.site_id=%s',$db->qstr($default),DEFAULT_SITE,DEFAULT_SITE);
$result = $db->Execute(str_replace('{p}',AGILE_DB_PREFIX,$sql));
if ($result->RecordCount() > 0)
$val = sprintf('%s %s',$result->fields['first_name'],$result->fields['last_name']);
}
return osb_html_select($val,$id,$params['name'],$default,$module);
}
function osb_html_select_name($params,&$smarty) {
if (! $params['name']) {
printf('MISSING name:%s',__METHOD__);
return;
}
$module = isset($params['module']) ? $params['module'] : '';
$table = isset($params['table']) ? $params['table'] : '';
$default = isset($params['default']) ? $params['default'] : '';
$id = isset($params['id']) ? $params['id'] : sprintf('%s_id',$params['name']);
$val = '';
if ($default) {
$db = &DB();
$result = $db->Execute($q=sqlSelect($db,$table,'name',array('id'=>$default)));
if ($result && $result->RecordCount() > 0)
$val = $result->fields['name'];
}
return osb_html_select($val,$id,$params['name'],$default,$module);
}
function osb_autoselect($params,&$smarty) {
$module = isset($params['module']) ? $params['module'] : (isset($smarty->_tpl_vars['meth'][0]) ? $smarty->_tpl_vars['meth'][0] : '');
$field = isset($params['field']) ? $params['field'] : '';
$return = isset($params['return']) ? $params['return'] : '';
$default = isset($params['default']) ? $params['default'] : '';
$val = '';
if (! $module || ! $field || ! $return) {
printf('MISSING module (%s),field (%s) OR return (%s):%s',$module,$field,$return,__METHOD__);
return;
}
if ($default) {
$db = &DB();
$result = $db->Execute($q=sqlSelect($db,$module,$return.',first_name,last_name',array($return=>$default)));
if ($result && $result->RecordCount() == 1)
$val = sprintf('%s %s',$result->fields['first_name'],$result->fields['last_name']);
}
printf('<input type="hidden" id="autoselect_%s_hidden" name="%s" size="35" value="%s"/>',$field,$field,$default);
printf('<input type="text" id="autoselect_%s" name="autosearch_%s" size="35" value="%s" autocomplete="off"/>',$field,$field,$val);
printf('<div class="auto_complete" id="%s_auto_complete"></div>',$field);
echo '<script type="text/javascript"><!--'."\n";
printf('new Ajax.Autocompleter("autoselect_%s","%s_auto_complete","ajax.php?do[]=%s:autoselect&return=%s&field=%s",{});',$field,$field,$module,$return,$field);
echo "\n";
echo '//--></script>'."\n";
}
/**
* Get list of files from the filesystem, and present in a select list
*/
function osb_html_menu_files($params,&$smarty) {
if (! $params['name'] || ! $params['path']) {
printf('MISSING name OR path:%s',__METHOD__);
return;
}
$id = isset($params['id']) ? $params['id'] : $params['name'];
$ext = '';
switch ($params['path']) {
case 'affiliate_plugin': $path = sprintf('%s/affiliate/',PATH_PLUGINS); break;
case 'checkout_plugin': $path = sprintf('%s/checkout/',PATH_PLUGINS); break;
case 'invoice_pdf': $path = sprintf('%s/invoice/PDF/',PATH_MODULES); $ext = '.inc.php'; $pre = 'pdf_invoice_'; break;
case 'invoice_pagetype': $path = sprintf('%s%s/invoice/',PATH_THEMES,DEF_THEME_N); $ext = '.pdf'; $pre = 'invoice-'; break;
case 'language': $path = sprintf('%s/core/',PATH_LANGUAGE); $ext = '_core.xml'; $cap=1; break;
case 'product' : $path = sprintf('%s/product',PATH_PLUGINS); break;
case 'product_cat' : $path = sprintf('%s%s/blocks/product_cat',PATH_THEMES,DEF_THEME_N); break;
case 'provision_plugin': $path = sprintf('%s/provision/',PATH_PLUGINS); break;
case 'static_template': $path = sprintf('%s/default/blocks/static_page/',PATH_THEMES); $ext = '_template.tpl'; $cap=1; break;
case 'theme' : $path = PATH_THEMES; break;
case 'whois_plugin': $path = sprintf('%s/whois/',PATH_PLUGINS); break;
default:
printf('Unkonwn path: %s',$params['path']);
return;
}
$count = 0;
$arr = array();
$dir = opendir($path);
while ($file_name = readdir($dir)) {
$display = true;
if (! in_array($file_name,array('.','..'))) {
if ($ext) {
$cute = preg_replace("/{$ext}$/",'',$file_name);
if (! preg_match("/{$ext}$/",$file_name))
$display = false;
}
if ($pre) {
$cute = preg_replace("/^{$pre}/",'',$cute);
if (! preg_match("/^{$pre}/",$file_name))
$display = false;
}
if ($display) {
$value = str_replace('_',' ',str_replace('-',' ',$cute));
if ($cap==1)
$value = ucfirst(strtolower($value));
elseif ($cap==2)
$value = ucwords(strtolower($value));
elseif($cap)
$value = strtoupper($value);
$arr[$cute] = $value;
}
}
}
$return = sprintf('<select id="%s" name="%s">',$id,$params['name']);
if ($params['default'] == 'all')
$return .= '<option value="" selected>&nbsp;</option>';
if (count($arr))
foreach ($arr as $index => $value)
$return .= sprintf('<option value="%s"%s>%s</option>',$index,($params['default'] == $index) ? ' selected' : '',$value);
$return .= '</select>';
echo $return;
}
function osb_html_link($params,&$smarty) {
$name = 'submit';
$module = 'CORE';
$_ignore['show'] = true;
$_ignore['hide'] = true;
$_ignore['name'] = true;
# Get the values passed...
$vals = '';
foreach ($params as $_key => $_val)
if (empty($_ignore[$_key]))
$vals .= sprintf(' %s="%s"',$_key,$_val);
else
$$_key = $_val;
foreach ($params as $_key => $_val)
$$_key = $_val;
# Change state(s) (hide)
$t = 0;
if ($hide) {
if (preg_match('/,/',$hide))
$hides = explode(',',$hide);
else
$hides = array($hide);
foreach ($hides as $element)
if (preg_match('/\|/',$element)) {
$el = explode('|',$element);
$action .= sprintf("new Effect.%s('%s',{duration: %s});",$el[2],$el[0],$el[1]);
} else {
$action .= sprintf("$('%s').style.display='none';",$element);
}
}
# Change state(s) (show)
if ($show) {
if (preg_match('/,/',$show))
$shows = explode(',',$show);
else
$shows = array($show);
foreach ($shows as $element) {
if (preg_match('/\|/',$element)) {
$el = explode('|',$element);
$action .= sprintf("new Effect.%s('%s',{duration: %s});",$el[2],$el[0],$el[1]);
} else {
$action .= sprintf("$('%s').style.display='block';",$element);
}
}
}
# translate name
global $C_translate;
$trans = $C_translate->translate($name,$module);
if (! empty($trans))
$name = $trans;
if (empty($link))
$link = '#';
return sprintf('<a href="%s"%s%s>%s</a>',$link,$vals,$action ? sprintf(' onclick="%s"',$action) : '',$name);
}
/**
* Hides a div/span element without disabling the view
*/
function osb_style_hide($params,&$smarty) {
echo 'style="display:none;"';
}
/**
* Displays & Populates an Plug In template
* @todo change this to be dynmaic, ie: defined by the instalation of a module and calling a method.
*/
function osb_plugin($params,&$smarty) {
# Some Validation
if ((! isset($params['type']) || ! trim($params['type'])) || (! isset($params['name']) || ! trim($params['name'])))
return;
if (! isset($params['name_prefix']))
$params['name_prefix'] = '';
if (! isset($params['data']) && $params['data'])
$smarty->assign('plugin',unserialize($params['data']));
# Pass any other vars to smarty
foreach ($params as $var=>$val)
$smarty->assign($var,$val);
# Get full template file-path:
switch ($params['type']) {
case 'affiliate':
$meth = 'affiliate:plugin';
break;
case 'checkout':
$meth = 'checkout_plugin:plugin';
break;
case 'import':
$meth = ''; // @todo
break;
case 'product':
$meth = 'product_plugin:plugin';
break;
case 'provision':
$meth = 'host_provision_plugin:plugin';
break;
case 'registrar':
$meth = 'host_registrar_plugin:plugin';
break;
case 'whois':
$meth = 'host_whois_plugin:plugin';
break;
case 'voip_did':
$meth = 'voip_did_plugin:config';
break;
}
$_tpl = sprintf('%s_%s%s',$meth,$params['name_prefix'],$params['name']);
# Check if file exists:
$_template_full = sprintf('%s%s/blocks/%s.tpl',PATH_THEMES,DEF_THEME_N,str_replace(':','/',$_tpl));
if (! is_file($_template_full)) {
$_template_full = sprintf('%s%s/blocks/%s.tpl',PATH_THEMES,'default',str_replace(':','/',$_tpl));
if (! is_file($_template_full)) {
if ($debug)
printf('Error loading plugin template: %s',$_template_full);
return;
}
}
// Load file
$smarty->display(sprintf('file:%s',$_template_full));
}
/**
* Translate a table title
*/
function osb_tt($params,&$smarty) {
require_once(PATH_CORE.'translate.inc.php');
$C_translate = new CORE_translate;
echo $C_translate->tt($params,$smarty);
}
/**
* Translate a table field
*/
function osb_tf($params,&$smarty) {
require_once(PATH_CORE.'translate.inc.php');
$C_translate = new CORE_translate;
echo $C_translate->tf($params,$smarty);
}
function osb_html_menu_product_host($params,&$smarty) {
$id = $params['id'];
$default = unserialize($params['default']);
if (empty($id))
$id = $params['name'];
$db = &DB();
$result = $db->Execute(sqlSelect($db,'product','id,sku',sprintf('host=1 AND active=1 AND price_type=1 AND id!%s',$params['exclude'])));
if ($result && $result->RecordCount()) {
printf('<select id="%s" name="%s[]" size="%s" multiple="multiple">',$id,$params['name'],$params['size']);
while(!$result->EOF) {
$sel = '';
foreach ($default as $cur)
if ($cur == $result->fields['id'])
$sel = ' selected="selected"';
printf('<option value="%s"%s>%s</option>',$result->fields['id'],$sel,$result->fields['sku']);
$result->MoveNext();
}
echo '</select>';
}
}
function osb_html_menu_product_subscription($params,&$smarty) {
$id = $params['id'];
$default = unserialize($params['default']);
if (empty($id))
$id = $params['name'];
$db = &DB();
$result = $db->Execute(sqlSelect($db,'product','id,sku',sprintf('(host=0 OR host IS NULL) AND active=1 AND price_type=1 AND id!=%s',$params['exclude']),'sku'));
if ($result && $result->RecordCount()) {
printf('<select id="%s" name="%s[]" size="%s" multiple="multiple">',$id,$params['name'],$params['size']);
while (! $result->EOF) {
$sel = '';
foreach ($default as $cur)
if ($cur == $result->fields['id'])
$sel = ' selected="selected"';
printf('<option value="%s"%s>%s</option>',$result->fields['id'],$sel,$result->fields['sku']);
$result->MoveNext();
}
echo '</select>';
}
}
?>

View File

@@ -1,70 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: plugin
* Purpose: Displays & Populates an AB plugin template
* -------------------------------------------------------------
*/
function smarty_function_plugin($params, &$smarty)
{
$conditions='';
extract($params);
if(empty($type)) return;
if(empty($name)) return;
if(empty($name_prefix)) $name_prefix='';
if(!empty($data)) $smarty->assign('plugin', unserialize($data));
// pass any other vars to smarty
foreach($params as $var=>$val) $smarty->assign($var,$val);
// get full template file-path:
switch($type) {
case 'affiliate':
$_tpl = "affiliate:plugin_{$name_prefix}{$name}";
break;
case 'checkout':
$_tpl = "checkout_plugin:plugin_{$name_prefix}{$name}";
break;
case 'db_mapping':
$_tpl = "db_mapping:group_map_{$name_prefix}{$name}";
break;
case 'import':
$_tpl = ""; // todo
break;
case 'product':
$_tpl = "product_plugin:plugin_{$name_prefix}{$name}";
break;
case 'provision':
$_tpl = "host_provision_plugin:plugin_{$name_prefix}{$name}";
break;
case 'registrar':
$_tpl = "host_registrar_plugin:plugin_{$name_prefix}{$name}";
break;
case 'whois':
$_tpl = "host_whois_plugin:plugin_{$name_prefix}{$name}";
break;
case 'voip_did':
$_tpl = "voip_did_plugin:config_{$name_prefix}{$name}";
break;
}
// check if file exists:
$_template_full = PATH_THEMES.DEF_THEME_N."/blocks/". ereg_replace(":", "/", $_tpl).".tpl";
if(!is_file($_template_full)) {
$_template_full = PATH_THEMES."default/blocks/". ereg_replace(":", "/", $_tpl).".tpl";
if(!is_file($_template_full)) {
if($debug) echo "Error loading plugin template: $_template_full";
return;
}
}
// load file
$smarty->display("file:$_template_full");
}
?>

View File

@@ -1,17 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.style_hide.php
* Type: function
* Name: style_hide
* Version: 1.0
* Purpose: Hides a div/span element without disabling the view in dreamweaver
* -------------------------------------------------------------
*/
function smarty_function_style_hide($params, &$smarty)
{
return 'style="display:none"';
}
?>

View File

@@ -1,7 +0,0 @@
<?php
function smarty_modifier_date($string, $format="%b %e, %Y", $default_date=null)
{
echo timestampToDate($string);
}
?>

View File

@@ -1,28 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: linkalize
* Version: 1.0
* Purpose: parse a string and turn text links into clickable links...
* Input: string to catenate
* Example: {$var|linkalize}
* Notes: make sure there is an http:// on all URLs
* -------------------------------------------------------------
*/
function smarty_modifier_linkalize($string)
{
return linkalize($string);
}
function linkalize($text)
{
$text = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2", $text);
$text = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "<A TARGET=\"_blank\" HREF=\"$1\">$1</A>", $text); //make all URLs links
$text = preg_replace("/[\w-\.]+@(\w+[\w-]+\.){0,3}\w+[\w-]+\.[a-zA-Z]{2,4}\b/i","<ahref=\"mailto:$0\">$0</a>",$text);
return $text;
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,854 +0,0 @@
<?php
#
# SmartyPants - Smart punctuation for web sites
#
# by John Gruber
# <http://daringfireball.net>
#
# PHP port by Michel Fortin
# <http://www.michelf.com/>
#
# Copyright (c) 2003-2004 John Gruber
# Copyright (c) 2004-2005 Michel Fortin
#
global $SmartyPantsPHPVersion, $SmartyPantsSyntaxVersion,
$smartypants_attr, $sp_tags_to_skip;
$SmartyPantsPHPVersion = '1.5.1d'; # Mon 6 Jun 2005
$SmartyPantsSyntaxVersion = '1.5.1'; # Fri 12 Mar 2004
# Configurable variables:
$smartypants_attr = "1"; # Change this to configure.
# 1 => "--" for em-dashes; no en-dash support
# 2 => "---" for em-dashes; "--" for en-dashes
# 3 => "--" for em-dashes; "---" for en-dashes
# See docs for more configuration options.
# Globals:
$sp_tags_to_skip = '<(/?)(?:pre|code|kbd|script|math)[\s>]';
# -- WordPress plugin interface -----------------------------------------------
/*
Plugin Name: SmartyPants
Plugin URI: http://www.michelf.com/projects/php-smartypants/
Description: SmartyPants is a web publishing utility that translates plain ASCII punctuation characters into &#8220;smart&#8221; typographic punctuation HTML entities. This plugin <strong>replace the default WordPress Texturize algorithm</strong> for the content and the title of your posts, the comments body and author name, and everywhere else Texturize normally apply. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>.
Version: 1.5.1c
Author: Michel Fortin
Author URI: http://www.michelf.com/
*/
if (isset($wp_version)) {
# Remove default Texturize filter that would conflict with SmartyPants.
remove_filter('category_description', 'wptexturize');
remove_filter('list_cats', 'wptexturize');
remove_filter('comment_author', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
remove_filter('single_post_title', 'wptexturize');
remove_filter('the_title', 'wptexturize');
remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
# Add SmartyPants filter with priority 10 (same as Texturize).
add_filter('category_description', 'SmartyPants', 10);
add_filter('list_cats', 'SmartyPants', 10);
add_filter('comment_author', 'SmartyPants', 10);
add_filter('comment_text', 'SmartyPants', 10);
add_filter('single_post_title', 'SmartyPants', 10);
add_filter('the_title', 'SmartyPants', 10);
add_filter('the_content', 'SmartyPants', 10);
add_filter('the_excerpt', 'SmartyPants', 10);
}
# -- Smarty Modifier Interface ------------------------------------------------
function smarty_modifier_smartypants($text, $attr = NULL) {
return SmartyPants($text, $attr);
}
function SmartyPants($text, $attr = NULL, $ctx = NULL) {
global $smartypants_attr, $sp_tags_to_skip;
# Paramaters:
$text; # text to be parsed
$attr; # value of the smart_quotes="" attribute
$ctx; # MT context object (unused)
if ($attr == NULL) $attr = $smartypants_attr;
# Options to specify which transformations to make:
$do_stupefy = FALSE;
$convert_quot = 0; # should we translate &quot; entities into normal quotes?
# Parse attributes:
# 0 : do nothing
# 1 : set all
# 2 : set all, using old school en- and em- dash shortcuts
# 3 : set all, using inverted old school en and em- dash shortcuts
#
# q : quotes
# b : backtick quotes (``double'' only)
# B : backtick quotes (``double'' and `single')
# d : dashes
# D : old school dashes
# i : inverted old school dashes
# e : ellipses
# w : convert &quot; entities to " for Dreamweaver users
if ($attr == "0") {
# Do nothing.
return $text;
}
else if ($attr == "1") {
# Do everything, turn all options on.
$do_quotes = 1;
$do_backticks = 1;
$do_dashes = 1;
$do_ellipses = 1;
}
else if ($attr == "2") {
# Do everything, turn all options on, use old school dash shorthand.
$do_quotes = 1;
$do_backticks = 1;
$do_dashes = 2;
$do_ellipses = 1;
}
else if ($attr == "3") {
# Do everything, turn all options on, use inverted old school dash shorthand.
$do_quotes = 1;
$do_backticks = 1;
$do_dashes = 3;
$do_ellipses = 1;
}
else if ($attr == "-1") {
# Special "stupefy" mode.
$do_stupefy = 1;
}
else {
$chars = preg_split('//', $attr);
foreach ($chars as $c){
if ($c == "q") { $do_quotes = 1; }
else if ($c == "b") { $do_backticks = 1; }
else if ($c == "B") { $do_backticks = 2; }
else if ($c == "d") { $do_dashes = 1; }
else if ($c == "D") { $do_dashes = 2; }
else if ($c == "i") { $do_dashes = 3; }
else if ($c == "e") { $do_ellipses = 1; }
else if ($c == "w") { $convert_quot = 1; }
else {
# Unknown attribute option, ignore.
}
}
}
$tokens = _TokenizeHTML($text);
$result = '';
$in_pre = 0; # Keep track of when we're inside <pre> or <code> tags.
$prev_token_last_char = ""; # This is a cheat, used to get some context
# for one-character tokens that consist of
# just a quote char. What we do is remember
# the last character of the previous text
# token, to use as context to curl single-
# character quote tokens correctly.
foreach ($tokens as $cur_token) {
if ($cur_token[0] == "tag") {
# Don't mess with quotes inside tags.
$result .= $cur_token[1];
if (preg_match("@$sp_tags_to_skip@", $cur_token[1], $matches)) {
$in_pre = isset($matches[1]) && $matches[1] == '/' ? 0 : 1;
}
} else {
$t = $cur_token[1];
$last_char = substr($t, -1); # Remember last char of this token before processing.
if (! $in_pre) {
$t = ProcessEscapes($t);
if ($convert_quot) {
$t = preg_replace('/&quot;/', '"', $t);
}
if ($do_dashes) {
if ($do_dashes == 1) $t = EducateDashes($t);
if ($do_dashes == 2) $t = EducateDashesOldSchool($t);
if ($do_dashes == 3) $t = EducateDashesOldSchoolInverted($t);
}
if ($do_ellipses) $t = EducateEllipses($t);
# Note: backticks need to be processed before quotes.
if ($do_backticks) {
$t = EducateBackticks($t);
if ($do_backticks == 2) $t = EducateSingleBackticks($t);
}
if ($do_quotes) {
if ($t == "'") {
# Special case: single-character ' token
if (preg_match('/\S/', $prev_token_last_char)) {
$t = "&#8217;";
}
else {
$t = "&#8216;";
}
}
else if ($t == '"') {
# Special case: single-character " token
if (preg_match('/\S/', $prev_token_last_char)) {
$t = "&#8221;";
}
else {
$t = "&#8220;";
}
}
else {
# Normal case:
$t = EducateQuotes($t);
}
}
if ($do_stupefy) $t = StupefyEntities($t);
}
$prev_token_last_char = $last_char;
$result .= $t;
}
}
return $result;
}
function SmartQuotes($text, $attr = NULL, $ctx = NULL) {
global $smartypants_attr, $sp_tags_to_skip;
# Paramaters:
$text; # text to be parsed
$attr; # value of the smart_quotes="" attribute
$ctx; # MT context object (unused)
if ($attr == NULL) $attr = $smartypants_attr;
$do_backticks; # should we educate ``backticks'' -style quotes?
if ($attr == 0) {
# do nothing;
return $text;
}
else if ($attr == 2) {
# smarten ``backticks'' -style quotes
$do_backticks = 1;
}
else {
$do_backticks = 0;
}
# Special case to handle quotes at the very end of $text when preceded by
# an HTML tag. Add a space to give the quote education algorithm a bit of
# context, so that it can guess correctly that it's a closing quote:
$add_extra_space = 0;
if (preg_match("/>['\"]\\z/", $text)) {
$add_extra_space = 1; # Remember, so we can trim the extra space later.
$text .= " ";
}
$tokens = _TokenizeHTML($text);
$result = '';
$in_pre = 0; # Keep track of when we're inside <pre> or <code> tags
$prev_token_last_char = ""; # This is a cheat, used to get some context
# for one-character tokens that consist of
# just a quote char. What we do is remember
# the last character of the previous text
# token, to use as context to curl single-
# character quote tokens correctly.
foreach ($tokens as $cur_token) {
if ($cur_token[0] == "tag") {
# Don't mess with quotes inside tags
$result .= $cur_token[1];
if (preg_match("@$sp_tags_to_skip@", $cur_token[1], $matches)) {
$in_pre = isset($matches[1]) && $matches[1] == '/' ? 0 : 1;
}
} else {
$t = $cur_token[1];
$last_char = substr($t, -1); # Remember last char of this token before processing.
if (! $in_pre) {
$t = ProcessEscapes($t);
if ($do_backticks) {
$t = EducateBackticks($t);
}
if ($t == "'") {
# Special case: single-character ' token
if (preg_match('/\S/', $prev_token_last_char)) {
$t = "&#8217;";
}
else {
$t = "&#8216;";
}
}
else if ($t == '"') {
# Special case: single-character " token
if (preg_match('/\S/', $prev_token_last_char)) {
$t = "&#8221;";
}
else {
$t = "&#8220;";
}
}
else {
# Normal case:
$t = EducateQuotes($t);
}
}
$prev_token_last_char = $last_char;
$result .= $t;
}
}
if ($add_extra_space) {
preg_replace('/ \z/', '', $result); # Trim trailing space if we added one earlier.
}
return $result;
}
function SmartDashes($text, $attr = NULL, $ctx = NULL) {
global $smartypants_attr, $sp_tags_to_skip;
# Paramaters:
$text; # text to be parsed
$attr; # value of the smart_dashes="" attribute
$ctx; # MT context object (unused)
if ($attr == NULL) $attr = $smartypants_attr;
# reference to the subroutine to use for dash education, default to EducateDashes:
$dash_sub_ref = 'EducateDashes';
if ($attr == 0) {
# do nothing;
return $text;
}
else if ($attr == 2) {
# use old smart dash shortcuts, "--" for en, "---" for em
$dash_sub_ref = 'EducateDashesOldSchool';
}
else if ($attr == 3) {
# inverse of 2, "--" for em, "---" for en
$dash_sub_ref = 'EducateDashesOldSchoolInverted';
}
$tokens;
$tokens = _TokenizeHTML($text);
$result = '';
$in_pre = 0; # Keep track of when we're inside <pre> or <code> tags
foreach ($tokens as $cur_token) {
if ($cur_token[0] == "tag") {
# Don't mess with quotes inside tags
$result .= $cur_token[1];
if (preg_match("@$sp_tags_to_skip@", $cur_token[1], $matches)) {
$in_pre = isset($matches[1]) && $matches[1] == '/' ? 0 : 1;
}
} else {
$t = $cur_token[1];
if (! $in_pre) {
$t = ProcessEscapes($t);
$t = $dash_sub_ref($t);
}
$result .= $t;
}
}
return $result;
}
function SmartEllipses($text, $attr = NULL, $ctx = NULL) {
# Paramaters:
$text; # text to be parsed
$attr; # value of the smart_ellipses="" attribute
$ctx; # MT context object (unused)
if ($attr == NULL) $attr = $smartypants_attr;
if ($attr == 0) {
# do nothing;
return $text;
}
$tokens;
$tokens = _TokenizeHTML($text);
$result = '';
$in_pre = 0; # Keep track of when we're inside <pre> or <code> tags
foreach ($tokens as $cur_token) {
if ($cur_token[0] == "tag") {
# Don't mess with quotes inside tags
$result .= $cur_token[1];
if (preg_match("@$sp_tags_to_skip@", $cur_token[1], $matches)) {
$in_pre = isset($matches[1]) && $matches[1] == '/' ? 0 : 1;
}
} else {
$t = $cur_token[1];
if (! $in_pre) {
$t = ProcessEscapes($t);
$t = EducateEllipses($t);
}
$result .= $t;
}
}
return $result;
}
function EducateQuotes($_) {
#
# Parameter: String.
#
# Returns: The string, with "educated" curly quote HTML entities.
#
# Example input: "Isn't this fun?"
# Example output: &#8220;Isn&#8217;t this fun?&#8221;
#
# Make our own "punctuation" character class, because the POSIX-style
# [:PUNCT:] is only available in Perl 5.6 or later:
$punct_class = "[!\"#\\$\\%'()*+,-.\\/:;<=>?\\@\\[\\\\\]\\^_`{|}~]";
# Special case if the very first character is a quote
# followed by punctuation at a non-word-break. Close the quotes by brute force:
$_ = preg_replace(
array("/^'(?=$punct_class\\B)/", "/^\"(?=$punct_class\\B)/"),
array('&#8217;', '&#8221;'), $_);
# Special case for double sets of quotes, e.g.:
# <p>He said, "'Quoted' words in a larger quote."</p>
$_ = preg_replace(
array("/\"'(?=\w)/", "/'\"(?=\w)/"),
array('&#8220;&#8216;', '&#8216;&#8220;'), $_);
# Special case for decade abbreviations (the '80s):
$_ = preg_replace("/'(?=\\d{2}s)/", '&#8217;', $_);
$close_class = '[^\ \t\r\n\[\{\(\-]';
$dec_dashes = '&\#8211;|&\#8212;';
# Get most opening single quotes:
$_ = preg_replace("{
(
\\s | # a whitespace char, or
&nbsp; | # a non-breaking space entity, or
-- | # dashes, or
&[mn]dash; | # named dash entities
$dec_dashes | # or decimal entities
&\\#x201[34]; # or hex
)
' # the quote
(?=\\w) # followed by a word character
}x", '\1&#8216;', $_);
# Single closing quotes:
$_ = preg_replace("{
($close_class)?
'
(?(1)| # If $1 captured, then do nothing;
(?=\\s | s\\b) # otherwise, positive lookahead for a whitespace
) # char or an 's' at a word ending position. This
# is a special case to handle something like:
# \"<i>Custer</i>'s Last Stand.\"
}xi", '\1&#8217;', $_);
# Any remaining single quotes should be opening ones:
$_ = str_replace("'", '&#8216;', $_);
# Get most opening double quotes:
$_ = preg_replace("{
(
\\s | # a whitespace char, or
&nbsp; | # a non-breaking space entity, or
-- | # dashes, or
&[mn]dash; | # named dash entities
$dec_dashes | # or decimal entities
&\\#x201[34]; # or hex
)
\" # the quote
(?=\\w) # followed by a word character
}x", '\1&#8220;', $_);
# Double closing quotes:
$_ = preg_replace("{
($close_class)?
\"
(?(1)|(?=\\s)) # If $1 captured, then do nothing;
# if not, then make sure the next char is whitespace.
}x", '\1&#8221;', $_);
# Any remaining quotes should be opening ones.
$_ = str_replace('"', '&#8220;', $_);
return $_;
}
function EducateBackticks($_) {
#
# Parameter: String.
# Returns: The string, with ``backticks'' -style double quotes
# translated into HTML curly quote entities.
#
# Example input: ``Isn't this fun?''
# Example output: &#8220;Isn't this fun?&#8221;
#
$_ = str_replace(array("``", "''",),
array('&#8220;', '&#8221;'), $_);
return $_;
}
function EducateSingleBackticks($_) {
#
# Parameter: String.
# Returns: The string, with `backticks' -style single quotes
# translated into HTML curly quote entities.
#
# Example input: `Isn't this fun?'
# Example output: &#8216;Isn&#8217;t this fun?&#8217;
#
$_ = str_replace(array("`", "'",),
array('&#8216;', '&#8217;'), $_);
return $_;
}
function EducateDashes($_) {
#
# Parameter: String.
#
# Returns: The string, with each instance of "--" translated to
# an em-dash HTML entity.
#
$_ = str_replace('--', '&#8212;', $_);
return $_;
}
function EducateDashesOldSchool($_) {
#
# Parameter: String.
#
# Returns: The string, with each instance of "--" translated to
# an en-dash HTML entity, and each "---" translated to
# an em-dash HTML entity.
#
# em en
$_ = str_replace(array("---", "--",),
array('&#8212;', '&#8211;'), $_);
return $_;
}
function EducateDashesOldSchoolInverted($_) {
#
# Parameter: String.
#
# Returns: The string, with each instance of "--" translated to
# an em-dash HTML entity, and each "---" translated to
# an en-dash HTML entity. Two reasons why: First, unlike the
# en- and em-dash syntax supported by
# EducateDashesOldSchool(), it's compatible with existing
# entries written before SmartyPants 1.1, back when "--" was
# only used for em-dashes. Second, em-dashes are more
# common than en-dashes, and so it sort of makes sense that
# the shortcut should be shorter to type. (Thanks to Aaron
# Swartz for the idea.)
#
# en em
$_ = str_replace(array("---", "--",),
array('&#8211;', '&#8212;'), $_);
return $_;
}
function EducateEllipses($_) {
#
# Parameter: String.
# Returns: The string, with each instance of "..." translated to
# an ellipsis HTML entity. Also converts the case where
# there are spaces between the dots.
#
# Example input: Huh...?
# Example output: Huh&#8230;?
#
$_ = str_replace(array("...", ". . .",), '&#8230;', $_);
return $_;
}
function StupefyEntities($_) {
#
# Parameter: String.
# Returns: The string, with each SmartyPants HTML entity translated to
# its ASCII counterpart.
#
# Example input: &#8220;Hello &#8212; world.&#8221;
# Example output: "Hello -- world."
#
# en-dash em-dash
$_ = str_replace(array('&#8211;', '&#8212;'),
array('-', '--'), $_);
# single quote open close
$_ = str_replace(array('&#8216;', '&#8217;'), "'", $_);
# double quote open close
$_ = str_replace(array('&#8220;', '&#8221;'), '"', $_);
$_ = str_replace('&#8230;', '...', $_); # ellipsis
return $_;
}
function ProcessEscapes($_) {
#
# Parameter: String.
# Returns: The string, with after processing the following backslash
# escape sequences. This is useful if you want to force a "dumb"
# quote or other character to appear.
#
# Escape Value
# ------ -----
# \\ &#92;
# \" &#34;
# \' &#39;
# \. &#46;
# \- &#45;
# \` &#96;
#
$_ = str_replace(
array('\\', '\"', "\'", '\.', '\-', '\`'),
array('&#92;', '&#34;', '&#39;', '&#46;', '&#45;', '&#96;'), $_);
return $_;
}
# _TokenizeHTML is shared between PHP SmartyPants and PHP Markdown.
# We only define it if it is not already defined.
if (!function_exists('_TokenizeHTML')) :
function _TokenizeHTML($str) {
#
# Parameter: String containing HTML markup.
# Returns: An array of the tokens comprising the input
# string. Each token is either a tag (possibly with nested,
# tags contained therein, such as <a href="<MTFoo>">, or a
# run of text between tags. Each element of the array is a
# two-element array; the first is either 'tag' or 'text';
# the second is the actual value.
#
#
# Regular expression derived from the _tokenize() subroutine in
# Brad Choate's MTRegex plugin.
# <http://www.bradchoate.com/past/mtregex.php>
#
$index = 0;
$tokens = array();
$match = '(?s:<!(?:--.*?--\s*)+>)|'. # comment
'(?s:<\?.*?\?>)|'. # processing instruction
# regular tags
'(?:<[/!$]?[-a-zA-Z0-9:]+\b(?>[^"\'>]+|"[^"]*"|\'[^\']*\')*>)';
$parts = preg_split("{($match)}", $str, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($parts as $part) {
if (++$index % 2 && $part != '')
$tokens[] = array('text', $part);
else
$tokens[] = array('tag', $part);
}
return $tokens;
}
endif;
/*
PHP SmartyPants
===============
Description
-----------
This is a PHP translation of the original SmartyPants quote educator written in
Perl by John Gruber.
SmartyPants is a web publishing utility that translates plain ASCII
punctuation characters into "smart" typographic punctuation HTML
entities. SmartyPants can perform the following transformations:
* Straight quotes (`"` and `'`) into "curly" quote HTML entities
* Backticks-style quotes (` ``like this'' `) into "curly" quote HTML
entities
* Dashes (`--` and `---`) into en- and em-dash entities
* Three consecutive dots (`...`) into an ellipsis entity
SmartyPants does not modify characters within `<pre>`, `<code>`, `<kbd>`,
`<script>`, or `<math>` tag blocks. Typically, these tags are used to
display text where smart quotes and other "smart punctuation" would not
be appropriate, such as source code or example markup.
### Backslash Escapes ###
If you need to use literal straight quotes (or plain hyphens and
periods), SmartyPants accepts the following backslash escape sequences
to force non-smart punctuation. It does so by transforming the escape
sequence into a decimal-encoded HTML entity:
Escape Value Character
------ ----- ---------
\\ &#92; \
\" &#34; "
\' &#39; '
\. &#46; .
\- &#45; -
\` &#96; `
This is useful, for example, when you want to use straight quotes as
foot and inch marks: 6'2" tall; a 17" iMac.
Bugs
----
To file bug reports or feature requests (other than topics listed in the
Caveats section above) please send email to:
<michel.fortin@michelf.com>
If the bug involves quotes being curled the wrong way, please send example
text to illustrate.
### Algorithmic Shortcomings ###
One situation in which quotes will get curled the wrong way is when
apostrophes are used at the start of leading contractions. For example:
'Twas the night before Christmas.
In the case above, SmartyPants will turn the apostrophe into an opening
single-quote, when in fact it should be a closing one. I don't think
this problem can be solved in the general case -- every word processor
I've tried gets this wrong as well. In such cases, it's best to use the
proper HTML entity for closing single-quotes (`&#8217;`) by hand.
Version History
---------------
1.5.1d (25 May 2005)
* Corrected a small bug in `_TokenizeHTML` where a Doctype declaration
was not seen as HTML (smart quotes where applied inside).
1.5.1c (13 Dec 2004)
* Changed a regular expression in `_TokenizeHTML` that could lead to
a segmentation fault with PHP 4.3.8 on Linux.
1.5.1b (6 Sep 2004)
* Corrected a problem with quotes immediately following a dash
with no space between: `Text--"quoted text"--text.`
* PHP SmartyPants can now be used as a modifier by the Smarty
template engine. Rename the file to "modifier.smartypants.php"
and put it in your smarty plugins folder.
* Replaced a lot of space characters by tabs, saving about 4 KB.
1.5.1a (30 Jun 2004)
* PHP Markdown and PHP Smartypants now share the same `_TokenizeHTML`
function when loaded simultanously.
* Changed the internals of `_TokenizeHTML` to lower the PHP version
requirement to PHP 4.0.5.
1.5.1 (6 Jun 2004)
* Initial release of PHP SmartyPants, based on version 1.5.1 of the
original SmartyPants written in Perl.
Author
------
John Gruber
<http://daringfireball.net/>
Ported to PHP by Michel Fortin
<http://www.michelf.com/>
Additional Credits
------------------
Portions of this plug-in are based on Brad Choate's nifty MTRegex plug-in.
Brad Choate also contributed a few bits of source code to this plug-in.
Brad Choate is a fine hacker indeed. (<http://bradchoate.com/>)
Jeremy Hedley (<http://antipixel.com/>) and Charles Wiltgen
(<http://playbacktime.com/>) deserve mention for exemplary beta testing.
Copyright and License
---------------------
Copyright (c) 2003 John Gruber
<http://daringfireball.net/>
All rights reserved.
Copyright (c) 2004 Michel Fortin
<http://www.michelf.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name "SmartyPants" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
This software is provided by the copyright holders and contributors "as is"
and any express or implied warranties, including, but not limited to, the
implied warranties of merchantability and fitness for a particular purpose
are disclaimed. In no event shall the copyright owner or contributors be
liable for any direct, indirect, incidental, special, exemplary, or
consequential damages (including, but not limited to, procurement of
substitute goods or services; loss of use, data, or profits; or business
interruption) however caused and on any theory of liability, whether in
contract, strict liability, or tort (including negligence or otherwise)
arising in any way out of the use of this software, even if advised of the
possibility of such damage.
*/
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
/*
* Smarty plugin
* -------------------------------------------------------------
* File: postfilter.lang.php
* Type: postfilter
* Name: lang
* Version: 1.0
* Date: August 12, 2002
* Purpose: Parses the intermediate tags left by compiler.lang
* and replaces them with the translated strings,
* according to the $compile_id value (language code).
*
* Install: Drop into the plugin directory, call
* $smarty->load_filter('post','lang');
* or
* $smarty->autoload_filters = array('post' => array('lang'));
* from application.
* Author: Alejandro Sarco <ale@sarco.com.ar>
* -------------------------------------------------------------
*/
function smarty_postfilter_lang1($tpl, &$smarty) {
//Include your own respective translation strings here
//include('path/to/your/languages/directory/'.$smarty->compile_id.'/.your_language_file.php');
$offset = 0;
while ( $start = strpos($tpl, '<?php ($lang.', $offset )) {
$end = strpos($tpl, ') ?>', $start );
$rplstr = substr($tpl, $start + 13, $end - ($start + 13));
$tpl = substr_replace($tpl, $lang[$rplstr], $start, $end - ($start - 4));
$offset = $end + 4;
}
return $tpl;
}
?>