Example #1
0
 /**
  * Do full replacement of the HTML output
  */
 private function replace_output()
 {
     // Pattern translation
     if (!empty($this->regex_statements['pattern'])) {
         foreach ($this->regex_statements['pattern'] as $handler => $rules) {
             foreach ($rules as $search => $replace) {
                 $this->output = preg_replace($search, $replace, $this->output);
             }
         }
     }
     // Alias translation
     if (!empty($this->regex_statements['alias'])) {
         foreach ($this->regex_statements['alias'] as $handler => $rules) {
             $_patterns = flatten_array($rules);
             foreach ($_patterns as $search => $replace) {
                 $this->output = preg_replace($search, $replace, $this->output);
             }
         }
     }
     // Alias Redirecting
     if (!empty($this->regex_statements['alias_redirect'])) {
         foreach ($this->regex_statements['alias_redirect'] as $handler => $rules) {
             $_patterns = flatten_array($rules);
             foreach ($_patterns as $search => $replace) {
                 if (preg_match($search, PERMALINK_CURRENT_PATH, $matches)) {
                     $this->redirect_301($replace);
                 }
             }
         }
     }
 }
Example #2
0
function serialize_exif($uploaded_file)
{
    //$exif_tmp = read_exif_data_raw($_FILES['upload_file']['tmp_name'],0);
    $exif_tmp = read_exif_data_raw($uploaded_file, 0);
    $flat_exif_tmp = flatten_array($exif_tmp);
    if (in_array("DataDumpMakerNote", $flat_exif_tmp)) {
        // this field is set to empty because it causes trouble
        $flat_exif_tmp['DataDumpMakerNote'] = NULL;
    }
    //search for all "unknown:*" fields because like the MakerNote it causes trouble.
    // Thanks to erdbeerbaum for pointing this out.
    foreach ($flat_exif_tmp as $key => $value) {
        $pos = strpos($key, "unknown:");
        if ($pos === 0) {
            $flat_exif_tmp[$key] = NULL;
        }
    }
    foreach ($flat_exif_tmp as $key => $value) {
        $flat_exif_tmp[$key] = trim($value);
    }
    $exif_info = serialize($flat_exif_tmp);
    // we need to escape the string before saving it to the db
    $exif_info = mysql_real_escape_string($exif_info);
    return $exif_info;
}
 public function setUp()
 {
     global $xml_data;
     $this->xml_data_in = $xml_data;
     $array = json_decode(json_encode((array) simplexml_load_string($xml_data)), 1);
     $newarraytest = array();
     $last_subarray_found = "";
     $this->arr_xml_data = flatten_array($array, 2, $newarraytest, $last_subarray_found);
 }
 /**
  * Set the attributes in which to insert values.
  *
  * Component: "insertColumns"
  * ----------
  *
  * @param array $fields The attributes.
  * @return $this
  */
 public function fields(array $fields)
 {
     // $fields can be either attributes or columns. It depends on $useModel
     // value.
     if ($this->_useModel) {
         $fields = $this->convertAttributesToColumns($fields, $this->_table);
     }
     $this->_components['insertColumns'] = flatten_array($fields);
     return $this;
 }
function flatten_array(array $items, array $flattened = [])
{
    foreach ($items as $item) {
        if (is_array($item)) {
            $flattened = flatten_array($item, $flattened);
            continue;
        }
        $flattened[] = $item;
    }
    return $flattened;
}
function flatten_array($mArray)
{
    $sArray = array();
    foreach ($mArray as $row) {
        if (!is_array($row)) {
            if ($sArray[] = $row) {
            }
        } else {
            $sArray = array_merge($sArray, flatten_array($row));
        }
    }
    return $sArray;
}
Example #7
0
/**
 * Flatten a multiple dim array into a single list
 *
 * @param array $array
 * @return array
 */
