public function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $uniquesTable = $input->getArgument('uniques'); $removalsTable = $input->getArgument('removes'); $columns = explode(':', $input->getArgument('columns')); $fillerMode = (bool) $input->getOption('fillerMode'); $this->info('Adding new ids to removes table...'); $affectedRows = $this->insertNewIdsToRemovesTable($uniquesTable, $removalsTable, $columns, $fillerMode); $this->feedback('Linked ' . pretty($affectedRows) . ' records on new_id in ' . $removalsTable); }
function pretty($arr, $level = 0) { $tabs = ""; for ($i = 0; $i < $level; $i++) { $tabs .= " "; } foreach ($arr as $key => $val) { if (is_array($val)) { print_r($tabs . $key . " : " . ">" . "<br />"); pretty($val, $level + 1); } else { if ($val && $val !== 0) { print_r($tabs . $key . " " . $val . ">" . "<br />"); } } } }
protected function reverseRemap($remapTable, $removesTable, $foreignKey, $startId) { $totalAffectedRows = 0; $totalRows = $this->pdo->getTotalRows($removesTable); $i = is_null($this->db->table($remapTable)->find($startId)) ? $this->db->table($remapTable)->min('id') : $startId; while (is_int($i)) { $remapRow = keysToLower($this->db->table($remapTable)->find($i)); $remapRowFk = $remapRow[$foreignKey]; if (!is_null($remapRowFk)) { $newId = $this->db->table($removesTable)->find($remapRowFk)['new_id']; if (!is_null($newId)) { $affectedRows = $this->db->table($remapTable)->where('id', $i)->update([$foreignKey => $newId]); $totalAffectedRows += $affectedRows; $this->feedback('Remapped ' . pretty($totalAffectedRows) . ' rows'); } else { $this->feedback($removesTable . '.' . $foreignKey . ' was null. continuing...'); } } else { $this->feedback($remapTable . '.' . $foreignKey . ' was null. continuing...'); } $i = $this->pdo->getNextId($i, $remapTable); } return $totalAffectedRows; }
public function execute(InputInterface $input, OutputInterface $output) { $this->output = $output; $originalTable = $input->getArgument('originalTable'); $uniquesTable = $originalTable . '_uniques'; $removalsTable = $originalTable . '_removes'; $columns = explode(':', $input->getArgument('columns')); $firstRun = !$this->pdo->tableExists($uniquesTable); $this->info('Counting duplicate rows...'); if ($firstRun) { $dupes = $this->pdo->getDuplicateRowCount($originalTable, $columns); } else { $dupes = $this->pdo->getDuplicateRowCount($uniquesTable, $columns); } if ($dupes === 0) { $this->feedback('There are no duplicates using columns: ' . commaSeperate($columns)); die; } else { $undedupedTable = $firstRun ? $originalTable : $uniquesTable; $this->feedback('There are ' . pretty($dupes) . ' dupes in ' . $undedupedTable . ' on ' . commaSeperate($columns)); } if ($firstRun) { $this->info('Creating uniques table: ' . $uniquesTable); $this->pdo->statement('CREATE TABLE ' . $uniquesTable . ' LIKE ' . $originalTable); $this->feedback('Created uniques table'); if (!$this->pdo->indexExists($originalTable, implode('_', $columns))) { $this->info('Creating comp index on ' . $originalTable . ' on ' . commaSeperate($columns) . ' to speed process...'); $this->pdo->createCompositeIndex($originalTable, $columns); $this->feedback('Created composite index on ' . $originalTable); } $this->info('Creating removals table: ' . $removalsTable); $this->pdo->statement('CREATE TABLE ' . $removalsTable . ' LIKE ' . $originalTable); $this->feedback('Created removals table'); $this->info('Adding new_id field to ' . $removalsTable . ' to store the id from ' . $uniquesTable . '...'); $this->pdo->addIntegerColumn($removalsTable, 'new_id'); $this->feedback('Added new_id field to ' . $removalsTable); } else { $this->info('Creating temp_uniques table...'); $tempTable = 'temp_uniques'; $this->pdo->statement('CREATE TEMPORARY TABLE ' . $tempTable . ' LIKE ' . $uniquesTable); $this->feedback('Created temporary table: ' . $tempTable); } if (!$this->pdo->indexExists($uniquesTable, implode('_', $columns))) { $this->info('Creating comp index on ' . $uniquesTable . ' on ' . commaSeperate($columns) . ' to speed process...'); $this->pdo->createCompositeIndex($uniquesTable, $columns); $this->feedback('Created composite index on ' . $uniquesTable); } $dedupedTable = $firstRun ? $uniquesTable : $tempTable; $this->info('Inserting current unique rows on ' . $undedupedTable . ' to ' . $dedupedTable . '...'); $affectedRows = $this->insertUniquesToTable($undedupedTable, $dedupedTable, $columns); $this->feedback('Inserted ' . pretty($affectedRows) . ' unique rows from ' . $undedupedTable . ' to ' . $dedupedTable); $this->info('Inserting duplicate rows to ' . $removalsTable . '...'); $affectedRows = $this->insertDuplicatesToRemovalsTable($undedupedTable, $dedupedTable, $removalsTable); $this->feedback('Inserted ' . pretty($affectedRows) . ' duplicates to ' . $removalsTable); if (!$this->pdo->indexExists($removalsTable, implode('_', $columns))) { $this->info('Adding comp index to ' . $removalsTable . ' on ' . commaSeperate($columns) . ' to speed process...'); $this->pdo->createCompositeIndex($removalsTable, $columns); $this->feedback('Added composite index for ' . $removalsTable); } if (!$firstRun) { $this->info('Deleting duplicate rows in ' . $uniquesTable . '...'); $affectedRows = $this->deleteDuplicatesFromUniquesTable($uniquesTable, $removalsTable); $this->feedback('Deleted ' . pretty($affectedRows) . ' rows ' . $removalsTable); } }
function event_column_select() { global $wpdb; global $pagenow; if (is_admin() && $_GET['post_type'] == 'event' && $pagenow == 'edit.php') { $event_types = array('iscp-talk', 'exhibition', 'open-studios', 'event', 'off-site-project'); echo '<select name="event_type">'; echo '<option value="">' . __('Event Type', 'textdomain') . '</option>'; foreach ($event_types as $value) { $selected = !empty($_GET['event_type']) && $_GET['event_type'] == $value ? 'selected="selected"' : ''; echo '<option ' . $selected . 'value="' . $value . '">' . pretty($value) . '</option>'; } echo '</select>'; } }
function pretty_all($array) { //prepare an array of text messages for tidy display as HTML foreach ($array as $key => $val) { $array[$key] = pretty($val); } return $array; }
function out($data, $pretty = true) { $json = json_encode($data); echo $pretty ? pretty($json) : $json; }
/** * Parses an exception into a content type * @access public * @param Exception $e The exception to parse * @param string $contentType The type of content to return * @param string $recoverer The recoverer used to recover from the exception * @return string A parsed verion of the exception as the supplied content type */ public static function parse(Exception $e, $contentType = self::HTML, $recoverer = null) { $out = ''; switch ($contentType) { default: case self::PLAINTEXT: $out .= sfl('###### ATSUMI has caught an Exception : %s', date(DATE_ATOM)); $out .= sfl("\n" . ' >> %s <<', $e->getMessage()); $out .= sfl("\n" . 'Exception type: %s', get_class($e)); if ($e instanceof ErrorException) { $out .= sfl("\n" . 'Severity level: ' . $e->getSeverity()); } $out .= sfl("\n" . '%s #%s', $e->getFile(), $e->getLine()); /* Show the request URL if avalable */ if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_HOST', $_SERVER) && array_key_exists('REQUEST_URI', $_SERVER)) { $out .= sfl("\nRequest: http://%s", $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } /* Show the referer URL if avalable */ if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_REFERER', $_SERVER)) { $out .= sfl("\nReferer: %s", $_SERVER['HTTP_REFERER']); } if (!is_null($recoverer)) { $out .= sfl("\n" . 'Recoverer: %s()', is_object($recoverer) ? get_class($recoverer) : $recoverer); $out .= sfl('Recoverer action: %s', $recoverer->getActionDetails()); } if (isset($e->details) && !is_null($e->details)) { $out .= sfl("\n" . '-Additional Detail'); $out .= sfl('%s', pretty($e->details)); } if ($e instanceof atsumi_AbstractException) { $out .= sfl("\n" . '-How to resolve this issue'); $out .= sfl($e->getInstructions('text/plain')); } $out .= sfl("\n" . '-Stack Trace'); $out .= sfl('%s', atsumi_ErrorParser::formatTrace($e->getTrace())); $out .= sfl('###### End of Exception ' . "\n\n"); break; case 'text/html': $out .= sfl(self::getHtmlCss()); $out .= sfl('<div class="atsumiError">'); $out .= sfl('<h3><strong>ATSUMI</strong> has caught an Exception : <strong>%s</strong></h3>', date(DATE_ATOM)); $out .= sfl('<h1>%s</h1>', $e->getMessage()); $out .= sfl('<h4>Exception type: <strong>%s</strong></h4>', get_class($e)); if ($e instanceof ErrorException) { $out .= sfl('<h4>Severity level: <strong>%s</strong></h4>', $e->getSeverity()); } $out .= sfl('<h2>%s #<strong>%s</strong></h2>', preg_replace('|\\/([a-zA-Z0-9\\-\\_\\.]+\\.php)|', '/<strong>\\1</strong>', htmlentities($e->getFile())), $e->getLine()); /* Show the request URL if avalable */ if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_HOST', $_SERVER) && array_key_exists('REQUEST_URI', $_SERVER)) { $out .= sfl("<h4>Request: <strong><a href='http://%s'>http://%s</a></strong></h4>", $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } /* Show the referer URL if avalable */ if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_REFERER', $_SERVER)) { $out .= sfl("<h4>Referer: <strong><a href='%s'>%s</a></strong></h4>", $_SERVER['HTTP_REFERER'], $_SERVER['HTTP_REFERER']); } if (!is_null($recoverer)) { $out .= sfl('<h4>Recoverer: <strong>%s()</strong></h4>', is_object($recoverer) ? get_class($recoverer) : $recoverer); $out .= sfl('<h4>Recoverer action: <strong>%s</strong></h4>', $recoverer->getActionDetails()); } if (isset($e->details) && !is_null($e->details)) { $out .= sfl('<br /><h3>Additional Detail</h3>'); $out .= sfl('<div class="atsumiDetailsContainer"><pre>%s</pre></div>', pretty($e->details)); } if ($e instanceof atsumi_AbstractException) { $out .= sfl('<br /><h3><strong>ATSUMI</strong>: How to resolve this issue</h3>'); $out .= sfl('<div class="atsumiDetailsContainer">%s</div>', $e->getInstructions('text/html')); } $out .= sfl('<br /><h4>Stack Trace</h4>'); $out .= sfl('<div class="atsumiDetailsContainer"><pre>%s</pre></div>', atsumi_ErrorParser::formatTrace($e->getTrace(), 'text/html')); $out .= sfl('</div>'); break; } return $out; }
$remove[$merge_start][] = $time; $average[$merge_start] = ($merge_start + array_sum($remove[$merge_start])) / (count($remove[$merge_start]) + 1); continue; } else { $merge_start = $time; continue; } } // make sure we convert back to date('Y-m-d H:i:s',$time); // delete $remove[]; // update $average; if (!empty($remove)) { echo join("\n", $times) . "\n"; } foreach ($remove as $mt => $times) { foreach ($times as $t) { $t = pretty($t); echo "Removing {$t}\n"; $db->query("delete from trends where tag_id={$id} and woeid={$woeid} and time='{$t}'"); } $pmt = pretty($mt); $pav = pretty($average[$mt]); echo "Moving {$pmt} to {$pav}\n"; $db->query("update trends set time='{$pav}' where time='{$pmt}' and tag_id={$id} and woeid={$woeid}"); } } } function pretty($time) { return date('Y-m-d H:i:s', $time); }
/** * Appends a html representation of the data to a log file * @access protected * @param mixed $data The data to log */ protected function appendLogFile($data) { $fp = fopen($this->fileLogPath, 'a'); fwrite($fp, pretty($data) . PHP_EOL); fclose($fp); }
<?php $title = get_post($post)->post_title; $slug = get_post($post)->post_name; $id = get_post($post)->ID; $today = new DateTime(); $today = $today->format('Ymd'); $event_classes = $event_type_param . ' ' . $year_param; $page_url = get_the_permalink(); $delay = $post->delay; $paged = 1; if ($query_vars) { $slug = $query_vars['pagename']; $paged = $query_vars['paged']; $event_type_param = $query_vars['type']; $year_param = $query_vars['date']; $upcoming_ids = $query_vars['upcoming_ids']; $post = get_page_by_path($slug, OBJECT, 'page'); $events_section = $query_vars['events_section']; $page_param = $slug; } else { $event_type_param = get_query_var('type'); $year_param = get_query_var('date'); } $event_type_param_title = pretty($event_type_param);
$First = false; $Str = "<TABLE cellpadding=2>"; $Str .= "<TR><TH align-left>" . pretty($Key) . "</TH>"; foreach ($before as $header) { $Str .= "<TH align=right>" . pretty($header[$Key]) . "</TH>"; } $Str .= "<TH align=right>" . pretty($Value) . "</TH>"; foreach ($after as $footer) { $Str .= "<TH align=right>" . pretty($footer[$Key]) . "</TH>"; } $Str .= "</TR>"; } else { // same as first except no TABLE and TH replaced by TR $Str .= "<TR><TD align-left>" . pretty($Key) . "</TD>"; foreach ($before as $header) { $Str .= "<TD align=right>" . pretty($header[$Key]) . "</TD>"; } $Str .= "<TD align=right>" . pretty($Value) . "</TD>"; foreach ($after as $footer) { $Str .= "<TD align=right>" . pretty($footer[$Key]) . "</TD>"; } $Str .= "</TR>"; } } $Str .= "</TABLE>"; echo "<HR>{$Str}<HR>"; // show on web page $Mail[$Values['email']] = $Str; // save for session variable } $_SESSION['Mail'] = $Mail;
$table["rdf:type (ignored)"] = $rdftype; $table["owlproperty (ignored)"] = $owlproperty; $table["classes (ignored)"] = count($classes); $table["Objects"] = $resourceobjects; $table["Triples"] = $triples; $table["Triples_with_Object_ratio"] = pretty($resourceobjects, $triples); $table["unique_subjects"] = count($uniquesubjects); $table["subsAreObjects"] = count($subsAreObjects); $table["subsAreObjectsRatio"] = pretty(count($subsAreObjects), count($uniquesubjects)); $table["avg_indegree_subjects"] = avg($subsAreObjects); $table["avg_outdegree_subjects"] = avg($uniquesubjects); $table["unique_predicates"] = count($uniquepredicates); $table["avg_usage_predicates"] = avg($uniquepredicates); $table["unique_objects"] = count($uniqueobjects); $table["objsAreSubjects"] = count($objsAreSubjects); $table["objsAreSubjectsRatio"] = pretty(count($objsAreSubjects), count($uniqueobjects)); $table["avg_indegree_objects"] = avg($uniqueobjects); $table["avg_outdegree_objects"] = avg($objsAreSubjects); p($table); if ($detailed) { echo "classes\n"; detailed($classes); echo "predicates\n"; detailed($uniquepredicates); } } //foreach function detailed($arr) { foreach ($arr as $key => $value) { echo "{$key}\t{$value}\n";
function pretty($value, $prefix = '') { if (is_null($value)) { return 'null'; } if (is_string($value)) { return '\'' . str_replace(array('\'', "\n", "\r", "\t"), array('\\\'', '\\n', '\\r', '\\t'), $value) . '\''; } if (is_int($value)) { return (string) $value; } if (is_double($value)) { return (string) $value; } if (is_bool($value)) { return $value ? 'true' : 'false'; } if (is_array($value)) { $ret = 'array('; if (count($value) <= 0) { return $ret . ')'; } foreach ($value as $a => $b) { $ret .= "\n " . $prefix . pretty($a) . ': ' . pretty($b, ' ' . $prefix); } $ret .= "\n" . $prefix . ')'; return $ret; } if (is_object($value)) { $ret = ''; if (method_exists($value, 'toString')) { $ret = $value->toString(); } $ret = $ret . ' ' . get_class($value) . '('; if (method_exists($value, 'dumpDebug')) { $value = $value->dumpDebug(); } foreach ($value as $a => $b) { $ret .= "\n " . $prefix . $a . ': ' . pretty($b, ' ' . $prefix); } $ret .= "\n " . $prefix . ')'; return $ret; } return '?' . gettype($value) . '?'; }
} else { if ($method == "quec") { $data = getNumOfFeatures($map, $layer, $attribute); $breaks = quantile($data, $classes); $colors = getColors(hex2rgb($startColor), hex2rgb($endColor), count($breaks)); saveToMapFile($map, $layer, $attribute, $type, $breaks, $colors, $mapFile); } else { if ($method == "sd") { $data = getNumOfFeatures($map, $layer, $attribute); $breaks = standardDeviation($data, $classes); $colors = getColors(hex2rgb($startColor), hex2rgb($endColor), count($breaks)); saveToMapFile($map, $layer, $attribute, $type, $breaks, $colors, $mapFile); } else { if ($method == "pb") { $data = getNumOfFeatures($map, $layer, $attribute); $breaks = pretty($data, $classes); $colors = getColors(hex2rgb($startColor), hex2rgb($endColor), count($breaks)); saveToMapFile($map, $layer, $attribute, $type, $breaks, $colors, $mapFile); } } } } } } } } } else { if ($_POST["function"] == "updateStyles") { $mapFile = $_POST["mapFile"]; $layerName = $_POST["layerName"]; $data = json_decode($_POST["data"]);
* 1 - add cms level new tags * 2 - delete existing tag post association * 3 - add new tag post association * DONE */ //only add tags, //do not remove tags from CMS when there is no tag-post association // //trim spaces if (!empty($tagstring)) { $tagstring = str_replace(' ', '', $tagstring); //echo $tagstring ; $tags = explode(',', $tagstring); sort($tags); echo '<h2>identified tags from the form field</h2>'; pretty($tags); } add_cms_tags($tags); //now that we know which tags are sent from the form //attach them to the post //delete current tag_post association // remove_tag_post_association($id); add_tag_post_association($tags, $id); echo '<h2>======= END TAG SECTION ============</h2>'; //END OF METADATA PROCESSING //update the RSS Feed build_rss(); //update the sitemap build_sitemap(); echo "<meta http-equiv='refresh' content='" . $redir_delay . "; url={$tld2}/manage/write.php?id={$id}'>";
<div class="options"> <?php $event_types = array('exhibition', 'offsite-project', 'iscp-talk', 'open-studios', 'events'); foreach ($event_types as $event_type) { $event_type_count = get_event_count('type', $event_type); if ($event_type_count) { $filter_url = query_url('type', $event_type, $page_url); if ($event_type == $type_param) { $classes = 'selected '; } else { $classes = null; } $classes .= $event_type; echo '<div class="option ' . $classes . '">'; echo '<a href="' . $filter_url . '" data-value="' . $event_type . '">'; $event_type = pretty($event_type); echo $event_type; echo '<div class="swap">'; echo '<div class="icon default"></div>'; echo '<div class="icon hover"></div>'; echo '</div>'; echo '</a>'; echo '</div>'; } } ?> </div> </div> <div class="filter-list sub year <?php echo $slug;
$skip_first_partial_line = true; } } do { usleep($retry_microseconds); clearstatcache(); $stat = stat($datafile); $seek_position = $stat['size']; } while ($seek_position <= $get && $tries++ <= $maxtries && time() - $start_time < $max_poll_seconds - 1); $file = fopen($datafile, "r"); if ($file) { if (flock($file, LOCK_SH)) { fseek($file, $get, 0); // stream_select($read,$write,$except,1); $data = fread($file, $max_bytes_fistory); $seek_position = ftell($file); flock($file, LOCK_UN); } else { die("COULD NOT aquire shared lock."); } fclose($file); $data = pretty($data); if ($skip_first_partial_line) { $data = preg_replace('/^[^\\n]+/s', '', $data); } echo $seek_position . ";" . $data; exit; } else { die("ERRAR. Could not open {$datafile} for reading."); } }
<?php global $post; setup_postdata($post); $event_id = $post->ID; $event_status = get_event_status($event_id); $event_title = get_the_title($event_id); $event_url = get_permalink(); $event_type = get_field('event_type'); $event_type_name = pretty($event_type); $event_status = get_event_status($event_id); $event_date_format = get_event_date($event_id); $event_thumb = get_thumb($event_id, 'thumb'); $today = date('Ymd'); if (get_field('opening_reception', $event_id) >= $today) { $opening = new DateTime(get_field('opening_reception', $event_id)); $opening = $opening->format('M d, Y'); $opening_hours = get_field('opening_reception_hours', $event_id); if ($opening_hours) { $opening .= ', ' . $opening_hours; } } echo '<div class="event item shelf-item border-bottom ' . $event_status . '" data-id="' . $event_id . '">'; echo '<div class="inner">'; echo '<a class="wrap value date" href="' . $event_url . '">'; echo '<h2 class="link name title">' . $event_title . '</h2>'; echo '<div class="image">'; echo '<img src="' . $event_thumb . '"/>'; echo '</div>'; if ($opening) { echo '<div class="value date link">Opening Reception: ' . $opening . '</div>';
function renderBodyContent() { pfl('<pre>%s</pre>', stripslashes(pretty($this->get_output))); }
function __toString() { return pretty($this->output()); }
function verbosify($a, $b, $col, $form, $verbose) { #$result = ($a === $b); $result = strcmp($a, $b) == 0; if ($verbose) { $aa = pretty($a); $bb = pretty($b); $ok = $result ? "succeed" : " failed"; $eq = $result ? "==" : "!="; print " {$ok} {$form} c{$col} '{$aa}' {$eq} '{$bb}'\n"; } return $result; }
function toHTML($opts = false) { global $session_user; pretty($this); }