first commit
This commit is contained in:
39
application/helpers/MY_form.php
Normal file
39
application/helpers/MY_form.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class form extends form_Core {
|
||||
|
||||
/**
|
||||
* Creates an HTML form image input tag.
|
||||
*
|
||||
* @param string|array input name or an array of HTML attributes
|
||||
* @param string input value, when using a name
|
||||
* @param string a string to be attached to the end of the attributes
|
||||
* @return string
|
||||
*/
|
||||
public static function image($data = '', $src, $value = '', $extra = '', $index = FALSE)
|
||||
{
|
||||
if ( ! is_array($data))
|
||||
{
|
||||
$data = array('name' => $data);
|
||||
}
|
||||
|
||||
if (empty($data['name']))
|
||||
{
|
||||
// Remove the name if it is empty
|
||||
unset($data['name']);
|
||||
}
|
||||
|
||||
if (strpos($src, '://') === FALSE)
|
||||
{
|
||||
// Make the src attribute into an absolute URL
|
||||
$src = url::base($index).$src;
|
||||
}
|
||||
|
||||
$data['type'] = 'image';
|
||||
$data['src'] = $src;
|
||||
$data['alt'] = $value;
|
||||
|
||||
return form::input($data, $value, $extra);
|
||||
}
|
||||
}
|
||||
?>
|
||||
33
application/helpers/MY_html.php
Normal file
33
application/helpers/MY_html.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class html extends html_Core {
|
||||
|
||||
public static function span_class($text, $class = false)
|
||||
{
|
||||
$html = '<span';
|
||||
$html .= $class ? ' class="'.$class.'">' : '>';
|
||||
$html .= $text;
|
||||
$html .= '</span>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function span_box($text)
|
||||
{
|
||||
$html = '<span class="before"> </span>';
|
||||
$html .= $text;
|
||||
$html .= '<span class="after"> </span>';
|
||||
return $html;
|
||||
}
|
||||
public static function tag($name, $content, $attributes = false)
|
||||
{
|
||||
$html = '<'. $name;
|
||||
if($attributes)
|
||||
{
|
||||
$html .= $attributes;
|
||||
}
|
||||
$html .= '>';
|
||||
$html .= $content;
|
||||
$html .= '</'.$name.'>';
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
10
application/helpers/MY_valid.php
Normal file
10
application/helpers/MY_valid.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class valid extends valid_Core {
|
||||
|
||||
public static function alpha($str, $utf8 = true)
|
||||
{
|
||||
return parent::alpha($str, $utf8);
|
||||
}
|
||||
|
||||
}
|
||||
88
application/helpers/categories.php
Normal file
88
application/helpers/categories.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class categories_Core {
|
||||
|
||||
public static function print_menu($menu, $path, $selected = '', $level = 0)
|
||||
{
|
||||
echo "\n<ul>\n";
|
||||
foreach($menu as $item)
|
||||
{
|
||||
$class = 'level_'. $level;
|
||||
if (!$item[0]->parent_id)
|
||||
{
|
||||
$class .= ' main';
|
||||
}
|
||||
if ($item[0]->id == $selected || $item[0]->name == $selected)
|
||||
{
|
||||
$class .= ' selected';
|
||||
}
|
||||
echo '<li class="'. $class .'">';
|
||||
echo "<div>";
|
||||
echo html::anchor($path. $item[0]->name, $item[0]->title);
|
||||
echo "</div>";
|
||||
if ($item[1])
|
||||
{
|
||||
self::print_menu($item[1], $path, $selected, $level+1);
|
||||
}
|
||||
echo "</li>\n";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
}
|
||||
|
||||
public static function print_menu_admin($menu, $path, $pad = 0)
|
||||
{
|
||||
if($pad == 0)
|
||||
{
|
||||
echo '<table cellpadding="0" cellspacing="0">'."\n";
|
||||
}
|
||||
foreach($menu as $item)
|
||||
{
|
||||
echo '<tr>';
|
||||
echo '<td style="padding-left: '. (5+$pad*15) .'px;">';
|
||||
echo html::anchor($path.'edit/'. $item[0]->id, $item[0]->title);
|
||||
echo '</td><td class="action">';
|
||||
if(!$item[0]->has_products)
|
||||
{
|
||||
echo html::anchor(
|
||||
$path.'add/'. $item[0]->id,
|
||||
html::image('images/admin/add.png'),
|
||||
array('title' => 'dodaj podkategorię')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a title="dodaj podkategorię (niedostępne)">'. html::image('images/admin/add_gray.png') .'</a>';
|
||||
}
|
||||
echo html::anchor(
|
||||
$path.'edit/'. $item[0]->id,
|
||||
html::image('images/admin/edit.png'),
|
||||
array('title' => 'edytuj podkategorię')
|
||||
);
|
||||
|
||||
# czy posiada podkategorie lub produkty?
|
||||
if($item[1] == null && !$item[0]->has_products)
|
||||
{
|
||||
echo html::anchor(
|
||||
$path.'delete/'. $item[0]->id,
|
||||
html::image('images/admin/delete.png'),
|
||||
array('title' => 'usuń podkategorię', 'onclick' => "return confirm('Czy chcesz usunąć kategorię?');")
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a title="usuń podkategorię (niedostępne)">'. html::image('images/admin/delete_gray.png') .'</a>';
|
||||
}
|
||||
|
||||
echo '</td></tr>'."\n";
|
||||
if ($item[1])
|
||||
{
|
||||
self::print_menu_admin($item[1],$path, $pad+1);
|
||||
}
|
||||
}
|
||||
if($pad == 0)
|
||||
{
|
||||
echo '</table>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
83
application/helpers/javascript.php
Normal file
83
application/helpers/javascript.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class javascript_Core {
|
||||
|
||||
public static function open()
|
||||
{
|
||||
return '<script type="text/javascript">';
|
||||
}
|
||||
|
||||
public static function close()
|
||||
{
|
||||
return "</script>\n";
|
||||
}
|
||||
|
||||
public static function tag($script)
|
||||
{
|
||||
$js = '<script type="text/javascript">';
|
||||
$js .= "\n// <![CDATA[\n";
|
||||
$js .= $script;
|
||||
$js .= "\n// ]]>\n";
|
||||
$js .= "</script>\n";
|
||||
return $js;
|
||||
}
|
||||
public static function script($src)
|
||||
{
|
||||
$js = '<script type="text/javascript" src="';
|
||||
$js .= $src;
|
||||
$js .= '"></script>'."\n";
|
||||
return $js;
|
||||
}
|
||||
|
||||
public static function alert($message)
|
||||
{
|
||||
return "alert('$message');";
|
||||
}
|
||||
|
||||
public static function button_anchor_old($link, $name)
|
||||
{
|
||||
$link = url::site($link);
|
||||
return "<button type=\"button\" onclick=\"location.href='$link'\">$name</button>";
|
||||
}
|
||||
|
||||
public static function button_anchor_referer($link, $name)
|
||||
{
|
||||
$link = url::site($link);
|
||||
return "<button type=\"button\" onclick=\"location.href='$link?referer=' + escape( location.href )\">$name</button>";
|
||||
}
|
||||
|
||||
public static function button_anchor($link, $name)
|
||||
{
|
||||
$link = url::site($link);
|
||||
$js = "
|
||||
<script type=\"text/javascript\">
|
||||
function navigateWithReferrer(url)
|
||||
{
|
||||
var fakeLink = document.createElement('a');
|
||||
if (typeof(fakeLink.click) == 'undefined')
|
||||
location.href = url;
|
||||
else
|
||||
{
|
||||
fakeLink.href = url;
|
||||
document.body.appendChild(fakeLink);
|
||||
fakeLink.click();
|
||||
}
|
||||
}
|
||||
</script>\n";
|
||||
return $js ."<button type=\"button\" onclick=\"navigateWithReferrer('$link');\">$name</button>";
|
||||
}
|
||||
|
||||
public static function back_anchor($name)
|
||||
{
|
||||
return "<a href=\"javascript:history.back()\">$name</a>";
|
||||
}
|
||||
|
||||
public static function back_button($name)
|
||||
{
|
||||
return "<button type=\"button\" onclick=\"history.back()\">$name</button>";
|
||||
}
|
||||
public static function print_button($name)
|
||||
{
|
||||
return "<button type=\"button\" onclick=\"print()\">$name</button>";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user