}
    ?>
          </td>
          <td align="center" valign="top">
            <table>
                <tr>
                    <td class="default" align="right">From</td>
                    <td align="center" NOWRAP><?php 
    echo smarty_function_html_select_date(array('time' => $this->_tpl_vars['start_date'], 'prefix' => "", 'field_array' => 'start', 'start_year' => "-2", 'end_year' => "+1", 'field_order' => 'YMD', 'month_format' => "%b", 'year_empty' => 'year', 'month_empty' => 'mon', 'day_empty' => 'day', 'all_extra' => "class='default'"), $this);
    ?>
</td>
                </tr>
                <tr>
                    <td class="default" align="right">To</td>
                    <td align="center" NOWRAP><?php 
    echo smarty_function_html_select_date(array('time' => $this->_tpl_vars['end_date'], 'prefix' => "", 'field_array' => 'end', 'start_year' => "-2", 'end_year' => "+1", 'field_order' => 'YMD', 'month_format' => "%b", 'year_empty' => 'year', 'month_empty' => 'mon', 'day_empty' => 'day', 'all_extra' => "class='default'"), $this);
    ?>
</td>
                </tr>
            </table>
            <input type="button" name="clear_date" value="Clear Date" onClick="clearDate()" class="shortcut">
          </td>
          <td align="center" valign="top">
            <select name="display_sections[]" size="5" multiple class="default">
                <?php 
    echo smarty_function_html_options(array('options' => $this->_tpl_vars['sections'], 'selected' => $this->_tpl_vars['display_sections']), $this);
    ?>

            </select>
          </td>
        </tr>
Пример #2
0
function smarty_function_dataform2($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
    require_once $smarty->_get_plugin_filepath('shared', 'video_service');
    require_once $smarty->_get_plugin_filepath('function', 'html_options');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_date');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_time');
    require_once $smarty->_get_plugin_filepath('modifier', 'truncate');
    require_once $smarty->_get_plugin_filepath('modifier', 'nl2br');
    require_once $smarty->_get_plugin_filepath('modifier', 'wordwrap');
    require_once $smarty->_get_plugin_filepath('modifier', 'return_bytes');
    require_once $smarty->_get_plugin_filepath('modifier', 'fsize_format');
    $row = array();
    $dd = array();
    $options = array();
    $key = null;
    $key1 = null;
    $key2 = null;
    $type = 0;
    $name = 'dfform';
    $object = null;
    $edit = false;
    $table = null;
    $preset = null;
    $is_child = false;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'name':
            case 'object':
            case 'title':
            case 'key':
            case 'key1':
            case 'key2':
            case 'preset':
                ${$_key} = (string) $_val;
                break;
            case 'options':
            case 'row':
            case 'dd':
                ${$_key} = (array) $_val;
                break;
            case 'paginate':
            case 'is_child':
            case 'edit':
                ${$_key} = (bool) $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("dataform: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    if (!$object) {
        $object = $name;
    }
    if (!$table) {
        $table = $object;
    }
    if (empty($row) && empty($dd)) {
        $smarty->trigger_error("dataform: either dd or row attribute must be present", E_USER_NOTICE);
        return '';
    }
    if (empty($row)) {
        $type = 2;
        /* new record */
    }
    if ($edit) {
        $type = 1;
    }
    if (empty($dd)) {
        $labels = null;
    } else {
        foreach ($dd as $_key => $_val) {
            $labels[$_key] = $_val['label'];
        }
    }
    if ($preset) {
        list($_field, $_text) = preg_split('/,/', $preset);
        list($_fieldname, $_fieldvalue) = preg_split('/=/', $_field);
        $_preset[$_fieldname] = $_fieldvalue;
        $_preset_text[$_fieldname] = $_text;
    }
    $_html_rows = '';
    $_html_result = '';
    $h_f = $key2 ? F2 : F;
    # Determinar el tamaño máximo de los archivo
    $upload = smarty_modifier_return_bytes(ini_get('upload_max_filesize'));
    $post = smarty_modifier_return_bytes(ini_get('post_max_size'));
    $max_size = 0;
    if ($upload < $post) {
        $max_size = $upload;
    } else {
        $max_size = $post;
    }
    $max_size = smarty_modifier_fsize_format($max_size);
    # Crea las filas del dataform
    $_i = 0;
    // Para los preset
    $_pre = '';
    if ($type) {
        foreach ((array) $dd as $_key => $_val) {
            if (!$dd[$_key]) {
                continue;
            }
            if ($type == 2) {
                $_val = '';
            }
            if ($type == 1) {
                $_val = $row[$_val['name']];
            }
            if ($dd[$_key]['references'] && $dd[$_key]['type'] != 'auto' && $dd[$_key]['type'] != 'hidden') {
                if ($_preset[$_key]) {
                    $_selected = $_preset[$_key];
                } else {
                    $_selected = $_val;
                    $_val = $row[$dd[$_key]['references']];
                }
                $dd[$_key]['type'] = 'references';
            }
            $_start_year = "-10";
            $_end_year = "+10";
            $_ispreset = false;
            switch ($dd[$_key]['type']) {
                //Add
                case 'video':
                    $_tmp = '';
                    $_options = smarty_function_video_service();
                    if ($_val) {
                        require_once $smarty->_get_plugin_filepath('shared', 'video_service');
                        $a_vs = smarty_function_video_service();
                        //      XML
                        require_once 'XML/Unserializer.php';
                        $options = array(XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE => true, XML_UNSERIALIZER_OPTION_ATTRIBUTES_ARRAYKEY => false);
                        $unserializer = new XML_Unserializer($options);
                        $status = $unserializer->unserialize($_val, false);
                        if (PEAR::isError($status)) {
                            echo 'Error: ' . $status->getMessage();
                        } else {
                            $vs = $unserializer->getUnserializedData();
                        }
                        //  -----
                        $_tmp .= smarty_function_html_options(array('name' => $_key . '_type', 'options' => $_options, 'selected' => $vs['tipo']), $smarty) . '<input type="text" size="25" name="' . $_key . '_src" maxlength="500" value="' . $vs['src'] . '" />';
                    } else {
                        $_tmp .= smarty_function_html_options(array('name' => $_key . '_type', 'options' => $_options, 'selected' => $_val), $smarty) . '<input type="text" size="25" name="' . $_key . '_src" maxlength="500" />';
                    }
                    break;
                    //End Add
                //End Add
                case 'auto':
                    if ($dd[$_key]['extra']['default']) {
                        $_tmp = '<span class="auto">' . $dd[$_key]['extra']['default'] . '</span>';
                    } else {
                        $_tmp = !empty($_val) ? $_val : '';
                    }
                    break;
                case 'file':
                    $_tmp = '';
                    if ($_val) {
                        $_file = HOMEDIR . "/_" . $table . "/" . $_val;
                        $_icon = 'doc.png';
                        $_p = explode('.', $_file);
                        $_pc = count($_p);
                        $ext = $_p[$_pc - 1];
                        if (preg_match('/doc|rtf|swx|osd/i', $ext)) {
                            $_icon = 'doc.png';
                        }
                        if (preg_match('/pdf/i', $ext)) {
                            $_icon = 'pdf.png';
                        }
                        if (preg_match('/xls/i', $ext)) {
                            $_icon = 'excel.png';
                        }
                        if (preg_match('/jpg|gif|png/i', $ext)) {
                            $_icon = 'image.png';
                        }
                        $_tmp = '<input type="checkbox" checked name="' . $_key . '_keep" /> Conservar archivo actual (' . $_val . ')<br /><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" alt="' . $_val . '" border="0" /><br />';
                    }
                    $_tmp .= '[' . $max_size . ']<input type="file" name="' . $_key . '" value="' . $_val . '" />';
                    break;
                case 'image':
                case 'img':
                    $_tmp = '';
                    $_icon = 'image.png';
                    $_tmp = '[' . $max_size . ']<input name="old_' . $_key . '" type="hidden" value="' . $_val . '" /><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" border="0" alt="Imagen" title="Imagen" />';
                    if ($_val) {
                        $_tmp .= '<input type="checkbox" checked name="' . $_key . '_keep" /> Conservar archivo actual (' . $_val . ')<br /><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /><br />';
                    }
                    $_tmp .= '<input type="file" name="' . $_key . '" value="' . $_val . '" />';
                    break;
                case 'boolean':
                case 'bool':
                    if (preg_match("/:/", $dd[$_key]['extra']['label_bool'])) {
                        list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                        $_tchecked = $_val == 't' ? 'checked' : '';
                        $_fchecked = $_val == 'f' ? 'checked' : '';
                        $_tmp = $_si . '<input type="radio" name="' . $_key . '" ' . $_tchecked . ' value="on" />' . $_no . '<input type="radio" name="' . $_key . '" ' . $_fchecked . ' value="" />';
                    } else {
                        $_checked = $_val == 't' ? 'checked' : '';
                        $_tmp = '<input type="checkbox" name="' . $_key . '" ' . $_checked . ' />';
                    }
                    break;
                case 'datenull':
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    if (!isset($_val) || empty($_val)) {
                        $_val = '--';
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year, 'day_empty' => '--', 'month_empty' => '--', 'year_empty' => '--'), $smarty);
                    break;
                case 'date':
                    if (!$_val) {
                        $_val = $dd[$_key]['extra']['default'];
                    }
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year), $smarty);
                    break;
                case 'time':
                    $_tmp = smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                    break;
                case 'datetime':
                    if (!$_val) {
                        $_val = $dd[$_key]['extra']['default'];
                    }
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year), $smarty);
                    $_tmp .= smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                    break;
                case 'datetimenull':
                    if (!$_val) {
                        $_val = $dd[$_key]['extra']['default'];
                    }
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year, 'day_empty' => '--', 'month_empty' => '--', 'year_empty' => '--'), $smarty);
                    $_tmp .= smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                    break;
                case 'password':
                    $_tmp = '<input type="password" name="' . $_key . '" size="20" maxlength="16" />';
                    break;
                case 'text':
                    $_tmp = '<textarea rows="5" cols="40" name="' . $_key . '">' . $_val . '</textarea> <a href="javascript:edittext(\'' . $name . '\', \'' . $_key . '\', document.forms[\'' . $name . '\'].' . $_key . '.value);">' . ALM_MAX . '</a>';
                    break;
                case 'html':
                    $_tmp = '<textarea rows="5" cols="40" class="adm" id="' . $_key . '" name="' . $_key . '">' . $_val . '</textarea>';
                    $_tmp .= "<script language=\"JavaScript\">\ngenerate_wysiwyg('" . $_key . "');\n</script>\n";
                    break;
                case 'xhtml':
                    $_tmp = '<textarea rows="5" cols="40" class="adm" id="' . $_key . '" name="' . $_key . '"' . ($dd[$_key]['extra']['style'] ? ' style="' . $dd[$_key]['extra']['style'] . '"' : '') . '>' . $_val . '</textarea>';
                    $_tmp .= "<script language=\"JavaScript\">\ntinyMCE.execCommand(\"mceAddControl\", true,\"{$_key}\");\n</script>\n";
                    break;
                case 'varchar':
                case 'char':
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_val), $smarty);
                        $_tmp = preg_replace("/_REFERENCE_/", $_tmp, FCELLMODREF);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                    } else {
                        $_val = preg_replace("/\"/", "&quot;", $_val);
                        $_tmp = preg_replace("/_VALUE_/", qdollar($_val), FCELLMODSTR);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        $_tmp = preg_replace("/_SIZE_/", $dd[$_key]['size'], $_tmp);
                        if ($dd[$_key]['extra']['source']) {
                            $_tmp .= '<script type="text/javascript">
                          addEvent(document.getElementById(\'' . $dd[$_key]['extra']['source'] . '\'), \'blur\', function () { if(document.getElementById(\'' . $_key . '\').value.replace(/(^\\s*)|(\\s*$)/g, \'\') == \'\')  document.getElementById(\'' . $_key . '\').value = ' . $dd[$_key]['extra']['apply_funct_js'] . '(document.getElementById(\'' . $dd[$_key]['extra']['source'] . '\').value) });
                        </script>';
                        }
                        if ($dd[$_key]['extra']['autocomplete']) {
                            $_tmp .= '<script type="text/javascript">
                          $(\'#' . $_key . '\').autocomplete({ serviceUrl:' . ($dd[$_key]['extra']['autocomplete_sr'] ? $dd[$_key]['extra']['autocomplete_sr'] : '\'' . URL . '/' . ALM_URI . '/js/autocomplete/autocomplete.php\'') . ', delimiter: /(,|;)\\s*/, params: { table:\'' . ($dd[$_key]['extra']['autocomplete_tb'] ? $dd[$_key]['extra']['autocomplete_tb'] : $table) . '\', field:\'' . ($dd[$_key]['extra']['autocomplete_fd'] ? $dd[$_key]['extra']['autocomplete_fd'] : ($dd[$_key]['extra']['autocomplete_tb'] ? $dd[$_key]['extra']['autocomplete_tb'] : $_key)) . '\' } });
                        </script>';
                        }
                    }
                    break;
                case 'numeric':
                case 'int':
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_val), $smarty);
                        $_tmp = preg_replace("/_REFERENCE_/", $_tmp, FCELLMODREF);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                    } else {
                        $_tmp = preg_replace("/_VALUE_/", $_val, FCELLMODSTR);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        $_tmp = preg_replace("/_SIZE_/", 10, $_tmp);
                    }
                    break;
                case 'references':
                    if ($_preset[$_key]) {
                        $_tmp = '';
                        $_ispreset = true;
                        $_pre .= '<input type="hidden" name="' . $_key . '" value="' . $_selected . '" />';
                        //$_tmp = '<input type="hidden" name="' . $_key . '" value="' . $_selected . '" />';
                        //$_tmp .= $_selected;
                    } else {
                        if ($dd[$_key]['extra']['readonly']) {
                            $_tmp = preg_replace("/_FIELD_/", $_key, FCELLHIDEN);
                            $_tmp = preg_replace("/_VALUE_/", qdollar($_selected), $_tmp);
                            $_tmp = preg_replace("/_LABEL_/", $_val, $_tmp);
                        } else {
                            $_options = $options[$_key];
                            $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_selected), $smarty);
                            $_tmp = preg_replace("/_REFERENCE_/", $_tmp, FCELLMODREF);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                            if ($dd[$_key]['extra']['son']) {
                                $_tmp = preg_replace("/_CHANGE_/", "updateCombo('{$_key}', '" . $dd[$_key]['extra']['son'] . "', null)", $_tmp);
                            } else {
                                $_tmp = preg_replace("/_CHANGE_/", "", $_tmp);
                            }
                            if ($dd[$_key]['extra']['open_popup']) {
                                $_tmp .= '&nbsp;<a href="javascript:openPopUp(\'' . URL . '/' . ALM_URI . '/query.php?f=' . $dd[$_key]['references'] . '&action=record&' . $_key . '=\'+document.forms[\'new\'].' . $_key . '.value,' . $dd[$_key]['extra']['height'] . ',' . $dd[$_key]['extra']['width'] . ');">consultar</a>';
                            }
                            if ($dd[$_key]['extra']['depend']) {
                                $_tmp .= "<script>updateCombo('" . $dd[$_key]['extra']['depend'] . "', '{$_key}', '{$_selected}')</script>";
                            }
                        }
                    }
                    break;
                case 'hidden':
                case 'serial':
                    $hidden = true;
                    $_tmp = '';
                    break;
                default:
                    $_tmp = $_val;
            }
            if (!$_ispreset) {
                $_tmp = preg_replace("/_FCELL_/", qdollar($_tmp), FROW);
            }
            $_tmp = preg_replace("/_LABEL_/", $labels[$_key], $_tmp);
            if (!$hidden) {
                $_html_rows .= $_tmp;
            }
            $hidden = false;
        }
    } else {
        foreach ((array) $row as $_key => $_val) {
            $_tmp = '';
            if (!$dd[$_key]) {
                continue;
            }
            if ($dd[$_key]['references']) {
                $pos = strpos($dd[$_key]['references'], '.');
                if ($pos !== false) {
                    $r_table = substr($dd[$_key]['references'], 0, $pos);
                    $pos_2 = strpos($dd[$_key]['references'], '[');
                    if ($pos_2 !== false) {
                        $r_field = substr($dd[$_key]['references'], $pos_2 + 1, strlen($dd[$_key]['references']) - ($pos_2 + 2));
                    } else {
                        $r_field = $r_table;
                    }
                    $_val = $row[$r_field];
                } else {
                    $_val = $row[$dd[$_key]['references']];
                }
            }
            switch ($dd[$_key]['type']) {
                case 'char':
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_tmp = $_options[$_val];
                    } else {
                        $_tmp = smarty_modifier_truncate($_val, 50);
                    }
                    break;
                case 'bool':
                case 'boolean':
                    $_si = ALM_YES;
                    $_no = ALM_NO;
                    if ($dd[$_key]['extra']['label_bool']) {
                        list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                    }
                    $_tmp = $_val == 't' ? $_si : $_no;
                    break;
                case 'video':
                    if ($_val) {
                        require_once $smarty->_get_plugin_filepath('shared', 'video_service');
                        $a_vs = smarty_function_video_service();
                        //      XML
                        require_once 'XML/Unserializer.php';
                        $options = array(XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE => true, XML_UNSERIALIZER_OPTION_ATTRIBUTES_ARRAYKEY => false);
                        $unserializer = new XML_Unserializer($options);
                        $status = $unserializer->unserialize($_val, false);
                        if (PEAR::isError($status)) {
                            echo 'Error: ' . $status->getMessage();
                        } else {
                            $vs = $unserializer->getUnserializedData();
                        }
                        //	-----
                        $_tmp = '<a href="javascript:openwindow(\'' . URL . '/' . ALM_URI . '/video.php?src=' . $vs['src'] . '&type=' . $vs['tipo'] . '\',400,333)"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $vs['tipo'] . '.png" alt="' . $a_vs[$vs['tipo']] . '" title="' . $a_vs[$vs['tipo']] . '" border="0" /></a>';
                    } else {
                        $_tmp = '--';
                    }
                    break;
                case 'file':
                    if ($_val) {
                        $_icon = $_val;
                        $_file = HOMEDIR . "/_" . $table . "/" . $_val;
                        $_icon = 'doc.png';
                        $_p = explode('.', $_file);
                        $_pc = count($_p);
                        if ($_p[$_pc - 1] == 'doc') {
                            $_icon = 'doc.png';
                        }
                        if ($_p[$_pc - 1] == 'pdf') {
                            $_icon = 'pdf.png';
                        }
                        if ($_p[$_pc - 1] == 'xls') {
                            $_icon = 'xls.png';
                        }
                        $_tmp = '<a title="' . $_val . '" href="' . URL . '/files/' . $table . '/' . $_val . '" target="_new"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" alt="' . $_val . '" border="0" /></a>';
                    } else {
                        $_tmp = '--';
                    }
                    break;
                case 'image':
                    if ($_val) {
                        if (THUMBNAILING) {
                            $_tmp = '<a href="javascript:openimage(\'' . URL . '/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /></a>';
                        } else {
                            $_tmp = '<a href="javascript:openimage(\'/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /></a>';
                        }
                    } else {
                        $_tmp = '--';
                    }
                    break;
                case 'hidden':
                case 'serial':
                    $hidden = true;
                    $_tmp = '';
                    break;
                default:
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_val = $_options[trim($_val)];
                    }
                    if ($_preset[$_key]) {
                        $_tmp = '';
                        if (!empty($_pre)) {
                            $_pre .= ',';
                        }
                        $_pre .= $_key . '=' . $_preset[$_key];
                    } else {
                        $_tmp = smarty_modifier_wordwrap($_val);
                        $_tmp = smarty_modifier_nl2br($_tmp);
                    }
            }
            if (!$_preset[$_key]) {
                $_tmp = preg_replace('/_FCELL_/', qdollar($_tmp), FROW);
                $_tmp = preg_replace('/_LABEL_/', $labels[$_key], $_tmp);
            }
            if (!$hidden) {
                $_html_rows .= $_tmp;
            }
            $hidden = false;
        }
        $_html_cmd = preg_replace('/{_ID_}/', $row[$key], FCMD);
        if (!empty($_pre)) {
            $_pre = '<input type="hidden" name="preset" value="' . $_pre . '" />';
        }
    }
    if ($type == 2) {
        $_html_cmd = FCMDADD;
        $action = "add";
    }
    if ($type == 1) {
        $_html_cmd = FCMDMOD;
        $action = "save";
    }
    if ($type == 0) {
        $_html_cmd = FCMD;
        $action = "edit";
    }
    //if ($cmd)
    $_html_rows .= $_html_cmd;
    $_i++;
    $_tmp = FROW;
    if (!($_i % 2)) {
        $_tmp = preg_replace("/class=\"dgrow\"/", "class=\"dgrow2\"", $_tmp);
    }
    #$_html_rows .= preg_replace("/_FCELL_/", $_html_row, $_tmp);
    if ($paginate && $maxrows && $_i >= $maxrows * $pg) {
        $_need_paginate = true;
        break;
    }
    $_f = preg_replace('/_PRESET_/', $_pre, $h_f);
    //$_f = $h_f;
    $_html_result = preg_replace("/_FHEADER_/", $_html_labels, $_f);
    if ($cmd) {
        $_html_result = preg_replace("/_FHEADERCMD_/", FHEADERCMD, $_html_result);
    }
    $_html_result = preg_replace("/_FHEADERCMD_/", '', $_html_result);
    $_html_result = preg_replace("/_TITLE_/", $title, $_html_result);
    $_html_result = preg_replace('/_FROW_/', qdollar($_html_rows), $_html_result);
    #$_npgs = ceil(count($rows) / $maxrows);
    $_paginate = '';
    if ($paginate && $_npgs > 1) {
        if ($pg != 1) {
            $_paginate = PREV;
        }
        for ($_j = 1; $_j <= $_npgs; $_j++) {
            $npg = $_j == $pg ? CURRENTPG : NPG;
            $_paginate .= preg_replace("/_NPG_/", $_j, $npg);
        }
        if ($pg != $_npgs) {
            $_paginate .= NEXT;
        }
    }
    $_html_result = preg_replace("/_PAGINATE_/", $_paginate, $_html_result);
    # christian | a new way to know if this pages is the 404.php file
    $params = preg_split('/\\//', $_SERVER['PHP_SELF']);
    $page = $params[count($params) - 1];
    # end
    if ($page == '404.php') {
        $_html_result = preg_replace("/_SELF_/", SELF, $_html_result);
    } else {
        $_html_result = preg_replace("/_SELF_/", $_SERVER['PHP_SELF'], $_html_result);
    }
    $_referer = preg_replace("/\\//", "\\/", $_SERVER['PHP_SELF']);
    if (preg_match("/{$_referer}/", $_SERVER['HTTP_REFERER']) || $is_child || $_SERVER['PHP_SELF'] == '/cms/query.php' || $_SERVER['PHP_SELF'] == '/' . ALM_URI . '/query.php') {
        $_referer = $_SERVER['PHP_SELF'];
    } else {
        if (defined('SELF')) {
            $_referer = SELF;
        } else {
            $_referer = $_SERVER['PHP_SELF'];
        }
    }
    if ($is_child) {
        $_referer .= '?action=close';
    }
    // Si es el popup de consulta
    if ($_SERVER['PHP_SELF'] == '/cms/query.php' || $_SERVER['PHP_SELF'] == '/' . ALM_URI . '/query.php') {
        $_referer .= '?action=close';
    }
    $_html_result = preg_replace("/_REFERER_/", $_referer, $_html_result);
    $_html_result = preg_replace("/_KEY_/", $key, $_html_result);
    $_html_result = preg_replace("/_KEY1_/", $key1, $_html_result);
    $_html_result = preg_replace("/_KEY2_/", $key2, $_html_result);
    $_html_result = preg_replace("/{_ID_}/", $_REQUEST[$key], $_html_result);
    $_html_result = preg_replace("/_ID1_/", $_REQUEST[$key1], $_html_result);
    $_html_result = preg_replace("/_ID2_/", $_REQUEST[$key2], $_html_result);
    $_html_result = preg_replace("/_SORT_/", $_REQUEST['sort'], $_html_result);
    $_html_result = preg_replace("/_PG_/", $_REQUEST[$object . 'pg'], $_html_result);
    $_html_result = preg_replace("/_PGPREV_/", $pg - 1, $_html_result);
    $_html_result = preg_replace("/_PGNEXT_/", $pg + 1, $_html_result);
    $_html_result = preg_replace("/_FORM_/", $name, $_html_result);
    $_html_result = preg_replace("/_OBJECT_/", $object, $_html_result);
    $_html_result = preg_replace("/_ACTION_/", $action, $_html_result);
    if ($type == 0) {
        $_html_result = preg_replace('/old_/', '', $_html_result);
    }
    if (strpos($_html_rows, 'value="Agregar"') != '') {
        $_SESSION['accion'] = 'add';
    } elseif (isset($_SESSION['accion'])) {
        unset($_SESSION['accion']);
    }
    return $_html_result;
}
	</select>
	<?php 
