Example #1
0
 /**
  * Method to render text
  *
  * @access public
  * @param string $text the text to render
  * @return rendered text
  *
  */
 function textEncode($text)
 {
     // attempt to translate HTML entities in the source.
     // get the config options.
     $type = $this->getConf('translate', HTML_ENTITIES);
     $quotes = $this->getConf('quotes', ENT_COMPAT);
     $charset = $this->getConf('charset', 'ISO-8859-1');
     // have to check null and false because HTML_ENTITIES is a zero
     if ($type === HTML_ENTITIES) {
         // keep a copy of the translated version of the delimiter
         // so we can convert it back.
         $new_delim = htmlentities($this->wiki->delim, $quotes, $charset);
         // convert the entities.  we silence the call here so that
         // errors about charsets don't pop up, per counsel from
         // Jan at Horde.  (http://pear.php.net/bugs/bug.php?id=4474)
         $text = @htmlentities($text, $quotes, $charset);
         // re-convert the delimiter
         $text = str_replace($new_delim, $this->wiki->delim, $text);
     } elseif ($type === HTML_SPECIALCHARS) {
         // keep a copy of the translated version of the delimiter
         // so we can convert it back.
         $new_delim = df_escape($this->wiki->delim, $quotes, $charset);
         // convert the entities.  we silence the call here so that
         // errors about charsets don't pop up, per counsel from
         // Jan at Horde.  (http://pear.php.net/bugs/bug.php?id=4474)
         $text = @df_escape($text, $quotes, $charset);
         // re-convert the delimiter
         $text = str_replace($new_delim, $this->wiki->delim, $text);
     }
     return $text;
 }
/**
 * escape_special_chars common function
 *
 * Function: smarty_function_escape_special_chars<br>
 * Purpose:  used by other smarty functions to escape
 *           special chars except for already escaped ones
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param string
 * @return string
 */
function smarty_function_escape_special_chars($string)
{
    if (!is_array($string)) {
        $string = preg_replace('!&(#?\\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
        $string = df_escape($string);
        $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
    }
    return $string;
}
Example #3
0
/**
 * Smarty escape modifier plugin
 *
 * Type:     modifier<br>
 * Name:     escape<br>
 * Purpose:  Escape the string according to escapement type
 * @link http://smarty.php.net/manual/en/language.modifier.escape.php
 *          escape (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param string
 * @param html|htmlall|url|quotes|hex|hexentity|javascript
 * @return string
 */
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1')
{
    switch ($esc_type) {
        case 'html':
            return df_escape($string, ENT_QUOTES, $char_set);
        case 'htmlall':
            return htmlentities($string, ENT_QUOTES, $char_set);
        case 'url':
            return rawurlencode($string);
        case 'urlpathinfo':
            return str_replace('%2F', '/', rawurlencode($string));
        case 'quotes':
            // escape unescaped single quotes
            return preg_replace("%(?<!\\\\)'%", "\\'", $string);
        case 'hex':
            // escape every character into hex
            $return = '';
            for ($x = 0; $x < strlen($string); $x++) {
                $return .= '%' . bin2hex($string[$x]);
            }
            return $return;
        case 'hexentity':
            $return = '';
            for ($x = 0; $x < strlen($string); $x++) {
                $return .= '&#x' . bin2hex($string[$x]) . ';';
            }
            return $return;
        case 'decentity':
            $return = '';
            for ($x = 0; $x < strlen($string); $x++) {
                $return .= '&#' . ord($string[$x]) . ';';
            }
            return $return;
        case 'javascript':
            // escape quotes and backslashes, newlines, etc.
            return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\\/'));
        case 'mail':
            // safe way to display e-mail address on a web page
            return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
        case 'nonstd':
            // escape non-standard chars, such as ms document quotes
            $_res = '';
            for ($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
                $_ord = ord(substr($string, $_i, 1));
                // non-standard char, escape it
                if ($_ord >= 126) {
                    $_res .= '&#' . $_ord . ';';
                } else {
                    $_res .= substr($string, $_i, 1);
                }
            }
            return $_res;
        default:
            return $string;
    }
}
/**
 * Smarty debug_print_var modifier plugin
 *
 * Type:     modifier<br>
 * Name:     debug_print_var<br>
 * Purpose:  formats variable contents for display in the console
 * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
 *          debug_print_var (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com>
 * @param array|object
 * @param integer
 * @param integer
 * @return string
 */
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
    $_replace = array("\n" => '<i>\\n</i>', "\r" => '<i>\\r</i>', "\t" => '<i>\\t</i>');
    switch (gettype($var)) {
        case 'array':
            $results = '<b>Array (' . count($var) . ')</b>';
            foreach ($var as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
                $depth--;
            }
            break;
        case 'object':
            $object_vars = get_object_vars($var);
            $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
            foreach ($object_vars as $curr_key => $curr_val) {
                $results .= '<br>' . str_repeat('&nbsp;', $depth * 2) . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = ' . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
                $depth--;
            }
            break;
        case 'boolean':
        case 'NULL':
        case 'resource':
            if (true === $var) {
                $results = 'true';
            } elseif (false === $var) {
                $results = 'false';
            } elseif (null === $var) {
                $results = 'null';
            } else {
                $results = df_escape((string) $var);
            }
            $results = '<i>' . $results . '</i>';
            break;
        case 'integer':
        case 'float':
            $results = df_escape((string) $var);
            break;
        case 'string':
            $results = strtr($var, $_replace);
            if (strlen($var) > $length) {
                $results = substr($var, 0, $length - 3) . '...';
            }
            $results = df_escape('"' . $results . '"');
            break;
        case 'unknown type':
        default:
            $results = strtr((string) $var, $_replace);
            if (strlen($results) > $length) {
                $results = substr($results, 0, $length - 3) . '...';
            }
            $results = df_escape($results);
    }
    return $results;
}
Example #5
0
    function oneLineDescription(&$record)
    {
        $del =& $record->_table->getDelegate();
        $origRecord = $this->origRecords[$record->getId()];
        if (!$origRecord) {
            $origRecord = $record;
        }
        if (is_a($origRecord, 'Dataface_RelatedRecord')) {
            $origDel = $origRecord->_record->table()->getDelegate();
            $method = 'rel_' . $origRecord->_relationshipName . '__' . oneLineDescription;
            if (isset($origDel) and method_exists($origDel, $method)) {
                return $del->{$method}($origRecord);
            }
        }
        if (isset($del) and method_exists($del, 'oneLineDescription')) {
            return $del->oneLineDescription($record);
        }
        $app =& Dataface_Application::getInstance();
        $adel =& $app->getDelegate();
        if (isset($adel) and method_exists($adel, 'oneLineDescription')) {
            return $adel->oneLineDescription($record);
        }
        $out = '<span class="Dataface_GlanceList-oneLineDescription">
			<span class="Dataface_GlanceList-oneLineDescription-title"><a href="' . df_escape($record->getURL('-action=view')) . '" title="View this record">' . df_escape($origRecord->getTitle()) . '</a></span> ';
        if ($creator = $record->getCreator()) {
            $show = true;
            if (isset($app->prefs['hide_posted_by']) and $app->prefs['hide_posted_by']) {
                $show = false;
            }
            if (isset($record->_table->_atts['__prefs__']['hide_posted_by']) and $record->_table->_atts['__prefs__']['hide_posted_by']) {
                $show = false;
            }
            if ($show) {
                $out .= '<span class="Dataface_GlanceList-oneLineDescription-posted-by">Posted by ' . df_escape($creator) . '.</span> ';
            }
        }
        if ($modified = $record->getLastModified()) {
            $show = true;
            if (isset($app->prefs['hide_updated']) and $app->prefs['hide_updated']) {
                $show = false;
            }
            if (isset($record->_table->_atts['__prefs__']['hide_updated']) and $record->_table->_atts['__prefs__']['hide_updated']) {
                $show = false;
            }
            if ($show) {
                $out .= '<span class="Dataface_GlanceList-oneLineDescription-updated">Updated ' . df_escape(df_offset(date('Y-m-d H:i:s', $modified))) . '</span>';
            }
        }
        $out .= '
			</span>';
        return $out;
    }
Example #6
0
function ConvertToXmlAttribute($value)
{
    if (defined('PHP_OS')) {
        $os = PHP_OS;
    } else {
        $os = php_uname();
    }
    if (strtoupper(substr($os, 0, 3)) === 'WIN') {
        return utf8_encode(df_escape($value));
    } else {
        return df_escape($value);
    }
}
Example #7
0
 /**
  * 
  * Generates a replacement for the matched text.  Token options are:
  * 
  * 'type' => ['start'|'end'] The starting or ending point of the
  * heading text.  The text itself is left in the source.
  * 
  * @access public
  *
  * @param array &$matches The array of matches from parse().
  *
  * @return string A pair of delimited tokens to be used as a
  * placeholder in the source text surrounding the heading text.
  *
  */
 function process(&$matches)
 {
     // keep a running count for header IDs.  we use this later
     // when constructing TOC entries, etc.
     static $id;
     if (!isset($id)) {
         $id = 0;
     }
     $prefix = df_escape($this->getConf('id_prefix'));
     $start = $this->wiki->addToken($this->rule, array('type' => 'start', 'level' => strlen($matches[1]), 'text' => $matches[2], 'id' => $prefix . $id++));
     $end = $this->wiki->addToken($this->rule, array('type' => 'end', 'level' => strlen($matches[1])));
     return $start . $matches[2] . $end . "\n";
 }
