Ejemplo n.º 1
0
/**
 * Image (REPLACES ORIGINAL)
 *
 * Generates an <img /> element
 *
 * @param	mixed
 * @param	bool
 * @param	mixed
 * @return	string
 */
function img($src = '', $index_page = FALSE, $attributes = '')
{
    if (!is_array($src)) {
        $src = array('src' => $src);
    }
    // If there is no alt attribute defined, set it to an empty string
    if (!isset($src['alt'])) {
        $src['alt'] = '';
    }
    $img = '<img';
    foreach ($src as $k => $v) {
        if ($k === 'src' && !preg_match('#^([a-z]+:)?//#i', $v)) {
            if ($index_page === TRUE) {
                $img .= ' src="' . get_instance()->config->site_url($v) . '"';
            } else {
                // prefix with assets/images/
                if (!preg_match('/^assets\\/images/', $v)) {
                    $v = 'assets/images/' . $v;
                }
                $img .= ' src="' . get_instance()->config->slash_item('base_url') . $v . '"';
            }
        } else {
            $img .= ' ' . $k . '="' . $v . '"';
        }
    }
    return $img . _stringify_attributes($attributes) . ' />';
}
 /**
  * Lang
  *
  * Fetches a language variable and optionally outputs a form label
  *
  * @param	string	$line		The language line
  * @param	string	$for		The "for" value (id of the form element)
  * @param	array	$attributes	Any additional HTML attributes
  * @return	string
  */
 function lang($line, $for = '', $attributes = array())
 {
     $line = get_instance()->lang->line($line);
     if ($for !== '') {
         $line = '<label for="' . $for . '"' . _stringify_attributes($attributes) . '>' . $line . '</label>';
     }
     return $line;
 }
Ejemplo n.º 3
0
 public function test_stringify_js_attributes()
 {
     $this->assertEquals('width=800,height=600', _stringify_attributes(array('width' => '800', 'height' => '600'), TRUE));
     $atts = new Stdclass();
     $atts->width = 800;
     $atts->height = 600;
     $this->assertEquals('width=800,height=600', _stringify_attributes($atts, TRUE));
 }
 /**
  * Generates a html select with all countries
  *
  * @access 	public
  * @param 	string
  * @param 	string
  * @param 	string
  * @param 	mixed
  * @return 	string
  */
 function countries_menu($default = 'DZ', $class = '', $name = 'countries', $attributes = '')
 {
     $CI =& get_instance();
     $default or $default = 'DZ';
     $menu = '<select name="' . $name . '"';
     if ($class !== '') {
         $menu .= ' class="' . $class . '"';
     }
     $menu .= _stringify_attributes($attributes) . ">\n";
     //foreach (timezones() as $key => $val)
     foreach (countries() as $key => $val) {
         $selected = $default === $key ? ' selected="selected"' : '';
         $menu .= '<option value="' . $key . '"' . $selected . '>' . _dgettext("system", $val['name']) . "</option>\n";
     }
     return $menu . '</select>';
 }
Ejemplo n.º 5
0
 function display_user($user_id, $photo_size = null, $attributes = null, $show_names = true)
 {
     $ci = get_instance();
     $ci->load->model('users');
     $ci->load->model('user_photo');
     $user_id = (int) $user_id;
     $photo_size = (int) $photo_size;
     if ($photo_size <= 0) {
         $photo_size = 24;
     }
     $user = $ci->users->with_deleted()->get($user_id);
     if (empty($user)) {
         return null;
     }
     $attributes = _stringify_attributes($attributes);
     if (!$show_names) {
         $attributes .= ' title="' . html_escape($user['first_name'] . ' ' . $user['last_name'] . ' (' . $user['username'] . ')') . '"';
     }
     $result = img($ci->user_photo->get($user, $photo_size), false, $attributes);
     if ($show_names) {
         $result .= ' ' . $user['first_name'] . ' ' . $user['last_name'] . ' (' . $user['username'] . ')';
     }
     return $result;
 }
Ejemplo n.º 6
0
 /**
  * Timezone Menu
  *
  * Generates a drop-down menu of timezones.
  *
  * @param	string	timezone
  * @param	string	classname
  * @param	string	menu name
  * @param	mixed	attributes
  * @return	string
  */
 function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
 {
     $CI =& get_instance();
     $CI->lang->load('date');
     $default = $default === 'GMT' ? 'UTC' : $default;
     $menu = '<select name="' . $name . '"';
     if ($class !== '') {
         $menu .= ' class="' . $class . '"';
     }
     $menu .= _stringify_attributes($attributes) . ">\n";
     foreach (timezones() as $key => $val) {
         $selected = $default === $key ? ' selected="selected"' : '';
         $menu .= '<option value="' . $key . '"' . $selected . '>' . $CI->lang->line($key) . "</option>\n";
     }
     return $menu . '</select>';
 }