echo $this->_plugins['function']['translate'][0][0]->smartyTranslate(array('key' => "common.between"), $this);
?>

	<?php 
echo smarty_function_html_select_date(array('prefix' => 'dateFrom', 'time' => $this->_tpl_vars['dateFrom'], 'all_extra' => "class=\"selectMenu\"", 'year_empty' => "", 'month_empty' => "", 'day_empty' => "", 'start_year' => "-5", 'end_year' => "+1"), $this);
?>

	<?php 
echo $this->_plugins['function']['translate'][0][0]->smartyTranslate(array('key' => "common.and"), $this);
?>

	<?php 
echo smarty_function_html_select_date(array('prefix' => 'dateTo', 'time' => $this->_tpl_vars['dateTo'], 'all_extra' => "class=\"selectMenu\"", 'year_empty' => "", 'month_empty' => "", 'day_empty' => "", 'start_year' => "-5", 'end_year' => "+1"), $this);
?>

	<input type="hidden" name="dateToHour" value="23" />
	<input type="hidden" name="dateToMinute" value="59" />
	<input type="hidden" name="dateToSecond" value="59" />
	<br/>
	<input type="submit" value="<?php 
echo $this->_plugins['function']['translate'][0][0]->smartyTranslate(array('key' => "common.search"), $this);
?>
" class="button" />
</form>
&nbsp;

<?php 
if ($this->_tpl_vars['displayResults']) {
                $this->_smarty_include(array('smarty_include_tpl_file' => "error_icon.tpl.html", 'smarty_include_vars' => array('field' => "custom_field[" . $this->_tpl_vars['custom_field_id'] . "][Month]")));
                $this->_tpl_vars = $_smarty_tpl_vars;
                unset($_smarty_tpl_vars);
                ?>
                    <?php 
                echo smarty_function_html_select_date(array('field_array' => "custom_field[" . $this->_tpl_vars['custom_field_id'] . "]", 'prefix' => '', 'all_extra' => "class=\"default\"", 'day_empty' => '', 'time' => '--', 'display_months' => false, 'display_years' => false, 'day_value_format' => "%02d", 'day_extra' => "id=\"custom_field_" . $this->_tpl_vars['custom_field_id'] . "_day\" tabindex=\"" . $this->_tpl_vars['tabindex']++ . "\""), $this);
                ?>

                    <?php 
                $_smarty_tpl_vars = $this->_tpl_vars;
                $this->_smarty_include(array('smarty_include_tpl_file' => "error_icon.tpl.html", 'smarty_include_vars' => array('field' => "custom_field[" . $this->_tpl_vars['custom_field_id'] . "][Day]")));
                $this->_tpl_vars = $_smarty_tpl_vars;
                unset($_smarty_tpl_vars);
                ?>
                    <?php 
                echo smarty_function_html_select_date(array('field_array' => "custom_field[" . $this->_tpl_vars['custom_field_id'] . "]", 'prefix' => '', 'all_extra' => "class=\"default\"", 'year_empty' => '', 'time' => '--', 'display_months' => false, 'display_days' => false, 'start_year' => -1, 'end_year' => "+2", 'year_extra' => "id=\"custom_field_" . $this->_tpl_vars['custom_field_id'] . "_year\" tabindex=\"" . $this->_tpl_vars['tabindex']++ . "\""), $this);
                ?>

                    <?php 
                $_smarty_tpl_vars = $this->_tpl_vars;
                $this->_smarty_include(array('smarty_include_tpl_file' => "error_icon.tpl.html", 'smarty_include_vars' => array('field' => "custom_field[" . $this->_tpl_vars['custom_field_id'] . "][Year]")));
                $this->_tpl_vars = $_smarty_tpl_vars;
                unset($_smarty_tpl_vars);
                ?>
                  <?php 
            }
            ?>
                </td>
              <?php 
            if ($this->_foreach['custom_fields']['iteration'] % 2 != 1) {
                ?>
		</td>
	</tr>
	<tr>
		<td width=20% valign=top class=td1_left>
			&nbsp;&nbsp;Время показа:
		</td>
		<td class=td1_right>

			<table>
				<tr><td>C</td><td><?php 
echo smarty_function_html_select_date(array('prefix' => 'start_', 'start_year' => '2011', 'end_year' => '2021', 'time' => $this->_tpl_vars['curdate']), $this);
?>
</td></tr>
				<tr><td colspan="2" height="10"></td></tr>
				<tr><td>По</td><td><?php 
echo smarty_function_html_select_date(array('prefix' => 'end_', 'start_year' => '2011', 'end_year' => '2021', 'time' => $this->_tpl_vars['curdate2']), $this);
?>
</td></tr>
			</table>
		</td>
	</tr>
	<tr>
		<td width=20% valign=top class=td1_left>&nbsp;</td>
		<td class=td1_right>&nbsp;</td>
	</tr>
	
	<?php 
if ($this->_tpl_vars['mode'] == 'edit') {
    ?>
	<tr>
		<td width=20% valign=top class=td1_left>&nbsp;&nbsp;Кликов:</td><td class=td1_right><?php 
    function content_56453e89398133_84829262($_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_capitalize')) {
            require_once '/var/www/html/smarty/libs/plugins/modifier.capitalize.php';
        }
        if (!is_callable('smarty_modifier_date_format')) {
            require_once '/var/www/html/smarty/libs/plugins/modifier.date_format.php';
        }
        if (!is_callable('smarty_function_html_select_date')) {
            require_once '/var/www/html/smarty/libs/plugins/function.html_select_date.php';
        }
        if (!is_callable('smarty_function_html_select_time')) {
            require_once '/var/www/html/smarty/libs/plugins/function.html_select_time.php';
        }
        if (!is_callable('smarty_function_html_options')) {
            require_once '/var/www/html/smarty/libs/plugins/function.html_options.php';
        }
        $_smarty_tpl->properties['nocache_hash'] = '141063041656453e88eecc04_08919544';
        Smarty_Internal_Extension_Config::configLoad($_smarty_tpl, "test.conf", "setup", 'local');
        echo $_smarty_tpl->getSubTemplate("header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, $_smarty_tpl->cache_lifetime, array('title' => 'foo'), 0);
        ?>


<PRE>


    <?php 
        if ($_smarty_tpl->getConfigVariable('bold')) {
            ?>
<b><?php 
        }
        ?>
        
        Title: <?php 
        echo smarty_modifier_capitalize($_smarty_tpl->getConfigVariable('title'));
        ?>

        <?php 
        if ($_smarty_tpl->getConfigVariable('bold')) {
            ?>
</b><?php 
        }
        ?>

    The current date and time is <?php 
        echo smarty_modifier_date_format(time(), "%Y-%m-%d %H:%M:%S");
        ?>


    The value of global assigned variable $SCRIPT_NAME is <?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>


    Example of accessing server environment variable SERVER_NAME: <?php 
        echo $_SERVER['SERVER_NAME'];
        ?>


    The value of {$Name} is <b><?php 
        echo '/*%%SmartyNocache:141063041656453e88eecc04_08919544%%*/<?php echo $_smarty_tpl->tpl_vars[\'Name\']->value;?>
/*/%%SmartyNocache:141063041656453e88eecc04_08919544%%*/';
        ?>
</b>

variable modifier example of {$Name|upper}

<b><?php 
        echo '/*%%SmartyNocache:141063041656453e88eecc04_08919544%%*/<?php echo mb_strtoupper($_smarty_tpl->tpl_vars[\'Name\']->value, \'UTF-8\');?>
/*/%%SmartyNocache:141063041656453e88eecc04_08919544%%*/';
        ?>
</b>


An example of a section loop:

    <?php 
        if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer'])) {
            unset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']);
        }
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['name'] = 'outer';
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'] = is_array($_loop = $_smarty_tpl->tpl_vars['FirstName']->value) ? count($_loop) : max(0, (int) $_loop);
        unset($_loop);
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = true;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] = 1;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'] - 1;
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']) {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
            if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] == 0) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = false;
            }
        } else {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = 0;
        }
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']) {
            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration']++) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'];
                ?>
        <?php 
                if (1 & $_smarty_tpl->getVariable('smarty')->value['section']['outer']['index'] / 2) {
                    ?>
            <?php 
                    echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];
                    ?>
 . <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>

        <?php 
                } else {
                    ?>
            <?php 
                    echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];
                    ?>
 * <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>

        <?php 
                }
                ?>
        <?php 
            }
        } else {
            ?>
        none
    <?php 
        }
        ?>

    An example of section looped key values:

    <?php 
        if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1'])) {
            unset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']);
        }
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['name'] = 'sec1';
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] = is_array($_loop = $_smarty_tpl->tpl_vars['contacts']->value) ? count($_loop) : max(0, (int) $_loop);
        unset($_loop);
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = true;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] = 1;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] - 1;
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
            if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] == 0) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = false;
            }
        } else {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = 0;
        }
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration']++) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'];
                ?>
        phone: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['phone'];
                ?>

        <br>

            fax: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['fax'];
                ?>

        <br>

            cell: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['cell'];
                ?>

        <br>
    <?php 
            }
        }
        ?>
    <p>

        testing strip tags
        <table border=0><tr><td><A HREF="<?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>
"><font color="red">This is a test </font></A></td></tr></table>

</PRE>

This is an example of the html_select_date function:

<form>
    <?php 
        echo smarty_function_html_select_date(array('start_year' => 1998, 'end_year' => 2010), $_smarty_tpl);
        ?>

</form>

This is an example of the html_select_time function:

<form>
    <?php 
        echo smarty_function_html_select_time(array('use_24_hours' => false), $_smarty_tpl);
        ?>

</form>

This is an example of the html_options function:

<form>
    <select name=states>
        <?php 
        echo smarty_function_html_options(array('values' => $_smarty_tpl->tpl_vars['option_values']->value, 'selected' => $_smarty_tpl->tpl_vars['option_selected']->value, 'output' => $_smarty_tpl->tpl_vars['option_output']->value), $_smarty_tpl);
        ?>

    </select>
</form>

<?php 
        echo $_smarty_tpl->getSubTemplate("footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, $_smarty_tpl->cache_lifetime, array(), 0);
        ?>

<?php 
    }
					<?php 
        } else {
            ?>
												<?php 
            echo is_array($_tmp = smarty_function_math(array('equation' => "x-10", 'x' => $this->_tpl_vars['currentYear']), $this)) ? $this->_run_mod_handler('assign', true, $_tmp, 'minYear') : $this->_plugins['modifier']['assign'][0][0]->smartyAssign($_tmp, 'minYear');
            ?>

						<?php 
            echo is_array($_tmp = smarty_function_math(array('equation' => "x+2", 'x' => $this->_tpl_vars['currentYear']), $this)) ? $this->_run_mod_handler('assign', true, $_tmp, 'maxYear') : $this->_plugins['modifier']['assign'][0][0]->smartyAssign($_tmp, 'maxYear');
            ?>

					<?php 
        }
        ?>
					<?php 
        echo smarty_function_html_select_date(array('prefix' => 'datePublished', 'time' => is_array($_tmp = @$this->_tpl_vars['publishedArticle']->getDatePublished()) ? $this->_run_mod_handler('default', true, $_tmp, "---") : smarty_modifier_default($_tmp, "---"), 'all_extra' => "class=\"selectMenu\"", 'start_year' => $this->_tpl_vars['minYear'], 'end_year' => $this->_tpl_vars['maxYear'], 'year_empty' => "-", 'month_empty' => "-", 'day_empty' => "-"), $this);
        ?>

				</td>
				<td class="value">
					<input type="submit" value="<?php 
        echo $this->_plugins['function']['translate'][0][0]->smartyTranslate(array('key' => "common.record"), $this);
        ?>
