Ejemplo n.º 1
0
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access
defined('_HZEXEC_') or die;
//Html::behavior('chart');
//Html::behavior('chart', 'resize');
$this->css();
$this->js('flot/jquery.colorhelpers.min.js', 'system')->js('jquery.flot.min.js')->js('jquery.flot.time.min.js')->js('jquery.flot.resize.min.js')->js('jquery.flot.canvas.min.js')->js('flot/jquery.flot.tooltip.min.js', 'system')->js('jquery.flot.selection.min.js')->js('base64.js')->js('canvas2image.js')->js('jquery.flot.saveAsImage.js');
$db = Components\Usage\Helpers\Helper::getUDBO();
$datetime = $this->datetime;
$period = $this->period;
if ($this->message) {
    ?>
	<p class="info"><?php 
    echo nl2br($this->message);
    ?>
</p>
<?php 
}
?>

<nav class="time-periods">
	<ul>
		<li<?php 
Ejemplo n.º 2
0
 /**
  * Get data for orgs, countries, domains for a given time period
  * (1 = country, 2 = domain, 3 = org)
  *
  * @return  void
  */
 public function getUsageForDate()
 {
     $period = $this->periodToInt(Request::getVar('period', $this->params->get('period', 'prior12')));
     $datetime = Request::getVar('datetime', date("Y") . '-' . date("m")) . '-00 00:00:00';
     $db = Components\Usage\Helpers\Helper::getUDBO();
     $sql = "SELECT value, valfmt\n\t\t\t\tFROM `summary_user_vals`\n\t\t\t\tWHERE rowid=" . $db->quote(1) . " AND period=" . $db->quote($period) . " AND datetime=" . $db->quote($datetime) . "\n\t\t\t\tORDER BY colid";
     $db->setQuery($sql);
     $results = $db->loadObjectList();
     $res_iden = 1;
     $org_iden = 1;
     $i = 0;
     $highest = 1;
     foreach ($results as $row) {
         $i++;
         if ($i == 2) {
             $highest = $row->value;
         }
         if ($i == 7) {
             $highest = $row->value;
         }
         if ($row->valfmt == 2 && $highest > 100) {
             $row->value = number_format($row->value / $highest * 100);
         }
         switch ($i) {
             case 3:
                 $residence[] = array('column' => 'US', 'value' => $row->value, 'key' => 'users-visits-res-us');
                 break;
             case 4:
                 $residence[] = array('column' => 'Asia', 'value' => $row->value, 'key' => 'users-visits-res-asia');
                 break;
             case 5:
                 $residence[] = array('column' => 'Europe', 'value' => $row->value, 'key' => 'users-visits-res-europe');
                 break;
             case 6:
                 $residence[] = array('column' => 'Other', 'value' => $row->value, 'key' => 'users-visits-res-other');
                 break;
             case 8:
                 $organization[] = array('column' => 'Education', 'value' => $row->value, 'key' => 'users-visits-org-education');
                 break;
             case 9:
                 $organization[] = array('column' => 'Industry', 'value' => $row->value, 'key' => 'users-visits-org-industry');
                 break;
             case 10:
                 $organization[] = array('column' => 'Government', 'value' => $row->value, 'key' => 'users-visits-org-government');
                 break;
             case 11:
                 $organization[] = array('column' => 'Other', 'value' => $row->value, 'key' => 'users-visits-org-other');
                 break;
                 break;
             default:
                 break;
         }
     }
     $sql = "SELECT value\n\t\t\tFROM `summary_user_vals`\n\t\t\tWHERE rowid=" . $db->quote(1) . " AND period=" . $db->quote($period) . " AND datetime=" . $db->quote($datetime) . " AND colid=" . $db->quote(1) . "\n\t\t\tORDER BY datetime ASC";
     $db->setQuery($sql);
     $result = $db->loadResult();
     $data = new stdClass();
     $data->visits = new stdClass();
     $data->visits->total = number_format($result);
     $data->visits->residence = $residence;
     $data->visits->organization = $organization;
     $sql = "SELECT value, valfmt\n\t\t\t\tFROM `summary_user_vals`\n\t\t\t\tWHERE rowid=" . $db->quote(4) . " AND period=" . $db->quote($period) . " AND datetime=" . $db->quote($datetime) . "\n\t\t\t\tORDER BY colid";
     $db->setQuery($sql);
     $results = $db->loadObjectList();
     $res_iden = 1;
     $org_iden = 1;
     $i = 0;
     $highest = 1;
     foreach ($results as $row) {
         $i++;
         if ($i == 2) {
             $highest = $row->value;
         }
         if ($i == 7) {
             $highest = $row->value;
         }
         if ($row->valfmt == 2 && $highest > 100) {
             $row->value = number_format($row->value / $highest * 100);
         }
         switch ($i) {
             case 3:
                 $residence[] = array('column' => 'US', 'value' => $row->value, 'key' => 'users-downloads-res-us');
                 break;
             case 4:
                 $residence[] = array('column' => 'Asia', 'value' => $row->value, 'key' => 'users-downloads-res-asia');
                 break;
             case 5:
                 $residence[] = array('column' => 'Europe', 'value' => $row->value, 'key' => 'users-downloads-res-europe');
                 break;
             case 6:
                 $residence[] = array('column' => 'Other', 'value' => $row->value, 'key' => 'users-downloads-res-other');
                 break;
             case 8:
                 $organization[] = array('column' => 'Education', 'value' => $row->value, 'key' => 'users-downloads-org-education');
                 break;
             case 9:
                 $organization[] = array('column' => 'Industry', 'value' => $row->value, 'key' => 'users-downloads-org-industry');
                 break;
             case 10:
                 $organization[] = array('column' => 'Government', 'value' => $row->value, 'key' => 'users-downloads-org-government');
                 break;
             case 11:
                 $organization[] = array('column' => 'Other', 'value' => $row->value, 'key' => 'users-downloads-org-other');
                 break;
                 break;
             default:
                 break;
         }
     }
     $sql = "SELECT value\n\t\t\tFROM `summary_user_vals`\n\t\t\tWHERE rowid=" . $db->quote(4) . " AND period=" . $db->quote($period) . " AND datetime=" . $db->quote($datetime) . " AND colid=" . $db->quote(1) . "\n\t\t\tORDER BY datetime ASC";
     $db->setQuery($sql);
     $result = $db->loadResult();
     $data->downloads = new stdClass();
     $data->downloads->total = number_format($result);
     $data->downloads->residence = $residence;
     $data->downloads->organization = $organization;
     $db->setQuery("SELECT value\n\t\t\tFROM `summary_simusage_vals`\n\t\t\tWHERE `period` = " . $db->quote($period) . "\n\t\t\tAND `rowid`= " . $db->quote(1) . "\n\t\t\tAND `datetime`=" . $db->quote($datetime) . "\n\t\t\tORDER BY `datetime` ASC");
     $data->simulation_users = number_format($db->loadResult());
     $db->setQuery("SELECT value\n\t\t\tFROM `summary_simusage_vals`\n\t\t\tWHERE `period` = " . $db->quote($period) . "\n\t\t\tAND `rowid`= " . $db->quote(2) . "\n\t\t\tAND `datetime`=" . $db->quote($datetime) . "\n\t\t\tORDER BY `datetime` ASC");
     $data->simulation_jobs = number_format($db->loadResult());
     $db->setQuery("SELECT a.label,b.value,b.valfmt,a.plot,a.id\n\t\t\tFROM `summary_simusage` AS a\n\t\t\tINNER JOIN `summary_simusage_vals` AS b\n\t\t\tWHERE a.id=b.rowid AND b.period = " . $db->quote($period) . " AND b.datetime = " . $db->quote($datetime) . " AND a.id > 2\n\t\t\tORDER BY a.id");
     $data->simulation = $db->loadObjectList();
     foreach ($data->simulation as $key => $sim) {
         $sim->key = 'simulation-' . preg_replace('/[^a-z0-9\\-_]/', '', strtolower($sim->label));
         $sim->value = self::formatValue($sim->value, $sim->valfmt);
         $data->simulation[$key] = $sim;
     }
     //ob_clean();
     echo json_encode($data);
     die;
 }