Example #1
0
 public function testAddEllipsis()
 {
     // Define test string
     $str = '1234567890';
     // Ensure it does not add '...' when string is short
     $this->assertTrue(MiscHelpers::addEllipsis($str, 10) == $str);
     // Ensure it does add '...' when string is long
     $this->assertTrue(MiscHelpers::addEllipsis($str, 5) == '12...');
 }
Example #2
0
 /**
  * Generates a crash report geographic location distribution graph for currently 
  * selected project and dumps it to stdout.
  * @param type $w Desired image width.
  * @param type $h Desired image height.
  * @throws CHttpException
  * @return void
  */
 public static function generateGeoLocationDistributionGraph($w, $h, $file = null)
 {
     if (!is_numeric($w) || $w <= 0 || $w > 1024) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     if (!is_numeric($h) || $h <= 0 || $h > 960) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Get current project info
     $curProjectId = Yii::app()->user->getCurProjectId();
     if ($curProjectId == false) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Prepare data
     $criteria = new CDbCriteria();
     $criteria->select = 'geo_location, COUNT(*) as cnt';
     $criteria->group = 'geo_location';
     $criteria->compare('t.project_id', $curProjectId);
     $criteria->order = 'cnt DESC';
     $curVer = '(not set)';
     $versions = Yii::app()->user->getCurProjectVersions($curVer);
     if ($curVer != -1) {
         $criteria->compare('appversion_id', $curVer == 0 ? null : $curVer);
     }
     $data = array();
     $models = CrashReport::model()->findAll($criteria);
     $totalCount = 0;
     foreach ($models as $model) {
         $totalCount += $model->cnt;
         if ($model->geo_location === null) {
             if (isset($data[''])) {
                 $data[''] += $model->cnt;
             } else {
                 $data[''] = $model->cnt;
             }
         } else {
             $data[$model->geo_location] = $model->cnt;
         }
     }
     if ($file == null) {
         $fout = fopen('php://output', 'w');
     } else {
         $fout = fopen($file, 'wt');
     }
     fprintf($fout, '<div class="digest-pane-image" style="width:' . $w . 'px;min-height:' . $h . 'px;max-height:' . $h . 'px;overflow:hidden"><table id="geo-locations">');
     // Check the case when $data is empty.
     if (count($data) == 0) {
         fprintf($fout, '<tr><td><i>No data available</i></td></tr>');
     } else {
         foreach ($data as $name => $val) {
             $percent = 100 * $val / $totalCount;
             $percentStr = sprintf('%0.1f', $percent);
             $nameStr = '(not set)';
             if ($name != '') {
                 $nameStr = MiscHelpers::addEllipsis(CrashReport::geoIdToCountryName($name), 30);
             }
             fprintf($fout, '<tr><td>' . $nameStr . '</td><td>' . $percentStr . '%%</td></tr>');
         }
     }
     fprintf($fout, '</table></div>');
     if ($file != null) {
         fclose($fout);
     }
 }
Example #3
0
	<div class="span-27 prepend-top">
		<div class="digest-pane">
		<div class="subheader" title="Displays top collections containing the majority of crash reports">Top Crash Collections</div>				
		<?php 
        $curProjectVer = Yii::app()->user->getCurProjectVer();
        $topCollections = Yii::app()->user->getCurProject()->getTopCrashGroups($curProjectVer);
        if (count($topCollections) == 0) {
            echo '<ul class="totals"><li>No data available<li></ul>';
        } else {
            echo '<ul id="top_collections">';
            $percentOfDiskQuota = 0;
            $curProjectVer = Yii::app()->user->getCurProjectVer();
            $reportCount = Yii::app()->user->getCurProject()->getCrashReportCount($totalFileSize, $percentOfDiskQuota, $curProjectVer);
            foreach ($topCollections as $collection) {
                $percent = sprintf("%.0f", $reportCount != 0 ? 100 * $collection->crashReportCount / $reportCount : 0);
                echo '<li>' . $collection->crashReportCount . ' reports (' . $percent . '%) in ' . CHtml::link(CHtml::encode(MiscHelpers::addEllipsis($collection->title, 110)), array('crashGroup/view', 'id' => $collection->id), array('class' => 'top-collection-title')) . '</li>';
            }
            echo '</ul>';
        }
        ?>
				
		</div>
	</div>
    	
	<?php 
    }
    ?>
	
	<?php 
    if (Yii::app()->user->checkAccess('pperm_browse_bugs', array('project_id' => Yii::app()->user->getCurProjectId()))) {
        ?>
Example #4
0
 
		by <?php 
echo CHtml::encode($model->user->username);
?>
 
		on <?php 
echo date('j F Y, G:i', $model->timestamp);
?>
	</div>
	
	<?php 
if (($model->flags & BugChange::FLAG_INITIAL_CHANGE) != 0) {
    echo '<div class="bug-change-comment">' . CHtml::encode(MiscHelpers::addEllipsis($model->bug->summary, 150)) . '</div>';
}
if ($model->comment != null) {
    echo '<div class="bug-change-comment">' . CHtml::encode(MiscHelpers::addEllipsis($model->comment->text, 150)) . '</div>';
}
if ($model->statuschange) {
    echo '<div class="bug-change-status bug-change-status-digest"><ul>';
    if (isset($model->statuschange->status)) {
        echo '<li>Status: ' . Lookup::item('BugStatus', $model->statuschange->status);
    }
    if (isset($model->statuschange->merged_into)) {
        echo '<li>Merged into bug: ' . CHtml::link($model->statuschange->merged_into, array('bug/view', 'id' => $model->statuschange->merged_into));
    }
    if (isset($model->statuschange->priority)) {
        echo '<li>Priority: ' . Lookup::item('BugPriority', $model->statuschange->priority);
    }
    if (isset($model->statuschange->reproducability)) {
        echo '<li>Repro: ' . Lookup::item('BugReproducability', $model->statuschange->reproducability);
    }