/** * * * @since 1.4 */ public function dashboardCanRenderStats($dashboard, $form_index) { $render = false; $this->dashboardIsRendering = true; if ($is_google_form = $form_index == 0) { $context = 'stats_xml'; $render = $this->db->xmlEnabled(); } else { $context = 'stats_html5'; if (!$this->formConfigMode) { $render = $this->db->html5Enabled(); } } if (!$render) { return false; } $date_stat = (int) $this->db->getOption('date', 0, $context); $class = time() - $date_stat < 11 ? 'sitetree-new-stat' : ''; if ($is_google_form) { $url_stat = (int) $this->db->getOption('url_count', 0, $context); if ($url_stat == 10000) { $url_stat = '<div class="sitetree-stat-limit">' . $url_stat . '<div class="sitetree-stat-limit-msg">' . 'Remarkable! Your Sitemap has as many links as each neuron in your brain has!<br>' . "Unfortunately, I'm not as much complex at this time, thus, I can't add more URLs.<br>" . "However, don't be upset … I'm growing like a bamboo."; $url_stat .= '</div></div>'; } $dashboard->registerStat(__('URLs', 'sitetree'), $url_stat, $class); if ($this->db->getOption('images', true)) { $dashboard->registerStat(__('Images', 'sitetree'), (int) $this->db->getOption('num_images', 0, $context), $class); } } else { $items_stat = (int) $this->db->getOption('url_count', 0, $context); if ($items_stat === $this->db->getOption('items_limit', 200)) { $items_stat = '<div class="sitetree-stat-limit">' . $items_stat . '<div class="sitetree-stat-limit-msg">'; $items_stat .= __('Beware! Your Archive is about to explode: the limit set in the ' . '“Under the Hood” section has been reached.', 'sitetree'); $items_stat .= '</div></div>'; } $dashboard->registerStat(__('Items', 'sitetree'), $items_stat, $class); } $dashboard->registerStat(__('Queries', 'sitetree'), (int) $this->db->getOption('num_queries', 0, $context), $class); $dashboard->registerStat(__('Rebuild Time', 'sitetree'), (double) $this->db->getOption('runtime', 0, $context) . 's', $class); $dashboard->registerStat(__('Rebuilt on', 'sitetree'), SiteTreeUtilities::localDate($date_stat), $class); return true; }
/** * Helper method: it pushes a new status element into the @see $pingInfo['stati'] array. * * @see getPingInfo() * @since 1.5 * * @param string $message * @param int $timestamp * @param bool $can_be_cancelled */ private function enqueueStatus($message, $timestamp = null, $can_be_cancelled = false) { // Checking $timestamp against 'null' forces the date-formatting block // to be executed even if $timestamp is zero. So, if an error occurs, no %s is displayed. if ($timestamp !== null) { if ($can_be_cancelled) { $message = sprintf($message, '<strong>' . SiteTreeUtilities::localDate($timestamp) . '</strong>'); } else { $message = sprintf($message, '<em>' . SiteTreeUtilities::localDate($timestamp) . '</em>'); } } $this->pingInfo['stati'][] = array('can_be_cancelled' => $can_be_cancelled, 'message' => $message); }