function flatten_array($array)
{
    $return = array();
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            $value = flatten_array($value);
            $return = array_merge($return, $value);
        } else {
            $return[] = $value;
        }
    }
    return $return;
}
Example #8
0
function flatten_array($array)
{
    if (!is_array($array)) {
        throw new Exception('Argument 1 must be an array');
    }
    $output_array = [];
    foreach ($array as $value) {
        if (is_array($value)) {
            $output_array = array_merge($output_array, flatten_array($value));
        } elseif (is_integer($value)) {
            $output_array[] = $value;
        }
    }
    sort($output_array);
    return $output_array;
}
         } else {
             $course_count = 0;
         }
         $child_objectives[$i]["course_count"] = $course_count;
         if ($PROCESSED["count"] == 1 || $PROCESSED["count"] == 3) {
             $event_count = array_sum(count_objective_child_events($child["objective_id"], $SEARCH_DURATION["start"], $SEARCH_DURATION["end"], $PROCESSED["course_id"], $PROCESSED["group_id"]));
         } else {
             $event_count = 0;
         }
         $child_objectives[$i]["event_count"] = $event_count;
         $i++;
     }
 }
 $objective_parents = fetch_objective_parents($PROCESSED["objective_parent"]);
 if ($objective_parents) {
     $flattened_objectives = flatten_array($objective_parents);
     for ($i = 0; $i <= count($flattened_objectives); $i++) {
         if ($i % 2 == 0 && (!empty($flattened_objectives[$i]) && ($flattened_objectives[$i] != $PROCESSED["objective_parent"] || count($objective_parents) == 2))) {
             $o_breadcrumb[] = "<a class=\"objective-link\" href=\"" . ENTRADA_RELATIVE . "/curriculum/explorer?objective_parent=" . ($flattened_objectives[$i + 2] ? $flattened_objectives[$i + 2] : 0) . "&id=" . $flattened_objectives[$i] . "&step=2\" data-id=\"" . $flattened_objectives[$i] . "\">" . $flattened_objectives[$i + 1] . "</a>";
         } else {
             if ($i % 2 == 0) {
                 $o_breadcrumb[] = $flattened_objectives[$i + 1];
             }
         }
     }
     if ($o_breadcrumb) {
         $breadcrumb = implode(" / ", array_reverse($o_breadcrumb));
     } else {
         $breadcrumb = null;
     }
 }
Example #10
0
<script>
	$(function() {
		dbFields = <?php 
echo json_encode(flatten_array($table_fields));
?>
;
		$("#dimension-ts_min_start").datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'hh:mm:ss' });
		$("#dimension-ts_min_end").datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'hh:mm:ss' });
		$("#fact-first_seen").datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'hh:mm:ss' });
		$(".typeahead").typeahead({ source: dbFields, items: 8});
		$('.combobox').combobox();
		prettyPrint();
	});
</script>

<div class="row">
	<form action="<?php 
echo site_url() . "?action=report";
?>
" method="GET" class="form-inline">
	<input type="hidden" name="action" value="report">
	<input type="hidden" name="datasource" value="<?php 
echo $datasource;
?>
">
	<div class="row">
		<div class="span3">
			From<br>
			<div class="input-append">
				<input type="text" class="span2" name="dimension-<?php 
echo $time_field_name;
Example #11
0
function flatten_array($array, &$result_keys, &$result_values, $key_str = "")
{
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            if (strlen($key_str) > 0) {
                flatten_array($value, $result_keys, $result_values, "{$key_str}[{$key}]");
            } else {
                flatten_array($value, $result_keys, $result_values, $key);
            }
        } else {
            if (strlen($key_str) > 0) {
                $result_keys[] = "{$key_str}[{$key}]";
                $result_values[] = $value;
            } else {
                $result_keys[] = $key;
                $result_values[] = $value;
            }
        }
    }
}
Example #12
0
function form_input_hidden_array($array)
{
    if (!is_array($array)) {
        return false;
    }
    $array_keys = array();
    $array_values = array();
    flatten_array($array, $array_keys, $array_values);
    $result_var = "";
    foreach ($array_keys as $key => $key_name) {
        if ($key_name != 'webtag' && isset($array_values[$key])) {
            $result_var .= form_input_hidden(htmlentities_array($key_name), htmlentities_array($array_values[$key]));
        }
    }
    return $result_var;
}
 /**
  * Get list of installed directories from db for easy pre-install check.
  */
 protected function dbCheckDirs()
 {
     $result = $this->db->get('theme_list', null, 'directory');
     flatten_array($result);
     $this->dbDirList = $result;
 }