" class="button defaultButton" />&nbsp;
				</td>
			</tr>
		</form>
	<?php 
    }
} else {
    ?>
Пример #8
0
function smarty_function_calendar($params, &$smarty){

        require_once $smarty->_get_plugin_filepath('function','html_select_date');
  $days = array('Domingo', 'Lunes', 'Martes', 'Mi&eacute;rcoles', 'Jueves', 'Viernes', 'S&aacute;bado');
  $months = array(1=>'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');
  $start = 'start';
  $end = 'end';
  $desc = 'desc';
  $year = '';
  $month = '';
  $id = null;
  
  //  Month is required
  if (!isset($params['month']))
    $month = date("m");  
  else
    $month = $params['month'];
  
  //  Year is required
  if (!isset($params['year']))
    $year = date("Y");
  else  $year = $params['year'];
  
  //  Name of day of the week
  if(isset($params['days'])){
    unset($days);
    $days = $params['days'];
  }
  
  
  if(isset($params['months'])){
    unset($months);
    $months = $params['months'];
  }
  
  if(isset($params['events'])){
    //  This param describe who is the field that
    //  contain the info of  star date, if there's not
    //  is the same name
    if(isset($params['start'])){
      $start = $params['start'];
    }
    //  Describe name field of the end date
    if(isset($params['end'])){
      $end = $params['end'];
    }
    //  Field describe the description of event
    if(isset($params['desc'])){
      $desc = $params['desc'];
    }
    //  Field id is number unique of the event
    if(isset($params['id'])){
      $id = $params['id'];
    }
    
    $events = array();
    //  add the events
    for($i=0;$i<count($params['events']);$i++){
      $events[] = array(
        'id' => $params['events'][$i][$id],
        'start' => $params['events'][$i][$start],
        'end' => $params['events'][$i][$end],
        'desc' => $params['events'][$i][$desc]
      );
    }
  }
  
  $Month = & new Calendar_Month_Weekdays($year, $month);
  $MonthDecorator = new MonthPayload_Decorator($Month);
  $MonthDecorator->build($events);
  
  echo '<table class="calendar" cellspacing="0" cellpadding="0" border="0">';
  echo '<caption class="caption">';
   echo $months[$MonthDecorator->thisMonth()].' / '.$MonthDecorator->thisYear();
  echo '</caption>';
  echo '<tr>';
  //  Days of weeks
  for($i=0;$i<count($days);$i++)
    echo '<th class="day_week">'.$days[$i].'</th>';
  echo '</tr>';
  
  while ($Day = $MonthDecorator->fetch()) {

    if ($Day->isFirst()) {
        echo "<tr>\n";
    }

    echo '<td class="general calCell';
    if ($Day->isSelected()) {
        echo ' calCellBusy';
    } elseif ($Day->isEmpty()) {
        echo ' calCellEmpty';
    }
    echo '">';
    
    if($Day->isEmpty())
      echo '<div class="dayNumber2">'.$Day->thisDay().'</div>';
    else
      echo '<div class="dayNumber">'.$Day->thisDay().'</div>';

    if ($Day->isEmpty()) {
        echo '&nbsp;';
    } else {
        echo '<div class="dayContents"><ul>';
        while ($entry = $Day->getEntry()) {
            echo  '<li>';
            if(isset($entry['id']))
              echo '<a href="?'.$id.'='.$entry['id'].'" class="event">'.$entry['desc'].'</a>';
             else echo $entry['desc'];
            echo '</li>';
            //you can print the time range as well
        }
        echo '</ul></div>';
    }
    echo '</td>';

    if ($Day->isLast()) {
        echo "</tr>\n";
    }
    
  }
  echo '</table>';
  $PMonth = $Month->prevMonth('object');
  $prev = $_SERVER['PHP_SELF'].'?year='.$PMonth->thisYear().'&month='.$PMonth->thisMonth();
  $NMonth = $Month->nextMonth('object');
  $next = $_SERVER['PHP_SELF'].'?year='.$NMonth->thisYear().'&month='.$NMonth->thisMonth();
  echo '<table class="calendar_option"><tr><td class="prev"><a href="'.$prev.'" class="option">&lt;&lt; '.$months[$PMonth->thisMonth()].' '.$PMonth->thisYear().'</a></td><td class="next"><a href="'.$next.'" class="option">'.$months[$NMonth->thisMonth()].' '.$NMonth->thisYear().' &gt;&gt;</a></td></tr></table>';
        echo '<form method="GET"><table><tr><td>'.smarty_function_html_select_date(array('prefix'=>'','start_year'=>'-5','end_year'=>'+5','display_days'=>false),$smarty).'</td><td></td>'.'<td><input type="submit" value="Mostrar"/></td></table></form>';
}
function wikiplugin_tracker($data, $params)
{
    global $tikilib, $userlib, $dbTiki, $user, $group, $page, $tiki_p_admin, $tiki_p_create_tracker_items, $smarty, $prefs, $trklib, $tiki_p_tracker_vote_ratings;
    include_once 'lib/trackers/trackerlib.php';
    //var_dump($_REQUEST);
    extract($params, EXTR_SKIP);
    if ($prefs['feature_trackers'] != 'y') {
        return $smarty->fetch("wiki-plugins/error_tracker.tpl");
    }
    if (empty($trackerId) || !($tracker = $trklib->get_tracker($trackerId))) {
        return $smarty->fetch("wiki-plugins/error_tracker.tpl");
    }
    if ($t = $trklib->get_tracker_options($trackerId)) {
        $tracker = array_merge($tracker, $t);
    }
    if (empty($trackerId) && !empty($view) && $view == 'user' && $prefs['userTracker'] == 'y') {
        // the user tracker item
        $utid = $userlib->get_tracker_usergroup($user);
        if (!empty($utid) && !empty($utid['usersTrackerId'])) {
            $itemId = $trklib->get_item_id($utid['usersTrackerId'], $utid['usersFieldId'], $user);
            $trackerId = $utid['usersTrackerId'];
            $usertracker = true;
        }
    } elseif (!empty($trackerId) && !empty($view) && $view == 'user') {
        // the user item of a tracker
        $itemId = $trklib->get_user_item($trackerId, $tracker);
        $usertracker = true;
    } elseif (!empty($trackerId) && !empty($_REQUEST['view_user'])) {
        $itemId = $trklib->get_user_item($trackerId, $tracker, $_REQUEST['view_user']);
    }
    if (!isset($trackerId)) {
        return $smarty->fetch("wiki-plugins/error_tracker.tpl");
    }
    if (!isset($embedded)) {
        $embedded = "n";
    }
    if (!isset($showtitle)) {
        $showtitle = "n";
    }
    if (!isset($showdesc)) {
        $showdesc = "n";
    }
    if (!isset($sort)) {
        $sort = 'n';
    }
    if (!isset($action)) {
        $action = 'Save';
    }
    if (isset($preview)) {
        if (empty($preview)) {
            $preview = 'Preview';
        }
    } else {
        unset($_REQUEST['tr_preview']);
    }
    if (!isset($showmandatory)) {
        $showmandatory = 'y';
    }
    $smarty->assign('showmandatory', $showmandatory);
    if (isset($values)) {
        if (!is_array($values)) {
            $values = explode(':', $values);
        }
    }
    if (isset($_REQUEST['values'])) {
        if (is_array($_REQUEST['values'])) {
            foreach ($_REQUEST['values'] as $i => $k) {
                $_REQUEST['values'][$i] = urldecode($k);
            }
        } else {
            $_REQUEST['values'] = urldecode($_REQUEST['values']);
        }
    }
    if (empty($_SERVER['SCRIPT_NAME']) || !strstr($_SERVER['SCRIPT_NAME'], 'tiki-register.php')) {
        if (!empty($itemId) && $tracker['writerCanModify'] == 'y' && isset($usertracker) && $usertracker) {
            // user tracker he can modify
        } else {
            $perms = $tikilib->get_perm_object($trackerId, 'tracker', $tracker, false);
            if ($perms['tiki_p_create_tracker_items'] == 'n' && empty($itemId)) {
                return '<b>' . tra("You do not have permission to insert an item") . '</b>';
            } elseif ($perms['tiki_p_modify_tracker_items'] == 'n' && !empty($itemId)) {
                return '<b>' . tra("You do not have permission to modify an item") . '</b>';
            }
        }
    }
    if (isset($_REQUEST['removeattach']) && $tracker['useAttachments'] == 'y') {
        $owner = $trklib->get_item_attachment_owner($_REQUEST['removeattach']);
        if ($tiki_p_wiki_admin_attachments == 'y' || $user && $user == $owner) {
            $trklib->remove_item_attachment($_REQUEST["removeattach"]);
            unset($_REQUEST['removeattach']);
        }
    }
    if (isset($_REQUEST['removeImage']) && !empty($_REQUEST['trackerId']) && !empty($_REQUEST['itemId']) && !empty($_REQUEST['fieldId']) && !empty($_REQUEST['fieldName'])) {
        $img_field = array('data' => array());
        $img_field['data'][] = array('fieldId' => $_REQUEST['fieldId'], 'type' => 'i', 'name' => $_REQUEST['fieldName'], 'value' => 'blank');
        $trklib->replace_item($_REQUEST['trackerId'], $_REQUEST['itemId'], $img_field);
    }
    $back = '';
    $thisIsThePlugin = isset($_REQUEST['trackit']) && $_REQUEST['trackit'] == $trackerId && (isset($_REQUEST['fields']) && isset($params['fields']) && $_REQUEST['fields'] == $params['fields'] || !isset($_REQUEST['fields']) && !isset($params['fields']));
    if (!isset($_REQUEST["ok"]) || $_REQUEST["ok"] == "n" || !$thisIsThePlugin || isset($_REQUEST['tr_preview'])) {
        $field_errors = array('err_mandatory' => array(), 'err_value' => array());
        global $notificationlib;
        include_once 'lib/notifications/notificationlib.php';
        $tracker = $trklib->get_tracker($trackerId);
        $tracker = array_merge($tracker, $trklib->get_tracker_options($trackerId));
        if (!empty($tracker['start']) && $tikilib->now < $tracker['start'] || !empty($tracker['end']) && $tikilib->now > $tracker['end']) {
            return;
        }
        $flds = $trklib->list_tracker_fields($trackerId, 0, -1, "position_asc", "");
        $bad = array();
        $embeddedId = false;
        $onemandatory = false;
        $full_fields = array();
        $mainfield = '';
        if ($thisIsThePlugin) {
            /* ------------------------------------- Recup all values from REQUEST -------------- */
            $cpt = 0;
            if (isset($fields)) {
                $fields_plugin = split(':', $fields);
            }
            foreach ($flds['data'] as $fl) {
                // store value to display it later if form
                // isn't fully filled.
                if (($flds['data'][$cpt]['type'] == 'u' || $flds['data'][$cpt]['type'] == 'g' || $flds['data'][$cpt]['type'] == 'I') && ($flds['data'][$cpt]['options_array'][0] == '1' || $flds['data'][$cpt]['options_array'][0] == '2') && $tiki_p_admin_trackers != 'y' && empty($_REQUEST['track'][$fl['fieldId']])) {
                    if (empty($itemId) && ($flds['data'][$cpt]['options_array'][0] == '1' || $flds['data'][$cpt]['options_array'][0] == '2')) {
                        if ($flds['data'][$cpt]['type'] == 'u') {
                            $_REQUEST['track'][$fl['fieldId']] = empty($user) ? empty($_REQUEST['name']) ? '' : $_REQUEST['name'] : $user;
                        } elseif ($flds['data'][$cpt]['type'] == 'g') {
                            $_REQUEST['track'][$fl['fieldId']] = $group;
                        } elseif ($flds['data'][$cpt]['type'] == 'I') {
                            $_REQUEST['track'][$fl['fieldId']] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
                        }
                    } elseif (!empty($itemId) && $flds['data'][$cpt]['options_array'][0] == '2') {
                        if ($flds['data'][$cpt]['type'] == 'u') {
                            $_REQUEST['track'][$fl['fieldId']] = $user;
                        } elseif ($flds['data'][$cpt]['type'] == 'g') {
                            $_REQUEST['track'][$fl['fieldId']] = $group;
                        } elseif ($flds['data'][$cpt]['type'] == 'I') {
                            $_REQUEST['track'][$fl['fieldId']] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
                        }
                    }
                } elseif ($flds['data'][$cpt]['type'] == 'f') {
                    $ins_id = 'track_' . $fl['fieldId'];
                    if (isset($_REQUEST[$ins_id . 'Day'])) {
                        if (empty($_REQUEST['$ins_id' . 'Hour'])) {
                            $_REQUEST['$ins_id' . 'Hour'] = 0;
                        }
                        if (empty($_REQUEST['$ins_id' . 'Minute'])) {
                            $_REQUEST['$ins_id' . 'Minute'] = 0;
                        }
                        $_REQUEST['track'][$fl['fieldId']] = $tikilib->make_time($_REQUEST["{$ins_id}" . "Hour"], $_REQUEST["{$ins_id}" . "Minute"], 0, $_REQUEST["{$ins_id}" . "Month"], $_REQUEST["{$ins_id}" . "Day"], $_REQUEST["{$ins_id}" . "Year"]);
                    } else {
                        $_REQUEST['track'][$fl['fieldId']] = $tikilib->now;
                    }
                }
                if (isset($_REQUEST['ins_cat_' . $fl['fieldId']])) {
                    // to remember if error
                    $_REQUEST['track'][$fl['fieldId']] = $_REQUEST['ins_cat_' . $fl['fieldId']];
                }
                if (isset($_REQUEST['track'][$fl['fieldId']])) {
                    $flds['data'][$cpt]['value'] = $_REQUEST['track'][$fl['fieldId']];
                } else {
                    $flds['data'][$cpt]['value'] = '';
                    if ($fl['type'] == 'c' && (empty($fields_plugin) || in_array($fl['fieldId'], $fields_plugin))) {
                        $_REQUEST['track'][$fl['fieldId']] = 'n';
                    } elseif ($fl['type'] == 'R' && $fl['isMandatory'] == 'y' && !isset($_REQUEST['track'][$fl['fieldId']])) {
                        // if none radio is selected, there will be no value and no error if mandatory
                        if (empty($fields_plugin) || in_array($fl['fieldId'], $fields_plugin)) {
                            $_REQUEST['track'][$fl['fieldId']] = '';
                        }
                    }
                }
                if (!empty($_REQUEST['other_track'][$fl['fieldId']])) {
                    $flds['data'][$cpt]['value'] = $_REQUEST['other_track'][$fl['fieldId']];
                }
                $full_fields[$fl['fieldId']] = $fl;
                if ($embedded == 'y' and $fl['name'] == 'page') {
                    $embeddedId = $fl['fieldId'];
                }
                if ($fl['isMain'] == 'y') {
                    $mainfield = $flds['data'][$cpt]['value'];
                }
                $cpt++;
            }
            /*foreach */
            if (isset($_REQUEST['track'])) {
                foreach ($_REQUEST['track'] as $fld => $val) {
                    //$ins_fields["data"][] = array('fieldId' => $fld, 'value' => $val, 'type' => 1);
                    if (!empty($_REQUEST['other_track'][$fld])) {
                        $val = $_REQUEST['other_track'][$fld];
                    }
                    $ins_fields["data"][] = array_merge(array('value' => $val), $full_fields[$fld]);
                }
            }
            if (isset($_FILES['track'])) {
                // image or attachment fields
                foreach ($_FILES['track'] as $label => $w) {
                    foreach ($w as $fld => $val) {
                        if ($label == 'tmp_name' && is_uploaded_file($val)) {
                            $fp = fopen($val, 'rb');
                            $data = '';
                            while (!feof($fp)) {
                                $data .= fread($fp, 8192 * 16);
                            }
                            fclose($fp);
                            $files[$fld]['old_value'] = $files[$fld]['value'];
                            $files[$fld]['value'] = $data;
                        } else {
                            $files[$fld]['file_' . $label] = $val;
                        }
                    }
                }
                foreach ($files as $fld => $file) {
                    $ins_fields['data'][] = array_merge($file, $full_fields[$fld]);
                }
            }
            if ($embedded == 'y' && isset($_REQUEST['page'])) {
                $ins_fields["data"][] = array('fieldId' => $embeddedId, 'value' => $_REQUEST['page']);
            }
            $ins_categs = array();
            $categorized_fields = array();
            while (list($postVar, $postVal) = each($_REQUEST)) {
                if (preg_match("/^ins_cat_([0-9]+)/", $postVar, $m)) {
                    foreach ($postVal as $v) {
                        $ins_categs[] = $v;
                    }
                    $categorized_fields[] = $m[1];
                }
            }
            /* ------------------------------------- End recup all values from REQUEST -------------- */
            /* ------------------------------------- Check field values for each type and presence of mandatory ones ------------------- */
            $field_errors = $trklib->check_field_values($ins_fields, $categorized_fields);
            if (empty($user) && $prefs['feature_antibot'] == 'y') {
                if (!isset($_SESSION['random_number']) || $_SESSION['random_number'] != $_REQUEST['antibotcode']) {
                    $field_errors['err_antibot'] = 'y';
                }
            }
            if (count($field_errors['err_mandatory']) == 0 && count($field_errors['err_value']) == 0 && empty($field_errors['err_antibot']) && !isset($_REQUEST['tr_preview'])) {
                /* ------------------------------------- save the item ---------------------------------- */
                if (!isset($itemId)) {
                    $itemId = $trklib->get_user_item($trackerId, $tracker);
                }
                if (isset($_REQUEST['status'])) {
                    $status = $_REQUEST['status'];
                } elseif (isset($newstatus) && ($newstatus == 'o' || $newstatus == 'c' || $newstatus == 'p')) {
                    $status = $newstatus;
                } elseif (empty($itemId) && isset($tracker['newItemStatus'])) {
                    $status = $tracker['newItemStatus'];
                } else {
                    $status = '';
                }
                $rid = $trklib->replace_item($trackerId, $itemId, $ins_fields, $status, $ins_categs);
                $trklib->categorized_item($trackerId, $rid, $mainfield, $ins_categs);
                if (!empty($email)) {
                    $emailOptions = split("\\|", $email);
                    if (is_numeric($emailOptions[0])) {
                        $emailOptions[0] = $trklib->get_item_value($trackerId, $rid, $emailOptions[0]);
                    }
                    if (empty($emailOptions[0])) {
                        // from
                        $emailOptions[0] = $prefs['sender_email'];
                    }
                    if (empty($emailOptions[1])) {
                        // to
                        $emailOptions[1][0] = $prefs['sender_email'];
                    } else {
                        $emailOptions[1] = split(',', $emailOptions[1]);
                        foreach ($emailOptions[1] as $key => $email) {
                            if (is_numeric($email)) {
                                $emailOptions[1][$key] = $trklib->get_item_value($trackerId, $rid, $email);
                            }
                        }
                    }
                    if (!empty($emailOptions[2])) {
                        //tpl
                        if (!preg_match('/\\.tpl$/', $emailOptions[2])) {
                            $emailOptions[2] .= '.tpl';
                        }
                        $tplSubject = str_replace('.tpl', '_subject.tpl', $emailOptions[2]);
                    } else {
                        $emailOptions[2] = 'tracker_changed_notification.tpl';
                    }
                    if (empty($tplSubject)) {
                        $tplSubject = 'tracker_changed_notification_subject.tpl';
                    }
                    include_once 'lib/webmail/tikimaillib.php';
                    $mail = new TikiMail();
                    @($mail_data = $smarty->fetch('mail/' . $tplSubject));
                    if (empty($mail_data)) {
                        $mail_data = tra('Tracker was modified at ') . $_SERVER["SERVER_NAME"];
                    }
                    $mail->setSubject($mail_data);
                    $mail_data = $smarty->fetch('mail/' . $emailOptions[2]);
                    $mail->setText($mail_data);
                    $mail->setHeader('From', $emailOptions[0]);
                    $mail->send($emailOptions[1]);
                }
                if (empty($url)) {
                    if (!empty($page)) {
                        $url = "tiki-index.php?page=" . urlencode($page) . "&ok=y&trackit={$trackerId}";
                        if (!empty($params['fields'])) {
                            $url .= "&fields=" . urlencode($params['fields']);
                        }
                        $url .= "#wikiplugin_tracker{$trackerId}";
                        header("Location: {$url}");
                        die;
                    } else {
                        return '';
                    }
                } else {
                    header("Location: {$url}");
                    die;
                }
                /* ------------------------------------- end save the item ---------------------------------- */
            } elseif (isset($_REQUEST['trackit']) and $_REQUEST['trackit'] == $trackerId) {
                $smarty->assign('wikiplugin_tracker', $trackerId);
                //used in vote plugin
            }
        } else {
            if (!empty($values) || (!empty($_REQUEST['values']) and empty($_REQUEST['prefills']))) {
                // assign default values for each filedId specify
                if (empty($values)) {
                    // url with values[]=x&values[] witouth the list of fields
                    $values = $_REQUEST['values'];
                }
                if (!is_array($values)) {
                    $values = array($values);
                }
                if (isset($fields)) {
                    $fl = split(':', $fields);
                    for ($j = 0; $j < count($fl); $j++) {
                        for ($i = 0; $i < count($flds['data']); $i++) {
                            if ($flds['data'][$i]['fieldId'] == $fl[$j]) {
                                $flds['data'][$i]['value'] = $values[$j];
                            }
                        }
                    }
                } else {
                    // values contains all the fields value in the default order
                    $i = 0;
                    foreach ($values as $value) {
                        $flds['data'][$i++]['value'] = $value;
                    }
                }
            } elseif (!empty($itemId)) {
                if (isset($fields)) {
                    $fl = split(':', $fields);
                    $filter = '';
                    foreach ($flds['data'] as $f) {
                        if (in_array($f['fieldId'], $fl)) {
                            $filter[] = $f;
                        }
                    }
                } else {
                    $filter =& $flds['data'];
                }
                if (!empty($filter)) {
                    $flds['data'] = $trklib->get_item_fields($trackerId, $itemId, $filter, $itemUser);
                }
            } else {
                if (isset($_REQUEST['values']) && isset($_REQUEST['prefills'])) {
                    //url:prefields=1:2&values[]=x&values[]=y
                    if (!is_array($_REQUEST['values'])) {
                        $_REQUEST['values'] = array($_REQUEST['values']);
                    }
                    $fl = split(':', $_REQUEST['prefills']);
                } else {
                    unset($fl);
                }
                for ($i = 0; $i < count($flds['data']); $i++) {
                    if (isset($fl) && ($j = array_search($flds['data'][$i]['fieldId'], $fl)) !== false) {
                        $flds['data'][$i]['value'] = $_REQUEST['values'][$j];
                    } else {
                        $flds['data'][$i]['value'] = '';
                        // initialize fields with blank values
                    }
                }
            }
        }
        $optional = array();
        $outf = array();
        if (isset($fields) && !empty($fields)) {
            $fl = split(":", $fields);
            if ($sort == 'y') {
                $flds = $trklib->sort_fields($flds, $fl);
            }
            foreach ($fl as $l) {
                if (substr($l, 0, 1) == '-') {
                    $l = substr($l, 1);
                    $optional[] = $l;
                }
                $ok = false;
                foreach ($flds['data'] as $f) {
                    if ($f['fieldId'] == $l) {
                        $ok = true;
                        break;
                    }
                }
                if (!$ok) {
                    $back .= tra('Incorrect fieldId:') . ' ' . $l;
                }
                $outf[] = $l;
            }
        } elseif (!isset($fields)) {
            foreach ($flds['data'] as $f) {
                if ($f['isMandatory'] == 'y') {
                    $optional[] = $f['fieldId'];
                }
                $outf[] = $f['fieldId'];
            }
        }
        // Display warnings when needed
        if (count($field_errors['err_mandatory']) > 0) {
            $back .= '<div class="simplebox highlight"><img src="pics/icons/exclamation.png" alt=" ' . tra('Error') . '" style="vertical-align:middle" /> ';
            $back .= tra('Following mandatory fields are missing') . '&nbsp;:<br/>';
            $coma_cpt = count($field_errors['err_mandatory']);
            foreach ($field_errors['err_mandatory'] as $f) {
                $back .= $f['name'];
                $back .= --$coma_cpt > 0 ? ',&nbsp;' : '';
            }
            $back .= '</div><br />';
            $_REQUEST['error'] = 'y';
        }
        if (count($field_errors['err_value']) > 0) {
            $back .= '<div class="simplebox highlight">';
            $b = '';
            foreach ($field_errors['err_value'] as $f) {
                if (!empty($f['errorMsg'])) {
                    $back .= tra($f['errorMsg']) . '<br>';
                } else {
                    if (!empty($b)) {
                        $b .= ' : ';
                    }
                    $b .= $f['name'];
                }
            }
            if (!empty($b)) {
                $back .= tra('Following fields are incorrect') . '&nbsp;:<br/>' . $b;
            }
            $back .= '</div><br />';
            $_REQUEST['error'] = 'y';
        }
        if (isset($field_errors['err_antibot'])) {
            $back .= '<div class="simplebox highlight"><img src="pics/icons/exclamation.png" alt=" ' . tra('Error') . '" style="vertical-align:middle" /> ';
            $back .= tra('You have mistyped the anti-bot verification code; please try again.');
            $back .= '</div><br />';
            $_REQUEST['error'] = 'y';
        }
        if (count($field_errors['err_mandatory']) > 0 || count($field_errors['err_value']) > 0 || isset($field_errors['err_antibot'])) {
            $smarty->assign('input_err', 'y');
        }
        if (!empty($page)) {
            $back .= '~np~';
        }
        $back .= '<form enctype="multipart/form-data" method="post"><input type="hidden" name="trackit" value="' . $trackerId . '" />';
        if (isset($fields)) {
            $back .= '<input type="hidden" name="fields" value="' . $params['fields'] . '" />';
        }
        //if plugin inserted twice with the same trackerId
        if (!empty($_REQUEST['page'])) {
            $back .= '<input type="hidden" name="page" value="' . $_REQUEST["page"] . '" />';
        }
        $back .= '<input type="hidden" name="refresh" value="1" />';
        if (isset($_REQUEST['page'])) {
            $back .= '<input type="hidden" name="page" value="' . $_REQUEST["page"] . '" />';
        }
        // for registration
        if (isset($_REQUEST['name'])) {
            $back .= '<input type="hidden" name="name" value="' . $_REQUEST["name"] . '" />';
        }
        if (isset($_REQUEST['pass'])) {
            $back .= '<input type="hidden" name="pass" value="' . $_REQUEST["pass"] . '" />';
            $back .= '<input type="hidden" name="passAgain" value="' . $_REQUEST["pass"] . '" />';
        }
        if (isset($_REQUEST['email'])) {
            $back .= '<input type="hidden" name="email" value="' . $_REQUEST["email"] . '" />';
        }
        if (isset($_REQUEST['regcode'])) {
            $back .= '<input type="hidden" name="regcode" value="' . $_REQUEST["regcode"] . '" />';
        }
        if (isset($_REQUEST['chosenGroup'])) {
            // for registration
            $back .= '<input type="hidden" name="chosenGroup" value="' . $_REQUEST["chosenGroup"] . '" />';
        }
        if (isset($_REQUEST['register'])) {
            $back .= '<input type="hidden" name="register" value="' . $_REQUEST["register"] . '" />';
        }
        if ($showtitle == 'y') {
            $back .= '<div class="titlebar">' . $tracker["name"] . '</div>';
        }
        if ($showdesc == 'y' && $tracker['description']) {
            if ($tracker["descriptionIsParsed"] == 'y') {
                $back .= '<div class="wikitext">' . $tikilib->parse_data($tracker["description"], 'false') . '</div><br />';
            } else {
                $back .= '<div class="wikitext">' . $tracker["description"] . '</div><br />';
            }
        }
        if (isset($_REQUEST['tr_preview'])) {
            // use for the computed and join fields
            $assocValues = array();
            $assocNumerics = array();
            foreach ($flds['data'] as $f) {
                if (empty($f['value']) && ($f['type'] == 'u' || $f['type'] == 'g' || $f['type'] == 'I') && ($f['options_array'][0] == '1' || $f['options_array'][0] == '2')) {
                    //need to fill the selector fields for the join
                    $f['value'] = $f['type'] == 'I' ? $_SERVER['REMOTE_ADDR'] : ($f['type'] == 'g' ? $group : $user);
                }
                $assocValues[$f['fieldId']] = $f['value'];
                $assocNumerics[$f['fieldId']] = preg_replace('/[^0-9\\.\\+]/', '', $f['value']);
                // get rid off the $ and such unit
            }
        }
        if (!empty($itemId)) {
            $item = array('itemId' => $itemId, 'trackerId' => $trackerId);
        }
        foreach ($flds['data'] as $i => $f) {
            // collect additional infos
            if (in_array($f['fieldId'], $outf)) {
                $flds['data'][$i]['ins_id'] = $f['type'] == 'e' ? 'ins_cat_' . $f['fieldId'] : ($f['type'] == 'f' ? 'track_' . $f['fieldId'] : 'track[' . $f['fieldId'] . ']');
                if ($f['isHidden'] == 'c' && !empty($itemId) && !isset($item['creator'])) {
                    $item['creator'] = $trklib->get_item_creator($trackerId, $itemId);
                }
                if ($f['type'] == 's' && ($f['name'] == 'Rating' || $f['name'] == tra('Rating')) && $tiki_p_tracker_vote_ratings == 'y' && isset($item)) {
                    $item['my_rate'] = $tikilib->get_user_vote("tracker{$trackerId}.{$itemId}", $user);
                }
                if ($f['type'] == 'r') {
                    $flds['data'][$i]['list'] = array_unique($trklib->get_all_items($f['options_array'][0], $f['options_array'][1], 'o'));
                    if (isset($f['options_array'][3])) {
                        $flds['data'][$i]['displayedList'] = array_unique($trklib->concat_all_items_from_fieldslist($f['options_array'][0], $f['options_array'][3]));
                    }
                } elseif ($f['type'] == 'y') {
                    $flds['data'][$i]['flags'] = $tikilib->get_flags();
                    if ($prefs['language'] != 'en') {
                        foreach ($flags as $flag) {
                            $flagsTranslated[] = $tikilib->take_away_accent(tra($flag));
                        }
                        array_multisort($flagsTranslated, $flds['data'][$i]['flags']);
                    }
                } elseif ($f['type'] == 'u') {
                    if ($tiki_p_admin == 'y' || $f['options_array'][0] != 1 && $f['options_array'][0] != 2) {
                        $flds['data'][$i]['list'] = $userlib->list_all_users();
                    }
                } elseif ($f['type'] == 'g') {
                    if ($tiki_p_admin == 'y' || $f['options_array'][0] != 1 && $f['options_array'][0] != 2) {
                        $flds['data'][$i]['list'] = $userlib->list_all_groups();
                    }
                } elseif ($f['type'] == 'e') {
                    global $categlib;
                    include_once 'lib/categories/categlib.php';
                    $flds['data'][$i]['list'] = $categlib->get_child_categories($f["options_array"][0]);
                } elseif ($f['type'] == 'A') {
                    if (!empty($f['value'])) {
                        $flds['data'][$i]['info'] = $trklib->get_item_attachment($f['value']);
                    }
                } elseif ($f['type'] == 'a') {
                    if ($f['options_array'][0] == 1 && empty($quicktags)) {
                        global $quicktagslib;
                        include_once 'lib/quicktags/quicktagslib.php';
                        $quicktags = $quicktagslib->list_quicktags(0, -1, 'taglabel_desc', '', 'trackers');
                        $smarty->assign_by_ref('quicktags', $quicktags['data']);
                    }
                }
            }
        }
        // Loop on tracker fields and display form
        if (empty($tpl) && empty($wiki)) {
            $back .= '<table class="wikiplugin_tracker">';
        } else {
            $back .= '<div class="wikiplugin_tracker">';
        }
        $backLength0 = strlen($back);
        foreach ($flds['data'] as $f) {
            if ($f['type'] == 'u' and $f['options_array'][0] == '1') {
                $back .= '<input type="hidden" name="authorfieldid" value="' . $f['fieldId'] . '" />';
            }
            if ($f['type'] == 'I' and $f['options_array'][0] == '1') {
                $back .= '<input type="hidden" name="authoripid" value="' . $f['fieldId'] . '" />';
            }
            if ($f['type'] == 'g' and $f['options_array'][0] == '1') {
                $back .= '<input type="hidden" name="authorgroupfieldid" value="' . $f['fieldId'] . '" />';
            }
            if ($f['type'] == 'q') {
                $back .= '<input type="hidden" name="track[' . $f['fieldId'] . ']" />';
            }
            if (in_array($f['fieldId'], $outf)) {
                if (!empty($tpl) || !empty($wiki)) {
                    $smarty->assign_by_ref('field_value', $f);
                    $smarty->assign('f_' . $f['fieldId'], $smarty->fetch('tracker_item_field_input.tpl'));
                } elseif (true) {
                    // comment this block in problem
                    if (in_array($f['fieldId'], $optional)) {
                        $f['name'] = "<i>" . $f['name'] . "</i>";
                    }
                    if ($f['type'] != 'h') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                    } else {
                        $back .= "<tr><td class='heading' colspan='2'>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                    }
                    $smarty->assign_by_ref('field_value', $f);
                    if (isset($item)) {
                        $smarty->assign_by_ref('item', $item);
                    }
                    $back .= $smarty->fetch('tracker_item_field_input.tpl');
                } else {
                    //old
                    // numeric or text field
                    if ($f['type'] == 't' or $f['type'] == 'n' and $f["fieldId"] != $embeddedId or $f['type'] == 'm') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        if ($f['type'] != 'h') {
                            $back .= "</td><td>";
                        }
                        $back .= '<input type="text" name="track[' . $f["fieldId"] . ']" value="' . $f['value'] . '"';
                        if (isset($f['options_array'][1])) {
                            $back .= 'size="' . $f['options_array'][1] . '" maxlength="' . $f['options_array'][1] . '"';
                        } else {
                            $back .= 'size="30"';
                        }
                        $back .= '/>';
                        // item link
                    } elseif ($f['type'] == 'r') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                        $back .= '<select name="track[' . $f["fieldId"] . ']">';
                        $back .= '<option value=""></option>';
                        foreach ($f['list'] as $key => $item) {
                            $selected = $f['value'] == $item ? 'selected="selected"' : '';
                            $back .= '<option value="' . $item . '" ' . $selected . '>';
                            $back .= isset($f['displayedList'][$key]) ? $f['displayedList'][$key] : $item;
                            $back .= '</option>';
                        }
                        $back .= "</select>";
                        // country
                    } elseif ($f['type'] == 'y') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                        $back .= '<select name="track[' . $f["fieldId"] . ']">';
                        $back .= '<option value=""></option>';
                        foreach ($f['flags'] as $flag) {
                            $selected = $f['value'] == $flag ? 'selected="selected"' : '';
                            if (!isset($f['options_array'][0]) || $f['options_array'][0] != '1') {
                                $selected .= ' style="background-image:url(\'img/flags/' . $flag . '.gif\');background-repeat:no-repeat;padding-left:25px;padding-bottom:3px;"';
                            }
                            $back .= '<option value="' . $flag . '" ' . $selected . '>' . tra($flag) . '</option>';
                        }
                        $back .= "</select>";
                        // textarea
                    } elseif ($f['type'] == 'a') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                        if (isset($f['options_array'][1])) {
                            $back .= '<textarea cols="' . $f['options_array'][1] . '" rows="' . $f['options_array'][2] . '" name="track[' . $f["fieldId"] . ']" wrap="soft">' . $f['value'] . '</textarea>';
                        } else {
                            $back .= '<textarea cols="29" rows="7" name="track[' . $f["fieldId"] . ']" wrap="soft">' . $f['value'] . '</textarea>';
                        }
                        // user selector
                    } elseif (($f['type'] == 'u' or $f['type'] == 'g' or $f['type'] == 'I') and ($f['options_array'][0] == '1' or $f['options_array'][0] == '2')) {
                        $back .= '<tr><td>' . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors) . '</td><td>';
                        $back .= $f['type'] == 'I' ? $_SERVER['REMOTE_ADDR'] : ($f['type'] == 'g' ? $group : $user);
                        // drop down, user selector or group selector
                    } elseif ($f['type'] == 'd' or $f['type'] == 'D' or $f['type'] == 'u' or $f['type'] == 'g' or $f['type'] == 'r' or $f['type'] == 'R') {
                        if ($f['type'] == 'd' or $f['type'] == 'D' or $f['type'] == 'R') {
                            $list = $f['options_array'];
                        } elseif ($f['type'] == 'u') {
                            $list = $f['list'];
                        } elseif ($f['type'] == 'g') {
                            $list = $f['list'];
                        }
                        if ($list) {
                            $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                            if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                                $back .= "&nbsp;<b>*</b>&nbsp;";
                                $onemandatory = true;
                            }
                            $back .= "</td><td>";
                            if ($f['type'] == 'R') {
                                foreach ($list as $item) {
                                    $selected = $f['value'] == $item || empty($f['value']) && !empty($f['defaultvalue']) && $item == $f['defaultvalue'] ? 'checked="checked"' : '';
                                    $back .= '<div class="radio"><input type="radio" name="track[' . $f["fieldId"] . ']" value="' . $item . '" ' . $selected . ' />' . $item . '</div>';
                                }
                            } else {
                                $back .= '<select name="track[' . $f["fieldId"] . ']">';
                                $back .= '<option value=""></option>';
                                $otherValue = $f['value'];
                                foreach ($list as $item) {
                                    if ($f['value'] == $item || empty($f['value']) && !empty($f['defaultvalue']) && $item == $f['defaultvalue']) {
                                        $selected = 'selected="selected"';
                                        $otherValue = '';
                                    } else {
                                        $selected = '';
                                    }
                                    $back .= '<option value="' . $item . '" ' . $selected . '>' . tra($item) . '</option>';
                                }
                                $back .= "</select>";
                            }
                            if ($f['type'] == 'D') {
                                $back .= '<br />' . tra('Other:') . ' <input type="text" name="track_other[' . $f["fieldId"] . ']" value="' . $otherValue . '" />';
                            }
                        } else {
                            $back .= '<input type="hidden" name="track[' . $f["fieldId"] . ']" value="' . $user . '" />';
                        }
                    } elseif ($f['type'] == 'h') {
                        if (strlen($back) != $backLength0) {
                            $back .= '</td></tr>';
                        }
                        $back .= "<tr><td colspan=\"2\" class=\"trackerheader\"><h2>";
                        $n = wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        $back .= $n ? $n : ' ' . '</h2>';
                        if (!empty($f['description'])) {
                            $back .= '<i>' . $f['description'] . '</i>';
                        }
                    } elseif ($f['type'] == 'e') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                        $i = 0;
                        if (!empty($f['options_array'][2]) && ($f['options_array'][2] == '1' || $f['options_array'][2] == 'y')) {
                            $back .= '<script type="text/javascript"> /* <![CDATA[ */';
                            $back .= "document.write('<div class=\"categSelectAll\"><input type=\"checkbox\" onclick=\"switchCheckboxes(this.form,\\'ins_cat_{$f['fieldId']}[]\\',this.checked)\"/>";
                            $back .= tra('Select All');
                            $back .= "</div>')/* ]]> */</script>";
                        }
                        if (isset($f['options_array'][1]) && ($f['options_array'][1] == 'd' || $f['options_array'][1] == 'm')) {
                            $back .= '<select name="ins_cat_' . $f['fieldId'] . '[]"';
                            if ($f['options_array'][1] == 'm') {
                                $back .= ' multiple="multiple"';
                            }
                            $back .= '>';
                            if ($f['options_array'][1] == 'd') {
                                $back .= '<option value=""></option>"';
                            }
                            foreach ($f['list'] as $cat) {
                                $checked = $f['value'] == $cat['categId'] ? 'selected="selected"' : '';
                                $back .= '<option value="' . $cat['categId'] . '" ' . $checked . '>' . $cat['name'] . '</option>';
                            }
                            $back .= '</select>';
                        } else {
                            $t = isset($f["options_array"][1]) && $f["options_array"][1] == 'radio' ? 'radio' : 'checkbox';
                            foreach ($f['list'] as $cat) {
                                $checked = $f['value'] == $cat['categId'] ? 'checked="checked"' : '';
                                $back .= '<input type="' . $t . '" name="ins_cat_' . $f['fieldId'] . '[]" value="' . $cat["categId"] . '" ' . $checked . '>' . $cat['name'] . '</input><br />';
                            }
                        }
                    } elseif ($f['type'] == 'c') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $checked = $f['value'] == 'y' ? 'checked="checked"' : '';
                        $back .= '</td><td><input type="checkbox" name="track[' . $f["fieldId"] . ']" value="y" ' . $checked . '/>';
                    } elseif ($f['type'] == 'i') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                        $back .= '<input type="file" name="track[' . $f["fieldId"] . ']" />';
                    } elseif ($f['type'] == 'f') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                        include_once 'lib/smarty_tiki/function.html_select_date.php';
                        include_once 'lib/smarty_tiki/function.html_select_time.php';
                        $params['prefix'] = 'track_' . $f['fieldId'];
                        if (isset($f['options_array'][1])) {
                            $params['start_year'] = $f['options_array'][1];
                        }
                        if (isset($f['options_array'][2])) {
                            $params['end_year'] = $f['options_array'][2];
                        }
                        if (isset($f['value'])) {
                            $params['time'] = $f['value'];
                        }
                        $back .= smarty_function_html_select_date($params, $smarty);
                        if (empty($f['options_array'][0]) || $f['options_array'][0] != 'd') {
                            $params['display_seconds'] = false;
                            $back .= smarty_function_html_select_time($params, $smarty);
                        }
                    } elseif ($f['type'] == 'j') {
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors);
                        if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                            $back .= "&nbsp;<b>*</b>&nbsp;";
                            $onemandatory = true;
                        }
                        $back .= "</td><td>";
                        include_once 'lib/smarty_tiki/function.jscalendar.php';
                        $params['id'] = 'track[' . $f['fieldId'] . ']';
                        $params['fieldname'] = 'track[' . $f['fieldId'] . ']';
                        if (empty($f['options_array'][0]) || $f['options_array'][0] != 'd') {
                            $params['showtime'] = 'y';
                        } else {
                            $params['showtime'] = 'n';
                        }
                        if (isset($f['value'])) {
                            $params['date'] = $f['value'];
                        }
                        $back .= smarty_function_jscalendar_body($params, $smarty);
                    } elseif ($f['type'] == 'C' && isset($_REQUEST['tr_preview'])) {
                        // computed
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors) . "</td><td>";
                        $calc = preg_replace('/#([0-9]+)/', '$assocNumerics[\\1]', $f['options_array'][0]);
                        eval('$computed = ' . $calc . ';');
                        $back .= $computed;
                    } elseif ($f['type'] == 'l' && isset($_REQUEST['tr_preview'])) {
                        // itemlist
                        $back .= "<tr><td>" . wikiplugin_tracker_name($f['fieldId'], $f['name'], $field_errors) . "</td><td>";
                        $items = $trklib->get_items_list($f['options_array'][0], $f['options_array'][1], $assocValues[$f['options_array'][2]]);
                        $i = 0;
                        foreach ($items as $id) {
                            $value = $trklib->get_item_value($f['options_array'][0], $id, $f['options_array'][3]);
                            $assocValues[$f['fieldId']] = $value;
                            // can be used in another computed field
                            $assocNumerics[$f['fieldId']] = preg_replace('/[^0-9\\.\\+]/', '', $value);
                            if ($i++ > 0) {
                                $back .= ',';
                            }
                            $back .= $value;
                        }
                    } else {
                    }
                }
                //old
                if (!empty($f['description']) && $f['type'] != 'h' && $f['type'] != 'S') {
                    $back .= '<br /><i>' . $f['description'] . '</i>';
                }
                if (empty($tpl) && empty($wiki)) {
                    $back .= "</td></tr>";
                }
            }
        }
        if (!empty($tpl)) {
            $smarty->security = true;
            $back .= $smarty->fetch($tpl);
        } elseif (!empty($wiki)) {
            $smarty->security = true;
            $back .= $smarty->fetch('wiki:' . $wiki);
        }
        if ($prefs['feature_antibot'] == 'y' && empty($user)) {
            $back .= $smarty->fetch('antibot.tpl');
        }
        if (empty($tpl) && empty($wiki)) {
            $back .= "<tr><td></td><td>";
        }
        if (!empty($preview)) {
            $back .= "<input type='submit' name='tr_preview' value='" . tra($preview) . "' />";
        }
        $back .= "<input type='submit' name='action' value='" . tra($action) . "' />";
        if ($showmandatory == 'y' and $onemandatory) {
            $back .= "<br /><i>" . tra("Fields marked with a * are mandatory.") . "</i>";
        }
        if (empty($tpl) && empty($wiki)) {
            $back .= "</td></tr>";
            $back .= "</table>";
        } else {
            $back .= '</div>';
        }
        $back .= '</form>';
        if (!empty($page)) {
            $back .= '~/np~';
        }
        return $back;
    } else {
        if (isset($_REQUEST['trackit']) and $_REQUEST['trackit'] == $trackerId) {
            $smarty->assign('wikiplugin_tracker', $trackerId);
        }
        //used in vote plugin
        $id = ' id="wikiplugin_tracker' . $trackerId . '"';
        if ($showtitle == 'y') {
            $back .= '<div class="titlebar"' . $id . '>' . $tracker["name"] . '</div>';
            $id = '';
        }
        if ($showdesc == 'y') {
            $back .= '<div class="wikitext"' . $id . '>' . $tracker["description"] . '</div><br />';
            $id = '';
        }
        $back .= "<div{$id}>" . $data . '</div>';
        return $back;
    }
}
Пример #10
0
function smarty_function_dataform($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
    require_once $smarty->_get_plugin_filepath('function', 'html_options');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_date');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_time');
    require_once $smarty->_get_plugin_filepath('modifier', 'truncate');
    require_once $smarty->_get_plugin_filepath('modifier', 'nl2br');
    require_once $smarty->_get_plugin_filepath('modifier', 'wordwrap');
    require_once $smarty->_get_plugin_filepath('modifier', 'return_bytes');
    require_once $smarty->_get_plugin_filepath('modifier', 'fsize_format');
    $row = array();
    $dd = array();
    $options = array();
    $keys = array();
    $type = 0;
    $name = 'dfform';
    $object = null;
    $edit = false;
    $table = null;
    $preset = null;
    $is_child = false;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'name':
            case 'object':
            case 'title':
            case 'preset':
                ${$_key} = (string) $_val;
                break;
            case 'options':
            case 'row':
            case 'dd':
            case 'keys':
                ${$_key} = (array) $_val;
                break;
            case 'paginate':
            case 'is_child':
            case 'edit':
                ${$_key} = (bool) $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("dataform: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    if (!$object) {
        $object = $name;
    }
    if (!$table) {
        $table = $object;
    }
    if (empty($row) && empty($dd)) {
        $smarty->trigger_error("dataform: either dd or row attribute must be present", E_USER_NOTICE);
        return '';
    }
    if (empty($row)) {
        $type = 2;
        /* new record */
    }
    if ($edit) {
        $type = 1;
    }
    if (empty($dd)) {
        $labels = null;
    } else {
        foreach ($dd as $_key => $_val) {
            $labels[$_key] = $_val['label'];
        }
    }
    if ($preset) {
        list($_field, $_text) = preg_split('/,/', $preset);
        list($_fieldname, $_fieldvalue) = preg_split('/=/', $_field);
        $_preset[$_fieldname] = $_fieldvalue;
        $_preset_text[$_fieldname] = $_text;
    }
    $_html_rows = '';
    $_html_result = '';
    # Determinar el tamaño máximo de los archivo
    $upload = smarty_modifier_return_bytes(ini_get('upload_max_filesize'));
    $post = smarty_modifier_return_bytes(ini_get('post_max_size'));
    $max_size = 0;
    if ($upload < $post) {
        $max_size = $upload;
    } else {
        $max_size = $post;
    }
    $max_size = smarty_modifier_fsize_format($max_size);
    #
    # Crea las filas del dataform en modo edicion
    #
    $_i = 0;
    if ($type) {
        foreach ((array) $dd as $_key => $_val) {
            if (!$dd[$_key]) {
                continue;
            }
            if ($type == 2) {
                $_val = '';
            }
            if ($type == 1) {
                $_val = $row[$_val['name']];
            }
            # Tenemos permiso para mostrar este campo?
            if (isset($dd[$_key]['extra']['role']) && $dd[$_key]['extra']['role'] !== $_SESSION['idalm_role']) {
                $dd[$_key]['type'] = 'hidden';
            }
            if ($dd[$_key]['references'] && !in_array($dd[$_key]['type'], array('hidden', 'auto'))) {
                if ($_preset[$_key]) {
                    $_selected = $_preset[$_key];
                } else {
                    $_selected = $_val;
                    if (!isset($references[$dd[$_key]['references']])) {
                        $references[$dd[$_key]['references']] = 0;
                    }
                    $references[$dd[$_key]['references']]++;
                    $n = $references[$dd[$_key]['references']] == 1 ? '' : $references[$dd[$_key]['references']];
                    $_val = $row[$dd[$_key]['references'] . $n];
                }
                $dd[$_key]['type'] = 'references';
            }
            $_start_year = "-10";
            $_end_year = "+10";
            switch ($dd[$_key]['type']) {
                case 'auto':
                    if ($dd[$_key]['extra']['default']) {
                        if (!empty($options[$_key])) {
                            $_val = $options[$_key][trim($dd[$_key]['extra']['default'])];
                        } else {
                            $_val = $dd[$_key]['extra']['default'];
                        }
                        $_tmp = '<span class="auto">' . $_val . '</span>';
                    } else {
                        $_tmp = !empty($_val) ? $_val : '';
                    }
                    break;
                case 'file':
                    $_tmp = '';
                    if ($_val) {
                        $_file = HOMEDIR . "/_" . $table . "/" . $_val;
                        $_icon = 'doc.png';
                        $_p = explode('.', $_file);
                        $_pc = count($_p);
                        $ext = $_p[$_pc - 1];
                        if (preg_match('/doc|rtf|swx|osd/i', $ext)) {
                            $_icon = 'doc.png';
                        }
                        if (preg_match('/pdf/i', $ext)) {
                            $_icon = 'pdf.png';
                        }
                        if (preg_match('/xls/i', $ext)) {
                            $_icon = 'excel.png';
                        }
                        if (preg_match('/jpg|gif|png/i', $ext)) {
                            $_icon = 'image.png';
                        }
                        $_tmp = '<input type="checkbox" checked name="' . $_key . '_keep" /> Conservar archivo actual (' . $_val . ')<br /><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" alt="' . $_val . '" border="0" /><br />';
                    }
                    $_tmp .= '[' . ALM_MAXIMUM . ' ' . $max_size . '] <input type="file" name="' . $_key . '" value="' . $_val . '" />';
                    break;
                case 'image':
                case 'img':
                    $_tmp = '';
                    $_icon = 'image.png';
                    $_tmp = '[' . ALM_MAXIMUM . ' ' . $max_size . '] <img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" border="0" alt="Imagen" title="Imagen" />';
                    if ($_val) {
                        $_tmp .= '<input type="checkbox" checked name="' . $_key . '_keep" /> Conservar archivo actual (' . $_val . ')<br /><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /><br />';
                    }
                    $_tmp .= '<input type="file" name="' . $_key . '" value="' . $_val . '" />';
                    break;
                case 'boolean':
                case 'bool':
                    if (preg_match("/:/", $dd[$_key]['extra']['label_bool'])) {
                        list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                        $_tchecked = $_val == 't' ? 'checked' : '';
                        $_fchecked = $_val == 'f' ? 'checked' : '';
                        $_tmp = $_si . '<input type="radio" name="' . $_key . '" ' . $_tchecked . ' value="on" />' . $_no . '<input type="radio" name="' . $_key . '" ' . $_fchecked . ' value="" />';
                    } else {
                        $_checked = $_val == 't' ? 'checked' : '';
                        $_tmp = '<input type="checkbox" name="' . $_key . '" ' . $_checked . ' />';
                    }
                    break;
                case 'datenull':
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    if (!isset($_val) || empty($_val)) {
                        $_val = '--';
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year, 'day_empty' => '--', 'month_empty' => '--', 'year_empty' => '--'), $smarty);
                    break;
                case 'date':
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year), $smarty);
                    break;
                case 'time':
                    $_tmp = smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                    break;
                case 'datetime':
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year), $smarty);
                    $_tmp .= smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                    break;
                case 'datetimenull':
                    if (preg_match("/:/", $dd[$_key]['extra']['range'])) {
                        list($_start_year, $_end_year) = preg_split('/:/', $dd[$_key]['extra']['range']);
                    }
                    $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => $_start_year, 'end_year' => $_end_year, 'day_empty' => '--', 'month_empty' => '--', 'year_empty' => '--'), $smarty);
                    $_tmp .= smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                    break;
                case 'password':
                    $_tmp = '<input type="password" name="' . $_key . '" size="20" maxlength="16" />';
                    break;
                case 'text':
                    $_tmp = '<textarea rows="5" cols="40" name="' . $_key . '">' . $_val . '</textarea> <a href="javascript:edittext(\'' . $name . '\', \'' . $_key . '\', document.forms[\'' . $name . '\'].' . $_key . '.value);">' . ALM_MAX . '</a>';
                    break;
                case 'html':
                    $_tmp = '<textarea rows="5" cols="40" id="' . $_key . '" name="' . $_key . '">' . $_val . '</textarea> <a href="javascript:edithtml(\'' . $name . '\', \'' . $_key . '\', document.forms[\'' . $name . '\'].' . $_key . '.value);">' . ALM_MAX . '</a>';
                    $_tmp .= "<script language=\"JavaScript\">\ngenerate_wysiwyg('" . $_key . "');\n</script>\n";
                    break;
                case 'xhtml':
                    $_tmp = '<textarea rows="5" cols="40" class="adm" id="' . $_key . '" name="' . $_key . '"' . ($dd[$_key]['extra']['style'] ? ' style="' . $dd[$_key]['extra']['style'] . '"' : '') . '>' . $_val . '</textarea>';
                    $_tmp .= "<script language=\"JavaScript\">\ntinyMCE.execCommand(\"mceAddControl\", true,\"{$_key}\");\n</script>\n";
                    break;
                case 'varchar':
                case 'char':
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_val), $smarty);
                        $_tmp = preg_replace("/_REFERENCE_/", $_tmp, FCELLMODREF);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                    } else {
                        $_val = preg_replace("/\"/", "&quot;", $_val);
                        $_tmp = preg_replace("/_VALUE_/", qdollar($_val), FCELLMODSTR);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        $_tmp = preg_replace("/_SIZE_/", $dd[$_key]['size'], $_tmp);
                    }
                    break;
                case 'numeric':
                case 'int':
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_val), $smarty);
                        $_tmp = preg_replace("/_REFERENCE_/", $_tmp, FCELLMODREF);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                    } else {
                        $_tmp = preg_replace("/_VALUE_/", $_val, FCELLMODSTR);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        $_tmp = preg_replace("/_SIZE_/", 10, $_tmp);
                    }
                    break;
                case 'references':
                    if ($_preset[$_key]) {
                        $_tmp = '<input type="hidden" name="' . $_key . '" value="' . $_selected . '" />';
                        if ($options[$_key]) {
                            $_tmp .= $options[$_key][$_selected];
                        } else {
                            $_tmp .= $_selected;
                        }
                    } else {
                        $_options = $options[$_key];
                        $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_selected), $smarty);
                        $_tmp = preg_replace("/_REFERENCE_/", qdollar($_tmp), FCELLMODREF);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                    }
                    break;
                case 'hidden':
                case 'serial':
                    $hidden = true;
                    $_tmp = '';
                    break;
                default:
                    $_tmp = $_val;
            }
            if (!empty($dd[$_key]['extra']['help'])) {
                $_tmp .= '<sup title="' . $dd[$_key]['extra']['help'] . '">&nbsp;?&nbsp;</sup>';
            }
            $_tmp = preg_replace("/_FCELL_/", qdollar($_tmp), FROW);
            $_tmp = preg_replace("/_LABEL_/", $labels[$_key], $_tmp);
            if (!$hidden) {
                $_html_rows .= $_tmp;
            }
            $hidden = false;
        }
    } else {
        #
        # Crea las filas del dataform en modo lectura
        #
        foreach ((array) $row as $_key => $_val) {
            $_tmp = '';
            if (!$dd[$_key]) {
                continue;
            }
            # Tenemos permiso para mostrar este campo?
            if (isset($dd[$_key]['extra']['role']) && $dd[$_key]['extra']['role'] !== $_SESSION['idalm_role']) {
                $dd[$_key]['type'] = 'hidden';
            }
            if ($dd[$_key]['references']) {
                if (!isset($references[$dd[$_key]['references']])) {
                    $references[$dd[$_key]['references']] = 0;
                }
                $references[$dd[$_key]['references']]++;
                $n = $references[$dd[$_key]['references']] == 1 ? '' : $references[$dd[$_key]['references']];
                $_val = $row[$dd[$_key]['references'] . $n];
            }
            switch ($dd[$_key]['type']) {
                case 'char':
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_tmp = $_options[$_val];
                    } else {
                        $_tmp = smarty_modifier_truncate($_val, 50);
                    }
                    break;
                case 'bool':
                case 'boolean':
                    $_si = ALM_YES;
                    $_no = ALM_NO;
                    if ($dd[$_key]['extra']['label_bool']) {
                        list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                    }
                    $_tmp = $_val == 't' ? $_si : $_no;
                    break;
                case 'file':
                    if ($_val) {
                        $_icon = $_val;
                        $_file = HOMEDIR . "/_" . $table . "/" . $_val;
                        $_icon = 'doc.png';
                        $_p = explode('.', $_file);
                        $_pc = count($_p);
                        if ($_p[$_pc - 1] == 'doc') {
                            $_icon = 'doc.png';
                        }
                        if ($_p[$_pc - 1] == 'pdf') {
                            $_icon = 'pdf.png';
                        }
                        if ($_p[$_pc - 1] == 'xls') {
                            $_icon = 'xls.png';
                        }
                        $_tmp = '<a title="' . $_val . '" href="' . URL . '/files/' . $table . '/' . $_val . '" target="_new"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" alt="' . $_val . '" border="0" /></a>';
                    } else {
                        $_tmp = '--';
                    }
                    break;
                case 'image':
                    if ($_val) {
                        if (THUMBNAILING) {
                            $_tmp = '<a href="javascript:openimage(\'' . URL . '/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /></a>';
                        } else {
                            $_tmp = '<a href="javascript:openimage(\'' . URL . '/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /></a>';
                        }
                    } else {
                        $_tmp = '--';
                    }
                    break;
                case 'hidden':
                case 'serial':
                    $hidden = true;
                    $_tmp = '';
                    break;
                default:
                    if ($dd[$_key]['extra']['list_values']) {
                        $_options = $dd[$_key]['extra']['list_values'];
                        $_val = $_options[trim($_val)];
                    }
                    if ($_preset[$_key]) {
                        $_tmp = $_val;
                        if (!empty($_pre)) {
                            $_pre .= ',';
                        }
                        $_pre .= $_key . '=' . $_preset[$_key];
                    } else {
                        $_tmp = smarty_modifier_wordwrap($_val);
                        $_tmp = smarty_modifier_nl2br($_tmp);
                    }
            }
            $_tmp = preg_replace('/_FCELL_/', qdollar($_tmp), FROW);
            $_tmp = preg_replace('/_LABEL_/', $labels[$_key], $_tmp);
            if (!$hidden) {
                $_html_rows .= $_tmp;
            }
            $hidden = false;
        }
        $_html_cmd = preg_replace("/{_ID_}/", $row[$key], FCMD);
        if (!empty($_pre)) {
            $_pre = '<input type="hidden" name="preset" value="' . $_pre . '" />';
        }
    }
    if ($type == 2) {
        $_html_cmd = FCMDADD;
        $action = "add";
    }
    if ($type == 1) {
        $_html_cmd = FCMDMOD;
        $action = "save";
    }
    if ($type == 0) {
        $_html_cmd = FCMD;
        $action = "edit";
    }
    //if ($cmd)
    $_html_rows .= $_html_cmd;
    $_i++;
    $_tmp = FROW;
    if (!($_i % 2)) {
        $_tmp = preg_replace("/class=\"dgrow\"/", "class=\"dgrow2\"", $_tmp);
    }
    #$_html_rows .= preg_replace("/_FCELL_/", $_html_row, $_tmp);
    if ($paginate && $maxrows && $_i >= $maxrows * $pg) {
        $_need_paginate = true;
        break;
    }
    $_f = F;
    $oldkeys = null;
    foreach ($keys as $val) {
        $oldkeys .= '<input type="hidden" name="alm_old_' . $val . '" value="' . $row[$val] . '" />';
    }
    $_f = preg_replace("/{_OLDKEYS_}/", $oldkeys, $_f);
    $_f = preg_replace('/{_PRESET_}/', $_pre, $_f);
    $_html_result = preg_replace("/_FHEADER_/", $_html_labels, $_f);
    if ($cmd) {
        $_html_result = preg_replace("/_FHEADERCMD_/", FHEADERCMD, $_html_result);
    }
    $_html_result = preg_replace("/_FHEADERCMD_/", '', $_html_result);
    $_html_result = preg_replace("/_TITLE_/", $title, $_html_result);
    $_html_result = preg_replace("/_FROW_/", qdollar($_html_rows), $_html_result);
    #$_npgs = ceil(count($rows) / $maxrows);
    $_paginate = '';
    if ($paginate && $_npgs > 1) {
        if ($pg != 1) {
            $_paginate = PREV;
        }
        for ($_j = 1; $_j <= $_npgs; $_j++) {
            $npg = $_j == $pg ? CURRENTPG : NPG;
            $_paginate .= preg_replace("/_NPG_/", $_j, $npg);
        }
        if ($pg != $_npgs) {
            $_paginate .= NEXT;
        }
    }
    $_html_result = preg_replace("/_PAGINATE_/", $_paginate, $_html_result);
    $params = preg_split('/\\//', $_SERVER['PHP_SELF']);
    $page = $params[count($params) - 1];
    if ($page == '404.php') {
        $_html_result = preg_replace("/_SELF_/", SELF, $_html_result);
    } else {
        $_html_result = preg_replace("/_SELF_/", $_SERVER['PHP_SELF'], $_html_result);
    }
    $_referer = preg_replace("/\\//", "\\/", $_SERVER['PHP_SELF']);
    if (preg_match("/{$_referer}/", $_SERVER['HTTP_REFERER']) || $is_child) {
        $_referer = $_SERVER['PHP_SELF'];
    } else {
        if (defined('SELF')) {
            $_referer = SELF;
        } else {
            $_referer = $_SERVER['HTTP_REFERER'];
        }
    }
    if ($is_child) {
        $_referer .= '?action=close';
    }
    $_html_result = preg_replace("/_REFERER_/", $_referer, $_html_result);
    $_html_result = preg_replace("/_KEY_/", $key, $_html_result);
    $_html_result = preg_replace("/_KEY1_/", $key1, $_html_result);
    $_html_result = preg_replace("/_KEY2_/", $key2, $_html_result);
    $_html_result = preg_replace("/{_ID_}/", $_REQUEST[$key], $_html_result);
    $_html_result = preg_replace("/_ID1_/", $_REQUEST[$key1], $_html_result);
    $_html_result = preg_replace("/_ID2_/", $_REQUEST[$key2], $_html_result);
    $_html_result = preg_replace("/_SORT_/", $_REQUEST['sort'], $_html_result);
    $_html_result = preg_replace("/_PG_/", $_REQUEST[$object . 'pg'], $_html_result);
    $_html_result = preg_replace("/_PGPREV_/", $pg - 1, $_html_result);
    $_html_result = preg_replace("/_PGNEXT_/", $pg + 1, $_html_result);
    $_html_result = preg_replace("/_FORM_/", $name, $_html_result);
    $_html_result = preg_replace("/_OBJECT_/", $object, $_html_result);
    $_html_result = preg_replace("/_ACTION_/", $action, $_html_result);
    if ($type == 0) {
        $_html_result = preg_replace('/alm_old_/', '', $_html_result);
    }
    if (strpos($_html_rows, 'value="Agregar"') != '') {
        $_SESSION['accion'] = 'add';
    } elseif (isset($_SESSION['accion'])) {
        unset($_SESSION['accion']);
    }
    return $_html_result;
}
function smarty_function_mini_calendar($params, &$smarty){
  $start = getmicrotime();

  # includes
  require_once 'Calendar/Calendar.php';
  require_once 'Calendar/Month/Weekdays.php';
  require_once 'Calendar/Day.php';
  require_once $smarty->_get_plugin_filepath('modifier','date_format');
  require_once $smarty->_get_plugin_filepath('function','html_select_date');
  require_once $smarty->_get_plugin_filepath('modifier','strip');

  # Cuando se hacia un redirect usando el ErrorDocument del 403 al archivo, no se pasaban los
  # parametros
  if((!isset($_REQUEST['Year'])&&!isset($_REQUEST['Month']))||!isset($_REQUEST['Day'])) {
    $query = parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY);
    parse_str($query,$_REQUEST);
  }
  if (!isset($_REQUEST['Year'])) $_REQUEST['Year'] = date('Y');
  if (!isset($_REQUEST['Month'])) $_REQUEST['Month'] = date('m');
  if (!isset($_REQUEST['Day'])) $_REQUEST['Day'] = date('d');
  
  // Build the month
  $Month = new Calendar_Month_Weekdays($_REQUEST['Year'],$_REQUEST['Month']);
  
  // Construct strings for next/previous links
  $PMonth = $Month->prevMonth('object'); // Get previous month as object
  $prev = '?Year='.$PMonth->thisYear().'&amp;Month='.$PMonth->thisMonth().'&amp;Day='.$PMonth->thisDay();
  $NMonth = $Month->nextMonth('object');
  $next = '?Year='.$NMonth->thisYear().'&amp;Month='.$NMonth->thisMonth().'&amp;Day='.$NMonth->thisDay();
  
  // Build the days in the month
  if($params['selectedDays'])
    foreach($params['selectedDays'] as $selectedDay) {
      $selectedDays[] = new Calendar_Day(smarty_modifier_date_format($selectedDay,"%Y"),smarty_modifier_date_format($selectedDay,"%m"), smarty_modifier_date_format($selectedDay,"%d"));
    }
  
  $class = ($params['custom_class']?$params['custom_class']:'');
  $Month->build($selectedDays);
  
  $out = "<table class=\"calendar\">";
  $out .= "<caption>".smarty_modifier_date_format($Month->getTimeStamp(),"%B %Y")."</caption>";
  $out .= "<tr>";
  $out .= "<th>Lun</th>";
  $out .= "<th>Mar</th>";
  $out .= "<th>Mie</th>";
  $out .= "<th>Jue</th>";
  $out .= "<th>Vie</th>";
  $out .= "<th".($params['dif_weekend']?" class=\"weekend sat\"":"").">Sáb</th>";
  $out .= "<th".($params['dif_weekend']?" class=\"weekend sun\"":"").">Dom</th>";
  $out .= "</tr>";
  while ( $Day = $Month->fetch() ) {
    // Build a link string for each day
    //$link = $_SERVER['PHP_SELF'].
    $link =     ($params['action']?$params['action']:"").'?Year='.$Day->thisYear().
                '&amp;Month='.$Day->thisMonth().
                '&amp;Day='.$Day->thisDay();

    
    //	Contain the week's day's number, 0 = sunday, ..., 6 = saturday
    $num_day = date("w",strtotime($Day->thisYear()."-".$Day->thisMonth()."-".$Day->thisDay()));
    // isFirst() to find start of week
    if ( $Day->isFirst() )
        $out .= "<tr>\n";

    if ( $Day->isSelected() ) {
        $out .= "<td class=\"selected\">";
        if($params['dif_weekend'])
          if($num_day == 6)
            $out .= "<div class=\"weekend sat\">";
          elseif($num_day == 0)
            $out .= "<div class=\"weekend sun\">";
          elseif($Day->thisDay()==date("d") AND $Day->thisMonth()==date("m") AND $Day->thisYear()==date("Y"))
            $out .= "<div class=\"now\">";
        $out .= "<a href=\"".$link."\"".(($class)?" class=\"$class\"":"").">".$Day->thisDay()."</a>";
        if(($params['dif_weekend'] && ($num_day == 6 || $num_day == 0)) || ($Day->thisDay()==date("d") && $Day->thisMonth()==date("m") && $Day->thisYear()==date("Y")))
          $out .= "</div>";
        $out .= "</td>\n";
    } else if ( $Day->isEmpty() ) {
        $out .= "<td>&nbsp;</td>\n";
    } elseif($Day->thisDay()==date("d") AND $Day->thisMonth()==date("m") AND $Day->thisYear()==date("Y")) {
        $out .= "<td><div class=\"now\">".$Day->thisDay()."</div></td>\n";
    } else {
        $out .= "<td>";
        if($num_day == 6 && $params['dif_weekend'])
          $out .= "<div class=\"weekend sat\">".$Day->thisDay()."</div>";
        elseif($num_day == 0 && $params['dif_weekend'])
          $out .= "<div class=\"weekend sun\">".$Day->thisDay()."</div>";
        else $out .= $Day->thisDay();
	$out .= "</td>\n";
    }
    // isLast() to find end of week
    if ( $Day->isLast() )
        $out .= "</tr>\n";
  }
 
  $start_year = ($params['start_year'])?$params['start_year']:"-5";
  $end_year = ($params['end_year'])?$params['end_year']:"+5";
  if (!isset($params['display_date'])) $params['display_date'] = true;
  $display_date = $params['display_date'];
  $day = $_REQUEST['Year']."-".$_REQUEST['Month']."-01";
  if($display_date) {
    $out .= "<tr>";
    $out .= "<td colspan=\"7\" class=\"control\"><form method=\"get\" action=\"".$params['action']."\"";
    $out .= ($params['frm_extra']?" ".$params['frm_extra']:"").">".smarty_function_html_select_date(array('time'=>$day,'prefix'=>'','start_year'=>$start_year,'end_year'=>$end_year,'display_days'=>false, 'display_months'=>true, 'display_years'=>true, 'month_extra'=>'id="Month"', 'year_extra'=>'id="Year"'),$smarty)."&nbsp;".($params['btn_img']?"<input name=\"btnsubmit\" type=\"image\" src=\"".$params['btn_img']."\"/>":"<input name=\"btnsubmit\" type=\"submit\" value=\"Ir\" />").($params['today_btn']===true?"&nbsp;<input name=\"today\" type=\"button\" value=\"Hoy\" title=\"Presione para ir al mes en curso\" onclick=\"location.href = './'\" />":"")."</form></td>";
    $out .= "</tr>";
  }
  $out .= "</table>";
  $out = smarty_modifier_strip($out);
  return $out;
}
Пример #12
0
function smarty_function_datagrid2($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
    require_once $smarty->_get_plugin_filepath('function', 'html_options');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_date');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_time');
    require_once $smarty->_get_plugin_filepath('modifier', 'truncate');
    require_once $smarty->_get_plugin_filepath('modifier', 'wordwrap');
    require_once $smarty->_get_plugin_filepath('modifier', 'url');
    $rows = array();
    $dd = array();
    $options = array();
    $paginate = false;
    $selected = null;
    $key = null;
    $key1 = null;
    $key2 = null;
    $maxrows = defined('MAXROWS') ? MAXROWS : 5;
    $maxcols = defined('MAXCOLS') ? MAXCOLS : 5;
    $name = 'dgform';
    $table = null;
    $parent = null;
    $truncate = true;
    $is_child = null;
    $have_child = null;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'name':
            case 'title':
            case 'key':
            case 'key1':
            case 'key2':
            case 'parent':
            case 'search':
                ${$_key} = (string) $_val;
                break;
            case 'options':
            case 'rows':
            case 'dd':
                ${$_key} = (array) $_val;
                break;
            case 'shortEdit':
                if (isset($params[$_key])) {
                    ${$_key} = (bool) $_val;
                }
                break;
            case 'paginate':
            case 'cmd':
            case 'truncate':
            case 'have_child':
            case 'is_child':
                ${$_key} = (bool) $_val;
                break;
            case 'selected':
                if (is_array($_val)) {
                    $smarty->trigger_error('datagrid: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
                } else {
                    $selected = (string) $_val;
                }
                break;
            case 'num_rows':
            case 'maxcols':
            case 'maxrows':
                ${$_key} = (int) $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("datagrid: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    if (empty($rows) && empty($search)) {
        #$smarty->trigger_error("datagrid: rows attribute must be present", E_USER_NOTICE);
        return ALM_NODATA;
        /* raise error here? */
    }
    if (empty($dd)) {
        $headers = null;
    } else {
        foreach ($dd as $_key => $_val) {
            $headers[$_key] = $_val['label'];
        }
    }
    if (!$table) {
        $table = $name;
    }
    $_html_search = '';
    $_html_headers = '';
    $_html_rows = '';
    $_html_result = '';
    # Crea el Buscador del datagrid
    if (!empty($search)) {
        $_html_search = preg_replace("/_FIELDS_/", 'Filtro', DS);
        $fields = preg_split('/,/', trim($search));
        $_html_sch = '';
        if ($fields) {
            foreach ($fields as $field) {
                $_tmp = '';
                if (!empty($_html_sch)) {
                    $_html_sch .= ' | ';
                }
                switch ($dd[$field]['type']) {
                    case 'varchar':
                        $_tmp = preg_replace("/_LABEL_/", $dd[$field]['label'], DSLABEL);
                        $_tmp .= '&nbsp;' . preg_replace("/_VALUE_/", '', DGCELLMODSTR);
                        $_tmp = preg_replace("/_FIELD_/", $field . 'search', $_tmp);
                        $_tmp = preg_replace("/_SIZE_/", $dd[$field]['size'], $_tmp);
                        if ($dd[$field]['extra']['autocomplete']) {
                            $_tmp .= '<script type="text/javascript">
                          $(\'#' . $field . 'search\').autocomplete({ serviceUrl:' . ($dd[$field]['extra']['autocomplete_sr'] ? $dd[$field]['extra']['autocomplete_sr'] : '\'' . URL . '/' . ALM_URI . '/js/autocomplete/autocomplete.php\'') . ', delimiter: /(,|;)\\s*/, params: { table:\'' . ($dd[$field]['extra']['autocomplete_tb'] ? $dd[$field]['extra']['autocomplete_tb'] : $table) . '\', field:\'' . ($dd[$field]['extra']['autocomplete_fd'] ? $dd[$field]['extra']['autocomplete_fd'] : ($dd[$field]['extra']['autocomplete_tb'] ? $dd[$field]['extra']['autocomplete_tb'] : $field)) . '\' } });
                        </script>';
                        }
                        break;
                }
                $_html_sch .= $_tmp;
            }
        }
        $_html_search = preg_replace("/_DSFIELDS_/", $_html_sch, $_html_search);
    }
    # Crea los encabezados del datagrid
    if (!empty($rows)) {
        $_cols = 0;
        if (!empty($headers)) {
            foreach ($headers as $_key => $_val) {
                if ($maxcols && $_cols >= $maxcols) {
                    break;
                }
                if ($parent == $_key || $dd[$_key]['type'] == 'external') {
                    continue;
                }
                $_html_header = DGHEADERCELL;
                $_field = $dd[$_key]['references'] ? $dd[$_key]['references'] : $_key;
                if ($_SESSION[$name . 'sort'] == $_field) {
                    $_img = '<img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/up.gif" border="0" />';
                    $_html_header = preg_replace("/_DESC_/", ' desc', $_html_header);
                    $_html_header = preg_replace("/_SORTIMG_/", $_img, $_html_header);
                } else {
                    $_html_header = preg_replace("/_DESC_/", '', $_html_header);
                }
                if ($_SESSION[$name . 'sort'] == $_field . ' desc') {
                    $_img = '<img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/down.gif" border="0" />';
                    $_html_header = preg_replace("/_SORTIMG_/", $_img, $_html_header);
                } else {
                    $_html_header = preg_replace("/_SORTIMG_/", '', $_html_header);
                }
                $_html_header = preg_replace("/_LABEL_/", $_val, $_html_header);
                $_html_header = preg_replace("/_FIELD_/", $_field, $_html_header);
                $_html_headers .= $_html_header;
                ++$_cols;
            }
        } else {
            foreach ($rows[0] as $_key => $_val) {
                if ($maxcols && $_cols >= $maxcols) {
                    break;
                }
                $_html_header = preg_replace("/_LABEL_|_FIELD_/", $_key, DGHEADERCELL);
                $_html_headers .= $_html_header;
                ++$_cols;
            }
        }
        # Crea las filas del datagrid
        $_i = 0;
        $pg = $_SESSION[$name . 'pg'] ? $_SESSION[$name . 'pg'] : 1;
        foreach ((array) $rows as $row) {
            $_html_row = '';
            $_chosen = $key2 ? $_REQUEST[$key1] == $row[$key1] && $_REQUEST[$key2] == $row[$key2] : $_REQUEST[$key] == $row[$key];
            if ($_REQUEST['f'] == $name && $_REQUEST['action'] == 'mod' && $_chosen) {
                $_cols = 0;
                foreach ($row as $_key => $_val) {
                    if ($maxcols && $_cols >= $maxcols) {
                        break;
                    }
                    if (!$dd[$_key]) {
                        continue;
                    }
                    if ($parent == $_key) {
                        $parentid = $_val;
                        $dd[$_key]['type'] = 'hidden';
                    } elseif ($dd[$_key]['references']) {
                        $_selected = $_val;
                        $_val = $row[$dd[$_key]['references']];
                        $dd[$_key]['type'] = 'references';
                    }
                    switch ($dd[$_key]['type']) {
                        case 'hidden':
                            $_tmp = '<input type="hidden" name="' . $_key . '" value="' . $_val . '"  />';
                            break;
                        case 'file':
                        case 'image':
                        case 'img':
                            $_tmp = '';
                            if ($_val) {
                                $_tmp = '<input type="checkbox" checked name="' . $_key . '_keep" /> Conservar archivo actual (' . $_val . ')<br /><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /><br />';
                            }
                            $_tmp .= '<input type="file" name="' . $_key . '" value="' . $_val . '" />';
                            break;
                        case 'time':
                            $_tmp = smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                            break;
                        case 'datetime':
                            $_tmp = '<input type="hidden" name="' . $_key . '" value="' . $_val . '" />';
                            $_tmp .= $_val;
                            break;
                        case 'date':
                            $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => "-10", 'end_year' => "+10"), $smarty);
                            break;
                        case 'boolean':
                        case 'bool':
                            if ($dd[$_key]['extra']['label_bool']) {
                                list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                                $_tchecked = $_val == 't' ? 'checked' : '';
                                $_fchecked = $_val == 'f' ? 'checked' : '';
                                $_tmp = $_si . '<input type="radio" name="' . $_key . '" ' . $_tchecked . ' value="on">' . $_no . '<input type="radio" name="' . $_key . '" ' . $_fchecked . ' value="">';
                            } else {
                                $_checked = $_val == 't' ? 'checked' : '';
                                $_tmp = '<input type="checkbox" name="' . $_key . '" ' . $_checked . ' />';
                            }
                            break;
                        case 'text':
                            $_tmp = preg_replace("/_VALUE_/", qdollar($_val), DGCELLMODTXT);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                            break;
                        case 'xhtml':
                            $_tmp = '<textarea rows="5" cols="40" class="adm" id="grid' . $_key . '" name="' . $_key . '"' . ($dd[$_key]['extra']['style'] ? ' style="' . $dd[$_key]['extra']['style'] . '"' : '') . '>' . $_val . '</textarea>';
                            $_tmp .= "<script language=\"JavaScript\">\ntinyMCE.execCommand(\"mceAddControl\", true,\"grid{$_key}\");\n</script>\n";
                            break;
                        case 'varchar':
                        case 'char':
                            if ($dd[$_key]['extra']['list_values']) {
                                $_options = $dd[$_key]['extra']['list_values'];
                                $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => trim($_val)), $smarty);
                                $_tmp = preg_replace("/_REFERENCE_/", qdollar($_tmp), DGCELLMODREF);
                                $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                            } else {
                                $_tmp = preg_replace("/_VALUE_/", qdollar($_val), DGCELLMODSTR);
                                $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                                $_tmp = preg_replace("/_SIZE_/", $dd[$_key]['size'], $_tmp);
                            }
                            break;
                        case 'int':
                        case 'numeric':
                            $_tmp = preg_replace("/_VALUE_/", $_val, DGCELLMODSTR);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                            $_tmp = preg_replace("/_SIZE_/", 10, $_tmp);
                            break;
                        case 'references':
                            $_options = $options[$_key];
                            $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_selected), $smarty);
                            $_tmp = preg_replace("/_REFERENCE_/", $_tmp, DGCELLMODREF);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                            break;
                        case 'order':
                            $_tmp = '- +';
                            break;
                        default:
                            $_tmp = $_val;
                    }
                    if ($dd[$_key]['type'] != 'hidden') {
                        $_tmp = preg_replace("/_VALUE_/", qdollar($_tmp), DGCELL);
                        $_cols++;
                    }
                    $_html_row .= $_tmp;
                }
                $_dgcmdmod = $key2 ? DGCMD2MOD : DGCMDMOD;
                $_html_cmd = preg_replace("/{_ID_}/", $row[$key], $_dgcmdmod);
            } else {
                $_cols = 0;
                foreach ($row as $_key => $_val) {
                    if ($maxcols && $_cols >= $maxcols) {
                        break;
                    }
                    if (!$dd[$_key] || $dd[$_key]['type'] == 'external') {
                        continue;
                    }
                    if ($parent == $_key) {
                        $parentid = $_val;
                        continue;
                    }
                    if ($dd[$_key]['references']) {
                        $pos = strpos($dd[$_key]['references'], '.');
                        if ($pos !== false) {
                            $r_table = substr($dd[$_key]['references'], 0, $pos);
                            $pos_2 = strpos($dd[$_key]['references'], '[');
                            if ($pos_2 !== false) {
                                $r_field = substr($dd[$_key]['references'], $pos_2 + 1, strlen($dd[$_key]['references']) - ($pos_2 + 2));
                            } else {
                                $r_field = $r_table;
                            }
                            $_val = $row[$r_field];
                        } else {
                            $_val = $row[$dd[$_key]['references']];
                        }
                    }
                    switch ($dd[$_key]['type']) {
                        case 'char':
                            if ($dd[$_key]['extra']['list_values']) {
                                $_options = $dd[$_key]['extra']['list_values'];
                                $_tmp = $_options[trim($_val)];
                            } else {
                                $_tmp = smarty_modifier_truncate($_val, 50);
                                $_tmp = smarty_modifier_url($_tmp);
                                $_tmp = preg_replace("/_SIZE_/", $dd[$_key]['size'], $_tmp);
                            }
                            break;
                        case 'bool':
                        case 'boolean':
                            $_si = ALM_YES;
                            $_no = ALM_NO;
                            if ($dd[$_key]['extra']['label_bool']) {
                                list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                            }
                            $_tmp = $_val == 't' ? $_si : $_no;
                            break;
                        case 'video':
                            if ($_val) {
                                require_once $smarty->_get_plugin_filepath('shared', 'video_service');
                                $a_vs = smarty_function_video_service();
                                //      XML
                                require_once 'XML/Unserializer.php';
                                $options = array(XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE => true, XML_UNSERIALIZER_OPTION_ATTRIBUTES_ARRAYKEY => false);
                                $unserializer = new XML_Unserializer($options);
                                $status = $unserializer->unserialize($_val, false);
                                if (PEAR::isError($status)) {
                                    echo 'Error: ' . $status->getMessage();
                                } else {
                                    $vs = $unserializer->getUnserializedData();
                                }
                                $_tmp = '<a href="javascript:openwindow(\'' . URL . '/' . ALM_URI . '/video.php?src=' . $vs['src'] . '&type=' . $vs['tipo'] . '\',400,333)"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $vs['tipo'] . '.png" alt="' . $a_vs[$vs['tipo']] . '" title="' . $a_vs[$vs['tipo']] . '" border="0" /></a>';
                            } else {
                                $_tmp = '--';
                            }
                            break;
                        case 'file':
                            if ($_val) {
                                $_file = HOMEDIR . "/_" . $table . "/" . $_val;
                                $_icon = 'doc.png';
                                $_p = explode('.', $_file);
                                $_pc = count($_p);
                                $ext = $_p[$_pc - 1];
                                if (preg_match('/doc|rtf|swx|osd/i', $ext)) {
                                    $_icon = 'doc.png';
                                }
                                if (preg_match('/pdf/i', $ext)) {
                                    $_icon = 'pdf.png';
                                }
                                if (preg_match('/xls/i', $ext)) {
                                    $_icon = 'excel.png';
                                }
                                if (preg_match('/jpg|gif|png/i', $ext)) {
                                    $_icon = 'image.png';
                                }
                                $_tmp = '<a href="' . URL . '/files/' . $table . '/' . $_val . '" target="_new"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" alt="' . $_val . '" border="0" /></a>';
                            } else {
                                $_tmp = '--';
                            }
                            break;
                        case 'image':
                            if ($_val) {
                                if (THUMBNAILING) {
                                    $_tmp = '<a href="javascript:openimage(\'' . URL . '/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /></a>';
                                } else {
                                    $_tmp = '<a href="javascript:openimage(\'' . URL . '/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="/_' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" height="20" border="0" /></a>';
                                }
                            } else {
                                $_tmp = '--';
                            }
                            break;
                        case 'order':
                            $_tmp = '';
                            if ($_SESSION[$name . 'first'] != $row[$key]) {
                                $_tmp .= '<a href="_SELF_?action=move&' . $key . '=' . $row[$key] . '&sense=up&key=' . $_key . '"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/up.gif" border="0"/></a>';
                            }
                            if ($_SESSION[$name . 'last'] != $row[$key]) {
                                if (!empty($_tmp)) {
                                    $tmp = ' ';
                                }
                                $_tmp .= '<a href="_SELF_?action=move&' . $key . '=' . $row[$key] . '&sense=down&key=' . $_key . '"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/down.gif" border="0"/></a>';
                            }
                            if (empty($_tmp)) {
                                $_tmp = '--';
                            }
                            break;
                        case 'text':
                        case 'html':
                        case 'xhtml':
                            # strip_tags quita los tags [x]html, preg_replace reemplaza los &nbsp; por espacio en blanco, el otro preg_replace quita mas de un espacio en blanco conjunto y lo reemplaza por un solo espacio y trim quita los espacios en blanco al final e inicio de la cadena.
                            $_val = trim(preg_replace('/\\s\\s+/', ' ', preg_replace('/&nbsp;/', ' ', strip_tags($_val))));
                        case 'varchar':
                            if ($dd[$_key]['extra']['list_values']) {
                                $_options = $dd[$_key]['extra']['list_values'];
                                $_tmp = $_options[trim($_val)];
                                break;
                            }
                        default:
                            if ($truncate) {
                                $_tmp = smarty_modifier_truncate($_val, 50);
                            } else {
                                $_tmp = smarty_modifier_wordwrap($_val, 50, "<br/>");
                            }
                            $_tmp = smarty_modifier_url($_tmp);
                    }
                    $_html_row .= preg_replace("/_VALUE_/", qdollar($_tmp), DGCELL);
                    $_cols++;
                }
                if ($key2) {
                    $_dgcmd = $_cols <= 3 || $parent ? DGCMD2R : DGCMD2;
                } elseif ($is_child) {
                    $_dgcmd = DGCMD_det;
                } else {
                    $_dgcmd = ($_cols <= 3 || $parent) && !$have_child ? $shortEdit === false ? DGCMD_NOSHORT_EDIT : DGCMDR : DGCMD;
                }
                $_html_cmd = preg_replace("/{_ID_}/", $row[$key], $_dgcmd);
                $_html_cmd = preg_replace("/_ID1_/", $row[$key1], $_html_cmd);
                $_html_cmd = preg_replace("/_ID2_/", $row[$key2], $_html_cmd);
            }
            if ($cmd) {
                $_html_row .= $_html_cmd;
            }
            $_i++;
            $_tmp = DGROW;
            if (!($_i % 2)) {
                $_tmp = preg_replace("/class=\"dgrow\"/", "class=\"dgrow2\"", $_tmp);
            }
            $_html_rows .= preg_replace("/_DGCELL_/", qdollar($_html_row), $_tmp);
            if ($paginate && $maxrows && $_i >= $maxrows * $pg) {
                $_need_paginate = true;
                break;
            }
        }
        $_dg = $key2 ? DG2 : DG;
        $_html_result = preg_replace("/_DGHEADER_/", $_html_headers, $_dg);
        if (!empty($search)) {
            $_html_result = $_html_search . $_html_result;
        }
        if ($cmd) {
            $_html_result = preg_replace("/_DGHEADERCMD_/", DGHEADERCMD, $_html_result);
        }
        $_html_result = preg_replace("/_DGHEADERCMD_/", '', $_html_result);
        $_html_result = preg_replace("/_TITLE_/", $title, $_html_result);
        $_html_result = preg_replace("/_ROWS_/", $num_rows, $_html_result);
        $_html_result = preg_replace("/_DGROW_/", qdollar($_html_rows), $_html_result);
        # Paginacion del datagrid
        $_npgs = ceil($num_rows / $maxrows);
        $_paginate = '';
        if ($paginate && $_npgs > 1) {
            if ($pg != 1) {
                $_paginate = PREV;
            }
            for ($_j = 1; $_j <= $_npgs; $_j++) {
                if ($_j > 2 && $_npgs > 10 && $_npgs - $_j >= 2 && abs($pg - $_j) > 3) {
                    $npg = $npg != '...' && $npg ? '...' : '';
                } else {
                    $npg = $_j == $pg ? CURRENTPG : NPG;
                }
                $_paginate .= preg_replace("/_NPG_/", $_j, $npg);
            }
            if ($pg != $_npgs) {
                $_paginate .= NEXT;
            }
        }
        $_html_result = preg_replace("/_PARENT_/", $parent, $_html_result);
        $_html_result = preg_replace("/_PARENTID_/", $parentid, $_html_result);
        $_html_result = preg_replace("/_PAGINATE_/", $_paginate, $_html_result);
        # christian | a new way to know if this pages is the 404.php file
        $params = preg_split('/\\//', $_SERVER['PHP_SELF']);
        $page = $params[count($params) - 1];
        # end
        if ($page == '404.php' || $page == '404c.php') {
            $_html_result = preg_replace("/_SELF_/", SELF, $_html_result);
        } else {
            $_html_result = preg_replace("/_SELF_/", $_SERVER['PHP_SELF'], $_html_result);
        }
        $_html_result = preg_replace("/_KEY_/", $key, $_html_result);
        $_html_result = preg_replace("/_KEY1_/", $key1, $_html_result);
        $_html_result = preg_replace("/_KEY2_/", $key2, $_html_result);
        $_html_result = preg_replace("/{_ID_}/", $_REQUEST[$key], $_html_result);
        $_html_result = preg_replace("/_ID1_/", $_REQUEST[$key1], $_html_result);
        $_html_result = preg_replace("/_ID2_/", $_REQUEST[$key2], $_html_result);
        $_html_result = preg_replace("/_SORT_/", $_SESSION[$name . 'sort'], $_html_result);
        $_html_result = preg_replace("/_PG_/", $_SESSION[$name . 'pg'], $_html_result);
        $_html_result = preg_replace("/_PGPREV_/", $pg - 1, $_html_result);
        $_html_result = preg_replace("/_PGNEXT_/", $pg + 1, $_html_result);
        $_html_result = preg_replace("/_MAXCOLS_/", $maxcols, $_html_result);
        $_html_result = preg_replace("/_FORM_/", $name, $_html_result);
        $_html_result = preg_replace("/_Q_/", $_REQUEST['q'], $_html_result);
    } else {
        if (!empty($search)) {
            $_html_result = $_html_search;
            if ($_SESSION[$table . 'query']) {
                $_html_result .= DSL . "<br />";
            }
        }
        # christian | a new way to know if this pages is the 404.php file
        $params = preg_split('/\\//', $_SERVER['PHP_SELF']);
        $page = $params[count($params) - 1];
        # end
        if ($page == '404.php' || $page == '404c.php') {
            $_html_result = preg_replace("/_SELF_/", SELF, $_html_result);
        } else {
            $_html_result = preg_replace("/_SELF_/", $_SERVER['PHP_SELF'], $_html_result);
        }
        $_html_result = preg_replace("/_DSQUERY_/", $_SESSION[$table . 'ssearch'], $_html_result);
        $_html_result .= ALM_NODATA;
    }
    return $_html_result;
}
       <td align='left'><?php 