Ejemplo n.º 7
0
 /**
  * Mailto Link
  *
  * @param	string	the email address
  * @param	string	the link title
  * @param	mixed	any attributes
  * @return	string
  */
 function mailto($email, $title = '', $attributes = '')
 {
     $title = (string) $title;
     if ($title === '') {
         $title = $email;
     }
     return '<a href="mailto:' . $email . '"' . _stringify_attributes($attributes) . '>' . $title . '</a>';
 }
 /**
  * Image
  *
  * Generates an <img /> element
  *
  * @param	mixed
  * @param	bool
  * @param	mixed
  * @return	string
  */
 function img($src = '', $index_page = FALSE, $attributes = '')
 {
     if (!is_array($src)) {
         $src = array('src' => $src);
     }
     // If there is no alt attribute defined, set it to an empty string
     if (!isset($src['alt'])) {
         $src['alt'] = '';
     }
     $img = '<img';
     foreach ($src as $k => $v) {
         if ($k === 'src' && strpos($v, '://') === FALSE) {
             $CI =& get_instance();
             if ($index_page === TRUE) {
                 $img .= ' src="' . $CI->config->site_url($v) . '"';
             } else {
                 $img .= ' src="' . $CI->config->slash_item('base_url') . $v . '"';
             }
         } else {
             $img .= ' ' . $k . '="' . $v . '"';
         }
     }
     return $img . _stringify_attributes($attributes) . ' />';
 }
Ejemplo n.º 9
0
 /**
  * Timezone Menu
  *
  * Generates a drop-down menu of timezones.
  *
  * @param	string	timezone
  * @param	string	classname
  * @param	string	menu name
  * @param	mixed	attributes
  * @return	string
  */
 function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
 {
     $CI =& get_instance();
     include_once BASEPATH . 'vendor/timezones.php';
     $default = $default === 'GMT' ? 'UTC' : $default;
     $menu = '<select name="' . $name . '"';
     if ($class !== '') {
         $menu .= ' class="' . $class . '"';
     }
     $menu .= _stringify_attributes($attributes) . ">\n";
     //foreach (timezones() as $key => $val)
     foreach ($timezones as $key => $val) {
         $selected = $default === $key ? ' selected="selected"' : '';
         $menu .= '<option value="' . $key . '"' . $selected . '>' . _dgettext("system", $val) . "</option>\n";
     }
     return $menu . '</select>';
 }
Ejemplo n.º 10
0
/**
 * Secure Anchor Link
 *
 * Creates a secure anchor based on the local URL, and if USE_SSL is 'on'.
 *
 * @param  string  the URL
 * @param  string  the link title
 * @param  mixed   any attributes
 */
function secure_anchor($uri = '', $title = '', $attributes = '')
{
    $title = (string) $title;
    $site_url = is_array($uri) ? secure_site_url($uri) : preg_match('#^(\\w+:)?//#i', $uri) ? $uri : secure_site_url($uri);
    if ($title === '') {
        $title = $site_url;
    }
    if ($attributes !== '') {
        $attributes = _stringify_attributes($attributes);
    }
    return '<a href="' . $site_url . '"' . $attributes . '>' . $title . '</a>';
}
function _main_menu_widget_display_children($items, $level = 0)
{
    foreach ($items as $item) {
        if (empty($item['blank'])) {
            ?>

                                <li<?php 
            if (!empty($item['is_active'])) {
                ?>
 class="active"<?php 
            }
            ?>
><a href="<?php 
            echo $item['link'];
            ?>
"<?php 
            echo _stringify_attributes($item['attributes']);
            ?>
><?php 
            echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level);
            if ($item['icon'] != '') {
                ?>
<i class="<?php 
                echo $item['icon'];
                ?>
"></i>&nbsp; <?php 
            }
            echo $item['label'];
            ?>
</a></li>

<?php 
        } else {
            ?>

                                <li class="divider"></li>

<?php 
        }
        if (!empty($item['children'])) {
            _main_menu_widget_display_children($item['children'], $level + 1);
        }
    }
}
Ejemplo n.º 12
0
 /**
  * Image.
  *
  * Generates an <img /> element
  *
  * @param	mixed
  * @param	bool
  * @param	mixed
  *
  * @return string
  */
 function img($src = '', $index_page = false, $attributes = '')
 {
     if (!is_array($src)) {
         $src = ['src' => $src];
     }
     // If there is no alt attribute defined, set it to an empty string
     if (!isset($src['alt'])) {
         $src['alt'] = '';
     }
     $img = '<img';
     foreach ($src as $k => $v) {
         if ($k === 'src' && !preg_match('#^([a-z]+:)?//#i', $v)) {
             if ($index_page === true) {
                 $img .= ' src="' . get_instance()->config->site_url($v) . '"';
             } else {
                 $img .= ' src="' . get_instance()->config->slash_item('base_url') . $v . '"';
             }
         } else {
             $img .= ' ' . $k . '="' . $v . '"';
         }
     }
     return $img . _stringify_attributes($attributes) . ' />';
 }