Example #8
0
    function showSummary(&$record)
    {
        $del =& $record->_table->getDelegate();
        if (isset($del) and method_exists($del, 'showSummary')) {
            return $del->showSummary($record);
        }
        $app =& Dataface_Application::getInstance();
        $adel =& $app->getDelegate();
        if (isset($adel) and method_exists($adel, 'showSummary')) {
            return $adel->showSummary($record);
        }
        // No custom summary defined.  We build our own.
        // See if there is an image of sorts.
        $logoField = $this->getLogoField($record);
        $out = '<div class="Dataface_SummaryList-record-summary">';
        if ($logoField) {
            if (isset($app->prefs['SummaryList_logo_width'])) {
                $width = $apps->prefs['SummaryList_logo_width'];
            } else {
                $width = '60';
            }
            $out .= '<div class="Dataface_SummaryList-record-logo"><a href="' . $record->getURL('-action=view') . '" title="Record details">
				<img src="' . $record->display($logoField) . '" width="' . df_escape($width) . '"/>
				</a>
				</div>';
        }
        $out .= '<table class="record-view-table">
					<tbody>';
        foreach ($this->getSummaryColumns($record) as $fieldname) {
            $field =& $record->_table->getField($fieldname);
            $out .= '
				<tr><th class="record-view-label">' . df_escape($field['widget']['label']) . '</th><td class="record-view-value">' . $record->htmlValue($fieldname) . '</td></tr>
			';
        }
        $out .= '		</tbody></table>';
        //$out .= '<h5 class="Dataface_SummaryList-record-title"><a href="'.$record->getURL('-action=view').'">'.df_escape($record->callDelegateFunction('summaryTitle',$record->getTitle())).'</a></h5>';
        //$out .= '<div class="Dataface_SummaryList-record-description">'.$record->callDelegateFunction('summaryDescription',$record->getDescription()).'</div>';
        //$out .= ( $record->getLastModified() + $record->getCreated() > 0 ? '<div class="Dataface_SummaryLIst-record-status">'.
        //	( $record->getLastModified() > 0 ? '<span class="Dataface_SummaryList-record-last-modified">
        //	'.df_translate('scripts.GLOBAL.LABEL_LAST_MODIFIED', 'Last updated '.df_offset(date('Y-m-d H:i:s',intval($record->getLastModified()))), array('last_mod'=>df_offset(date('Y-m-d H:i:s',intval($record->getLastModified()))))).'
        //	</span>' : '').
        //	( $record->getCreated() > 0 ?
        //		'<span class="Dataface_SummaryList-record-created">'.df_translate('scripts.GLOBAL.LABEL_DATE_CREATED','Created '.df_offset(date('Y-m-d H:i:s',intval($record->getCreated()))), array('created'=>df_offset(date('Y-m-d H:i:s',intval($record->getCreated()))))).'</span>':''
        //	).'
        //	</div>': '').'
        $out .= '	</div>';
        return $out;
    }
 public function Dataface_Record__htmlValue($event)
 {
     $fieldname = $event->fieldname;
     $record = $event->record;
     $field =& $record->table()->getField($fieldname);
     if ($field['widget']['type'] === 'geopicker') {
         $this->registerPaths();
         Dataface_JavascriptTool::getInstance()->import('xataface/modules/geopicker/widgets/geopicker.js');
         $val = $record->val($fieldname);
         if (!trim($val)) {
             $event->out = '';
         } else {
             $event->out = '<input type="hidden" value="' . df_escape($val) . '" class="xf-geopicker" data-geopicker-read-only="1"/>';
             //out geopicker data in a hidden file (js code will substitute the textbox with the map)
         }
     }
 }
 function handle($params)
 {
     $js = Dataface_JavascriptTool::getInstance();
     $js->import('xatacard/layout/tests/RecordSetTest.js');
     $js->setMinify(false);
     $js->setUseCache(false);
     df_register_skin('xatajax', XATAJAX_PATH . DIRECTORY_SEPARATOR . 'templates');
     try {
         df_display(array(), 'tests/xatacard/layout/RecordSet/RecordSetTest.html');
     } catch (Exception $ex) {
         //echo "here";exit;
         while ($ex) {
             echo '<h3>' . $ex->getMessage() . '</h3>';
             echo nl2br(df_escape($ex->getTraceAsString()));
             $ex = $ex->getPrevious();
         }
     }
 }
Example #11
0
 function CreateHtml()
 {
     $HtmlValue = df_escape($this->Value);
     $Html = '<div>';
     if (!isset($_GET)) {
         global $HTTP_GET_VARS;
         $_GET = $HTTP_GET_VARS;
     }
     if ($this->IsCompatible()) {
         if (isset($_GET['fcksource']) && $_GET['fcksource'] == "true") {
             $File = 'fckeditor.original.html';
         } else {
             $File = 'fckeditor.html';
         }
         $Link = "{$this->BasePath}editor/{$File}?InstanceName={$this->InstanceName}";
         if ($this->ToolbarSet != '') {
             $Link .= "&amp;Toolbar={$this->ToolbarSet}";
         }
         // Render the linked hidden field.
         $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}\" name=\"{$this->InstanceName}\" value=\"{$HtmlValue}\" style=\"display:none\" />";
         // Render the configurations hidden field.
         $Html .= "<input type=\"hidden\" id=\"{$this->InstanceName}___Config\" value=\"" . $this->GetConfigFieldString() . "\" style=\"display:none\" />";
         // Render the editor IFRAME.
         $Html .= "<iframe id=\"{$this->InstanceName}___Frame\" src=\"{$Link}\" width=\"{$this->Width}\" height=\"{$this->Height}\" frameborder=\"0\" scrolling=\"no\"></iframe>";
     } else {
         if (strpos($this->Width, '%') === false) {
             $WidthCSS = $this->Width . 'px';
         } else {
             $WidthCSS = $this->Width;
         }
         if (strpos($this->Height, '%') === false) {
             $HeightCSS = $this->Height . 'px';
         } else {
             $HeightCSS = $this->Height;
         }
         $Html .= "<textarea name=\"{$this->InstanceName}\" rows=\"4\" cols=\"40\" style=\"width: {$WidthCSS}; height: {$HeightCSS}\">{$HtmlValue}</textarea>";
     }
     $Html .= '</div>';
     return $Html;
 }
Example #12
0
 /**
  * Returns the string representation of a multiple variable
  *
  * @return string The string representation of a multiple variable.
  * @access private
  */
 function _toString_Array()
 {
     $txt = '';
     $stack = array(0);
     $counter = count($this->family);
     for ($c = 0; $c < $counter; $c++) {
         switch ($this->family[$c]) {
             case VAR_DUMP_START_GROUP:
                 array_push($stack, 0);
                 if ($this->depth[$c] > 0) {
                     $txt .= $this->options['start_td_colspan'];
                 }
                 $txt .= $this->options['start_table'];
                 if ($this->options['show_caption']) {
                     $txt .= $this->options['start_caption'] . df_escape($this->value[$c]) . $this->options['end_caption'];
                 }
                 break;
             case VAR_DUMP_FINISH_GROUP:
                 array_pop($stack);
                 $txt .= $this->options['end_table'];
                 if ($this->depth[$c] > 0) {
                     $txt .= $this->options['end_td_colspan'] . $this->options['end_tr'];
                 }
                 break;
             case VAR_DUMP_START_ELEMENT_NUM:
             case VAR_DUMP_START_ELEMENT_STR:
                 array_push($stack, 1 - array_pop($stack));
                 $tr = end($stack) == 1 ? 'start_tr' : 'start_tr_alt';
                 $comp = $this->family[$c] == VAR_DUMP_START_ELEMENT_NUM ? 'num' : 'str';
                 $txt .= $this->options[$tr] . $this->options['start_td_key'] . $this->options['before_' . $comp . '_key'] . df_escape($this->value[$c]) . $this->options['after_' . $comp . '_key'] . $this->options['end_td_key'];
                 break;
             case VAR_DUMP_FINISH_ELEMENT:
             case VAR_DUMP_FINISH_STRING:
                 $etr = end($stack) == 1 ? 'end_tr' : 'end_tr_alt';
                 if (!is_null($this->value[$c])) {
                     $string = df_escape($this->value[$c]);
                     if ($this->options['show_eol'] !== FALSE) {
                         $string = str_replace("\n", $this->options['show_eol'] . "\n", $string);
                     }
                     $txt .= $this->options['start_td_type'] . $this->options['before_type'] . df_escape($this->type[$c]) . $this->options['after_type'] . $this->options['end_td_type'] . $this->options['start_td_value'] . $this->options['before_value'] . nl2br($string) . $this->options['after_value'] . $this->options['end_td_value'] . $this->options[$etr];
                 } else {
                     $txt .= $this->options['start_td_colspan'] . $this->options['before_type'] . df_escape($this->type[$c]) . $this->options['after_type'] . $this->options['end_td_colspan'] . $this->options[$etr];
                 }
                 break;
         }
     }
     return $txt;
 }