echo smarty_function_html_select_time(array('prefix' => 'start_', 'display_minutes' => false, 'time' => $this->_tpl_vars['gui']->selected_start_time, 'display_seconds' => false, 'use_24_hours' => true), $this);
?>
</td>
       </tr>
			 </table>
			</td>

			<td align="center">
       <table border='0'>
       <tr>
       <td><?php 
echo $this->_tpl_vars['labels']['date'];
?>
</td><td><?php 
echo smarty_function_html_select_date(array('prefix' => 'end_', 'time' => $this->_tpl_vars['gui']->selected_end_date, 'month_format' => '%m', 'start_year' => "-1", 'end_year' => "+1", 'field_order' => $this->_tpl_vars['gsmarty_html_select_date_field_order']), $this);
?>
</td>
       </tr>
       <tr>
       <td><?php 
echo $this->_tpl_vars['labels']['hour'];
?>
</td>
       <td align='left'><?php 
echo smarty_function_html_select_time(array('prefix' => 'end_', 'display_minutes' => false, 'time' => $this->_tpl_vars['gui']->selected_end_time, 'display_seconds' => false, 'use_24_hours' => true), $this);
?>
</td>
       </tr>
			 </table>
			</td>
function smarty_function_bit_select_datetime($pParams, &$gBitSmarty)
{
    global $gBitSystem;
    global $gBitUser;
    // Default values
    $name = 'date';
    // ID of the input field
    // unsupported as of now $format       = $gBitSystem->getConfig( 'site_short_date_format' ).' '.$gBitSystem->getConfig( 'site_short_time_format' );      // date format used
    $showtime = 'true';
    //true: show time; false: pick date only
    $time = time();
    // override the currently set date
    //extract actual parameters from the params hashmap.
    extract($pParams);
    //calculate a name we can use for additional (internal) fields
    $nname = str_replace('[', '_', str_replace(']', '_', $name));
    if ($gBitSystem->isFeatureActive('site_use_jscalendar')) {
        // A readonly field will be used to display the currently selected value.
        //A button besides the field will bring up the calendar (style similar to other PIM rich client applications)
        //It is the readonly input field that will be evaluated back on the server
        //unsupported $format = preg_replace( "/%Z/", "", $format );  // JSCalendar does not know about time zones
        $html_result = "<input type=\"text\" name=\"{$name}\" id=\"{$nname}_id\" value=\"{$time}\" readonly />\n";
        $html_result = $html_result . "<button type=\"reset\" id=\"{$nname}_button\">...</button>\n";
        $html_result = $html_result . "<script type=\"text/javascript\">\n";
        $html_result = $html_result . "    Calendar.setup({\n";
        $html_result = $html_result . "        date        : \"{$time}\",\n";
        $html_result = $html_result . "        inputField  :    \"{$nname}_id\",      // id of the input field\n";
        $html_result = $html_result . "        ifFormat    :    \"%Y-%m-%d %H:%M\",       // format of the input field\n";
        $html_result = $html_result . "        showsTime   :    {$showtime},            // will display a time selector\n";
        $html_result = $html_result . "        button      :    \"{$nname}_button\",   // trigger for the calendar (button ID)\n";
        $html_result = $html_result . "        singleClick :    true,           // double-click mode\n";
        $html_result = $html_result . "        step        :    1                // show all years in drop-down boxes (instead of every other year as default)\n";
        $html_result = $html_result . "    });\n";
        $html_result = $html_result . "</script>\n";
    } else {
        $gBitSmarty->loadPlugin('smarty_modifier_html_select_date');
        $gBitSmarty->loadPlugin('smarty_modifier_html_select_time');
        // we use html_select_date and html_select_time to pick a date, which generate a number of select fields.
        //On every change a hidden field will be updated via javascript.
        //it's the hidden field that is evaluated back on the server.
        $pDate = array('prefix' => $nname, 'all_extra' => "onchange=\"bit_select_datetime_{$nname}()\"", 'time' => $time);
        $pTime = array('prefix' => $nname, 'all_extra' => "onchange=\"bit_select_datetime_{$nname}()\"", 'display_seconds' => false, 'time' => $time);
        $html_result = "<input type=\"hidden\" name=\"{$name}\" value=\"{$time}\">";
        $html_result .= smarty_function_html_select_date($pDate, $gBitSmarty);
        if ($showtime == 'true') {
            $html_result .= smarty_function_html_select_time($pTime, $gBitSmarty);
            $html_result .= "<script type=\"text/javascript\"> \n";
            $html_result .= "    function bit_select_datetime_{$nname} () {\n";
            $html_result .= "    \tvar date = new Date(); \n date.setHours ( document.getElementsByName(\"{$nname}Hour\")[0].value);\ndate.setMinutes( document.getElementsByName(\"{$nname}Minute\")[0].value); \n date.setFullYear(document.getElementsByName(\"{$nname}Year\")[0].value,document.getElementsByName(\"{$nname}Month\")[0].value-1,document.getElementsByName(\"{$nname}Day\")[0].value); \n ";
            $html_result .= "document.getElementsByName(\"{$name}\")[0].value = Math.floor(date.getTime() / 1000);";
            $html_result .= "}\n";
            $html_result .= "</script>\n";
        } else {
            $html_result .= "<script type=\"text/javascript\">\n";
            $html_result .= "    function bit_select_datetime_{$name} () {\n";
            $html_result .= "    \tvar date = new Date(); \n date.setDate( document.getElementsByName(\"{$nname}Day\")[0].value ); \n date.setMonth(document.getElementsByName(\"{$nname}Month\")[0].value-1); \n date.setFullYear(document.getElementsByName(\"{$nname}Year\")[0].value); \n ";
            $html_result .= "        document.getElementsByName(\"{$name}\")[0].value = Math.floor(date.getTime() / 1000);";
            $html_result .= "}\n";
            $html_result .= "</script>\n";
        }
    }
    return $html_result . "(" . $gBitUser->getPreference('site_display_utc') . ")\n";
}
    function content_56789a6a17e782_53410507($_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_capitalize')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/modifier.capitalize.php';
        }
        if (!is_callable('smarty_function_ci_config')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/function.ci_config.php';
        }
        if (!is_callable('smarty_modifier_date_format')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/modifier.date_format.php';
        }
        if (!is_callable('smarty_function_html_select_date')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/function.html_select_date.php';
        }
        if (!is_callable('smarty_function_html_select_time')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/function.html_select_time.php';
        }
        if (!is_callable('smarty_function_ci_language')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/function.ci_language.php';
        }
        if (!is_callable('smarty_function_ci_form_validation')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/function.ci_form_validation.php';
        }
        if (!is_callable('smarty_function_html_options')) {
            require_once '/home/hammad/Desktop/Sportoya/application/libraries/smarty/plugins/function.html_options.php';
        }
        $_smarty_tpl->properties['nocache_hash'] = '23305161056789a69797566_98732353';
        echo $_smarty_tpl->getSubTemplate("header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array('title' => "Example Smarty Page", 'name' => (string) $_smarty_tpl->tpl_vars['Name']->value), 0);
        ?>


<h1>
<?php 
        if ($_smarty_tpl->tpl_vars['bold']->value) {
            ?>
<b><?php 
        }
        ?>

Title: <?php 
        echo smarty_modifier_capitalize($_smarty_tpl->tpl_vars['title']->value);
        ?>

<?php 
        if ($_smarty_tpl->tpl_vars['bold']->value) {
            ?>
</b><?php 
        }
        ?>
</h1>

<?php 
        if ($_smarty_tpl->tpl_vars['error']->value != '') {
            ?>
<p class="error"><?php 
            echo $_smarty_tpl->tpl_vars['error']->value;
            ?>
</p><?php 
        }
        if ($_smarty_tpl->tpl_vars['message']->value != '') {
            ?>
<p class="message"><?php 
            echo $_smarty_tpl->tpl_vars['message']->value;
            ?>
</p><?php 
        }
        ?>

<?php 
        echo smarty_function_ci_config(array('name' => "base_url"), $_smarty_tpl);
        ?>

<p>The configuration value of base_url is <em><?php 
        echo $_smarty_tpl->tpl_vars['base_url']->value;
        ?>
</em></p>

<p>The current date and time is <em><?php 
        echo smarty_modifier_date_format(time(), "%Y-%m-%d %H:%M:%S");
        ?>
</em></p>

<p>The value of global assigned variable $SCRIPT_NAME is <em><?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>
</em></p>

<p>The value of server environment variable SERVER_NAME is <em><?php 
        echo $_SERVER['SERVER_NAME'];
        ?>
</em></p>

<p>The value of your IP address is: <em><?php 
        echo $_smarty_tpl->tpl_vars['ip_address']->value;
        ?>
</em></p>

<p>The value of {$Name} is <em><?php 
        echo $_smarty_tpl->tpl_vars['Name']->value;
        ?>
</em></p>

<p>The value of {$Name|upper} is <em><?php 
        echo mb_strtoupper($_smarty_tpl->tpl_vars['Name']->value, 'UTF-8');
        ?>
</em></p>

<h2>An example of a section loop:</h2>
<ul>
<?php 
        if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer'])) {
            unset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']);
        }
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['name'] = 'outer';
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'] = is_array($_loop = $_smarty_tpl->tpl_vars['FirstName']->value) ? count($_loop) : max(0, (int) $_loop);
        unset($_loop);
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = true;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] = 1;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'] - 1;
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']) {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
            if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] == 0) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = false;
            }
        } else {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = 0;
        }
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']) {
            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration']++) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'];
                if (1 & $_smarty_tpl->getVariable('smarty')->value['section']['outer']['index'] / 2) {
                    ?>
	<li><?php 
                    echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];
                    ?>
 . <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