Ejemplo n.º 13
0
 /**
  * Encodes any email address into HTML entities so that spam bots do not find it.
  *
  * @author 	Kader Bouyakoub <http://www.bkader.com/>
  * @link 	@bkader <github>
  * @link 	@KaderBouyakoub <twitter>
  *
  * @access 	public
  * @param 	string
  * @param 	string
  * @param 	mixed
  * @param 	string
  * @return 	string
  */
 function encode_emailto($email, $text = null, $attr = null, $subject = null)
 {
     $text or $text = $email;
     // remplazar aroba y puntos
     $email = str_replace('@', '&#64;', $email);
     $email = str_replace('.', '&#46;', $email);
     $email = str_split($email, 5);
     $text = str_replace('@', '&#64;', $text);
     $text = str_replace('.', '&#46;', $text);
     $text = str_split($text, 5);
     $part1 = '<a href="ma';
     $part2 = 'ilto&#58;';
     $part3 = '"' . _stringify_attributes($attr) . '>';
     $part4 = '</a>';
     $encoded = '<script type="text/javascript">';
     $encoded .= "document.write('{$part1}');";
     $encoded .= "document.write('{$part2}');";
     foreach ($email as $e) {
         $encoded .= "document.write('{$e}');";
     }
     $encoded .= "document.write('{$part3}');";
     foreach ($text as $l) {
         $encoded .= "document.write('{$l}');";
     }
     $encoded .= "document.write('{$part4}');";
     $encoded .= '</script>';
     return $encoded;
 }
Ejemplo n.º 14
0
 /**
  * Generates an image using placehold.it
  *
  * @access  public
  * @param   mixed
  * @param   integer
  * @param   string
  * @param   string
  * @param   string
  * @param   mixed
  * @return  string
  */
 function img_alt($width, $height = null, $text = null, $background = null, $foreground = null, $attr = null)
 {
     if (is_array($width)) {
         $params = $width;
     } else {
         $params = array();
         $params['width'] = $width;
         $params['height'] = $height;
         $params['text'] = $text;
         $params['background'] = $background;
         $params['foreground'] = $foreground;
         $params['attr'] = $attr;
     }
     $params['height'] = empty($params['height']) ? $params['width'] : $params['height'];
     $params['text'] = empty($params['text']) ? $params['width'] . ' x ' . $params['height'] : $params['text'];
     $params['background'] = empty($params['background']) ? 'CCCCCC' : $params['height'];
     $params['foreground'] = empty($params['foreground']) ? '969696' : $params['foreground'];
     return '<img src="http://placehold.it/' . $params['width'] . 'x' . $params['height'] . '/' . $params['background'] . '/' . $params['foreground'] . '&text=' . $params['text'] . '" alt="Placeholder"' . (isset($params['attr']) ? _stringify_attributes($params['attr']) : '') . ' />';
 }
Ejemplo n.º 15
0
 /**
  * Generates a html5 audio tag
  * It is required that you set html5 as the doctype to use this method
  *
  * @param	mixed 	one or multiple audio sources
  * @param	mixed 	tag attributes
  * @return	string
  */
 function audio($src = '', $attr = null)
 {
     if (is_array($src)) {
         $output = '';
         foreach ($src as $elem) {
             $output[] = audio($elem);
         }
         return implode("\n", $output);
     }
     return '<source src="' . $src . '"' . ($attr ? _stringify_attributes($attr) : '') . ' />';
 }