Example #1
0
function show_browse_rows()
{
    global $dbh;
    global $table_rows;
    global $allow;
    global $settings;
    $item_count = 0;
    foreach ($table_rows['rows'] as $key => $row) {
        // Cutoff for active items
        if ($item_count++ >= MAX_TABLE_ITEMS) {
            break;
        }
        // if there is an active field, set the classes
        if (!$table_rows['active']) {
            $status = 'status_active';
        } else {
            if ($row['active'] == 0) {
                $status = 'status_deleted';
            } else {
                if ($row['active'] == 1) {
                    $status = 'status_active';
                } else {
                    $status = 'status_inactive';
                }
            }
        }
        ?>
		<tr id="item_<?php 
        echo $row['id'];
        ?>
" class="item <?php 
        echo $status;
        ?>
">
			
			<?php 
        // Only show the handles if this table has an sort field
        if ($table_rows['sort'] && $allow['reorder']) {
            ?>
<td class="order handle" title="#<?php 
            echo $row['sort'];
            ?>
"><span class="order_field"><img src="media/site/icons/ui-splitter-horizontal.png" width="16" height="16" /></span></td><?php 
        }
        // Only show the checkboxes if this table has an active field
        if ($table_rows['active'] && $allow['delete']) {
            ?>
<td class="check"><input class="status_action_check" id="<?php 
            echo $row['id'];
            ?>
" type="checkbox" name="" value=""></td><?php 
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Loop through all field in this item
        foreach ($table_rows['fields'] as $key => $field) {
            $type = $table_rows['info'][$field]['type_lengthless'];
            $value = $row[$field];
            $field_format = $settings["field_format"][$table_rows['name'] . "," . $field];
            $browse_media = $field_format == 'media' && intval($settings['field_option'][$table_rows['name'] . "," . $field]['media']["browse_media"]) > 0 ? true : false;
            // Check if field is hidden by admin
            if ($settings['field_hidden'][$table_rows['name'] . ',' . $field] != 'true') {
                // Need no spaces here for proper DOM sorting
                ?>
					<td class="<?php 
                echo $allow['edit'] ? 'editable' : '';
                ?>
 field_<?php 
                echo $field;
                ?>
 <?php 
                echo $key == 0 ? 'first_field' : '';
                ?>
 <?php 
                echo $browse_media ? 'thumb' : '';
                ?>
" <?php 
                echo !$table_rows['header_fields'] && $key < 8 || $settings['field_primary'][$table_rows['name']] == $field || strpos($table_rows['header_fields'], ',' . $field . ',') !== false ? '' : 'style="display:none;"';
                ?>
 ><div <?php 
                echo $browse_media || $field_format == 'rating' ? '' : 'class="wrap"';
                ?>
 ><?php 
                // If there is an active field, enable status badges
                if ($table_rows['active']) {
                    if ($row['active'] == 2 && $key == 0) {
                        ?>
<span class="status">Inactive</span><?php 
                    } elseif ($row['active'] == 0 && $key == 0) {
                        ?>
<span class="status deleted">Deleted</span><?php 
                    }
                }
                //////////////////////////////////////////////////////////////////////////////
                // Check if field is relational
                $is_relational = $settings['field_format'][$table_rows['name'] . "," . $field] == 'relational' ? true : false;
                $row_relational = $settings['field_option'][$table_rows['name'] . ',' . $field]['relational'];
                $field_settings = $settings['field_option'][$table_rows['name'] . ',' . $field];
                //print_r($field_settings);
                if ($is_relational) {
                    // Get options
                    $echo_relational = array();
                    $option_fields = explode(",", $row_relational["option"]);
                    $sth = $dbh->query($row_relational["sql"]);
                    while ($row_options = $sth->fetch()) {
                        // Get the saved field
                        $option_value = $row_options[$row_relational["value"]];
                        // Loop through visible fields (field1,field2)
                        unset($option_array);
                        foreach ($option_fields as $temp) {
                            $option_array[] = $row_options[$temp];
                        }
                        // Check if this value is selected
                        if ($row_relational["multiple"] || $row_relational['style'] == 'fancy') {
                            $found = strpos($value, "," . $option_value . ",") !== false ? true : false;
                        } else {
                            $found = $value == $option_value || $value == ',' . $option_value . ',' ? true : false;
                        }
                        // If found then add this item to printed array
                        if ($found !== false) {
                            $echo_relational[] = implode($row_relational["option_glue"], $option_array);
                        }
                    }
                    echo implode(', ', $echo_relational);
                } elseif ($field_format == 'media') {
                    unset($array_media);
                    $array_media = explode(',', $value);
                    $array_media = array_filter($array_media);
                    if (count($array_media) > 0 && $browse_media) {
                        $sth = $dbh->prepare("SELECT * FROM `directus_media` WHERE `active` = '1' AND `id` = :id ");
                        $media_allowed_visible = 0;
                        foreach ($array_media as $media) {
                            if ($media_allowed_visible++ < $field_settings['media']["browse_media"]) {
                                $sth->bindParam(':id', $media);
                                $sth->execute();
                                if ($browse_media = $sth->fetch()) {
                                    generate_media_image($browse_media['extension'], $browse_media['source'], $browse_media['height'], $browse_media['width'], $browse_media['file_size']);
                                }
                            }
                        }
                    } else {
                        echo count($array_media) . ' Files';
                    }
                } elseif ($type == 'date') {
                    echo $value == "0000-00-00" ? "No date" : date('M j, Y', strtotime($value));
                } elseif ($type == 'time') {
                    ?>
<span title="and <?php 
                    echo ltrim(date('s', strtotime($value)), '0');
                    ?>
 seconds"><?php 
                    echo date('g:i A', strtotime($value));
                    ?>
</span><?php 
                } elseif ($type == 'datetime') {
                    ?>
<span title="<?php 
                    echo contextual_time(strtotime($value));
                    ?>
"><?php 
                    echo date('M j, Y - g:i A', strtotime($value));
                    ?>
</span><?php 
                } elseif ($field_format == 'tags') {
                    echo str_replace(',', ', ', substr($value, 1, -1));
                } elseif ($field_format == 'password') {
                    echo str_repeat("*", strlen($value));
                } elseif ($field_format == 'checkbox') {
                    ?>
<input type="checkbox" name="" value="1" disabled="disabled" <?php 
                    echo $value == '1' ? 'checked="checked"' : '';
                    ?>
 ><?php 
                } elseif ($field_format == 'histogram') {
                    //$histogram_table = get_rows_info($data['name']);
                    //$histogram_sql = ($histogram_table['active'] == true)? "AND `active` = '1' " : "";
                    //$sth = $dbh->query("SELECT max($key) as peak_amount FROM `".$data['name']."` WHERE id != '".$data['item_id']."' $histogram_sql");
                    //$peak_amount = ($peak = $sth->fetch())? ($peak["peak_amount"]) : 0;
                    ?>
<span class="histogram_bar" peak_amount="calculate"><span field="<?php 
                    echo $field;
                    ?>
" title="<?php 
                    echo $value;
                    ?>
" this_amount="<?php 
                    echo $value;
                    ?>
"></span></span> 
							<span class="histogram_percent">0%</span><?php 
                } elseif ($field_format == 'rating') {
                    $max = $settings['field_option'][$table_rows['name'] . "," . $field]['rating']["max"];
                    ?>
<div class="rating_system" style="width:<?php 
                    echo 16 * $max;
                    ?>
px;">
								<div class="rating_bar" style="width:<?php 
                    echo 16 * $value;
                    ?>
px;">&nbsp;</div><?php 
                    for ($i = 1; $i <= $max; $i++) {
                        ?>
<span class="star" alt="<?php 
                        echo $i;
                        ?>
" count="<?php 
                        echo $i;
                        ?>
"></span><?php 
                    }
                    ?>
</div><?php 
                } else {
                    echo strip_tags($value);
                }
                ?>
</div></td><?php 
                // Need no spaces here for proper DOM sorting
            }
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ?>
		</tr>
		<?php 
    }
    //////////////////////////////////////////////////////////////////////////////
    // Get number of visible fields
    $num_fields_shown = 0;
    foreach ($table_rows['fields'] as $key => $field) {
        if ($settings['field_hidden'][$table_rows['name'] . ',' . $field] != 'true') {
            $num_fields_shown++;
        }
    }
    ?>
<tr class="item no_rows"><td colspan="<?php 
    echo $num_fields_shown + 3;
    ?>
">No items</td></tr><?php 
    if (count($table_rows['rows']) > MAX_TABLE_ITEMS) {
        ?>
<tr class="item"><td colspan="<?php 
        echo $num_fields_shown + 3;
        ?>
"><b>The table "<?php 
        echo $table_rows['name_uc'];
        ?>
" has reached the maximum allowed number of items (<?php 
        echo MAX_TABLE_ITEMS;
        ?>
)</b><br>Please have your admin remove some items from your trash or raise this limit</td></tr><?php 
    }
}
Example #2
0
function generate_fields($data)
{
    global $dbh;
    global $settings;
    $item = $data['rows'][$data['item_id']];
    foreach ($data['info'] as $key => $field) {
        $value = $item[$key];
        $t_f = $data['name'] . ',' . $key;
        $note = $settings['field_note'][$t_f] ? ' <span class="note">' . $settings['field_note'][$t_f] . '</span>' : '';
        $required_mark = $settings['field_required'][$t_f] == 'true' ? '<span class="loud">*</span>' : '';
        $required = $settings['field_required'][$t_f] == 'true' ? 'required' : '';
        $field_format = $settings['field_format'][$t_f] ? $settings['field_format'][$t_f] : get_datatype_formats($field['type_lengthless'], $primary_only = true);
        // 'text_field'
        $is_relational = $settings['field_format'][$t_f] == 'relational' ? true : false;
        $field_option = $settings['field_option'][$t_f];
        // If field is hidden, add a hidden input and skip
        if ($settings['field_hidden'][$t_f] == 'true') {
            ?>
			<input type="hidden" name="<?php 
            echo $key;
            ?>
" value="<?php 
            echo esc_attr($value);
            ?>
">
			<?php 
            continue;
        }
        //////////////////////////////////////////////////////////////////////////////
        ?>
		<div class="field">
			<?php 
        //////////////////////////////////////////////////////////////////////////////s
        // Check if field is relational
        if ($is_relational) {
            // Get options
            // REMINDER: MUST CHECK THE SQL STATEMENT TO ENSURE THERE IS NOTHING MALICIOUS!
            if ($sth = $dbh->query($field_option['relational']['sql'])) {
                $option_fields = explode(",", $field_option['relational']["option"]);
                if ($field_option['relational']["style"] == 'fancy') {
                    unset($row_options);
                    while ($row_array = $sth->fetch()) {
                        $row_options[$row_array[$field_option['relational']["value"]]] = $row_array;
                    }
                    ?>
						<label class="primary" for="<?php 
                    echo $key;
                    ?>
"><?php 
                    echo uc_convert($key) . $required_mark;
                    ?>
</label> <?php 
                    echo $note;
                    ?>
<br>
						<table id="fancy_<?php 
                    echo $key;
                    ?>
" cellpadding="0" cellspacing="0" border="0" class="simple_sortable">
							<tbody class="check_no_rows">
								<tr class="item no_rows"><td colspan="3">No items</td></tr>
								
								<?php 
                    $value_array = array_filter(explode(',', $value));
                    foreach ($value_array as $ordered_value) {
                        // Should save only ID for fancy... so we can edit items with a unique key
                        $id = str_replace('"', "&#34;", $ordered_value);
                        // Make visible option with multiple fields  (field1,field2)
                        unset($option_array);
                        foreach ($option_fields as $temp) {
                            $option_array[] = get_field_value($field_option['relational']["add_from_table"], $temp, $row_options[$ordered_value][$temp], 'code');
                        }
                        // Only show found
                        $found = $value == $ordered_value ? true : strpos($value, "," . $ordered_value . ",");
                        if ($found !== false) {
                            ?>
										<tr class="item" replace_with="<?php 
                            echo $id;
                            ?>
"> 
											<td class="order handle"><img src="media/site/icons/ui-splitter-horizontal.png" width="16" height="16" /></td> 
											<td>
												<div class="wrap">
													<?php 
                            echo implode($field_option['relational']["option_glue"], $option_array);
                            ?>
													<input type="hidden" name="<?php 
                            echo $key;
                            ?>
[]" value="<?php 
                            echo $id;
                            ?>
">
													<a class="badge edit_fancy modal" href="edit.php?modal=<?php 
                            echo $key;
                            ?>
&table=<?php 
                            echo $field_option['relational']["add_from_table"];
                            ?>
&parent_table=<?php 
                            echo $_GET['table'];
                            ?>
&item=<?php 
                            echo $id;
                            ?>
" style="display:none;">Edit</a>
												</div>
											</td> 
											<td width="10%"><a class="ui-icon ui-icon-close right remove_fancy" href=""></a></td> 
										</tr> 
										<?php 
                        }
                    }
                    ?>
																
							</tbody>
						</table> 
						
						<?php 
                    if (!$field_option['relational']["only_new"]) {
                        ?>
							<span class="fancy_new"> 
								<select field="<?php 
                        echo $key;
                        ?>
" table="<?php 
                        echo $field_option['relational']["add_from_table"];
                        ?>
" parent_table="<?php 
                        echo $_GET['table'];
                        ?>
"> 
									<option value="">Select One</option> 
									<?php 
                        foreach ($row_options as $row_option) {
                            $option_value = $row_option[$field_option['relational']["value"]];
                            // Make visible option with multiple fields  (field1,field2)
                            $safe_value = str_replace('"', "&#34;", $option_value);
                            unset($option_array);
                            foreach ($option_fields as $temp) {
                                $option_array[] = get_field_value($field_option['relational']["add_from_table"], $temp, $row_option[$temp], 'text');
                            }
                            // Only show non-used
                            //$found = ($value == $option_value)? true : strpos($value, ",".$option_value.",");
                            //if($found === false){
                            ?>
										<option value="<?php 
                            echo $safe_value;
                            ?>
"><?php 
                            echo implode($field_option['relational']["option_glue"], $option_array);
                            ?>
</option>
										<?php 
                        }
                        ?>
 
								</select> 
								
								<span> or </span>
							<?php 
                    }
                    ?>
							
							<a class="modal button pill" href="edit.php?modal=<?php 
                    echo $key;
                    ?>
&table=<?php 
                    echo $field_option['relational']["add_from_table"];
                    ?>
&parent_table=<?php 
                    echo $_GET['table'];
                    ?>
">Add New</a></span>
							
						<?php 
                } elseif ($field_option['relational']["style"] == 'checkboxes_radios') {
                    //////////////////////////////////////////////////////////////////////////////
                    // Checkboxes or Radio Buttons
                    $multiple = $field_option['relational']["multiple"] ? 'checkbox' : 'radio';
                    $array_code = $field_option['relational']["multiple"] ? '[]' : '';
                    ?>
						<label class="primary" <?php 
                    echo $required != '' ? 'class="required_multi" require="' . $key . $array_code . '"' : '';
                    ?>
><?php 
                    echo uc_convert($key) . $required_mark;
                    ?>
</label> <?php 
                    echo $note;
                    ?>
<br>
						<?php 
                    while ($row_options = $sth->fetch()) {
                        $option_value = $row_options[$field_option['relational']["value"]];
                        // Make visible option with multiple fields  (field1,field2)
                        $safe_value = str_replace('"', "&#34;", $option_value);
                        unset($option_array);
                        foreach ($option_fields as $temp) {
                            $option_array[] = $row_options[$temp];
                        }
                        if ($field_option['relational']["multiple"]) {
                            $found = $value == $option_value ? 1 : strpos($value, "," . $option_value . ",");
                            $selected = $found !== false ? 'checked="checked"' : '';
                        } else {
                            $selected = $value == $option_value ? 'checked="checked"' : '';
                        }
                        ?>
							<label class="multi_inputs"><input name="<?php 
                        echo $key . $array_code;
                        ?>
" value="<?php 
                        echo $safe_value;
                        ?>
" <?php 
                        echo $selected;
                        ?>
 type="<?php 
                        echo $multiple;
                        ?>
"><?php 
                        echo implode($field_option['relational']["option_glue"], $option_array);
                        ?>
</label>
							<?php 
                    }
                } else {
                    //////////////////////////////////////////////////////////////////////////////
                    // Default dropdown or multi-select list
                    $multiple = $field_option['relational']["multiple"] ? 'multiple="multiple"' : '';
                    $array_code = $field_option['relational']["multiple"] ? '[]' : '';
                    ?>
						<label class="primary" for="<?php 
                    echo $key;
                    ?>
"><?php 
                    echo uc_convert($key) . $required_mark;
                    ?>
</label> <?php 
                    echo $note;
                    ?>
<br>
						<select name="<?php 
                    echo $key . $array_code;
                    ?>
" <?php 
                    echo $multiple;
                    ?>
 class="<?php 
                    echo $required;
                    ?>
"> 
							<?php 
                    if (!$field_option['relational']["multiple"]) {
                        ?>
<option value="NULL">Select One</option><?php 
                    }
                    while ($row_options = $sth->fetch()) {
                        $option_value = $row_options[$field_option['relational']["value"]];
                        // Make visible option with multiple fields  (field1,field2)
                        $safe_value = str_replace('"', "&#34;", $option_value);
                        unset($option_array);
                        foreach ($option_fields as $temp) {
                            $option_array[] = $row_options[$temp];
                        }
                        if ($field_option['relational']["multiple"]) {
                            $found = $value == $option_value ? 1 : strpos($value, "," . $option_value . ",");
                            $selected = $found !== false ? 'selected="selected"' : '';
                        } else {
                            $selected = $value == $option_value ? 'selected="selected"' : '';
                        }
                        ?>
								<option value="<?php 
                        echo $safe_value;
                        ?>
" <?php 
                        echo $selected;
                        ?>
 ><?php 
                        echo implode($field_option['relational']["option_glue"], $option_array);
                        ?>
</option>
								<?php 
                    }
                    ?>
						</select>
						<?php 
                }
            } else {
                echo '<b class="warning">Error:</b> Update the options for this field on the <a class="warning" href="settings.php">settings page</a>.';
            }
        } elseif ($field_format == 'media') {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<table id="media_<?php 
            echo $key;
            ?>
" cellpadding="0" cellspacing="0" border="0" class="simple_sortable media_dropzone_target" parent_item="<?php 
            echo $key;
            ?>
" extensions="<?php 
            echo $field_option['media']["extensions"];
            ?>
" media_type="relational"> 
					<tbody class="check_no_rows">
						<tr class="item no_rows"><td colspan="4">No media</td></tr>
						
						<?php 
            $media_array = explode(',', $value);
            $media_array = array_filter($media_array);
            // Prepare the query once and run it for each media item
            // Reminder: This can be moved FURTHER up to before foreach to prepare only ONCE
            $sth = $dbh->prepare("SELECT * FROM `directus_media` WHERE `active` = '1' AND `id` = :id ");
            $sth->bindParam(':id', $media_id);
            foreach ($media_array as $media_id) {
                $sth->execute();
                if ($media = $sth->fetch()) {
                    ?>
								<tr class="item" replace_with="media_<?php 
                    echo $media_id;
                    ?>
"> 
									<td class="order handle"><img src="media/site/icons/ui-splitter-horizontal.png" width="16" height="16" /></td> 
									<td class="thumb"><?php 
                    generate_media_image($media['extension'], $media['source'], $media['height'], $media['width'], $media['file_size']);
                    ?>
</td> 
									<td>
										<div class="wrap">
											<?php 
                    echo $media['title'];
                    ?>
											<input type="hidden" name="<?php 
                    echo $key;
                    ?>
[]" value="<?php 
                    echo $media_id;
                    ?>
">
											<a class="badge edit_fancy modal" href="inc/media_modal.php?type=relational&replace=true&parent_item=<?php 
                    echo $key;
                    ?>
&id=<?php 
                    echo $media['id'];
                    ?>
" style="display:none;">Edit</a>
										</div>
									</td> 
									<td width="10%"><a tabindex="-1" class="ui-icon ui-icon-close right remove_media" href=""></a></td> 
								</tr>
								<?php 
                }
            }
            ?>
												
					</tbody>
				</table> 
				<span class="fancy_new">
					<a tabindex="-1" class="modal button pill" href="inc/media_modal.php?type=relational&parent_item=<?php 
            echo $key;
            echo $field_option['media']["new_only"] ? '&new_only=true' : '';
            echo $field_option['media']["extensions"] ? '&extensions=' . $field_option['media']["extensions"] : '';
            ?>
">Add Media</a>
					<?php 
            echo $field_option['media']["extensions"] ? ' <span class="note">(' . implode(' or ', array_filter(explode(',', str_replace(' ', '', strtolower($field_option['media']["extensions"]))))) . ')</span>' : '';
            ?>
				</span>
			
			<?php 
        } elseif ($field_format == 'options') {
            ?>
				
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				
				<?php 
            $array_code = $field_option['options']["multiple"] ? '[]' : '';
            // Get multiple options
            if ($field_option['options']["style"] != 'checkboxes_radios') {
                $select_code = 'selected="selected"';
                $multiple = $field_option['options']["multiple"] ? 'multiple="multiple"' : '';
                ?>
<select name="<?php 
                echo $key . $array_code;
                ?>
" <?php 
                echo $multiple;
                ?>
 class="<?php 
                echo $required;
                ?>
"> <?php 
            } else {
                $select_code = 'checked="checked"';
                $multiple = $field_option['options']["multiple"] ? 'checkbox' : 'radio';
            }
            if (!$field_option['options']["multiple"]) {
                ?>
<option value="NULL">Select One</option><?php 
            }
            $option_array = array_filter(explode(',', $field_option['options']["values"]));
            foreach ($option_array as $option_value) {
                // Clean up the value a bit
                $option_value = trim($option_value);
                // Make safe the attribute value
                $safe_value = str_replace('"', "&#34;", $option_value);
                if ($field_option['options']["multiple"]) {
                    $found = $value == $option_value ? 1 : strpos($value, "," . $option_value . ",");
                    $selected = $found !== false ? $select_code : '';
                } else {
                    $selected = $value == $option_value ? $select_code : '';
                }
                if ($field_option['options']["style"] == 'checkboxes_radios') {
                    ?>
<label class="multi_inputs"><input name="<?php 
                    echo $key . $array_code;
                    ?>
" value="<?php 
                    echo $safe_value;
                    ?>
" <?php 
                    echo $selected;
                    ?>
 type="<?php 
                    echo $multiple;
                    ?>
"><?php 
                    echo $option_value;
                    ?>
</label><?php 
                } else {
                    ?>
<option value="<?php 
                    echo $safe_value;
                    ?>
" <?php 
                    echo $selected;
                    ?>
 ><?php 
                    echo $option_value;
                    ?>
</option><?php 
                }
            }
            if ($field_option['options']["style"] != 'checkboxes_radios') {
                ?>
</select><?php 
            }
        } elseif ($field_format == 'tags') {
            $tags = explode(',', $value);
            $tags = array_filter($tags);
            ?>
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input id="input_<?php 
            echo $key;
            ?>
" class="short_half tag_input <?php 
            echo $field_option['tags']["autocomplete"] ? 'tag_autocomplete' : '';
            ?>
" type="text"> <input tabindex="-1" field="<?php 
            echo $key;
            ?>
" class="tag_add button pill" type="button" value="Add"> 
				<input id="hidden_<?php 
            echo $key;
            ?>
" type="hidden" name="<?php 
            echo $key;
            ?>
" value="<?php 
            echo esc_attr($value);
            ?>
" class="<?php 
            echo $required;
            ?>
">
				<div id="tags_<?php 
            echo $key;
            ?>
" class="tags_list clearfix">
					<?php 
            foreach ($tags as $tag_key => $tag_value) {
                ?>
						<span class="tag" tag="<?php 
                echo $tag_value;
                ?>
"><?php 
                echo $tag_value;
                ?>
<a class="tag_remove" tabindex="-1" href="#">&times;</a></span> 
						<?php 
            }
            ?>
				</div>
				
			<?php 
        } elseif ($field_format == 'checkbox') {
            ?>
				
				<label class="primary" for="<?php 
            echo $key;
            ?>
">
				<input name="<?php 
            echo $key;
            ?>
" type="checkbox" value="1" <?php 
            echo $value == 1 ? 'checked="checked"' : '';
            ?>
>
				 <?php 
            echo uc_convert($key) . $required_mark;
            ?>
				</label> <?php 
            echo $note;
            ?>
			
			<?php 
        } elseif ($field['type_lengthless'] == 'date') {
            $value = $value ? $value : date('Y-m-d');
            ?>
	
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input name="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $value ? $value : date('Y-m-d');
            ?>
" maxlength="10" class="small short_10 text_center date datepicker <?php 
            echo $required;
            ?>
" type="text" size="10"> 
			
			<?php 
        } elseif ($field['type_lengthless'] == 'time') {
            $value = $value ? $value : date('h:i:s');
            ?>
	
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input name="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $value;
            ?>
" maxlength="8" class="small short_8 text_center date <?php 
            echo $required;
            ?>
" type="text" size="10"> 
			
			<?php 
        } elseif ($field['type_lengthless'] == 'year') {
            $value = $value ? $value : date('Y');
            ?>
	
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input name="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $value;
            ?>
" maxlength="4" class="small short_4 text_center year force_numeric <?php 
            echo $required;
            ?>
" type="text" size="10"> 
			
			<?php 
        } elseif ($field['type_lengthless'] == 'datetime') {
            $value_time = $value ? strtotime($value) : strtotime('now');
            $month = date('m', $value_time);
            ?>
				
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<div class="datetime_fields">
					<select class="month"> 
						<option value="01" <?php 
            echo $month == '01' ? 'selected="selected"' : '';
            ?>
>Jan</option> 
						<option value="02" <?php 
            echo $month == '02' ? 'selected="selected"' : '';
            ?>
>Feb</option> 
						<option value="03" <?php 
            echo $month == '03' ? 'selected="selected"' : '';
            ?>
>Mar</option> 
						<option value="04" <?php 
            echo $month == '04' ? 'selected="selected"' : '';
            ?>
>Apr</option> 
						<option value="05" <?php 
            echo $month == '05' ? 'selected="selected"' : '';
            ?>
>May</option> 
						<option value="06" <?php 
            echo $month == '06' ? 'selected="selected"' : '';
            ?>
>Jun</option> 
						<option value="07" <?php 
            echo $month == '07' ? 'selected="selected"' : '';
            ?>
>Jul</option> 
						<option value="08" <?php 
            echo $month == '08' ? 'selected="selected"' : '';
            ?>
>Aug</option> 
						<option value="09" <?php 
            echo $month == '09' ? 'selected="selected"' : '';
            ?>
>Sep</option> 
						<option value="10" <?php 
            echo $month == '10' ? 'selected="selected"' : '';
            ?>
>Oct</option> 
						<option value="11" <?php 
            echo $month == '11' ? 'selected="selected"' : '';
            ?>
>Nov</option> 
						<option value="12" <?php 
            echo $month == '12' ? 'selected="selected"' : '';
            ?>
>Dec</option> 
					</select> 
					<input class="small short_1 text_center day force_numeric" type="text" size="2" maxlength="2" value="<?php 
            echo date('j', $value_time);
            ?>
">, 
					<input class="small short_4 text_center year force_numeric" type="text" size="4" maxlength="4" value="<?php 
            echo date('Y', $value_time);
            ?>
"> @ 
					<input class="small short_1 text_center hour force_numeric" type="text" size="2" maxlength="2" value="<?php 
            echo date('H', $value_time);
            ?>
"> : 
					<input class="small short_1 text_center minute force_numeric" type="text" size="2" maxlength="2" value="<?php 
            echo date('i', $value_time);
            ?>
"> : 
					<input class="small short_1 text_center second force_numeric" type="text" size="2" maxlength="2" value="<?php 
            echo date('s', $value_time);
            ?>
"> 
					<input class="small short_6 text_center datetime <?php 
            echo $required;
            ?>
" type="hidden" name="<?php 
            echo $key;
            ?>
" value="<?php 
            echo $value ? $value : date('Y-m-j H:i:s', $value_time);
            ?>
">
				</div>
			
			<?php 
        } elseif ($field_format == 'text_area') {
            ?>
				
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<div class="textarea_format clearfix"> 
					<ul> 
						<li><a href="#" class="text_format_button" tabindex="-1" format="bold"><strong>Bold</strong></a></li> 
						<li><a href="#" class="text_format_button" tabindex="-1" format="italic"><em>Italic</em></a></li> 
						<li><a href="#" class="text_format_button" tabindex="-1" format="link">Link</a></li> 
						<li><a href="#" class="text_format_button" tabindex="-1" format="mail">Mail</a></li>
						<li><a href="#" class="text_format_button" tabindex="-1" format="image">Insert Image</a></li> 
						<li><a href="#" class="text_format_button" tabindex="-1" format="excerpt">Excerpt</a></li> 
						<li><a href="#" class="text_format_button" tabindex="-1" format="blockquote">Blockquote</a></li> 
					</ul>
				</div> 
				<textarea class="textarea_formatted media_dropzone_target" parent_item="text_area_<?php 
            echo $key;
            ?>
" extensions="jpg,gif,png" media_type="inline" rows="<?php 
            echo $field_option['text_area']["height"] ? $field_option['text_area']["height"] : '8';
            ?>
" id="text_area_<?php 
            echo $key;
            ?>
" name="<?php 
            echo $key;
            ?>
" class="<?php 
            echo $required;
            ?>
"><?php 
            echo esc_attr(br2nl($value));
            ?>
</textarea> 
			
			<?php 
        } elseif ($field_format == 'table_view') {
            ?>
				
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br> 
				<textarea rows="4" id="text_area_<?php 
            echo $key;
            ?>
" name="<?php 
            echo $key;
            ?>
" class="<?php 
            echo $required;
            ?>
"><?php 
            echo $value;
            ?>
</textarea> 
				<a tabindex="-1" class="edit_table_view button pill" csv-id="text_area_<?php 
            echo $key;
            ?>
" href="inc/edit_table.php">Edit in table view</a>
				<span class="note">You can always paste a CSV file above to start with</span>
			
			<?php 
        } elseif ($field_format == 'short_name') {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input class="track_max_length short_name <?php 
            echo $required;
            ?>
" short_name="<?php 
            echo $field_option['short_name']["field"];
            ?>
" name="<?php 
            echo $key;
            ?>
" type="text" value="<?php 
            echo esc_attr($value);
            ?>
" maxlength="<?php 
            echo $field['type_length'];
            ?>
">
				<span class="char_count"><?php 
            echo $field['type_length'] - strlen($value);
            ?>
</span> 
				
			<?php 
        } elseif ($field_format == 'numeric') {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input class="track_max_length force_numeric <?php 
            echo $required;
            ?>
" name="<?php 
            echo $key;
            ?>
" type="text" value="<?php 
            echo esc_attr($value);
            ?>
" maxlength="<?php 
            echo $field['type_length'];
            ?>
">
				<span class="char_count"><?php 
            echo $field['type_length'] - strlen($value);
            ?>
</span> 
				
			<?php 
        } elseif ($field_format == 'password') {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input class="track_max_length <?php 
            echo $required;
            ?>
 <?php 
            echo $field_option['password']["unmask"] ? 'unmask' : '';
            ?>
" name="<?php 
            echo $key;
            ?>
" type="password" value="<?php 
            echo esc_attr($value);
            ?>
" maxlength="<?php 
            echo $field['type_length'];
            ?>
">
				<span class="char_count"><?php 
            echo $field['type_length'] - strlen($value);
            ?>
</span> 
				
			<?php 
        } elseif ($field_format == 'password_confirm') {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input class="track_max_length <?php 
            echo $required;
            ?>
" name="<?php 
            echo $key;
            ?>
" type="password" value="<?php 
            echo esc_attr($value);
            ?>
" maxlength="<?php 
            echo $field['type_length'];
            ?>
">
				<span class="char_count"><?php 
            echo $field['type_length'] - strlen($value);
            ?>
</span> 
				
			<?php 
        } elseif ($field_format == 'color') {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				# <input class="small short_6 text_center color_field <?php 
            echo $required;
            ?>
" name="<?php 
            echo $key;
            ?>
" type="text" value="<?php 
            echo $value ? strtoupper(esc_attr($value)) : 'FFFFFF';
            ?>
" maxlength="6"> <span class="color_box" color_box="<?php 
            echo $key;
            ?>
" style="background-color:#<?php 
            echo $value ? esc_attr($value) : 'FFFFFF';
            ?>
;"></span>
			
			<?php 
        } elseif ($field_format == 'histogram') {
            // Get highest value for this field across the table
            $histogram_table = get_rows_info($data['name']);
            $histogram_sql = $histogram_table['active'] == true ? "AND `active` = '1' " : "";
            $sth = $dbh->query("SELECT max({$key}) as peak_amount FROM `" . $data['name'] . "` WHERE id != '" . $data['item_id'] . "' {$histogram_sql}");
            $peak_amount = ($peak = $sth->fetch()) ? $peak["peak_amount"] : 0;
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input class="small short_6 force_numeric histogram <?php 
            echo $required;
            ?>
" name="<?php 
            echo $key;
            ?>
" type="text" value="<?php 
            echo esc_attr($value);
            ?>
" maxlength="<?php 
            echo $field['type_length'];
            ?>
"> <span class="histogram_bar" peak_amount="<?php 
            echo $peak_amount;
            ?>
"><span this_amount="<?php 
            echo esc_attr($value);
            ?>
"></span></span> <span title="<?php 
            echo esc_attr($value) . '/' . $peak_amount;
            ?>
" class="histogram_percent">0%</span>
				
			<?php 
        } elseif ($field_format == 'rating') {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<div class="editable_rating">
					<div class="rating_system" style="width:<?php 
            echo 16 * $field_option['rating']["max"];
            ?>
px;">
						<div class="rating_bar" style="width:<?php 
            echo 16 * $value;
            ?>
px;">&nbsp;</div>
						<?php 
            for ($i = 1; $i <= $field_option['rating']["max"]; $i++) {
                ?>
<span class="star" alt="<?php 
                echo $i;
                ?>
" count="<?php 
                echo $i;
                ?>
"></span><?php 
            }
            ?>
					</div>
					<input class="small short_2 text_center rating_input <?php 
            echo $required;
            ?>
" name="<?php 
            echo $key;
            ?>
" type="text" value="<?php 
            echo esc_attr($value);
            ?>
" maxlength="<?php 
            echo $field['type_length'];
            ?>
"> out of <?php 
            echo $field_option['rating']["max"];
            ?>
				</div>
				
			<?php 
        } else {
            ?>
			
				<label class="primary" for="<?php 
            echo $key;
            ?>
"><?php 
            echo uc_convert($key) . $required_mark;
            ?>
</label> <?php 
            echo $note;
            ?>
<br>
				<input class="<?php 
            echo $field_format == 'email' ? 'validate_email short_half' : '';
            ?>
 <?php 
            echo $field['type_length'] > 0 ? 'track_max_length' : '';
            ?>
 <?php 
            echo $required;
            ?>
" name="<?php 
            echo $key;
            ?>
" type="<?php 
            echo $field_format == 'email' ? 'email' : 'text';
            ?>
" value="<?php 
            echo esc_attr($value);
            ?>
" <?php 
            echo $field['type_length'] > 0 ? 'maxlength="' . $field['type_length'] . '"' : '';
            ?>
>
				<?php 
            if ($field['type_length'] > 0) {
                ?>
<span class="char_count"><?php 
                echo $field['type_length'] - strlen($value);
                ?>
</span> <?php 
            }
            ?>
			<?php 
        }
        ?>
			
		</div>
		<?php 
    }
}
Example #3
0
        ?>
								<td class="media_modal_thumb audio">
								<?php 
        echo generate_media_image($extension, $media_detail["source"], $media_detail["height"], $media_detail["width"], $media_detail["file_size"], 100);
        ?>
								</td>
								<?php 
    } else {
        ?>
								<td class="media_modal_thumb">
									<a href="<?php 
        echo $link;
        ?>
" target="_blank">
									<?php 
        echo generate_media_image($extension, $media_detail["source"], $media_detail["height"], $media_detail["width"], $media_detail["file_size"], 100);
        ?>
									</a>
								</td>
								<?php 
    }
    ?>
								<td>
									<?php 
    echo 'Uploaded by ' . $cms_all_users[$media_detail['user']]['username'] . ' ' . contextual_time(strtotime($media_detail['uploaded'])) . '<br>';
    echo $dimensions . $extension . ' - ' . $length_size . '<br>';
    echo $link_text ? $link_text . '<br>' : '';
    // If user is allowed to manage media then enable swapping and deleting
    if ($cms_user['media']) {
        ?>
<a id="media_modal_swap" href="#">Swap</a> or <a id="media_modal_delete" class="delete" media_id="<?php