</li>
<?php 
                } else {
                    ?>
	<li><?php 
                    echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];
                    ?>
 * <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
</li>
<?php 
                }
            }
        } else {
            ?>
	<li>none</li>
<?php 
        }
        ?>
</ul>

<h2>An example of section looped key values:</h2>
<?php 
        if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1'])) {
            unset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']);
        }
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['name'] = 'sec1';
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] = is_array($_loop = $_smarty_tpl->tpl_vars['contacts']->value) ? count($_loop) : max(0, (int) $_loop);
        unset($_loop);
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = true;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] = 1;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] - 1;
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
            if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] == 0) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = false;
            }
        } else {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = 0;
        }
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration']++) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'];
                ?>
</li>
<ul>
	<li>phone: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['phone'];
                ?>
</li>
	<li>fax: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['fax'];
                ?>
</li>
	<li>cell: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['cell'];
                ?>
</li>
</ul>
<?php 
            }
        }
        ?>

<h2>An example testing strip tags:</h2>
<table border=0><tr><td><a HREF="<?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>
"><font color="red">This is a  test     </font></a></td></tr></table>


<h2>An example of the html_select_date function:</h2>

<form>
<?php 
        echo smarty_function_html_select_date(array('start_year' => 1998, 'end_year' => 2010), $_smarty_tpl);
        ?>