if (!empty($locale['setup_3210'])) {
    dbquery("UPDATE " . DB_LANGUAGE_TABLES . " SET mlt_title='" . $locale['setup_3210'] . "' WHERE mlt_rights='SL'");
}
if (!empty($locale['setup_3208'])) {
    dbquery("UPDATE " . DB_LANGUAGE_TABLES . " SET mlt_title='" . $locale['setup_3208'] . "' WHERE mlt_rights='ET'");
}
if (!empty($locale['setup_3211'])) {
    dbquery("UPDATE " . DB_LANGUAGE_TABLES . " SET mlt_title='" . $locale['setup_3211'] . "' WHERE mlt_rights='PN'");
}
$inf_result = dbquery("SELECT * FROM " . DB_INFUSIONS);
if (dbrows($inf_result) > 0) {
    while ($cdata = dbarray($inf_result)) {
        include INFUSIONS . $cdata['inf_folder'] . "/infusion.php";
        // there is a system language inside. // cant read into system language.
        if (isset($inf_mlt) && is_array($inf_mlt)) {
            $inf_mlt = flatten_array($inf_mlt);
            if (!empty($inf_mlt['title']) && !empty($inf_mlt['rights'])) {
                dbquery("UPDATE " . DB_LANGUAGE_TABLES . " SET mlt_title='" . $inf_mlt['title'] . "' WHERE mlt_rights='" . $inf_mlt['rights'] . "'");
            } else {
                //$defender->stop();
                addNotice("danger", "Error due to incomplete locale translations in infusions folder " . $cdata['inf_folder'] . ". This infusion does not have the localized title and change is aborted. Please translate setup.php.");
            }
        }
        unset($inf_mlt);
    }
}
add_breadcrumb(array('link' => ADMIN . "settings_languages.php" . $aidlink, 'title' => $locale['682ML']));
if (isset($_POST['savesettings'])) {
    $inputData = array("localeset" => form_sanitizer($_POST['localeset'], fusion_get_settings('locale'), "localeset"), "old_localeset" => form_sanitizer($_POST['old_localeset'], fusion_get_settings('locale'), "old_localeset"), "enabled_languages" => isset($_POST['enabled_languages']) ? form_sanitizer($_POST['enabled_languages'], "", "enabled_languages") : fusion_get_settings('locale'), "old_enabled_languages" => form_sanitizer($_POST['old_enabled_languages'], "", "old_enabled_languages"));
    // format both to .
    if (empty($inputData['enabled_languages'])) {
Example #15
0
function flatten_array($array, $preserve_keys = 2, &$out = array(), &$last_subarray_found)
{
    foreach ($array as $key => $child) {
        if (is_array($child)) {
            $last_subarray_found = $key;
            $out = flatten_array($child, $preserve_keys, $out, $last_subarray_found);
        } elseif ($preserve_keys + is_string($key) > 1) {
            if ($last_subarray_found) {
                $sfinal_key_value = $last_subarray_found . "_" . $key;
                //$sfinal_key_value = $key;
            } else {
                $sfinal_key_value = $key;
            }
            $out[$sfinal_key_value] = $child;
        } else {
            $out[] = $child;
        }
    }
    return $out;
}
function flatten_array($array, $preserve_keys = 0, &$out = array())
{
    if ($array) {
        foreach ($array as $key => $child) {
            if (is_array($child)) {
                $out = flatten_array($child, $preserve_keys, $out);
            } elseif ($preserve_keys + is_string($key) > 1) {
                $out[$key] = $child;
            } else {
                $out[] = $child;
            }
        }
    }
    return $out;
}
Example #17
0
function wtk_classes($classes)
{
    $args = func_get_args();
    $classes = flatten_array($args);
    wtk_attr('class', implode(' ', $classes));
}
Example #18
0
 public function log_user_action($db, $primary_key)
 {
     if (\defender::safe()) {
         $output_fields = array();
         $field = flatten_array($this->fields);
         $output_fields[$db] = $this->callback_data;
         foreach ($field as $arr => $field_data) {
             $target_database = $field_data['field_cat_db'] ? DB_PREFIX . $field_data['field_cat_db'] : $db;
             $col_name = $field_data['field_cat_index'] ? $field_data['field_cat_index'] : $primary_key;
             $index_value = isset($_POST[$col_name]) ? form_sanitizer($_POST[$col_name], 0) : '';
             if ($field_data['field_log'] == TRUE && isset($this->callback_data[$field_data['field_name']]) && isset($this->output_fields[$target_database][$field_data['field_name']]) && $this->callback_data[$field_data['field_name']] !== $this->output_fields[$target_database][$field_data['field_name']]) {
                 //print_p($this->callback_data[$field_data['field_name']]." => ".$this->output_fields[$target_database][$field_data['field_name']]);
                 save_user_log($index_value, $field_data['field_name'], $this->output_fields[$target_database][$field_data['field_name']], $this->callback_data[$field_data['field_name']]);
             }
             //print_p($field_data);
             //print_p($this->output_fields);
             // nothing to return
         }
     }
 }
function flatten_array($array)
{
    if (!is_array($array)) {
        // nothing to do if it's not an array
        return array($array);
    }
    $result = array();
    foreach ($array as $value) {
        // explode the sub-array, and add the parts
        $result = array_merge($result, flatten_array($value));
    }
    return $result;
}
    $acr = $last_settings['last_acronym'];
    $metadata_provider_arr = array(node_load($last_settings['last_metadata_provider_ref']));
    $publisher_arr = array(node_load($last_settings['last_publisher_ref']));
    $views_bonus_eml_site_name = variable_get('site_name', NULL);
    /* -----------------
     * 2) calculate vid version
     * ---------------------
     */
    $ver_vid = $dataset_node['dataset']->vid;
    //  persons and sites vid
    foreach ($dataset_reference_names as $ref) {
        if (isset($dataset_node[$ref][0])) {
            foreach ($dataset_node[$ref] as $person_site) {
                if (isset($person_site->vid)) {
                    $ver_vid += $person_site->vid;
                }
            }
        }
    }
    // vid of datafiles + variables + datafile_sites
    $flatten_files = flatten_array($dataset_node['dataset_datafiles']);
    if ($flatten_files) {
        foreach ($flatten_files as $object_value) {
            if (isset($object_value->vid)) {
                $ver_vid += $object_value->vid;
            }
        }
    }
    $package_id = 'knb-lter-' . $acr . '.' . $dataset_id[0]['value'] . '.' . $ver_vid;
    $realNumber = 'real';
}
Example #21
0
 public function testException()
 {
     $this->setExpectedException('Exception', 'Argument 1 must be an array');
     $in = null;
     flatten_array($in);
 }
Example #22
0
function flatten_array($array, $preserve_keys = 0, &$out = array())
{
    # Flatten a multidimensional array to one dimension, optionally preserving keys.
    #
    # $array - the array to flatten
    # $preserve_keys - 0 (default) to not preserve keys, 1 to preserve string keys only, 2 to preserve all keys
    # $out - internal use argument for recursion
    foreach ($array as $key => $child) {
        if (is_array($child)) {
            $out = flatten_array($child, $preserve_keys, $out);
        } elseif ($preserve_keys + is_string($key) > 1) {
            $out[$key] = $child;
        } else {
            $out[] = $child;
        }
    }
    return $out;
}