Example #13
0
    function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
    {
        $table =& $record->_table;
        $widget =& $field['widget'];
        $factory = Dataface_FormTool::factory();
        $attributes = array('class' => $widget['class'], 'id' => $field['name']);
        if ($field['repeat']) {
            $attributes['multiple'] = true;
            $attributes['size'] = 5;
        }
        $options = $record->_table->getValuelist($field['vocabulary']);
        //Dataface_FormTool::getVocabulary($record, $field);
        if (!isset($options)) {
            $options = array();
        }
        $emptyOpt = array('' => df_translate('scripts.GLOBAL.FORMS.OPTION_PLEASE_SELECT', "Please Select..."));
        $opts = $emptyOpt;
        if ($record and $record->val($field['name'])) {
            if (!@$field['repeat'] and !isset($options[$record->strval($field['name'])])) {
                $opts[$record->strval($field['name'])] = $record->strval($field['name']);
            } else {
                if (@$field['repeat']) {
                    $vals = $record->val($field['name']);
                    if (is_array($vals)) {
                        foreach ($vals as $thisval) {
                            if (!isset($options[$thisval])) {
                                $opts[$thisval] = $thisval;
                            }
                        }
                    }
                }
            }
        }
        foreach ($options as $kopt => $opt) {
            $opts[$kopt] = $opt;
        }
        $el = $factory->addElement('select', $formFieldName, $widget['label'], $opts, $attributes);
        // Now to make it editable
        if (@$field['vocabulary']) {
            try {
                $rel =& Dataface_ValuelistTool::getInstance()->asRelationship($table, $field['vocabulary']);
                if ($rel and !PEAR::isError($rel)) {
                    if (!is_a($rel, 'Dataface_Relationship')) {
                        throw new Exception("The relationship object for the vocabulary " . $field['vocabulary'] . " could not be loaded.");
                    }
                    if (!$rel->getDomainTable()) {
                        throw new Exception("The relationship object for the vocabulary " . $field['vocabulary'] . " could not be loaded or the domain table could not be found");
                    }
                    $dtable = Dataface_Table::loadTable($rel->getDomainTable());
                    if ($dtable and !PEAR::isError($dtable)) {
                        $perms = $dtable->getPermissions();
                        if (@$perms['new']) {
                            $fields =& $rel->fields();
                            if (count($fields) > 1) {
                                $valfield = $fields[1];
                                $keyfield = $fields[0];
                            } else {
                                $valfield = $fields[0];
                                $keyfield = $fields[0];
                            }
                            if (strpos($valfield, '.') !== false) {
                                list($tmp, $valfield) = explode('.', $valfield);
                            }
                            if (strpos($keyfield, '.') !== false) {
                                list($tmp, $keyfield) = explode('.', $keyfield);
                            }
                            $jt = Dataface_JavascriptTool::getInstance();
                            $jt->import('RecordDialog/RecordDialog.js');
                            //$suffix =  '<script type="text/javascript" src="'.DATAFACE_URL.'/js/jquery-ui-1.7.2.custom.min.js"></script>';
                            //$suffix .= '<script type="text/javascript" src="'.DATAFACE_URL.'/js/RecordDialog/RecordDialog.js"></script>';
                            $suffix = '<a href="#" onclick="return false" id="' . df_escape($field['name']) . '-other">Other..</a>';
                            $suffix .= '<script>
							jQuery(document).ready(function($){
								$("#' . $field['name'] . '-other").each(function(){
									var tablename = "' . addslashes($dtable->tablename) . '";
									var valfld = ' . json_encode($valfield) . ';
									var keyfld = ' . json_encode($keyfield) . ';
									var fieldname = ' . json_encode($field['name']) . ';
									var btn = this;
									$(this).RecordDialog({
										table: tablename,
										callback: function(data){
											var key = data[keyfld];
											var val = data[valfld];
                                                                                        var $option = $(\'<option value="\'+key+\'">\'+val+\'</option>\');
                                                                                        
											$("#"+fieldname).append($option);
											$("#"+fieldname).val(key);
                                                                                        if ( !val || val === key ){
                                                                                            var q = {
                                                                                                "-action" : "field_vocab_value",
                                                                                                "-key" : key,
                                                                                                "-table" : ' . json_encode($field['tablename']) . ',
                                                                                                "-field" : ' . json_encode($field['name']) . '
                                                                                            };
                                                                                            $.get(DATAFACE_SITE_HREF, q, function(res){
                                                                                                if ( res && res.code === 200 ){
                                                                                                    $option.text(res.value);
                                                                                                }
                                                                                            });
                                                                                        }
											
										}
									});
								});
							});
							</script>
							';
                            $widget['suffix'] = $suffix;
                        }
                    }
                }
            } catch (Exception $ex) {
                error_log($ex->getMessage());
            }
        }
        //$el->setFieldDef($field);
        //return $el;
        return $el;
    }
Example #14
0
 /**
  * Returns the value of field without HTML tags (in this case, value is changed to a mask)
  * 
  * @since     1.0
  * @access    public
  * @return    string
  */
 function getFrozenHtml()
 {
     $value = df_escape($this->getValue());
     if ($this->getAttribute('wrap') == 'off') {
         $html = $this->_getTabs() . '<pre>' . $value . "</pre>\n";
     } else {
         $html = nl2br($value) . "\n";
     }
     return $html . $this->_getPersistantData();
 }
Example #15
0
 /**
  * Returns the value of field without HTML tags
  * 
  * @since     1.0
  * @access    public
  * @return    string
  */
 function getFrozenHtml()
 {
     $value = $this->getValue();
     return ('' != $value ? df_escape($value) : '&nbsp;') . $this->_getPersistantData();
 }
Example #16
0
 /**
  * @brief Returns an HTML-friendly value of a field.
  *
  * @param string $fieldname The name of the field to return.
  * @param int $index For related fields indicates the index within the related list of the record to retrieve.
  * @param string $where Optional where clause to filter related list when retrieving a related field.
  * @param string $sort Optional sort clause when retrieving a related field.  Used to sort related list before 
  *  selecting the related record from which the value is to be returned.
  * @param array $params Optional additional parameters to customize the HTML output.  This may be passed to 
  *		include HTML attributes width and height to blob fields containing an image.
  *
  * @return string The HTML string result.
  *
  * @since 0.5
  *
  * @section Synopsis
  * 
  * This method sits above "display" on the output stack for a field.
  * I.e. it wraps display() and adds some extra filtering to make the
  * output directly appropriate to be displayed as HTML.  In text fields
  * this will convert newlines to breaks, and in blob fields, this will output
  * either the full a-href tag or img tag depending on the type of content that
  * is stored.
  *
  * 
  * @see display()
  * @see getValue()
  * @see getValueAsString()
  * 
  */
 function htmlValue($fieldname, $index = 0, $where = 0, $sort = 0, $params = array())
 {
     $recid = $this->getId();
     $uri = $recid . '#' . $fieldname;
     $domid = $uri . '-' . rand();
     $delegate =& $this->_table->getDelegate();
     if (isset($delegate) && method_exists($delegate, $fieldname . '__htmlValue')) {
         $methodname = $fieldname . '__htmlValue';
         $res = $delegate->{$methodname}($this);
         //$res = call_user_func(array(&$delegate, $fieldname.'__htmlValue'), $this);
         if (is_string($res) and DATAFACE_USAGE_MODE == 'edit' and $this->checkPermission('edit', array('field' => $fieldname)) and !$this->_table->isMetaField($fieldname)) {
             $res = '<span id="' . df_escape($domid) . '" df:id="' . df_escape($uri) . '" class="df__editable">' . $res . '</span>';
         }
         return $res;
     }
     $event = new StdClass();
     $event->record = $this;
     $event->fieldname = $fieldname;
     $event->index = $index;
     $event->where = $where;
     $event->sort = $sort;
     $event->params = $params;
     $event->out = null;
     Dataface_Application::getInstance()->fireEvent('Dataface_Record__htmlValue', $event);
     if (isset($event->out)) {
         return $event->out;
     }
     $parent =& $this->getParentRecord();
     if (isset($parent) and $parent->_table->hasField($fieldname)) {
         return $parent->htmlValue($fieldname, $index, $where, $sort, $params);
     }
     $val = $this->display($fieldname, $index, $where, $sort);
     $strval = $this->strval($fieldname, $index, $where, $sort);
     $field = $this->_table->getField($fieldname);
     if (!@$field['passthru'] and $this->escapeOutput) {
         $val = nl2br(df_escape($val));
     }
     if ($this->secureDisplay and !Dataface_PermissionsTool::view($this, array('field' => $fieldname))) {
         $del =& $this->_table->getDelegate();
         if ($del and method_exists($del, 'no_access_link')) {
             $link = $del->no_access_link($this, array('field' => $fieldname));
             return '<a href="' . df_escape($link) . '">' . $val . '</a>';
         }
     }
     //if ( $field['widget']['type'] != 'htmlarea' ) $val = htmlentities($val,ENT_COMPAT, 'UTF-8');
     //if ( $this->_table->isText($fieldname) and $field['widget']['type'] != 'htmlarea' and $field['contenttype'] != 'text/html' ) $val = nl2br($val);
     if ($this->_table->isBlob($fieldname) or $this->_table->isContainer($fieldname)) {
         if ($this->getLength($fieldname, $index, $where, $sort) > 0) {
             if ($this->isImage($fieldname, $index, $where, $sort)) {
                 $val = '<img src="' . $val . '"';
                 if (!isset($parmas['alt'])) {
                     $params['alt'] = $strval;
                 }
                 if (!isset($params['width']) and isset($field['width'])) {
                     $params['width'] = $field['width'];
                 }
                 foreach ($params as $pkey => $pval) {
                     $val .= ' ' . df_escape($pkey) . '="' . df_escape($pval) . '"';
                 }
                 $val .= '/>';
             } else {
                 $file_icon = df_translate($this->getMimetype($fieldname, $index, $where, $sort) . ' file icon', df_absolute_url(DATAFACE_URL) . '/images/document_icon.gif');
                 $val = '<img src="' . df_escape($file_icon) . '"/><a href="' . $val . '" target="_blank"';
                 foreach ($params as $pkey => $pval) {
                     $val .= ' ' . df_escape($pkey) . '="' . df_escape($pval) . '"';
                 }
                 $val .= '>' . df_escape($strval) . ' (' . df_escape($this->getMimetype($fieldname, $index, $where, $sort)) . ')</a>';
             }
         } else {
             $val = "(Empty)";
         }
     }
     if (is_string($val) and DATAFACE_USAGE_MODE == 'edit' and $this->checkPermission('edit', array('field' => $fieldname)) and !$this->_table->isMetaField($fieldname)) {
         $val = '<span id="' . df_escape($domid) . '" df:id="' . df_escape($uri) . '" class="df__editable">' . $val . '</span>';
     }
     return $val;
 }
Example #17
0
 /**
  * Returns a HTML representation of the test result.
  *
  * @return string
  * @access public
  */
 function toHTML()
 {
     return '<pre>' . df_escape($this->toString()) . '</pre>';
 }
Example #18
0
function SendErrorNode($number, $text)
{
    echo '<Error number="' . $number . '" text="' . df_escape($text) . '" />';
}
Example #19
0
 /**
  * Returns an HTML formatted attribute string
  * @param    array   $attributes
  * @return   string
  * @access   private
  */
 function _getAttrString($attributes)
 {
     $strAttr = '';
     if (is_array($attributes)) {
         foreach ($attributes as $key => $value) {
             $strAttr .= ' ' . $key . '="' . df_escape($value) . '"';
         }
     }
     return $strAttr;
 }
Example #20
0
 function handle(&$params)
 {
     import('Dataface/FormTool.php');
     import('Dataface/QuickForm.php');
     $formTool =& Dataface_FormTool::getInstance();
     $app =& Dataface_Application::getInstance();
     $query =& $app->getQuery();
     $resultSet =& $app->getResultSet();
     $currentRecord =& $app->getRecord();
     $currentTable =& Dataface_Table::loadTable($query['-table']);
     if (!isset($query['--tab']) and count($currentTable->tabs($currentRecord)) > 1) {
         $tabs = $currentTable->tabs($currentRecord);
         uasort($tabs, array($formTool, '_sortTabs'));
         list($query['--tab']) = array_keys($tabs);
     } else {
         if (count($currentTable->tabs($currentRecord)) <= 1) {
             unset($query['--tab']);
         }
     }
     $includedFields = null;
     // Null for all fields
     if (@$query['-fields']) {
         $includedFields = explode(' ', $query['-fields']);
     }
     /*
      *
      * Create the quickform for the current record.
      *
      */
     //$form = new Dataface_QuickForm($query['-table'], $app->db(),  $query);
     if ($resultSet->found() > @$query['-cursor']) {
         $form = $formTool->createRecordForm($currentRecord, false, @$query['--tab'], $query, $includedFields);
         /*
          * There is either a result to edit, or we are creating a new record.
          *
          */
         $res = $form->_build();
         if (PEAR::isError($res)) {
             error_log($res->toString() . implode("\n", $res->getBacktrace()));
             throw new Exception("An error occurred while building the edit form.  See error log for details.", E_USER_ERROR);
         }
         $formTool->decorateRecordForm($currentRecord, $form, false, @$query['--tab']);
         /*
          *
          * We need to add the current GET parameter flags (the GET vars starting with '-') so
          * that the controller knows to pass control to this method again upon form submission.
          *
          */
         foreach ($query as $key => $value) {
             if (strpos($key, '-') === 0) {
                 $form->addElement('hidden', $key);
                 $form->setDefaults(array($key => $value));
             }
         }
         /*
          * Store the current query string (the portion after the '?') in the form, so we 
          * can retrieve it after and redirect back to our original location.
          */
         $form->addElement('hidden', '-query');
         $form->setDefaults(array('-action' => $query['-action'], '-query' => $_SERVER['QUERY_STRING']));
         /*
          * 
          * We have to deal with 3 cases.
          * 	1) The form has not been submitted.
          *	2) The form was submitted but didn't validate (ie: it had some bad input)
          * 	3) The form was submitted and was validated.
          *
          * We deal with Case 3 first...
          *
          */
         if ($formTool->validateRecordForm($currentRecord, $form, false, @$query['--tab'])) {
             /*
              *
              * The form was submitted and it validated ok.  We now process it (ie: save its contents).
              *
              */
             $app->clearMessages();
             $formTool->handleTabSubmit($currentRecord, $form, @$query['--tab']);
             if (!isset($query['--tab'])) {
                 // If we aren't using tabs we just do it the old way.
                 // (If it ain't broke don't fix it
                 $result = $form->process(array(&$form, 'save'));
             } else {
                 // If we are using tabs, we will use the formtool's
                 // session aware saving function
                 $result = $formTool->saveSession($currentRecord);
             }
             $success = true;
             $response =& Dataface_Application::getResponse();
             if (!$result) {
                 error_log("Error occurred in save: " . xf_db_error($app->db()) . Dataface_Error::printStackTrace());
                 throw new Exception("An error occurred while attempting to save the record.  See error log for details.", E_USER_ERROR);
             } else {
                 if (PEAR::isError($result) && !Dataface_Error::isNotice($result)) {
                     if (Dataface_Error::isDuplicateEntry($result)) {
                         $app->addError($result);
                         $success = false;
                     } else {
                         error_log($result->toString() . implode("\n", $result->getBacktrace()));
                         throw new Exception("An error occurred while attempting to save the record.  See error log for details.", E_USER_ERROR);
                     }
                 } else {
                     if (Dataface_Error::isNotice($result)) {
                         $app->addError($result);
                         //$response['--msg'] = @$response['--msg'] ."\n".$result->getMessage();
                         $success = false;
                     }
                 }
             }
             if ($success) {
                 if (@$query['-response'] == 'json') {
                     //header('Content-type: text/html; charset="'.$app->_conf['oe'].'"');
                     $rvals = $currentRecord->strvals();
                     $rvals['__title__'] = $currentRecord->getTitle();
                     $rvals['__id__'] = $currentRecord->getId();
                     echo df_escape(json_encode(array('response_code' => 200, 'record_data' => $rvals, 'response_message' => df_translate('Record Successfully Saved', 'Record Successfully Saved'))));
                     return;
                 }
                 import('Dataface/Utilities.php');
                 Dataface_Utilities::fireEvent('after_action_edit', array('record' => $form->_record));
                 /*
                  *
                  * The original query string will have the -new flag set.  We need to remove this 
                  * flag so that we don't redirect the user to create another new record.
                  *
                  */
                 $vals = $form->exportValues();
                 $vals['-query'] = preg_replace('/[&\\?]-new=[^&]+/i', '', $vals['-query']);
                 $_SESSION['--last_modified_record_url'] = $form->_record->getURL();
                 $_SESSION['--last_modified_record_title'] = $form->_record->getTitle();
                 $msg = implode("\n", $app->getMessages());
                 //$msg =@$response['--msg'];
                 $msg = urlencode(Dataface_LanguageTool::translate('Record successfully saved', "Record successfully saved.<br>") . $msg);
                 if (preg_match('/[&\\?]-action=edit&/', $vals['-query']) and !$form->_record->checkPermission('edit')) {
                     $vals['-query'] = preg_replace('/([&\\?])-action=edit&/', '$1-action=view&', $vals['-query']);
                 } else {
                     if (preg_match('/[&\\?]-action=edit$/', $vals['-query']) and !$form->_record->checkPermission('edit')) {
                         $vals['-query'] = preg_replace('/([&\\?])-action=edit$/', '$1-action=view', $vals['-query']);
                     }
                 }
                 $vals['-query'] = preg_replace('/&?--msg=[^&]*/', '', $vals['-query']);
                 if (@$query['--lang']) {
                     $vals['-query'] .= '&--lang=' . $query['--lang'];
                 }
                 $link = $_SERVER['HOST_URI'] . DATAFACE_SITE_HREF . '?' . $vals['-query'] . '&--saved=1&--msg=' . $msg;
                 /*
                  *
                  * Redirect the user to the appropriate record.
                  *
                  */
                 $app->redirect("{$link}");
             }
         }
         ob_start();
         $form->display();
         $out = ob_get_contents();
         ob_end_clean();
         if (count($form->_errors) > 0) {
             $app->clearMessages();
             $app->addError(PEAR::raiseError("Some errors occurred while processing this form: <ul><li>" . implode('</li><li>', $form->_errors) . "</li></ul>"));
         }
         $context = array('form' => $out);
         // Now let's add the tabs to the context
         $context['tabs'] = $formTool->createHTMLTabs($currentRecord, $form, @$query['--tab']);
     } else {
         // no records were found
         $context = array('form' => '');
         if (isset($_SESSION['--last_modified_record_url'])) {
             $lastModifiedURL = $_SESSION['--last_modified_record_url'];
             $lastModifiedTitle = $_SESSION['--last_modified_record_title'];
             unset($_SESSION['--last_modified_record_title']);
             unset($_SESSION['--last_modified_record_url']);
             $app->addMessage(df_translate('Return to last modified record', 'No records matched your request.  Click <a href="' . $lastModifiedURL . '">here</a> to return to <em>' . df_escape($lastModifiedTitle) . '</em>.', array('lastModifiedURL' => $lastModifiedURL, 'lastModifiedTitle' => $lastModifiedTitle)));
         } else {
             $app->addMessage(Dataface_LanguageTool::translate('No records matched request', 'No records matched your request'));
         }
         $query['-template'] = 'Dataface_Main_Template.html';
     }
     if (isset($query['-template'])) {
         $template = $query['-template'];
     } else {
         if (@$query['-headless']) {
             $template = 'Dataface_Edit_Record_headless.html';
         } else {
             if (isset($params['action']['template'])) {
                 $template = $params['action']['template'];
             } else {
                 $template = 'Dataface_Edit_Record.html';
             }
         }
     }
     df_display($context, $template, true);
 }
Example #21
0
 public function getHtml()
 {
     $this->compile();
     $out = array();
     //print_r($this->dependencies);
     $clazz = get_class($this);
     $js = new $clazz();
     foreach ($this->dependencies as $script => $path) {
         $js->import($script);
         $out[] = sprintf('<script src="%s"></script>', df_escape($js->getURL()));
         $js->unimport($script);
     }
     $out[] = sprintf('<script src="%s"></script>', df_escape($this->getURL()));
     return implode("\r\n", $out);
 }
Example #22
0
 function _prepareFailure($failure)
 {
     $test = $failure->failedTest();
     $ret['testName'] = $test->getName();
     $exception = $failure->thrownException();
     // a serialized string starts with a 'character:decimal:{'
     // if so we try to unserialize it
     // this piece of the regular expression is for detecting a serialized
     // type like 'a:3:' for an array with three element or an object i.e. 'O:12:"class":3'
     $serialized = '(\\w:\\d+:(?:"[^"]+":\\d+:)?\\{.*\\})';
     // Spaces might make a diff, so we shall show them properly (since a
     // user agent ignores them).
     if (preg_match('/^(.*)expected ' . $serialized . ', actual ' . $serialized . '$/sU', $exception, $matches)) {
         ob_start();
         print_r(unserialize($matches[2]));
         $ret['expected'] = df_escape($matches[1]) . "<pre>" . df_escape(rtrim(ob_get_contents())) . "</pre>";
         // Improved compatibility, ob_clean() would be PHP >= 4.2.0 only.
         ob_end_clean();
         ob_start();
         print_r(unserialize($matches[3]));
         $ret['actual'] = df_escape($matches[1]) . "<pre>" . df_escape(rtrim(ob_get_contents())) . "</pre>";
         ob_end_clean();
     } else {
         if (preg_match('/^(.*)expected (.*), actual (.*)$/sU', $exception, $matches)) {
             $ret['expected'] = nl2br(str_replace(" ", "&nbsp;", df_escape($matches[1] . $matches[2])));
             $ret['actual'] = nl2br(str_replace(" ", "&nbsp;", df_escape($matches[1] . $matches[3])));
         } else {
             $ret['message'] = nl2br(str_replace(" ", "&nbsp;", df_escape($exception)));
         }
     }
     return $ret;
 }
Example #23
0
 /**
  * Accepts next token
  *
  * @access public
  *
  * @param  string $class   Token class
  * @param  string $content Token content
  */
 function acceptToken($class, $content)
 {
     $theClass = $this->_getFullClassName($class);
     $content = df_escape($content);
     if (!$this->_output || $class != $this->_lastClass) {
         $tag = '';
         if ($this->_output) {
             $tag .= '</span>';
         }
         $tag .= '<span class="hl-' . $theClass . '">';
         $this->_output .= $tag;
     } else {
         $class = $this->_lastClass;
         $theClass = $this->_getFullClassName($class);
     }
     // make coloring tags not cross the list item tags
     if ($this->_numbers == HL_NUMBERS_LI) {
         $tag = "</span>\n<span class=\"hl-" . $theClass . '">';
         $content = str_replace("  ", '&nbsp; ', $content);
         $content = str_replace("\n", $tag, $content);
     }
     $this->_output .= $content;
     $this->_lastClass = $class;
 }
Example #24
0
 /**
  * Default method to render text (df_escape)
  *
  * @access public
  * @param string $text the text to render
  * @return rendered text
  *
  */
 function textEncode($text)
 {
     return df_escape($text);
 }
Example #25
0
 function getItemDescription(&$record)
 {
     $delegate =& $record->_table->getDelegate();
     if (isset($delegate) and method_exists($delegate, 'getRSSDescription')) {
         return $delegate->getRSSDescription($record);
     } else {
         $out = '<table><thead><tr><th>Field</th><th>Value</th></tr></thead>';
         $out .= '<tbody>';
         foreach ($record->_table->fields() as $field) {
             if (!$record->checkPermission('view')) {
                 continue;
             }
             if (@$field['visibility']['feed'] == 'hidden') {
                 continue;
             }
             if ($disp = @$record->val($field['name'])) {
                 $out .= '<tr><td valign="top">' . df_escape($field['widget']['label']) . '</td>';
                 $out .= '<td valign="top">' . @$record->htmlValue($field['name']) . '</td></tr>';
             }
         }
         $out .= '</tbody></table>';
         return $out;
     }
     //return $record->getDescription();
 }
Example #26
0
 function form_context($params, &$smarty)
 {
     $query = Dataface_Application::getInstance()->getQuery();
     $exclude = array();
     if (@$params['exclude']) {
         $tmp = array_map('trim', explode(',', $params['exclude']));
         foreach ($tmp as $t) {
             $exclude[$t] = $t;
         }
     }
     $fields = array();
     foreach ($query as $k => $v) {
         if (isset($exclude[$k])) {
             continue;
         }
         if (is_string($v) and strlen($k) > 1 and $k[0] === '-' and $k[1] !== '-') {
             $fields[] = '<input type="hidden" name="' . df_escape($k) . '" value="' . df_escape($v) . '"/>';
         } else {
             if (@$params['filters'] and is_string($v) and strlen($v) > 0 and strlen($k) > 0 and $k[0] !== '-') {
                 $fields[] = '<input type="hidden" name="' . df_escape($k) . '" value="' . df_escape($v) . '"/>';
             }
         }
     }
     return implode("\n", $fields);
 }
Example #27
0
 function &buildWidget(&$record, &$field, &$form, $formFieldName, $new = false)
 {
     $table =& $record->_table;
     $widget =& $field['widget'];
     if (!@$widget['separator']) {
         $widget['separator'] = '<br />';
     }
     $factory =& Dataface_FormTool::factory();
     if (isset($field['repeat']) and $field['repeat'] and isset($field['vocabulary']) and $field['vocabulary'] or isset($field['transient']) and isset($field['relationship'])) {
         $boxes = array();
         $options = array();
         if (@$field['vocabulary']) {
             $options =& Dataface_FormTool::getVocabulary($record, $field);
             $options__classes = Dataface_FormTool::getVocabularyClasses($record, $field);
         } else {
             if (isset($field['relationship'])) {
                 $relationship =& $record->_table->getRelationship($field['relationship']);
                 $options = $relationship->getAddableValues($record);
                 $options__classes = array();
                 // Now let's add the ability to add an option that isn't already there
                 // but only if the user has permission
                 if (!@$widget['suffix']) {
                     $widget['suffix'] = '';
                 }
                 $dtable =& Dataface_Table::loadTable($relationship->getDomainTable());
                 if (!PEAR::isError($dtable) and $record->checkPermission('add new related record', array('relationship' => $relationship->getName()))) {
                     import('Dataface/JavascriptTool.php');
                     $jt = Dataface_JavascriptTool::getInstance();
                     $jt->import('xataface/widgets/checkbox.js');
                     //	$suffix =  '<script type="text/javascript" src="'.DATAFACE_URL.'/js/jquery-ui-1.7.2.custom.min.js"></script>';
                     //$suffix .= '<script type="text/javascript" src="'.DATAFACE_URL.'/js/RecordDialog/RecordDialog.js"></script>';
                     $suffix = '<a 
                                     class="xf-checkbox-widget-other-link"
                                     href="#" 
                                     onclick="return false" 
                                     id="' . df_escape($field['name']) . '-other"
                                     data-relationship-name="' . df_escape($relationship->getName()) . '"
                                     data-table-name="' . df_escape($dtable->tablename) . '"
                                     data-field-name="' . df_escape($field['name']) . '"
                                     data-keys="' . df_escape(json_encode(array_keys($dtable->keys()))) . '"
                                 >Other..</a>';
                     $widget['suffix'] = $suffix;
                 }
             }
         }
         if ($record and $record->val($field['name'])) {
             $vals = $record->val($field['name']);
             if (is_array($vals)) {
                 foreach ($vals as $thisval) {
                     if (!isset($options[$thisval])) {
                         $options[$thisval] = $thisval;
                     }
                 }
             }
         }
         $dummyForm = new HTML_QuickForm();
         foreach ($options as $opt_val => $opt_text) {
             if ($opt_val === '') {
                 continue;
             }
             $boxes[] =& $dummyForm->createElement('checkbox', $opt_val, null, $opt_text, array('class' => 'checkbox-of-' . $field['name'] . ' ' . @$options__classes[$opt_val]));
             //$boxes[count($boxes)-1]->setValue($opt_val);
         }
         $el =& $factory->addGroup($boxes, $field['name'], $widget['label']);
     } else {
         $el =& $factory->addElement('advcheckbox', $formFieldName, $widget['label']);
         if ($field['vocabulary']) {
             $yes = '';
             $no = '';
             if ($table->isYesNoValuelist($field['vocabulary'], $yes, $no)) {
                 $el->setValues(array($no, $yes));
             }
         }
     }
     return $el;
 }
Example #28
0
    function toHtml()
    {
        $context = array();
        $context['relatedList'] = $this;
        $app =& Dataface_Application::getInstance();
        $context['app'] =& $app;
        $query =& $app->getQuery();
        $context['query'] =& $query;
        if (isset($query['-related:sort'])) {
            $sortcols = explode(',', trim($query['-related:sort']));
            $sort_columns = array();
            foreach ($sortcols as $sortcol) {
                $sortcol = trim($sortcol);
                if (strlen($sortcol) === 0) {
                    continue;
                }
                $sortcol = explode(' ', $sortcol);
                if (count($sortcol) > 1) {
                    $sort_columns[$sortcol[0]] = strtolower($sortcol[1]);
                } else {
                    $sort_columns[$sortcol[0]] = 'asc';
                }
                break;
            }
            unset($sortcols);
            // this was just a temp array so we get rid of it here
        } else {
            $sort_columns = array();
        }
        $context['sort_columns'] =& $sort_columns;
        $sort_columns_arr = array();
        foreach ($sort_columns as $colkey => $colorder) {
            $sort_columns_arr[] = '`' . $colkey . '`' . $colorder;
        }
        if (count($sort_columns_arr) > 0) {
            $sort_columns_str = implode(', ', $sort_columns_arr);
        } else {
            $sort_columns_str = 0;
        }
        unset($query);
        $skinTool =& Dataface_SkinTool::getInstance();
        $context['skinTool'] =& $skinTool;
        $resultController =& $skinTool->getResultController();
        $context['resultController'] =& $resultController;
        $s =& $this->_table;
        $r =& $this->_relationship->_schema;
        $fkeys = $this->_relationship->getForeignKeyValues();
        $local_fkey_fields = array();
        foreach ($fkeys as $fk_table_name => $fk_table_cols) {
            foreach ($fk_table_cols as $k => $v) {
                if (is_string($v) and $v and $v[0] === '$') {
                    $local_fkey_fields[$k] = $v;
                }
            }
        }
        $default_order_column = $this->_relationship->getOrderColumn();
        //echo "Def order col = $default_order_column";
        ob_start();
        df_display(array('redirectUrl' => $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']), 'Dataface_MoveUpForm.html');
        $moveUpForm = ob_get_contents();
        ob_end_clean();
        $context['moveUpForm'] = $moveUpForm;
        $records =& $this->_record->getRelatedRecords($this->_relationship_name, true, $this->_start, $this->_limit, $this->_where);
        if (PEAR::isError($records)) {
            $records->addUserInfo("Error retrieving records from relationship " . $this->_relationship_name);
            return $records;
        }
        $context['records'] =& $records;
        //echo "<br/><b>Now Showing</b> ".($this->_start+1)." to ".(min($this->_start + $this->_limit, $this->_record->numRelatedRecords($this->_relationship_name)));
        $perms = $this->_record->getPermissions(array('relationship' => $this->_relationship_name));
        $context['perms'] = $perms;
        $context['record_editable'] = Dataface_PermissionsTool::edit($this->_record);
        $context['can_add_new_related_record'] = @$perms['add new related record'];
        $context['can_add_existing_related_record'] = @$perms['add existing related record'];
        if (!$this->hideActions and ($context['record_editable'] or @$perms['add new related record'] or @$perms['add existing related record'])) {
            $query = array('-action' => 'new_related_record');
            $link = Dataface_LinkTool::buildLink($query);
            $context['new_related_record_query'] = $query;
            $context['new_related_record_link'] = $link;
            $domainTable = $this->_relationship->getDomainTable();
            //$context['domainTable'] =& $domainTable;
            $importTablename = $domainTable;
            if (!PEAR::isError($domainTable)) {
                //This relationship is many-to-many so we can add existing records to it.
                $query2 = array('-action' => 'existing_related_record');
                $context['existing_related_record_query'] = $query2;
                $link2 = Dataface_LinkTool::buildLink($query2);
                $context['existing_related_record_link'] = $link2;
                $destTables = $this->_relationship->getDestinationTables();
                $context['destTables'] =& $destTables;
                $importTablename = $destTables[0]->tablename;
                $context['importTablename'] = $importTablename;
            }
            if (!PEAR::isError($importTablename)) {
                $importTable =& Dataface_Table::loadTable($importTablename);
                $context['importTable'] =& $importTable;
                $query3 = array('-action' => 'import');
                $context['import_related_records_query'] =& $query3;
                $link3 = Dataface_LinkTool::buildLink($query3);
                $context['import_related_records_link'] = $link3;
            }
        }
        $imgIcon = DATAFACE_URL . '/images/search_icon.gif';
        $searchSrc = DATAFACE_URL . '/js/Dataface/RelatedList/search.js';
        $relname = $this->_relationship_name;
        $context['relationship_label'] = $this->_relationship->getLabel();
        $context['relname'] = $relname;
        $context['relationship_name'] = $this->_relationship_name;
        $context['searchSrc'] = $searchSrc;
        $context['imgIcon'] = $imgIcon;
        if (!$this->hideActions) {
            $num_related_records = $this->_record->numRelatedRecords($this->_relationship_name, $this->_where);
            $now_showing_start = $this->_start + 1;
            $now_showing_finish = min($this->_start + $this->_limit, $this->_record->numRelatedRecords($this->_relationship_name, $this->_where));
            $stats_context = array('num_related_records' => $num_related_records, 'now_showing_start' => $now_showing_start, 'now_showing_finish' => $now_showing_finish, 'relationship_name' => $this->_relationship_name, 'limit_field' => $resultController->limitField('related:'), 'back_link' => $this->_backButtonHtml(), 'next_link' => $this->_forwardButtonHtml());
            import('Dataface/ActionTool.php');
            $at =& Dataface_ActionTool::getInstance();
            $actions = $at->getActions(array('category' => 'related_list_actions'));
            $context['related_list_actions'] = $actions;
            foreach ($stats_context as $k => $v) {
                $context[$k] = $v;
            }
        }
        import('Dataface/ActionTool.php');
        $at =& Dataface_ActionTool::getInstance();
        $selected_actions = $at->getActions(array('category' => 'selected_related_result_actions'));
        $context['selected_actions'] = $selected_actions;
        if ($this->_relationship->_schema['list']['type'] == 'treetable') {
            import('Dataface/TreeTable.php');
            $treetable = new Dataface_TreeTable($this->_record, $this->_relationship->getName());
            $context['treetable'] = $treetable->toHtml();
        } else {
            echo $moveUpForm;
            if (!$this->hideActions and $this->_where) {
                $filterQuery =& $app->getQuery();
                $context['filterQuery'] =& $filterQuery;
            }
            if (count($records) > 0) {
                ob_start();
                echo '
                        <table class="listing relatedList relatedList--' . $this->_tablename . ' relatedList--' . $this->_tablename . '--' . $this->_relationship_name . '" id="relatedList">
                        <thead>
                        <tr>';
                if (count($selected_actions) > 0) {
                    echo '<th>';
                    if (!$this->hideActions) {
                        echo '<input type="checkbox" onchange="toggleSelectedRows(this,\'relatedList\');">';
                    }
                    echo '</th>';
                }
                $cols = array_keys(current($records));
                $col_tables = array();
                $table_keys = array();
                $localFields = $this->_record->table()->fields();
                $usedColumns = array();
                foreach ($cols as $key) {
                    if ($key == $default_order_column) {
                        continue;
                    }
                    if (is_int($key)) {
                        continue;
                    }
                    if (isset($sort_columns[$key])) {
                        $class = 'sorted-column-' . $sort_columns[$key];
                        $query = array();
                        $qs_columns = $sort_columns;
                        unset($qs_columns[$key]);
                        $sort_query = $key . ' ' . ($sort_columns[$key] == 'desc' ? 'asc' : 'desc');
                        foreach ($qs_columns as $qcolkey => $qcolvalue) {
                            $sort_query .= ', ' . $qcolkey . ' ' . $qcolvalue;
                        }
                    } else {
                        $class = 'unsorted-column';
                        $sort_query = $key . ' asc';
                        foreach ($sort_columns as $scolkey => $scolvalue) {
                            $sort_query .= ', ' . $scolkey . ' ' . $scolvalue;
                        }
                    }
                    $sq = array('-related:sort' => $sort_query);
                    $link = Dataface_LinkTool::buildLink($sq);
                    $fullpath = $this->_relationship_name . '.' . $key;
                    $field =& $this->_relationship->getField($key);
                    if (isset($this->_relationship->_schema['visibility'][$key]) and $this->_relationship->_schema['visibility'][$key] == 'hidden') {
                        continue;
                    }
                    if ($field['visibility']['list'] != 'visible') {
                        continue;
                    }
                    if ($s->isBlob($fullpath) or $s->isPassword($fullpath)) {
                        continue;
                    }
                    if (isset($local_fkey_fields[$key]) and !isset($this->_relationship->_schema['visibility'][$key])) {
                        continue;
                    }
                    if (PEAR::isError($field)) {
                        $field->addUserInfo("Error getting field info for field {$key} in RelatedList::toHtml() ");
                        return $field;
                    }
                    $usedColumns[] = $key;
                    $label = $field['widget']['label'];
                    if (isset($field['column']) and @$field['column']['label']) {
                        $label = $field['column']['label'];
                    }
                    $legend = '';
                    if (@$field['column'] and @$field['column']['legend']) {
                        $legend = '<span class="column-legend">' . df_escape($field['column']['legend']) . '</span>';
                    }
                    if (!$this->noLinks) {
                        echo '<th><a href="' . df_escape($link) . '">' . df_escape($field['widget']['label']) . "</a> {$legend}</th>\n";
                    } else {
                        echo '<th>' . $field['widget']['label'] . '</th>';
                    }
                    if (!isset($col_tables[$key])) {
                        $col_tables[$key] = $field['tablename'];
                    }
                    if (!isset($table_keys[$col_tables[$key]])) {
                        $table_table =& Dataface_Table::loadTable($field['tablename']);
                        $table_keys[$col_tables[$key]] = array_keys($table_table->keys());
                        unset($table_table);
                    }
                    unset($field);
                }
                echo "</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody id=\"relatedList-body\">\n\t\t\t\t\t";
                $limit = min($this->_limit, $this->_record->numRelatedRecords($this->_relationship_name, $this->_where) - $this->_start);
                $relatedTable = $this->_relationship->getDomainTable();
                if (PEAR::isError($relatedTable)) {
                    $relatedTable = reset($r['selected_tables']);
                }
                $relatedTable = Dataface_Table::loadTable($relatedTable);
                $relatedKeys = array_keys($relatedTable->keys());
                foreach (array_keys($relatedKeys) as $i) {
                    $relatedKeys[$i] = $this->_relationship_name . "." . $relatedKeys[$i];
                }
                $fullpaths = array();
                $fields_index = array();
                foreach ($usedColumns as $key) {
                    $fullpaths[$key] = $this->_relationship_name . '.' . $key;
                    $fields_index[$key] =& $this->_relationship->getField($key);
                }
                $evenRow = false;
                for ($i = $this->_start; $i < $this->_start + $limit; $i++) {
                    $rowClass = $evenRow ? 'even' : 'odd';
                    $evenRow = !$evenRow;
                    if ($default_order_column and @$perms['reorder_related_records']) {
                        $style = 'cursor:move';
                        // A variable that will be used below in javascript to decide
                        // whether to make the table sortable or not
                        $sortable_js = 'true';
                    } else {
                        $style = '';
                        $sortable_js = 'false';
                    }
                    $context['sortable_js'] = $sortable_js;
                    unset($rrec);
                    $rrec = $this->_record->getRelatedRecord($this->_relationship_name, $i, $this->_where, $sort_columns_str);
                    //new Dataface_RelatedRecord($this->_record, $this->_relationship_name, $this->_record->getValues($fullpaths, $i, 0, $sort_columns_str));
                    $rrecid = $rrec->getId();
                    $rowPerms = $rrec->getPermissions();
                    if (!@$rowPerms['view']) {
                        continue;
                    }
                    echo "<tr class=\"listing {$rowClass}\" style=\"{$style}\" id=\"row_{$rrecid}\">";
                    if (count($selected_actions) > 0) {
                        echo '
						<td class="' . $rowClass . ' viewableColumn" nowrap>';
                        if (!$this->hideActions) {
                            echo '<input xf-record-id="' . df_escape($rrecid) . '" class="rowSelectorCheckbox" id="rowSelectorCheckbox:' . df_escape($rrecid) . '" type="checkbox">';
                        }
                        echo '</td>';
                    }
                    $link_queries = array();
                    foreach ($usedColumns as $key) {
                        if (is_int($key)) {
                            continue;
                        }
                        $fullpath = $fullpaths[$key];
                        unset($field);
                        $field =& $fields_index[$key];
                        //$s->getField($fullpath);
                        $srcRecord =& $rrec->toRecord($field['tablename']);
                        if (!@$app->_conf['legacy_compatibility_mode']) {
                            $link = $this->_record->getURL('-action=view_related_record&-related-record-id=' . urlencode($rrecid));
                        } else {
                            //$link = $srcRecord->getURL('-action=browse&-portal-context=' . urlencode($rrecid));
                            $link = $rrec->getURL('-action=browse', $field['tablename']);
                        }
                        $srcRecordId = $srcRecord->getId();
                        //$val = $this->_record->preview($fullpath, $i,255, $this->_where, $sort_columns_str);
                        if ($srcRecord->table()->isContainer($field['name']) or $srcRecord->table()->isBlob($field['name'])) {
                            $val = $rrec->htmlValue($key, array('class' => 'blob-preview'));
                            //$rrec->htmlValue($key);
                        } else {
                            $val = strip_tags($rrec->display($key));
                        }
                        $title = "";
                        if ($key == $default_order_column) {
                            unset($field);
                            unset($srcRecord);
                            continue;
                        } else {
                            if ($val != 'NO ACCESS') {
                                $accessClass = 'viewableColumn';
                            } else {
                                $accessClass = '';
                            }
                            $cellClass = 'resultListCell resultListCell--' . $key;
                            $cellClass .= ' ' . $srcRecord->table()->getType($key);
                            $renderVal = $this->renderCell($srcRecord, $field['Field']);
                            if (isset($renderVal)) {
                                $val = $renderVal;
                            }
                            if ($link and !@$field['noLinkFromListView'] and !$this->noLinks and $rrec->checkPermission('link', array('field' => $key))) {
                                $val = "<a href=\"" . df_escape($link) . "\" title=\"" . df_escape($title) . "\" data-xf-related-record-id=\"" . df_escape($srcRecordId) . "\" class=\"xf-related-record-link\">" . $val . "</a>";
                            }
                            echo "<td class=\"{$cellClass} {$rowClass} {$accessClass}\">{$val}</td>\n";
                            unset($srcRecord);
                        }
                    }
                    echo "</tr>\n";
                }
                echo "</tbody>\n\t\t\t\t\t</table>";
                $related_table_html = ob_get_contents();
                $context['related_table_html'] = $related_table_html;
                ob_end_clean();
                if (!$this->hideActions) {
                    ob_start();
                    echo '<form id="result_list_selected_items_form" method="post">';
                    $app =& Dataface_Application::getInstance();
                    $q =& $app->getQuery();
                    foreach ($q as $key => $val) {
                        if (strlen($key) > 1 and $key[0] == '-' and $key[1] == '-') {
                            continue;
                        }
                        echo '<input type="hidden" name="' . $key . '" value="' . df_escape($val) . '">';
                    }
                    echo '<input type="hidden" name="--selected-ids" id="--selected-ids">';
                    echo '<input type="hidden" name="-from" id="-from" value="' . $q['-action'] . '">';
                    echo '</form>';
                    $selected_actions_form = ob_get_contents();
                    $context['selected_actions_form'] = $selected_actions_form;
                    ob_end_clean();
                    // This bit of javascript goes through all of the columns and removes all columns that
                    // don't have any accessible information for this query.  (i.e. any columns for which
                    // each row's value is 'NO ACCESS' is removed
                    $prototype_url = DATAFACE_URL . '/js/scriptaculous/lib/prototype.js';
                    $context['prototype_url'] = $prototype_url;
                    $scriptaculous_url = DATAFACE_URL . '/js/scriptaculous/src/scriptaculous.js';
                    $context['scriptaculous_url'] = $scriptaculous_url;
                    $effects_url = DATAFACE_URL . '/js/scriptaculous/src/effects.js';
                    $context['effects_url'] = $effects_url;
                    $dragdrop_url = DATAFACE_URL . '/js/scriptaculous/src/dragdrop.js';
                    $context['dragdrop_url'] = $dragdrop_url;
                    $thisRecordID = $this->_record->getId();
                    $context['thisRecordID'] = $thisRecordID;
                }
            }
        }
        Dataface_JavascriptTool::getInstance()->import('xataface/actions/related_list.js');
        ob_start();
        $context['filters'] = $this->filters;
        df_display($context, 'xataface/RelatedList/list.html');
        $out = ob_get_contents();
        ob_end_clean();
        return $out;
    }
Example #29
0
 function listHtml($prefix = '')
 {
     $app =& Dataface_Application::getInstance();
     $rs =& $this->_resultSet;
     $pages = array();
     $start = $rs->start();
     $end = $rs->end();
     $limit = max($rs->limit(), 1);
     $found = $rs->found();
     // we show up to 5 pages on either side of the current position
     $pages_before = ceil(floatval($start) / floatval($limit));
     $pages_after = ceil(floatval($found - $end - 1) / floatval($limit));
     $curr_page = $pages_before + 1;
     $total_pages = $pages_before + $pages_after + 1;
     //$i = $curr_page;
     $i_start = $start;
     for ($i = $curr_page; $i > max(0, $curr_page - 5); $i--) {
         $pages[$i] = $app->url('-' . $prefix . 'limit=' . $limit . '&-' . $prefix . 'skip=' . max($i_start, 0));
         if ($this->_baseUrl) {
             $pages[$i] = $this->_baseUrl . '?' . substr($pages[$i], strpos($pages[$i], '?') + 1);
         }
         $i_start -= $limit;
     }
     //$i = $curr_page+1;
     $i_start = $start + $limit;
     for ($i = $curr_page + 1; $i <= min($total_pages, $curr_page + 5); $i++) {
         $pages[$i] = $app->url('-' . $prefix . 'limit=' . $limit . '&-' . $prefix . 'skip=' . $i_start);
         if ($this->_baseUrl) {
             $pages[$i] = $this->_baseUrl . '?' . substr($pages[$i], strpos($pages[$i], '?') + 1);
         }
         $i_start += $limit;
     }
     ksort($pages);
     $pages2 = array();
     if ($curr_page > 1) {
         $pages2[df_translate('scripts.GLOBAL.LABEL_PREV', 'Prev')] = $pages[$curr_page - 1];
     }
     foreach ($pages as $pageno => $pageval) {
         $pages2[$pageno] = $pageval;
     }
     if ($curr_page < $total_pages) {
         $pages2[df_translate('scripts.GLOBAL.LABEL_NEXT', 'Next')] = $pages[$curr_page + 1];
     }
     $out = array('<ul class="resultController">');
     $out[] = '<li class="rs-description">' . df_translate('scripts.GLOBAL.MESSAGE_FOUND', 'Found ' . $found . ' records', array('found' => $found)) . ' </li>';
     foreach ($pages2 as $pageno => $link) {
         if ($pageno == $curr_page) {
             $selected = ' selected';
         } else {
             $selected = '';
         }
         $out[] = '<li class="' . $selected . '"><a href="' . df_escape($link) . '">' . $pageno . '</a></li>';
     }
     $appurl = $app->url('');
     $appurl = preg_replace('/[&\\?]' . preg_quote('-' . $prefix . 'limit=') . '[^&]*/', '', $appurl);
     $appurl = preg_replace('/[&\\?]' . preg_quote('-' . $prefix . 'skip=') . '[^&]*/', '', $appurl);
     $urlprefix = $this->_baseUrl ? $this->_baseUrl . '?' . substr($appurl, strpos($appurl, '?') + 1) : $appurl;
     $out[] = '<li class="results-per-page"> ' . df_translate('scripts.GLOBAL.LABEL_SHOWING', 'Showing') . ' <input type="text" value="' . $limit . '" onchange="window.location = \'' . $urlprefix . '&-' . $prefix . 'limit=\'+this.value" size="3"/>' . df_translate('scripts.GLOBAL.MESSAGE_RESULTS_PER_PAGE', 'Results per page');
     $out[] = '</ul>';
     return implode("\n", $out);
 }
Example #30
0
    function toHtml()
    {
        //print_r($this->getProperties());
        import('Dataface/JavascriptTool.php');
        $jt = Dataface_JavascriptTool::getInstance();
        $jt->import('xataface/widgets/grid.js');
        ob_start();
        //if ( !defined('HTML_QuickForm_grid_displayed') ){
        //	define('HTML_QuickForm_grid_displayed',true);
        //	echo '<script type="text/javascript" language="javascript" src="'.DATAFACE_URL.'/HTML/QuickForm/grid.js"></script>';
        //}
        $columnNames = $this->getColumnLabels();
        $columnIds = $this->getColumnIds();
        $fielddata = $this->getValue();
        if (!is_array($fielddata)) {
            $fielddata = array();
        }
        $fieldName = $this->name;
        ?>
			<table data-field-name="<?php 
        echo df_escape($fieldName);
        ?>
" data-grid-name="<?php 
        echo df_escape($this->getName());
        ?>
" id="xf-grid-table-<?php 
        echo df_escape($this->getName());
        ?>
" class="xf-grid-table xf-grid-table-<?php 
        echo df_escape($this->getName());
        ?>
" style="width: 100%; <?php 
        echo df_escape($this->getAttribute('style'));
        ?>
">
                <thead>
                    <tr>
                    <?php 
        foreach ($columnNames as $i => $columnName) {
            ?>
                        <th class="discreet" style="text-align: left">
                        	<?php 
            echo df_escape($columnName);
            ?>
                        	
                        	
                        </th>
                     <?php 
        }
        ?>
                        <th ></th> 
                        <th ></th>
                        <th ></th>
                    </tr>
                </thead>            
                <tbody>
                	<?php 
        $emptyRow = false;
        $count = 0;
        foreach ($fielddata as $rows) {
            ?>
                	
                	<?php 
            if (!is_array($rows)) {
                continue;
            }
            ?>
                    <?php 
            ob_start();
            ?>
                    <tr df:row_id="<?php 
            echo $this->next_row_id;
            ?>
" class="xf-form-group" data-xf-record-id="<?php 
            echo $rows['__id__'];
            ?>
">
                    	<?php 
            $fieldId = $fieldName . '_' . $this->next_row_id;
            ?>
                      
                     
                     <?php 
            //IE doesn't seem to respect em unit paddings here so we
            //use absolute pixel paddings.
            ?>
                       <?php 
            $rowEmpty = true;
            foreach ($columnIds as $column) {
                ?>
                       <?php 
                $fieldDef = $this->getColumnFieldDef($column);
                $fieldTable = Dataface_Table::loadTable($fieldDef['tablename']);
                ?>
                       
                        	
                       <td style="padding-right: 10px;" valign="top" data-xf-grid-default-value="<?php 
                echo df_escape($fieldTable->getDefaultValue($fieldDef['name']));
                ?>
">
                       <?php 
                unset($fieldDef, $fieldTable);
                ?>
                        <?php 
                //$column_definition = $this->getColumnDefinition($column);
                $cell_value = $rows[$column];
                if (trim($cell_value)) {
                    $rowEmpty = false;
                }
                if (isset($rows['__permissions__']) and @$rows['__permissions__'][$column]) {
                    $perms = $rows['__permissions__'][$column];
                } else {
                    $perms = array('view' => 1, 'edit' => 1);
                }
                //if ( isset($this->filters[$column]) ) $cell_value = $this->filters[$column]->pullValue($cell_value);
                $cell_html = $this->getCellTemplate($column, $fieldId, $cell_value, $perms);
                ?>
                        	
                        <span>
                             <?php 
                echo $cell_html;
                ?>
                        </span>
                       </td>
                       <?php 
            }
            if ($rowEmpty) {
                $emptyRow = true;
            }
            ?>
                        <td style="width: 20px">
                        	<input type="hidden" name="<?php 
            echo df_escape($fieldName . '[' . $this->next_row_id . '][__id__]');
            ?>
" value="<?php 
            echo df_escape($rows['__id__']);
            ?>
"/>
                            <?php 
            if ($this->delete) {
                ?>
                            <img src="<?php 
                echo DATAFACE_URL . '/images/delete_icon.gif';
                ?>
" 
                               style="cursor: pointer;"
                                  
                                 alt="Delete row"  
                                 onclick="dataGridFieldFunctions.removeFieldRow(this);return false"/>
                             <?php 
            }
            ?>
                        </td>
						<td style="width: 20px">
                
                            <?php 
            if ($this->reorder and $this->addNew) {
                ?>
                            <img src="<?php 
                echo DATAFACE_URL . '/images/add_icon.gif';
                ?>
" 
                               style="cursor: pointer;"
                                  
                                 alt="Insert Row"  
                                 onclick="dataGridFieldFunctions.addRowOnChange(this,true);return false"/>
                             <?php 
            }
            ?>
                        </td>
                       
                        <td style="width: 20px">
                           <?php 
            if ($this->reorder) {
                ?>
                           <img src="<?php 
                echo DATAFACE_URL . '/images/arrowUp.gif';
                ?>
" 
                               style="cursor: pointer; display: block;"
                                 
                                 alt="Move row up"  
                                 onclick="dataGridFieldFunctions.moveRowUp(this);return false"/>
                            <img src="<?php 
                echo DATAFACE_URL . '/images/arrowDown.gif';
                ?>
" 
                               style="cursor: pointer; display: block;"
                            
                                 alt="Move row up"  
                                 onclick="dataGridFieldFunctions.moveRowDown(this);return false"/> 
                          <?php 
            }
            ?>
                           <input type="hidden"
                                  name="<?php 
            echo df_escape($fieldName . '[' . $this->next_row_id . '][__order__]');
            ?>
"
                                  id="<?php 
            echo df_escape('orderindex__' . $fieldId);
            ?>
"
                                  value="<?php 
            echo $this->next_row_id;
            ?>
"
                                  />                         
                        </td>
                       
                        
                    
                    </tr>
                    <?php 
            $lastRowHtml = ob_get_contents();
            ob_end_flush();
            ?>
                    <?php 
            $this->next_row_id++;
        }
        ?>
                    <?php 
        if (!$emptyRow and ($this->addNew or $this->addExisting)) {
            ?>
                    <?php 
            ob_start();
            ?>
                    <tr class="xf-form-group" df:row_id="<?php 
            echo $this->next_row_id;
            ?>
" <?php 
            if (!$this->addNew) {
                ?>
style="display:none"<?php 
            }
            ?>
>
                    <?php 
            $fieldId = $fieldName . '_' . $this->next_row_id;
            ?>
                    	<?php 
            foreach ($columnIds as $column) {
                ?>
                       <?php 
                $fieldDef = $this->getColumnFieldDef($column);
                $fieldTable = Dataface_Table::loadTable($fieldDef['tablename']);
                ?>
                       
                        	
                       <td style="padding-right: 10px;" valign="top" data-xf-grid-default-value="<?php 
                echo df_escape($fieldTable->getDefaultValue($fieldDef['name']));
                ?>
">
                       <?php 
                unset($fieldDef, $fieldTable);
                ?>
                           <span >
                           <?php 
                $cell_html = $this->getEmptyCellTemplate($column, $fieldId);
                echo $cell_html;
                ?>
                                                                       
                              </span>
                        </td>
                        <?php 
            }
            ?>
                        <td style="width: 20px">
                        <?php 
            if (!$this->_flagFrozen) {
                ?>
                           <input type="hidden" name="<?php 
                echo df_escape($fieldName . '[' . $this->next_row_id . '][__id__]');
                ?>
" value="new"/>
                           
                            <img style="display: none; cursor: pointer" 
                                 src="<?php 
                echo DATAFACE_URL . '/images/delete_icon.gif';
                ?>
" 
                                 alt="Delete row"  
                                 onclick="dataGridFieldFunctions.removeFieldRow(this); return false"/>
                        <?php 
            }
            ?>
                        </td>
                        <td style="width: 20px">
                
                            <?php 
            if (!$this->_flagFrozen and $this->reorder) {
                ?>
                            <img src="<?php 
                echo DATAFACE_URL . '/images/add_icon.gif';
                ?>
" 
                               style="cursor: pointer; display: none"
                                  
                                 alt="Insert Row"  
                                 onclick="dataGridFieldFunctions.addRowOnChange(this,true);return false"/>
                             <?php 
            }
            ?>
                        </td>
                        <td style="width: 20px">
                        <?php 
            if (!$this->_flagFrozen and $this->reorder) {
                ?>
                           <img src="<?php 
                echo DATAFACE_URL . '/images/arrowUp.gif';
                ?>
" 
                                style="display: none; cursor: pointer;"
                                alt="Move row up"  
                                onclick="dataGridFieldFunctions.moveRowUp(this); return false"/>
                           <img src="<?php 
                echo DATAFACE_URL . '/images/arrowDown.gif';
                ?>
" 
                                 style="display: none; cursor: pointer;"
                                 alt="Move row down"  
                                 onclick="dataGridFieldFunctions.moveRowDown(this); return false"/>
                          
              			   
                           <input type="hidden"
                                   value="<?php 
                echo df_escape($this->getValue() ? 999999 : 0);
                ?>
"
                                   name="<?php 
                echo df_escape($fieldName . '[' . $this->next_row_id . '][__order__]');
                ?>
"
                                   id="<?php 
                echo df_escape('orderindex__' . $fieldId);
                ?>
"
                                    />
                        <?php 
            }
            ?>
                        </td>
                    </tr>
                    <?php 
            $lastRowHtml = ob_get_contents();
            ob_end_flush();
            ?>
                    <?php 
        }
        ?>
                </tbody>
                <tfoot style="display:none" class="xf-disable-decorate">
                	
                </tfoot>
            </table>
            
            
            <input type="hidden" name="<?php 
        echo $fieldName . '[__loaded__]';
        ?>
" value="1"/>
            
            <?php 
        if ($this->addExisting) {
            ?>
            <input 
                type="button" 
                class="xf-lookup-grid-row-button xf-lookup-grid-row-button-<?php 
            echo df_escape($fieldName);
            ?>
" 
                value="Add Existing Record"
                data-table-name="<?php 
            echo df_escape($this->table);
            ?>
"
                <?php 
            if ($this->addExistingFilters) {
                ?>
data-filters="<?php 
                echo df_escape(json_encode($this->addExistingFilters));
                ?>
"<?php 
            }
            ?>
            				
            />
            
            
            <?php 
        }
        ?>
           

<?php 
        $out = ob_get_contents();
        ob_end_clean();
        return $out;
    }