</form>

<h2>An example of the html_select_time function:</h2>

<form>
<?php 
        echo smarty_function_html_select_time(array('use_24_hours' => false), $_smarty_tpl);
        ?>

</form>

<h2>An example using form_validation:</h2>


<?php 
        echo smarty_function_ci_language(array('file' => "label", 'lang' => (string) $_smarty_tpl->tpl_vars['lang']->value), $_smarty_tpl);
        ?>

<form action="#" method="post">
<fieldset>
	<label for="username"><?php 
        echo smarty_function_ci_language(array('line' => "username"), $_smarty_tpl);
        ?>
:</label>
	<input type="text" name="username" id="username" value="<?php 
        echo smarty_function_ci_form_validation(array('field' => 'username'), $_smarty_tpl);
        ?>
" /><br />
	<?php 
        echo smarty_function_ci_form_validation(array('field' => 'username', 'error' => 'true'), $_smarty_tpl);
        ?>


	<label for="password"><?php 
        echo smarty_function_ci_language(array('line' => "password"), $_smarty_tpl);
        ?>
:</label>

	<input type="password" name="password" id="password" value="" /><br />
	<?php 
        echo smarty_function_ci_form_validation(array('field' => 'password', 'error' => 'true'), $_smarty_tpl);
        ?>


	<label for="passconf"><?php 
        echo smarty_function_ci_language(array('line' => "passconf"), $_smarty_tpl);
        ?>
:</label>
	<input type="password" name="passconf" id="passconf" value="" /><br />
	<?php 
        echo smarty_function_ci_form_validation(array('field' => 'passconf', 'error' => 'true'), $_smarty_tpl);
        ?>


	<label for="email"><?php 
        echo smarty_function_ci_language(array('line' => "email"), $_smarty_tpl);
        ?>
:</label>
	<input type="text" name="email" id="email" value="<?php 
        echo smarty_function_ci_form_validation(array('field' => 'email'), $_smarty_tpl);
        ?>
" /><br />
	<?php 
        echo smarty_function_ci_form_validation(array('field' => 'email', 'error' => 'true'), $_smarty_tpl);
        ?>


	<?php 
        echo smarty_function_ci_form_validation(array('field' => 'state', 'assign' => 'selected_state'), $_smarty_tpl);
        ?>

	<label for="state"><?php 
        echo smarty_function_ci_language(array('line' => "state"), $_smarty_tpl);
        ?>
:</label>
	<select name='state'>
	<?php 
        echo smarty_function_html_options(array('values' => (string) $_smarty_tpl->tpl_vars['state_values']->value, 'output' => (string) $_smarty_tpl->tpl_vars['state_output']->value, 'selected' => (string) $_smarty_tpl->tpl_vars['selected_state']->value), $_smarty_tpl);
        ?>

	</select><br />
	<?php 
        echo smarty_function_ci_form_validation(array('field' => 'states', 'error' => 'true'), $_smarty_tpl);
        ?>


	<input type="submit" name="action" value="submit" />
</form>

<?php 
        echo $_smarty_tpl->getSubTemplate("footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0);
        ?>

<?php 
    }
Пример #16
0
function smarty_function_datagrid($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
    require_once $smarty->_get_plugin_filepath('function', 'html_options');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_date');
    require_once $smarty->_get_plugin_filepath('function', 'html_select_time');
    require_once $smarty->_get_plugin_filepath('modifier', 'truncate');
    require_once $smarty->_get_plugin_filepath('modifier', 'wordwrap');
    require_once $smarty->_get_plugin_filepath('modifier', 'url');
    $rows = array();
    $dd = array();
    $options = array();
    $paginate = false;
    $selected = null;
    $keys = array();
    $maxrows = defined('MAXROWS') ? MAXROWS : 5;
    $maxcols = defined('MAXCOLS') ? MAXCOLS : 5;
    $name = 'dgform';
    $table = null;
    $parent = null;
    $truncate = true;
    $is_child = null;
    $have_child = null;
    $extra = '';
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'name':
            case 'title':
            case 'parent':
                ${$_key} = (string) $_val;
                break;
            case 'options':
            case 'rows':
            case 'dd':
            case 'keys':
                ${$_key} = (array) $_val;
                break;
            case 'paginate':
            case 'search':
            case 'cmd':
            case 'truncate':
            case 'have_child':
            case 'is_child':
                ${$_key} = (bool) $_val;
                break;
            case 'selected':
                if (is_array($_val)) {
                    $smarty->trigger_error('datagrid: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
                } else {
                    $selected = (string) $_val;
                }
                break;
            case 'num_rows':
            case 'maxcols':
            case 'maxrows':
                ${$_key} = (int) $_val;
                break;
            default:
                if (!is_array($_val)) {
                    $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
                } else {
                    $smarty->trigger_error("datagrid: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
                }
                break;
        }
    }
    if (empty($rows)) {
        $smarty->trigger_error("datagrid: rows attribute must be present", E_USER_NOTICE);
        return '';
        /* raise error here? */
    }
    if (empty($dd)) {
        $headers = null;
    } else {
        foreach ($dd as $_key => $_val) {
            $headers[$_key] = $_val['label'];
        }
    }
    if (!$table) {
        $table = $name;
    }
    $_html_search = '';
    $_html_headers = '';
    $_html_rows = '';
    $_html_result = '';
    #
    # Crea los encabezados del datagrid
    #
    $_cols = 0;
    if (!empty($headers)) {
        foreach ($headers as $_key => $_val) {
            if ($maxcols && $_cols >= $maxcols) {
                break;
            }
            # Tenemos permiso para mostrar este campo?
            if (isset($dd[$_key]['extra']['role']) && $dd[$_key]['extra']['role'] !== $_SESSION['idalm_role']) {
                $dd[$_key]['type'] = 'hidden';
            }
            if ($parent == $_key || $dd[$_key]['type'] == 'external' || $dd[$_key]['type'] == 'hidden') {
                continue;
            }
            $_html_header = DGHEADERCELL;
            # Para permitir referencias multiples a la misma tabla
            if ($dd[$_key]['references']) {
                if (!isset($references[$dd[$_key]['references']])) {
                    $references[$dd[$_key]['references']] = 0;
                }
                if ($dd[$_key]['references'] == $name && !$references[$dd[$_key]['references']]) {
                    $references[$dd[$_key]['references']] += 2;
                } else {
                    $references[$dd[$_key]['references']]++;
                }
                $n = $references[$dd[$_key]['references']] == 1 ? '' : $references[$dd[$_key]['references']];
                $_field = $dd[$_key]['references'] . $n;
            } else {
                $_field = $_key;
            }
            if ($_SESSION[$name . 'sort'] == $_field) {
                $_img = '<img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/up.gif" border="0" />';
                $_html_header = preg_replace("/_DESC_/", ' desc', $_html_header);
                $_html_header = preg_replace("/_SORTIMG_/", $_img, $_html_header);
            } else {
                $_html_header = preg_replace("/_DESC_/", '', $_html_header);
            }
            if ($_SESSION[$name . 'sort'] == $_field . ' desc') {
                $_img = '<img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/down.gif" border="0" />';
                $_html_header = preg_replace("/_SORTIMG_/", $_img, $_html_header);
            } else {
                $_html_header = preg_replace("/_SORTIMG_/", '', $_html_header);
            }
            $_html_header = preg_replace("/_LABEL_/", $_val, $_html_header);
            $_html_header = preg_replace("/_FIELD_/", $_field, $_html_header);
            $_html_headers .= $_html_header;
            ++$_cols;
        }
        unset($references);
    } else {
        foreach ($rows[0] as $_key => $_val) {
            if ($maxcols && $_cols >= $maxcols) {
                break;
            }
            $_html_header = preg_replace("/_LABEL_|_FIELD_/", $_key, DGHEADERCELL);
            $_html_headers .= $_html_header;
            ++$_cols;
        }
    }
    $_i = 0;
    $pg = $_SESSION[$name . 'pg'] ? $_SESSION[$name . 'pg'] : 1;
    foreach ((array) $rows as $row) {
        unset($references);
        #
        # Crea las filas del datagrid en modo edicion
        #
        $_html_row = '';
        $_chosen = true;
        foreach ($keys as $val) {
            if ($_REQUEST[$val] !== $row[$val]) {
                $_chosen = false;
                break;
            }
        }
        if ($_REQUEST['f'] == $name && $_REQUEST['action'] == 'mod' && $_chosen) {
            $selected_row = $row;
            $_cols = 0;
            foreach ($row as $_key => $_val) {
                if ($maxcols && $_cols >= $maxcols) {
                    break;
                }
                if (!$dd[$_key]) {
                    continue;
                }
                # Tenemos permiso para mostrar este campo?
                if (isset($dd[$_key]['extra']['role']) && $dd[$_key]['extra']['role'] !== $_SESSION['idalm_role']) {
                    $dd[$_key]['type'] = 'hidden';
                }
                if ($parent == $_key) {
                    $parentid = $_val;
                    $dd[$_key]['type'] = 'hidden';
                } elseif ($dd[$_key]['references']) {
                    $_selected = $_val;
                    if (!isset($references[$dd[$_key]['references']])) {
                        $references[$dd[$_key]['references']] = 0;
                    }
                    if ($dd[$_key]['references'] == $name && !$references[$dd[$_key]['references']]) {
                        $references[$dd[$_key]['references']] += 2;
                    } else {
                        $references[$dd[$_key]['references']]++;
                    }
                    $n = $references[$dd[$_key]['references']] == 1 ? '' : $references[$dd[$_key]['references']];
                    $_val = $row[$dd[$_key]['references'] . $n];
                    $dd[$_key]['type'] = 'references';
                }
                switch ($dd[$_key]['type']) {
                    case 'file':
                    case 'image':
                    case 'img':
                        $_tmp = '';
                        if ($_val) {
                            $_tmp = '<input type="checkbox" checked name="' . $_key . '_keep" /> ' . ALM_KEEP_FILE . ' (' . $_val . ')<br /><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /><br />';
                        }
                        $_tmp .= '<input type="file" name="' . $_key . '" value="' . $_val . '" />';
                        break;
                    case 'time':
                        $_tmp = smarty_function_html_select_time(array('prefix' => $_key . '_', 'time' => $_val, 'display_seconds' => false), $smarty);
                        break;
                    case 'datetime':
                        $_tmp = '<input type="hidden" name="' . $_key . '" value="' . $_val . '" />';
                        $_tmp .= $_val;
                        break;
                    case 'date':
                        $_tmp = smarty_function_html_select_date(array('prefix' => $_key . '_', 'time' => $_val, 'start_year' => "-10", 'end_year' => "+10"), $smarty);
                        break;
                    case 'boolean':
                    case 'bool':
                        if ($dd[$_key]['extra']['label_bool']) {
                            list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                            $_tchecked = $_val == 't' ? 'checked' : '';
                            $_fchecked = $_val == 'f' ? 'checked' : '';
                            $_tmp = $_si . '<input type="radio" name="' . $_key . '" ' . $_tchecked . ' value="on">' . $_no . '<input type="radio" name="' . $_key . '" ' . $_fchecked . ' value="">';
                        } else {
                            $_checked = $_val == 't' ? 'checked' : '';
                            $_tmp = '<input type="checkbox" name="' . $_key . '" ' . $_checked . ' />';
                        }
                        break;
                    case 'text':
                        $_tmp = preg_replace("/_VALUE_/", qdollar(htmlentities($_val, ENT_COMPAT, 'UTF-8')), DGCELLMODSTR);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        break;
                    case 'xhtml':
                        $_tmp = '<textarea rows="5" cols="40" class="adm" id="grid' . $_key . '" name="' . $_key . '"' . ($dd[$_key]['extra']['style'] ? ' style="' . $dd[$_key]['extra']['style'] . '"' : '') . '>' . $_val . '</textarea>';
                        $_tmp .= "<script language=\"JavaScript\">\ntinyMCE.execCommand(\"mceAddControl\", true,\"grid{$_key}\");\n</script>\n";
                        break;
                    case 'varchar':
                    case 'char':
                        if ($dd[$_key]['extra']['list_values']) {
                            $_options = $dd[$_key]['extra']['list_values'];
                            $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => trim($_val)), $smarty);
                            $_tmp = preg_replace("/_REFERENCE_/", qdollar($_tmp), DGCELLMODREF);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        } else {
                            $_tmp = preg_replace("/_VALUE_/", qdollar(htmlentities($_val, ENT_COMPAT, 'UTF-8')), DGCELLMODSTR);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                            $_tmp = preg_replace("/_SIZE_/", $dd[$_key]['size'], $_tmp);
                        }
                        break;
                    case 'int':
                    case 'numeric':
                        if ($dd[$_key]['extra']['list_values']) {
                            $_options = $dd[$_key]['extra']['list_values'];
                            $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => trim($_val)), $smarty);
                            $_tmp = preg_replace("/_REFERENCE_/", qdollar($_tmp), DGCELLMODREF);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        } else {
                            $_tmp = preg_replace("/_VALUE_/", $_val, DGCELLMODSTR);
                            $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                            $_tmp = preg_replace("/_SIZE_/", 10, $_tmp);
                        }
                        break;
                    case 'references':
                        $_options = $options[$_key];
                        $_tmp = smarty_function_html_options(array('options' => $_options, 'selected' => $_selected), $smarty);
                        $_tmp = preg_replace("/_REFERENCE_/", qdollar($_tmp), DGCELLMODREF);
                        $_tmp = preg_replace("/_FIELD_/", $_key, $_tmp);
                        break;
                    case 'order':
                        $_tmp = '- +';
                        break;
                        #case 'hidden':
                        #  $_tmp = '<input type="hidden" name="'.$_key.'" value="'.$_val.'"  />';
                        #  break;
                    #case 'hidden':
                    #  $_tmp = '<input type="hidden" name="'.$_key.'" value="'.$_val.'"  />';
                    #  break;
                    case 'hidden':
                        $hidden = true;
                        $_tmp = '';
                        break;
                    default:
                        $_tmp = $_val;
                }
                if ($dd[$_key]['type'] != 'hidden') {
                    $_tmp = preg_replace("/_VALUE_/", qdollar($_tmp), DGCELL);
                    $_cols++;
                }
                $_html_row .= $_tmp;
            }
            if ($_SESSION['credentials'][$table] == 'full' || $_SESSION['credentials'][$table] == 'edit' || $_SESSION['idalm_user'] === 'admin') {
                $_dgcmdmod = DGCMDMOD;
            }
            /*
            $key_id = null;
            foreach($keys as $val)
              $key_id[] = $val .'='. $row[$val];
            $_html_cmd = preg_replace("/{_IDS_}/", 'array('. join(',',$key_id) .')', $_dgcmdmod);
            */
            $_html_cmd = $_dgcmdmod;
        } else {
            #
            # Crea las filas del datagrid en modo lectura
            #
            $_cols = 0;
            foreach ($row as $_key => $_val) {
                if ($maxcols && $_cols >= $maxcols) {
                    break;
                }
                if (!$dd[$_key] || $dd[$_key]['type'] == 'external') {
                    continue;
                }
                # Tenemos permiso para mostrar este campo?
                if (isset($dd[$_key]['extra']['role']) && $dd[$_key]['extra']['role'] !== $_SESSION['idalm_role']) {
                    $dd[$_key]['type'] = 'hidden';
                }
                if ($parent == $_key) {
                    $parentid = $_val;
                    continue;
                }
                if ($dd[$_key]['references']) {
                    if (!isset($references[$dd[$_key]['references']])) {
                        $references[$dd[$_key]['references']] = 0;
                    }
                    if ($dd[$_key]['references'] == $name && !$references[$dd[$_key]['references']]) {
                        $references[$dd[$_key]['references']] += 2;
                    } else {
                        $references[$dd[$_key]['references']]++;
                    }
                    $n = $references[$dd[$_key]['references']] == 1 ? '' : $references[$dd[$_key]['references']];
                    $_val = empty($_val) ? '--' : $row[$dd[$_key]['references'] . $n];
                }
                switch ($dd[$_key]['type']) {
                    case 'varchar':
                    case 'char':
                        if ($dd[$_key]['extra']['list_values']) {
                            $_options = $dd[$_key]['extra']['list_values'];
                            $_tmp = $_options[trim($_val)];
                        } else {
                            $_tmp = smarty_modifier_truncate($_val, 50);
                            $_tmp = smarty_modifier_url($_tmp);
                            $_tmp = preg_replace("/_SIZE_/", $dd[$_key]['size'], $_tmp);
                        }
                        break;
                    case 'bool':
                    case 'boolean':
                        $_si = ALM_YES;
                        $_no = ALM_NO;
                        if ($dd[$_key]['extra']['label_bool']) {
                            list($_si, $_no) = preg_split('/:/', $dd[$_key]['extra']['label_bool']);
                        }
                        $_tmp = $_val == 't' ? $_si : $_no;
                        break;
                    case 'file':
                        if ($_val) {
                            $_file = HOMEDIR . "/_" . $table . "/" . $_val;
                            $_icon = 'doc.png';
                            $_p = explode('.', $_file);
                            $_pc = count($_p);
                            $ext = $_p[$_pc - 1];
                            if (preg_match('/doc|rtf|swx|osd/i', $ext)) {
                                $_icon = 'doc.png';
                            }
                            if (preg_match('/pdf/i', $ext)) {
                                $_icon = 'pdf.png';
                            }
                            if (preg_match('/xls/i', $ext)) {
                                $_icon = 'excel.png';
                            }
                            if (preg_match('/jpg|gif|png/i', $ext)) {
                                $_icon = 'image.png';
                            }
                            $_tmp = '<a href="' . URL . '/files/' . $table . '/' . $_val . '" target="_new"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/' . $_icon . '" alt="' . $_val . '" border="0" /></a>';
                        } else {
                            $_tmp = '--';
                        }
                        break;
                    case 'image':
                        if ($_val) {
                            if (THUMBNAILING) {
                                $_tmp = '<a href="javascript:openimage(\'' . URL . '/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="' . URL . '/' . ALM_URI . '/pic/50/' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" border="0" /></a>';
                            } else {
                                $_tmp = '<a href="javascript:openimage(\'/files/' . $table . '/' . $_val . '\',\'Imagen: ' . $_val . '\')"><img src="/_' . $table . '/' . $_val . '" alt="' . $_val . '" width="50" height="20" border="0" /></a>';
                            }
                        } else {
                            $_tmp = '--';
                        }
                        break;
                    case 'order':
                        $_tmp = '';
                        if ($_SESSION[$name . 'first'] != $row[$key]) {
                            $_tmp .= '<a href="_SELF_?action=move&' . $key . '=' . $row[$key] . '&sense=up&key=' . $_key . '"><img src="' . URI . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/up.gif" border="0"/></a>';
                        }
                        if ($_SESSION[$name . 'last'] != $row[$key]) {
                            if (!empty($_tmp)) {
                                $tmp = ' ';
                            }
                            $_tmp .= '<a href="_SELF_?action=move&' . $key . '=' . $row[$key] . '&sense=down&key=' . $_key . '"><img src="' . URL . '/' . ALM_URI . '/themes/' . ALM_ADMIN_THEME . '/img/down.gif" border="0"/></a>';
                        }
                        if (empty($_tmp)) {
                            $_tmp = '--';
                        }
                        break;
                    case 'hidden':
                        $hidden = true;
                        $_tmp = '';
                        break;
                    case 'text':
                    case 'html':
                    case 'xhtml':
                        # strip_tags quita los tags [x]html, preg_replace reemplaza los &nbsp; por espacio en blanco, el otro preg_replace quita mas de un espacio en blanco conjunto y lo reemplaza por un solo espacio y trim quita los espacios en blanco al final e inicio de la cadena.
                        $_val = trim(preg_replace('/\\s\\s+/', ' ', preg_replace('/&nbsp;/', ' ', strip_tags($_val))));
                    default:
                        $_val = $_val === '' ? "&nbsp;" : $_val;
                        if ($truncate) {
                            $_tmp = smarty_modifier_truncate($_val, 50);
                        } else {
                            $_tmp = smarty_modifier_wordwrap($_val, 50, "<br/>");
                        }
                        $_tmp = smarty_modifier_url($_tmp);
                }
                if ($dd[$_key]['type'] != 'hidden') {
                    $_tmp = preg_replace("/_VALUE_/", qdollar($_tmp), DGCELL);
                    $_cols++;
                }
                $_html_row .= $_tmp;
            }
            if ($_cols <= 3 || $parent) {
                if ($_SESSION['credentials'][$table] == 'full' || $_SESSION['idalm_user'] === 'admin') {
                    if ($is_child) {
                        $_dgcmd = DGCMD_det;
                    } else {
                        $_dgcmd = DGCMDR;
                    }
                } elseif ($_SESSION['credentials'][$table] == 'edit') {
                    $_dgcmd = DGCMDREDIT;
                } elseif ($_SESSION['credentials'][$table] == 'delete') {
                    $_dgcmd = DGCMDRDEL;
                } elseif ($_SESSION['credentials'][$table] == 'read') {
                    $_dgcmd = DGCMDRVER;
                }
            } else {
                if ($_SESSION['credentials'][$table] == 'full' || $_SESSION['idalm_user'] === 'admin') {
                    $_dgcmd = DGCMD;
                } elseif ($_SESSION['credentials'][$table] == 'edit') {
                    $_dgcmd = DGCMDEDIT;
                } elseif ($_SESSION['credentials'][$table] == 'delete') {
                    $_dgcmd = DGCMDDEL;
                } elseif ($_SESSION['credentials'][$table] == 'read') {
                    $_dgcmd = DGCMDVER;
                }
            }
            $ids = null;
            $key_id_url = null;
            $key_id_js = null;
            foreach ($keys as $val) {
                $key_id_url[] = $val . '=' . $row[$val];
                $key_id_js[] = "'{$val}':'" . $row[$val] . "'";
                $ids[] = "'" . $row[$val] . "'";
            }
            /* If it has a child, set parent keys */
            if (!empty($parent)) {
                $key_id_js[] = "'{$parent}':'" . $row[$parent] . "'";
            }
            $_html_cmd = preg_replace("/{_KEY=ID_}/", join('&amp;', $key_id_url), $_dgcmd);
            $_html_cmd = preg_replace("/{_KEY:ID_}/", '{' . join(',', $key_id_js) . '}', $_html_cmd);
            $_html_cmd = preg_replace("/{_IDS_}/", '[' . join(',', $ids) . ']', $_html_cmd);
        }
        if ($cmd) {
            $_html_row .= $_html_cmd;
        }
        $_i++;
        $_tmp = DGROW;
        if (!($_i % 2)) {
            $_tmp = preg_replace("/class=\"dgrow\"/", "class=\"dgrow2\"", $_tmp);
        }
        $_html_rows .= preg_replace("/_DGCELL_/", qdollar($_html_row), $_tmp);
        if ($paginate && $maxrows && $_i >= $maxrows * $pg) {
            $_need_paginate = true;
            break;
        }
    }
    $_dg = DG;
    $oldkeys = null;
    foreach ($keys as $val) {
        $oldkeys .= '<input type="hidden" name="alm_old_' . $val . '" value="' . $selected_row[$val] . '" />';
    }
    $_dg = preg_replace("/{_OLDKEYS_}/", $oldkeys, $_dg);
    $_html_result = preg_replace("/_DGHEADER_/", $_html_headers, $_dg);
    if ($search === true) {
        $_dgsearch = preg_replace("/{_Q_}/", htmlentities($_REQUEST['q']), DGSEARCH);
        $_html_result = preg_replace("/{_DGSEARCH_}/", $_dgsearch, $_html_result);
    } else {
        $_html_result = preg_replace("/{_DGSEARCH_}/", '', $_html_result);
    }
    if ($cmd) {
        $_html_result = preg_replace("/_DGHEADERCMD_/", DGHEADERCMD, $_html_result);
    }
    $_html_result = preg_replace("/_DGHEADERCMD_/", '', $_html_result);
    $_html_result = preg_replace("/_TITLE_/", $title, $_html_result);
    $_html_result = preg_replace("/_ROWS_/", $num_rows, $_html_result);
    $_html_result = preg_replace("/_DGROW_/", qdollar($_html_rows), $_html_result);
    # Paginacion del datagrid
    $_npgs = ceil($num_rows / $maxrows);
    $_paginate = '';
    if ($paginate && $_npgs > 1) {
        if ($pg != 1) {
            $_paginate = PREV;
        }
        for ($_j = 1; $_j <= $_npgs; $_j++) {
            if ($_j > 2 && $_npgs > 10 && $_npgs - $_j >= 2 && abs($pg - $_j) > 3) {
                $npg = $npg != '...' && $npg ? '...' : '';
            } else {
                $npg = $_j == $pg ? CURRENTPG : NPG;
            }
            $_paginate .= preg_replace("/_NPG_/", $_j, $npg);
        }
        if ($pg != $_npgs) {
            $_paginate .= NEXT;
        }
    }
    $_html_result = preg_replace("/_PARENT_/", $parent, $_html_result);
    $_html_result = preg_replace("/_PARENTID_/", $parentid, $_html_result);
    $_html_result = preg_replace("/_PAGINATE_/", $_paginate, $_html_result);
    $params = preg_split('/\\//', $_SERVER['PHP_SELF']);
    $page = $params[count($params) - 1];
    if ($page == '404.php' || $page == '404c.php') {
        $_html_result = preg_replace("/_SELF_/", SELF, $_html_result);
    } else {
        $_html_result = preg_replace("/_SELF_/", $_SERVER['PHP_SELF'], $_html_result);
    }
    $akeys = null;
    foreach ($keys as $val) {
        $akeys[] = "'" . $val . "'";
    }
    $_html_result = preg_replace("/{_KEYS_}/", '[' . join(',', $akeys) . ']', $_html_result);
    #$_html_result = preg_replace("/{_ID_}/", $_REQUEST[$key], $_html_result);
    $_html_result = preg_replace("/_SORT_/", $_SESSION[$name . 'sort'], $_html_result);
    $_html_result = preg_replace("/_PG_/", $_SESSION[$name . 'pg'], $_html_result);
    $_html_result = preg_replace("/_PGPREV_/", $pg - 1, $_html_result);
    $_html_result = preg_replace("/_PGNEXT_/", $pg + 1, $_html_result);
    $_html_result = preg_replace("/_MAXCOLS_/", $maxcols, $_html_result);
    $_html_result = preg_replace("/_FORM_/", $name, $_html_result);
    $_html_result = preg_replace("/_Q_/", $_REQUEST['q'], $_html_result);
    return $_html_result;
}
Пример #17
0
testing strip tags
<?php 
echo '<table border=0><tr><td><A HREF="';
echo $this->_tpl_vars['SCRIPT_NAME'];
echo '"><font color="red">This is a  test     </font></A></td></tr></table>';
?>


</PRE>

This is an example of the html_select_date function:

<form>
<?php 
echo smarty_function_html_select_date(array('start_year' => 1998, 'end_year' => 2010), $this);
?>

</form>

This is an example of the html_select_time function:

<form>
<?php 
echo smarty_function_html_select_time(array('use_24_hours' => false), $this);
?>

</form>

This is an example of the html_options function:
</span>
            <input type="hidden" name="closed_on_date" value=<?php 
echo $this->_tpl_vars['gui']->closed_on_date;
?>
>
        </td>
		</tr>

    <tr>
		    <th style="background:none;"><?php 
echo $this->_tpl_vars['labels']['release_date'];
?>
</th>
		    <td>
		    <?php 
echo smarty_function_html_select_date(array('prefix' => 'release_date_', 'time' => $this->_tpl_vars['gui']->release_date, 'month_format' => '%m', 'end_year' => "+1", 'day_value_format' => "%02d", 'all_empty' => ' ', 'month_empty' => ' ', 'field_order' => $this->_tpl_vars['gsmarty_html_select_date_field_order']), $this);
?>

        </td>
		</tr>

			<?php 
if (!$this->_tpl_vars['gui']->build_id && $this->_tpl_vars['gui']->source_build['build_count']) {
    ?>
		<tr>
			<th style="background:none;"><?php 
    echo $this->_tpl_vars['labels']['copy_tester_assignments'];
    ?>
</th>
			<td>
				<input type="checkbox"  name="copy_tester_assignments" id="copy_tester_assignments"
    <?php 
    $this->assign('dob', $this->_tpl_vars['dob_Year'] . "-" . $this->_tpl_vars['dob_Month'] . "-" . $this->_tpl_vars['dob_Day']);
    ?>
  <?php 
} else {
    ?>
    <?php 
    $this->assign('dob', "smarty.now");
    ?>
  <?php 
}
?>
  <tr>   
    <td>&nbsp;Date of Birth:</td>
    <td><?php 
echo smarty_function_html_select_date(array('prefix' => 'dob_', 'field_order' => 'DMY', 'time' => $this->_tpl_vars['dob'], 'start_year' => "-80", 'end_year' => "+1"), $this);
?>
</td>
  </tr>    
  
  <?php 
echo smarty_function_validate(array('field' => 'city', 'criteria' => 'notEmpty', 'message' => '<tr class="false"><td colspan="2"><li>Your city cannot be empty</td></tr>'), $this);
?>

  <tr>   
    <td>&nbsp;City:</td>
    <td><input type='text' name='city' value='<?php 
echo is_array($_tmp = @$this->_tpl_vars['city']) ? $this->_run_mod_handler('default', true, $_tmp) : smarty_modifier_default($_tmp);
?>
' size='30' maxlength='50'></td>
  </tr>
		<td class="table-form-title" colspan="2"><?php 
            echo is_array($_tmp = $this->_tpl_vars['data'][$this->_sections['d']['index']]['Value']) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp);
            ?>
</td>
	<?php 
        } elseif ($this->_tpl_vars['data'][$this->_sections['d']['index']]['Type'] == 'datetime') {
            ?>
		<td class="table-form-title" ><?php 
            echo $this->_tpl_vars['lang']['db'][$this->_tpl_vars['fullField']];
            if ($this->_tpl_vars['data'][$this->_sections['d']['index']]['Null'] != 'YES') {
                ?>
*<?php 
            }
            ?>
:</td><td class="table-form-field" ><?php 
            echo smarty_function_html_select_date(array('time' => $this->_tpl_vars['data'][$this->_sections['d']['index']]['value'], 'prefix' => "CONDATETIME_" . $this->_tpl_vars['data'][$this->_sections['d']['index']]['fullField'] . "_"), $this);
            ?>
 - <?php 
            echo smarty_function_html_select_time(array('time' => $this->_tpl_vars['data'][$this->_sections['d']['index']]['value'], 'prefix' => "CONDATETIME_" . $this->_tpl_vars['data'][$this->_sections['d']['index']]['fullField'] . "_"), $this);
            ?>
</td>
	<?php 
        } elseif ($this->_tpl_vars['data'][$this->_sections['d']['index']]['Type'] == 'text') {
            ?>
		<td class="table-form-title" ><?php 
            echo $this->_tpl_vars['lang']['db'][$this->_tpl_vars['fullField']];
            if ($this->_tpl_vars['data'][$this->_sections['d']['index']]['Null'] != 'YES') {
                ?>
*<?php 
            }
            ?>
if ($this->_tpl_vars['prescription']->get_active() > 0) {
    ?>
 checked<?php 
}
?>
 />
  </td>
</tr>
<tr>
	<td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" ><?php 
echo smarty_function_xl(array('t' => 'Starting Date'), $this);
?>
</td>
	<td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
		<?php 
echo smarty_function_html_select_date(array('start_year' => "-10", 'end_year' => "+5", 'time' => $this->_tpl_vars['prescription']->start_date, 'prefix' => 'start_date_'), $this);
?>

	</td>
</tr>
<tr>
	<td COLSPAN="1" class="text" ALIGN="right" VALIGN="MIDDLE" ><?php 
echo smarty_function_xl(array('t' => 'Provider'), $this);
?>
</td>
	<td COLSPAN="2" ALIGN="LEFT" VALIGN="MIDDLE" >
		<?php 
echo smarty_function_html_options(array('name' => 'provider_id', 'options' => $this->_tpl_vars['prescription']->provider->utility_provider_array(), 'selected' => $this->_tpl_vars['prescription']->provider->get_id()), $this);
?>

		<input type="hidden" name="patient_id" value="<?php 
	<tr>
		<td class="label">
			<label for="<?php 
    echo $this->_tpl_vars['filterName'];
    ?>
"><?php 
    echo $this->_plugins['function']['translate'][0][0]->smartyTranslate(array('key' => $this->_tpl_vars['key']), $this);
    ?>
</label>
		</td>
		<td class="value">
			<?php 
    if ($this->_tpl_vars['filterType'] == 'date') {
        ?>
				<?php 
        echo smarty_function_html_select_date(array('prefix' => $this->_tpl_vars['filterName'], 'time' => $this->_tpl_vars['filterValue'], 'all_extra' => "class=\"selectMenu\"", 'year_empty' => "", 'month_empty' => "", 'day_empty' => "", 'start_year' => $this->_tpl_vars['startYear'], 'end_year' => $this->_tpl_vars['endYear']), $this);
        ?>

				<?php 
        if ($this->_tpl_vars['filterName'] == 'dateTo') {
            ?>
					<input type="hidden" name="dateToHour" value="23" />
					<input type="hidden" name="dateToMinute" value="59" />
					<input type="hidden" name="dateToSecond" value="59" />
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
				<?php 
Пример #23
0
 /**	*/
 public function printDate()
 {
     global $ari;
     require_once $ari->t->_get_plugin_filepath('function', 'html_select_date');
     $class = $this->class;
     $checked = '';
     $disabled = '';
     if ($this->value['check'] == '1') {
         $checked = 'checked';
         $disabled = 'disabled';
     }
     /* 	
      		$attributes = array('prefix'=> $this->name,
                                 'time'=> $this->value['date'],
                                 'field_order'=> $this->type,
                                 'year_as_text'=>true,
                                 'all_extra' => $disabled);
     */
     $attributes = array('prefix' => $this->name, 'time' => $this->value['date'], 'field_order' => $this->type, 'year_as_text' => true, 'day_extra' => "id='" . $this->name . "Day'", 'month_extra' => "id='" . $this->name . "Month'", 'year_extra' => "id='" . $this->name . "Year'", 'all_extra' => $disabled);
     $name_check = $this->name . 'Check';
     $return = smarty_function_html_select_date($attributes, $ari->t);
     $return .= "<input type='checkbox' class='{$class}' id='{$name_check}' name='{$name_check}' value='1' {$checked} onclick=enabledDate('{$this->name}')>Sin especificar";
     return $return;
 }
    function content_5229c5f06cad74_86998761($_smarty_tpl)
    {
        if (!is_callable('smarty_function_html_select_date')) {
            include 'Z:\\home\\hst\\www\\libs\\plugins\\function.html_select_date.php';
        }
        if (!is_callable('smarty_function_html_options')) {
            include 'Z:\\home\\hst\\www\\libs\\plugins\\function.html_options.php';
        }
        echo $_smarty_tpl->getSubTemplate('header.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);
        ?>
       
		<!-- start middle -->
		<div id="middle">
        	<?php 
        echo $_smarty_tpl->getSubTemplate("aside_catalog.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);
        ?>

			<!-- start content -->
			<section id="content">
                <div class="edit_data">
					<form id="registration" action="<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
" method="POST">
                   <div class="upload_box">
                        <div class="upload_box_image"><?php 
        echo $_smarty_tpl->tpl_vars['thumbnail']->value;
        ?>
</div>
                        <a href="#" class="md-trigger" data-modal="modal-1">Нажмите для загрузки фото</a>
                    </div>  
                     <div class="registration-form">
                        <label>
                            <span>Имя Фамилия Отчество</span>
                            <input type="text" name="fio" value="<?php 
        if (isset($_POST['fio'])) {
            echo $_POST['fio'];
        } else {
            echo $_smarty_tpl->tpl_vars['user']->value['fio'];
        }
        ?>
" />
                        </label>
                        <label>
                            <span>Логин</span>
                            <input type="text" name="login" value="<?php 
        if (isset($_POST['login'])) {
            echo $_POST['login'];
        } else {
            echo $_smarty_tpl->tpl_vars['user']->value['login'];
        }
        ?>
" />
                        </label>
                        <label>
                            <span>Новый пароль</span>
                            <input type="password" name="password1" value="<?php 
        echo $_POST['password1'];
        ?>
" />
                        </label>
                        <label>
                            <span>Повторите пароль</span>
                            <input type="password" name="password2" value="<?php 
        echo $_POST['password2'];
        ?>
" />
                        </label>
                        <div class="sex-selection">
                            <input type="radio" name="male" value="0" <?php 
        if ($_smarty_tpl->tpl_vars['selected_male']->value == 0) {
            ?>
Checked="True"<?php 
        }
        ?>
 ><span> Я женщина </span>
                            <input type="radio" name="male" value="1" <?php 
        if ($_smarty_tpl->tpl_vars['selected_male']->value == 1) {
            ?>
Checked="True"<?php 
        }
        ?>
><span> Я мужчина</span>
                        </div>
                        <div class="pink-bg">
                            <small><font>Внимание! </font>Следующие данные ни при каких обстоятельствах не будут показаны в вашем профиле.</small>
                            <label>
                                <span>Я родился:</span>
                            </label>
                            <?php 
        echo smarty_function_html_select_date(array('prefix' => '', 'time' => $_smarty_tpl->tpl_vars['selected_time']->value, 'display_years' => false, 'display_months' => false), $_smarty_tpl);
        ?>

                
                            <?php 
        echo smarty_function_html_options(array('name' => 'Month', 'options' => $_smarty_tpl->tpl_vars['months_options']->value, 'selected' => $_smarty_tpl->tpl_vars['month_id']->value), $_smarty_tpl);
        ?>

                
                            <?php 
        echo smarty_function_html_select_date(array('prefix' => '', 'time' => $_smarty_tpl->tpl_vars['selected_time']->value, 'start_year' => "-50", 'end_year' => "-18", 'display_days' => false, 'display_months' => false, 'reverse_years' => true), $_smarty_tpl);
        ?>

 
                            <label>
                                <span>Мой телефон</span>
                                <input type="text" name="phone" value="<?php 
        if (isset($_POST['phone'])) {
            echo $_POST['phone'];
        } else {
            echo $_smarty_tpl->tpl_vars['user']->value['phone'];
        }
        ?>
" />
                            </label>
                            <label>
                                <span>Моя электронная почта</span>
                                <input type="text" name="mail" value="<?php 
        if (isset($_POST['mail'])) {
            echo $_POST['mail'];
        } else {
            echo $_smarty_tpl->tpl_vars['user']->value['mail'];
        }
        ?>
" />
                            </label>
                            <label>
                                <span>Я живу в городе</span>
                                     <?php 
        echo smarty_function_html_options(array('name' => 'city', 'options' => $_smarty_tpl->tpl_vars['city_options']->value, 'selected' => $_smarty_tpl->tpl_vars['city_id']->value), $_smarty_tpl);
        ?>

                            </label>
                            <label>
                                <span>Мой адрес</span>
                                <input type="text" name="address" value="<?php 
        if (isset($_POST['address'])) {
            echo $_POST['address'];
        } else {
            echo $_smarty_tpl->tpl_vars['user']->value['address'];
        }
        ?>
" />
                            </label>
                        </div>           
                        <div class="registration-info">
                        Вы можете обновить инфомрацию о себе нажав Сохранить
                        </div>
                        <div class="edit-buttons">
                            <a href="#" class="save yellow-button">Сохранить</a>
                        </div>
                       
                    </div>
				</form>
				</div>
			</section>          
			<!-- end content -->
		</div>
		<!-- end middle -->	
	</div>
	<!-- end mainarea --> 
    <?php 
        echo $_smarty_tpl->getSubTemplate('register-modal.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);
        ?>

<?php 
        echo $_smarty_tpl->getSubTemplate('footer.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);
    }
}
?>
<p>

testing strip tags<table border=0><tr><td><A HREF="<?php 
echo $_smarty_tpl->getVariable('SCRIPT_NAME')->value;
?>
"><font color="red">This is a  test     </font></A></td></tr></table>

</PRE>

This is an example of the html_select_date function:

<form>
<?php 
echo smarty_function_html_select_date(array('start_year' => 1998, 'end_year' => 2010), $_smarty_tpl->smarty, $_smarty_tpl);
?>
</form>

This is an example of the html_select_time function:

<form>
<?php 
echo smarty_function_html_select_time(array('use_24_hours' => false), $_smarty_tpl->smarty, $_smarty_tpl);
?>
</form>

This is an example of the html_options function:

<form>
<select name=states>
    if ($this->_tpl_vars['current_role'] > $this->_tpl_vars['roles']['customer']) {
        ?>
              <tr>
                <td colspan="2" class="default"><b>Record Phone Call:</b></td>
              </tr>
              <tr>
                <td bgcolor="<?php 
        echo $this->_tpl_vars['internal_color'];
        ?>
" class="default_white" width="190" nowrap><b>Date of Call:</b></td>
                <td bgcolor="<?php 
        echo $this->_tpl_vars['light_color'];
        ?>
" width="100%">
                  <?php 
        echo smarty_function_html_select_date(array('start_year' => '-1', 'day_value_format' => '%02d', 'field_array' => 'date', 'prefix' => '', 'all_extra' => ' class="default"'), $this);
        ?>
&nbsp;
                  <?php 
        echo smarty_function_html_select_time(array('minute_interval' => 5, 'field_array' => 'date', 'prefix' => '', 'all_extra' => ' class="default"', 'display_seconds' => false), $this);
        ?>

                  <a href="javascript:void(null);" onClick="javascript:updateTimeFields('add_phone_form', 'date[Year]', 'date[Month]', 'date[Day]', 'date[Hour]', 'date[Minute]');"><img src="images/icons/refresh.gif" border="0"></a>
                </td>
              </tr>
              <tr>
                <td bgcolor="<?php 
        echo $this->_tpl_vars['internal_color'];
        ?>
" class="default_white" width="190" nowrap><b>Reason:</b></td>
                <td bgcolor="<?php 
onchange="document.getElementById('issue').openAccessDateMonth.disabled=this.checked?false:true;document.getElementById('issue').openAccessDateDay.disabled=this.checked?false:true;document.getElementById('issue').openAccessDateYear.disabled=this.checked?false:true;" />&nbsp;<?php 
    echo $this->_plugins['function']['fieldLabel'][0][0]->smartyFieldLabel(array('name' => 'enableOpenAccessDate', 'key' => "editor.issues.enableOpenAccessDate"), $this);
    ?>
<br/>
			<?php 
    if ($this->_tpl_vars['openAccessDate']) {
        ?>
				<?php 
        echo smarty_function_html_select_date(array('prefix' => 'openAccessDate', 'time' => $this->_tpl_vars['openAccessDate'], 'end_year' => "+20", 'all_extra' => "class=\"selectMenu\""), $this);
        ?>

			<?php 
    } else {
        ?>
				<?php 
        echo smarty_function_html_select_date(array('prefix' => 'openAccessDate', 'time' => $this->_tpl_vars['openAccessDate'], 'end_year' => "+20", 'all_extra' => "class=\"selectMenu\" disabled=\"disabled\""), $this);
        ?>

			<?php 
    }
    ?>
		</td>
	</tr>
</table>
</div>
<?php 
}
?>

<div class="separator"></div>
<?php 
$_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => $this->_tpl_vars['_TEMPLATE_SOURCE_DIR'] . "/modules/validate_error.tpl", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
?>
<div>
<form action="<?php 
echo $this->_tpl_vars['action_link'];
?>
" method="post" name="frmNews" >
 	<label><?php 
echo $this->_tpl_vars['LABEL_NEWS_DATE'];
?>
*</label> <?php 
echo smarty_function_html_select_date(array('prefix' => 'news', 'end_year' => "+6", 'time' => $this->_tpl_vars['news_date']), $this);
?>
<br /><br />
	 <label><?php 
echo $this->_tpl_vars['LABEL_NEWS_TITLE'];
?>
*</label><input name="news_title" type="text" id="news_title" value="<?php 
echo $this->_tpl_vars['news_title'];
?>
" size="50"><br />
	 <label><?php 
echo $this->_tpl_vars['LABEL_NEWS_DESCRIPTION'];
?>
*</label><br /><br /><textarea name="news_description" cols="50" rows="20" id="news_description"  class="tinymce" ><?php 
echo $this->_tpl_vars['news_description'];
?>
    function content_4f8d361e373ac0_51310984($_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_capitalize')) {
            include 'C:\\wamp\\www\\mhealth\\lib\\smarty\\libs\\plugins\\modifier.capitalize.php';
        }
        if (!is_callable('smarty_modifier_date_format')) {
            include 'C:\\wamp\\www\\mhealth\\lib\\smarty\\libs\\plugins\\modifier.date_format.php';
        }
        if (!is_callable('smarty_function_html_select_date')) {
            include 'C:\\wamp\\www\\mhealth\\lib\\smarty\\libs\\plugins\\function.html_select_date.php';
        }
        if (!is_callable('smarty_function_html_select_time')) {
            include 'C:\\wamp\\www\\mhealth\\lib\\smarty\\libs\\plugins\\function.html_select_time.php';
        }
        if (!is_callable('smarty_function_html_options')) {
            include 'C:\\wamp\\www\\mhealth\\lib\\smarty\\libs\\plugins\\function.html_options.php';
        }
        $_config = new Smarty_Internal_Config("test.conf", $_smarty_tpl->smarty, $_smarty_tpl);
        $_config->loadConfigVars("setup", 'local');
        echo $_smarty_tpl->getSubTemplate("header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, null, array('title' => 'foo'), 0);
        ?>


<PRE>


<?php 
        if ($_smarty_tpl->getConfigVariable('bold')) {
            ?>
<b><?php 
        }
        ?>

Title: <?php 
        echo smarty_modifier_capitalize($_smarty_tpl->getConfigVariable('title'));
        ?>

<?php 
        if ($_smarty_tpl->getConfigVariable('bold')) {
            ?>
</b><?php 
        }
        ?>

The current date and time is <?php 
        echo smarty_modifier_date_format(time(), "%Y-%m-%d %H:%M:%S");
        ?>


The value of global assigned variable $SCRIPT_NAME is <?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>


Example of accessing server environment variable SERVER_NAME: <?php 
        echo $_SERVER['SERVER_NAME'];
        ?>


The value of {$Name} is <b><?php 
        echo '/*%%SmartyNocache:169334f8d361e0ed897-29351448%%*/<?php echo $_smarty_tpl->tpl_vars[\'Name\']->value;?>
/*/%%SmartyNocache:169334f8d361e0ed897-29351448%%*/';
        ?>
</b>

variable modifier example of {$Name|upper}

<b><?php 
        echo '/*%%SmartyNocache:169334f8d361e0ed897-29351448%%*/<?php echo mb_strtoupper($_smarty_tpl->tpl_vars[\'Name\']->value, \'UTF-8\');?>
/*/%%SmartyNocache:169334f8d361e0ed897-29351448%%*/';
        ?>
</b>


An example of a section loop:

<?php 
        if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer'])) {
            unset($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']);
        }
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['name'] = 'outer';
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'] = is_array($_loop = $_smarty_tpl->tpl_vars['FirstName']->value) ? count($_loop) : max(0, (int) $_loop);
        unset($_loop);
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = true;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] = 1;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'] - 1;
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']) {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['loop'];
            if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] == 0) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show'] = false;
            }
        } else {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'] = 0;
        }
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['show']) {
            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration']++) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['outer']['total'];
                if (1 & $_smarty_tpl->getVariable('smarty')->value['section']['outer']['index'] / 2) {
                    ?>
	<?php 
                    echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];
                    ?>
 . <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>

<?php 
                } else {
                    ?>
	<?php 
                    echo $_smarty_tpl->getVariable('smarty')->value['section']['outer']['rownum'];
                    ?>
 * <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[$_smarty_tpl->getVariable('smarty')->value['section']['outer']['index']];
                    ?>

<?php 
                }
            }
        } else {
            ?>
	none
<?php 
        }
        ?>

An example of section looped key values:

<?php 
        if (isset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1'])) {
            unset($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']);
        }
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['name'] = 'sec1';
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] = is_array($_loop = $_smarty_tpl->tpl_vars['contacts']->value) ? count($_loop) : max(0, (int) $_loop);
        unset($_loop);
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = true;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] = 1;
        $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'] - 1;
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['loop'];
            if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] == 0) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show'] = false;
            }
        } else {
            $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'] = 0;
        }
        if ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['show']) {
            for ($_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] = 1; $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total']; $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration']++) {
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['step'];
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['first'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == 1;
                $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['last'] = $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']['sec1']['total'];
                ?>
	phone: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['phone'];
                ?>
<br>
	fax: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['fax'];
                ?>
<br>
	cell: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec1']['index']]['cell'];
                ?>
<br>
<?php 
            }
        }
        ?>
<p>

testing strip tags
<table border=0><tr><td><A HREF="<?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>
"><font color="red">This is a  test     </font></A></td></tr></table>

</PRE>

This is an example of the html_select_date function:

<form>
<?php 
        echo smarty_function_html_select_date(array('start_year' => 1998, 'end_year' => 2010), $_smarty_tpl);
        ?>

</form>

This is an example of the html_select_time function:

<form>
<?php 
        echo smarty_function_html_select_time(array('use_24_hours' => false), $_smarty_tpl);
        ?>

</form>

This is an example of the html_options function:

<form>
<select name=states>
<?php 
        echo smarty_function_html_options(array('values' => $_smarty_tpl->tpl_vars['option_values']->value, 'selected' => $_smarty_tpl->tpl_vars['option_selected']->value, 'output' => $_smarty_tpl->tpl_vars['option_output']->value), $_smarty_tpl);
        ?>

</select>
</form>

<?php 
        echo $_smarty_tpl->getSubTemplate("footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, null, array(), 0);
        ?>

<?php 
    }
    function content_56de559f8adb60_70084273(Smarty_Internal_Template $_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_capitalize')) {
            require_once '/var/www/thevault/libs/plugins/modifier.capitalize.php';
        }
        if (!is_callable('smarty_modifier_date_format')) {
            require_once '/var/www/thevault/libs/plugins/modifier.date_format.php';
        }
        if (!is_callable('smarty_function_html_select_date')) {
            require_once '/var/www/thevault/libs/plugins/function.html_select_date.php';
        }
        if (!is_callable('smarty_function_html_select_time')) {
            require_once '/var/www/thevault/libs/plugins/function.html_select_time.php';
        }
        if (!is_callable('smarty_function_html_options')) {
            require_once '/var/www/thevault/libs/plugins/function.html_options.php';
        }
        $_smarty_tpl->compiled->nocache_hash = '100837203956de559f8747c3_31118991';
        $_smarty_tpl->smarty->ext->configLoad->_loadConfigFile($_smarty_tpl, "test.conf", "setup", 0);
        ?>

<?php 
        $_smarty_tpl->_subTemplateRender("file:header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, $_smarty_tpl->cache_lifetime, array('title' => 'foo'), 0, false);
        ?>


<PRE>


    <?php 
        if ($_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, 'bold')) {
            ?>
<b><?php 
        }
        ?>
        
        Title: <?php 
        echo smarty_modifier_capitalize($_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, 'title'));
        ?>

        <?php 
        if ($_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, 'bold')) {
            ?>
</b><?php 
        }
        ?>

    The current date and time is <?php 
        echo smarty_modifier_date_format(time(), "%Y-%m-%d %H:%M:%S");
        ?>


    The value of global assigned variable $SCRIPT_NAME is <?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>


    Example of accessing server environment variable SERVER_NAME: <?php 
        echo $_SERVER['SERVER_NAME'];
        ?>


    The value of {$Name} is <b><?php 
        echo '/*%%SmartyNocache:100837203956de559f8747c3_31118991%%*/<?php echo $_smarty_tpl->tpl_vars[\'Name\']->value;?>
/*/%%SmartyNocache:100837203956de559f8747c3_31118991%%*/';
        ?>
</b>

variable modifier example of {$Name|upper}

<b><?php 
        echo '/*%%SmartyNocache:100837203956de559f8747c3_31118991%%*/<?php echo mb_strtoupper($_smarty_tpl->tpl_vars[\'Name\']->value, \'UTF-8\');?>
/*/%%SmartyNocache:100837203956de559f8747c3_31118991%%*/';
        ?>
</b>


An example of a section loop:

    <?php 
        $__section_outer_0_saved = isset($_smarty_tpl->tpl_vars['__smarty_section_outer']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer'] : false;
        $__section_outer_0_loop = is_array(@($_loop = $_smarty_tpl->tpl_vars['FirstName']->value)) ? count($_loop) : max(0, (int) $_loop);
        $__section_outer_0_total = $__section_outer_0_loop;
        $_smarty_tpl->tpl_vars['__smarty_section_outer'] = new Smarty_Variable(array());
        if ($__section_outer_0_total != 0) {
            for ($__section_outer_0_iteration = 1, $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index'] = 0; $__section_outer_0_iteration <= $__section_outer_0_total; $__section_outer_0_iteration++, $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index']++) {
                $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['rownum'] = $__section_outer_0_iteration;
                ?>
        <?php 
                if (1 & (isset($_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index'] : null) / 2) {
                    ?>
            <?php 
                    echo isset($_smarty_tpl->tpl_vars['__smarty_section_outer']->value['rownum']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['rownum'] : null;
                    ?>
 . <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[isset($_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index'] : null];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[isset($_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index'] : null];
                    ?>

        <?php 
                } else {
                    ?>
            <?php 
                    echo isset($_smarty_tpl->tpl_vars['__smarty_section_outer']->value['rownum']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['rownum'] : null;
                    ?>
 * <?php 
                    echo $_smarty_tpl->tpl_vars['FirstName']->value[isset($_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index'] : null];
                    ?>
 <?php 
                    echo $_smarty_tpl->tpl_vars['LastName']->value[isset($_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_outer']->value['index'] : null];
                    ?>

        <?php 
                }
                ?>
        <?php 
            }
        } else {
            ?>
        none
    <?php 
        }
        if ($__section_outer_0_saved) {
            $_smarty_tpl->tpl_vars['__smarty_section_outer'] = $__section_outer_0_saved;
        }
        ?>

    An example of section looped key values:

    <?php 
        $__section_sec1_1_saved = isset($_smarty_tpl->tpl_vars['__smarty_section_sec1']) ? $_smarty_tpl->tpl_vars['__smarty_section_sec1'] : false;
        $__section_sec1_1_loop = is_array(@($_loop = $_smarty_tpl->tpl_vars['contacts']->value)) ? count($_loop) : max(0, (int) $_loop);
        $__section_sec1_1_total = $__section_sec1_1_loop;
        $_smarty_tpl->tpl_vars['__smarty_section_sec1'] = new Smarty_Variable(array());
        if ($__section_sec1_1_total != 0) {
            for ($__section_sec1_1_iteration = 1, $_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index'] = 0; $__section_sec1_1_iteration <= $__section_sec1_1_total; $__section_sec1_1_iteration++, $_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index']++) {
                ?>
        phone: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[isset($_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index'] : null]['phone'];
                ?>

        <br>

            fax: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[isset($_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index'] : null]['fax'];
                ?>

        <br>

            cell: <?php 
                echo $_smarty_tpl->tpl_vars['contacts']->value[isset($_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index']) ? $_smarty_tpl->tpl_vars['__smarty_section_sec1']->value['index'] : null]['cell'];
                ?>

        <br>
    <?php 
            }
        }
        if ($__section_sec1_1_saved) {
            $_smarty_tpl->tpl_vars['__smarty_section_sec1'] = $__section_sec1_1_saved;
        }
        ?>
    <p>

        testing strip tags
        <table border=0> <tr> <td> <A HREF="<?php 
        echo $_smarty_tpl->tpl_vars['SCRIPT_NAME']->value;
        ?>
"> <font color="red">This is a test </font> </A> </td> </tr> </table>

</PRE>

This is an example of the html_select_date function:

<form>
    <?php 
        echo smarty_function_html_select_date(array('start_year' => 1998, 'end_year' => 2010), $_smarty_tpl);
        ?>

</form>

This is an example of the html_select_time function:

<form>
    <?php 
        echo smarty_function_html_select_time(array('use_24_hours' => false), $_smarty_tpl);
        ?>

</form>

This is an example of the html_options function:

<form>
    <select name=states>
        <?php 
        echo smarty_function_html_options(array('values' => $_smarty_tpl->tpl_vars['option_values']->value, 'selected' => $_smarty_tpl->tpl_vars['option_selected']->value, 'output' => $_smarty_tpl->tpl_vars['option_output']->value), $_smarty_tpl);
        ?>

    </select>
</form>

<?php 
        $_smarty_tpl->_subTemplateRender("file:footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 9999, $_smarty_tpl->cache_lifetime, array(), 0, false);
        ?>

<?php 
    }