コード例 #1
0
 protected function parseTimeAsRatio($time)
 {
     if (substr($time, -1) === '%') {
         return substr($time, 0, strlen($time) - 1) / 100;
     }
     return Max(Min((double) $time, 1), 0);
 }
コード例 #2
0
ファイル: jpgraph_line.php プロジェクト: natanoj/nuBuilderPro
 function Min()
 {
     $nmax = 0;
     list($xmin, $ysetmin) = $this->plots[0]->Min();
     $n = count($this->plots);
     for ($i = 0; $i < $n; ++$i) {
         $nc = count($this->plots[$i]->coords[0]);
         $nmax = max($nmax, $nc);
         list($x, $y) = $this->plots[$i]->Min();
         $xmin = Min($xmin, $x);
         $ysetmin = Min($y, $ysetmin);
     }
     for ($i = 0; $i < $nmax; $i++) {
         $y = $this->plots[0]->coords[0][$i];
         for ($j = 1; $j < $this->nbrplots; $j++) {
             $y += $this->plots[$j]->coords[0][$i];
         }
         $ymin[$i] = $y;
     }
     $ymin = Min($ysetmin, Min($ymin));
     return array($xmin, $ymin);
 }
コード例 #3
0
ファイル: jpgraph.php プロジェクト: ahviplc/judgegirl
 function Stroke($aStrokeFileName = "")
 {
     // Do any pre-stroke adjustment that is needed by the different plot types
     // (i.e bar plots want's to add an offset to the x-labels etc)
     for ($i = 0; $i < count($this->plots); ++$i) {
         $this->plots[$i]->PreStrokeAdjust($this);
         $this->plots[$i]->Legend($this);
     }
     if ($this->y2scale != null) {
         for ($i = 0; $i < count($this->y2plots); ++$i) {
             $this->y2plots[$i]->PreStrokeAdjust($this);
             $this->y2plots[$i]->Legend($this);
         }
     }
     // Bail out if any of the Y-axis not been specified and
     // has no plots. (This means it is impossible to do autoscaling and
     // no other scale was given so we can't possible draw anything). If you use manual
     // scaling you also have to supply the tick steps as well.
     if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) {
         die("<strong>JpGraph: Can't draw unspecified Y-scale.</strong><br>\n\t\t\t\tYou have either:\n\t\t\t\t<br>* Specified an Y axis for autoscaling but have not supplied any plots\n\t\t\t\t<br>* Specified a scale manually but have forgot to specify the tick steps");
     }
     // Bail out if no plots and no specified X-scale
     if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) {
         die("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>");
     }
     //Check if we should autoscale y-axis
     if (!$this->yscale->IsSpecified() && count($this->plots) > 0) {
         list($min, $max) = $this->GetPlotsYMinMax($this->plots);
         $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
     }
     if ($this->y2scale != null) {
         if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) {
             list($min, $max) = $this->GetPlotsYMinMax($this->y2plots);
             $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
         }
     }
     //Check if we should autoscale x-axis
     if (!$this->xscale->IsSpecified()) {
         if (substr($this->axtype, 0, 4) == "text") {
             $max = 0;
             foreach ($this->plots as $p) {
                 $max = max($max, $p->numpoints - 1);
             }
             $min = 0;
             $this->xscale->Update($this->img, $min, $max);
             $this->xscale->ticks->Set($this->xaxis->tick_step, 1);
             $this->xscale->ticks->SupressMinorTickMarks();
         } else {
             list($min, $ymin) = $this->plots[0]->Min();
             list($max, $ymax) = $this->plots[0]->Max();
             foreach ($this->plots as $p) {
                 list($xmin, $ymin) = $p->Min();
                 list($xmax, $ymax) = $p->Max();
                 $min = Min($xmin, $min);
                 $max = Max($xmax, $max);
             }
             $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor);
         }
         //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale
         $this->yaxis->SetPos($this->xscale->GetMinVal());
         if ($this->y2axis != null) {
             $this->y2axis->SetPos($this->xscale->GetMaxVal());
             $this->y2axis->SetTitleSide(SIDE_RIGHT);
         }
     }
     // If we have a negative values and x-axis position is at 0
     // we need to supress the first and possible the last tick since
     // they will be drawn on top of the y-axis (and possible y2 axis)
     // The test below might seem strange the reasone being that if
     // the user hasn't specified a value for position this will not
     // be set until we do the stroke for the axis so as of now it
     // is undefined.
     if (!$this->xaxis->pos && $this->yscale->GetMinVal() < 0) {
         $this->yscale->ticks->SupressZeroLabel(false);
         $this->xscale->ticks->SupressFirst();
         if ($this->y2axis != null) {
             $this->xscale->ticks->SupressLast();
         }
     }
     // Copy in background image
     if ($this->background_image != "") {
         $bkgimg = $this->LoadBkgImage($this->background_image_format);
         $this->img->_AdjBrightContrast($bkgimg, $this->background_image_bright, $this->background_image_contr);
         $this->img->_AdjSat($bkgimg, $this->background_image_sat);
         $bw = ImageSX($bkgimg);
         $bh = ImageSY($bkgimg);
         $aa = $this->img->SetAngle(0);
         switch ($this->background_image_type) {
             case BGIMG_FILLPLOT:
                 // Resize to just fill the plotarea
                 $this->StrokeFrame();
                 imagecopyresized($this->img->img, $bkgimg, $this->img->left_margin, $this->img->top_margin, 0, 0, $this->img->plotwidth, $this->img->plotheight, $bw, $bh);
                 break;
             case BGIMG_FILLFRAME:
                 // Fill the whole area from upper left corner, resize to just fit
                 imagecopyresized($this->img->img, $bkgimg, 0, 0, 0, 0, $this->img->width, $this->img->height, $bw, $bh);
                 $this->StrokeFrame();
                 break;
             case BGIMG_COPY:
                 // Just copy the image from left corner, no resizing
                 imagecopyresized($this->img->img, $bkgimg, 0, 0, 0, 0, $bw, $bh, $bw, $bh);
                 $this->StrokeFrame();
                 break;
             default:
                 die("JpGraph Error: Unknown background image layout");
         }
         $this->img->SetAngle($aa);
     } else {
         $aa = $this->img->SetAngle(0);
         $this->StrokeFrame();
         $this->img->SetAngle($aa);
         $this->img->SetColor($this->plotarea_color);
         $this->img->FilledRectangle($this->img->left_margin, $this->img->top_margin, $this->img->width - $this->img->right_margin, $this->img->height - $this->img->bottom_margin);
     }
     // Stroke axis
     $this->xaxis->Stroke($this->yscale);
     $this->yaxis->Stroke($this->xscale);
     // Stroke bands
     if ($this->bands != null) {
         for ($i = 0; $i < count($this->bands); ++$i) {
             // Stroke all bands that asks to be in the background
             if ($this->bands[$i]->depth == DEPTH_BACK) {
                 $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale);
             }
         }
     }
     if ($this->grid_depth == DEPTH_BACK) {
         $this->ygrid->Stroke();
         $this->xgrid->Stroke();
     }
     // Stroke Y2-axis
     if ($this->y2axis != null) {
         $this->y2axis->Stroke($this->xscale);
         $this->y2grid->Stroke();
     }
     $oldoff = $this->xscale->off;
     if (substr($this->axtype, 0, 4) == "text") {
         $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step);
     }
     // Stroke all plots for Y1 axis
     for ($i = 0; $i < count($this->plots); ++$i) {
         $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale);
         $this->plots[$i]->StrokeMargin($this->img);
     }
     // Stroke all plots for Y2 axis
     if ($this->y2scale != null) {
         for ($i = 0; $i < count($this->y2plots); ++$i) {
             $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale);
         }
     }
     $this->xscale->off = $oldoff;
     // Stroke bands
     if ($this->bands != null) {
         for ($i = 0; $i < count($this->bands); ++$i) {
             // Stroke all bands that asks to be in the foreground
             if ($this->bands[$i]->depth == DEPTH_FRONT) {
                 $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale);
             }
         }
     }
     if ($this->grid_depth == DEPTH_FRONT) {
         $this->ygrid->Stroke();
         $this->xgrid->Stroke();
     }
     // Finally draw the axis again since some plots may have nagged
     // the axis in the edges.
     $this->yaxis->Stroke($this->xscale);
     $this->xaxis->Stroke($this->yscale);
     if ($this->y2scale != null) {
         $this->y2axis->Stroke($this->xscale);
     }
     // Should we draw a box around the plot area?
     if ($this->boxed) {
         $this->img->SetLineWeight($this->box_weight);
         $this->img->SetColor($this->box_color);
         $this->img->Rectangle($this->img->left_margin, $this->img->top_margin, $this->img->width - $this->img->right_margin, $this->img->height - $this->img->bottom_margin);
     }
     $aa = $this->img->SetAngle(0);
     // Stroke title
     $this->title->Center($this->img->left_margin, $this->img->width - $this->img->right_margin, 5);
     $this->title->Stroke($this->img);
     // ... and subtitle
     $this->subtitle->Center($this->img->left_margin, $this->img->width - $this->img->right_margin, 7 + $this->title->GetFontHeight($this->img));
     $this->subtitle->Stroke($this->img);
     // Stroke legend
     $this->legend->Stroke($this->img);
     // Stroke any user added text objects
     if ($this->texts != null) {
         for ($i = 0; $i < count($this->texts); ++$i) {
             $this->texts[$i]->x *= $this->img->width;
             $this->texts[$i]->y *= $this->img->height;
             $this->texts[$i]->Stroke($this->img);
         }
     }
     $this->img->SetAngle($aa);
     // Stroke any lines added
     if ($this->lines != null) {
         for ($i = 0; $i < count($this->lines); ++$i) {
             $this->lines[$i]->Stroke($this->img, $this->xscale, $this->yscale);
         }
     }
     if ($this->showcsim) {
         // Debug stuff - display the outline of the image map areas
         foreach ($this->plots as $p) {
             $csim .= $p->GetCSIMareas();
         }
         $csim .= $this->legend->GetCSIMareas();
         if (preg_match_all("/area shape=\"(\\w+)\" coords=\"([0-9\\, ]+)\"/", $csim, $coords)) {
             $this->img->SetColor($this->csimcolor);
             for ($i = 0; $i < count($coords[0]); $i++) {
                 if ($coords[1][$i] == "poly") {
                     preg_match_all('/\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,*/', $coords[2][$i], $pts);
                     $this->img->SetStartPoint($pts[1][count($pts[0]) - 1], $pts[2][count($pts[0]) - 1]);
                     for ($j = 0; $j < count($pts[0]); $j++) {
                         $this->img->LineTo($pts[1][$j], $pts[2][$j]);
                     }
                 } else {
                     if ($coords[1][$i] == "rect") {
                         $pts = preg_split('/,/', $coords[2][$i]);
                         $this->img->SetStartPoint($pts[0], $pts[1]);
                         $this->img->LineTo($pts[2], $pts[1]);
                         $this->img->LineTo($pts[2], $pts[3]);
                         $this->img->LineTo($pts[0], $pts[3]);
                         $this->img->LineTo($pts[0], $pts[1]);
                     }
                 }
             }
         }
     }
     // Adjust the brightness and contrast
     if ($this->image_contr || $this->image_bright) {
         $this->img->AdjBrightContrast($this->image_bright, $this->image_contr);
     }
     if ($this->image_sat) {
         $this->img->AdjSat($this->image_sat);
     }
     // Finally stream the generated picture
     $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
 }
コード例 #4
0
ファイル: jpgraph.php プロジェクト: nbgmaster/happify
 function GetXMinMax()
 {
     list($min, $ymin) = $this->plots[0]->Min();
     list($max, $ymax) = $this->plots[0]->Max();
     $i = 0;
     // Some plots, e.g. PlotLine should not affect the scale
     // and will return (null,null). We should ignore those
     // values.
     while (($min === null || $max === null) && $i < count($this->plots) - 1) {
         ++$i;
         list($min, $ymin) = $this->plots[$i]->Min();
         list($max, $ymax) = $this->plots[$i]->Max();
     }
     foreach ($this->plots as $p) {
         list($xmin, $ymin) = $p->Min();
         list($xmax, $ymax) = $p->Max();
         if ($xmin !== null && $xmax !== null) {
             $min = Min($xmin, $min);
             $max = Max($xmax, $max);
         }
     }
     if ($this->y2axis != null) {
         foreach ($this->y2plots as $p) {
             list($xmin, $ymin) = $p->Min();
             list($xmax, $ymax) = $p->Max();
             $min = Min($xmin, $min);
             $max = Max($xmax, $max);
         }
     }
     $n = count($this->ynaxis);
     for ($i = 0; $i < $n; ++$i) {
         if ($this->ynaxis[$i] != null) {
             foreach ($this->ynplots[$i] as $p) {
                 list($xmin, $ymin) = $p->Min();
                 list($xmax, $ymax) = $p->Max();
                 $min = Min($xmin, $min);
                 $max = Max($xmax, $max);
             }
         }
     }
     return array($min, $max);
 }
コード例 #5
0
 function Min()
 {
     return Min($this->data);
 }
コード例 #6
0
ファイル: jpgraph_bar.php プロジェクト: teammember8/roundcube
 function Min()
 {
     $nmax = 0;
     list($xmin, $ysetmin) = $this->plots[0]->Min();
     for ($i = 0; $i < count($this->plots); ++$i) {
         $n = count($this->plots[$i]->coords[0]);
         $nmax = max($nmax, $n);
         list($x, $y) = $this->plots[$i]->Min();
         $xmin = Min($xmin, $x);
         $ysetmin = Min($y, $ysetmin);
     }
     for ($i = 0; $i < $nmax; $i++) {
         // Get y-value for bar $i by adding the
         // individual bars from all the plots added.
         // It would be wrong to just add the
         // individual plots max y-value since that
         // would in most cases give to large y-value.
         $y = $this->plots[0]->coords[0][$i];
         for ($j = 1; $j < $this->nbrplots; $j++) {
             $y += $this->plots[$j]->coords[0][$i];
         }
         $ymin[$i] = $y;
     }
     $ymin = Min($ysetmin, Min($ymin));
     // Bar always start at baseline
     if ($ymin >= $this->ybase) {
         $ymin = $this->ybase;
     }
     return array($xmin, $ymin);
 }
コード例 #7
0
ファイル: file.php プロジェクト: k-kalashnikov/geekcon_new
 function ScaleImage($sourceImageWidth, $sourceImageHeight, $arSize, $resizeType, &$bNeedCreatePicture, &$arSourceSize, &$arDestinationSize)
 {
     if (!is_array($arSize)) {
         $arSize = array();
     }
     if (!array_key_exists("width", $arSize) || intval($arSize["width"]) <= 0) {
         $arSize["width"] = 0;
     }
     if (!array_key_exists("height", $arSize) || intval($arSize["height"]) <= 0) {
         $arSize["height"] = 0;
     }
     $arSize["width"] = intval($arSize["width"]);
     $arSize["height"] = intval($arSize["height"]);
     $bNeedCreatePicture = false;
     $arSourceSize = array("x" => 0, "y" => 0, "width" => 0, "height" => 0);
     $arDestinationSize = array("x" => 0, "y" => 0, "width" => 0, "height" => 0);
     if ($sourceImageWidth > 0 && $sourceImageHeight > 0) {
         if ($arSize["width"] > 0 && $arSize["height"] > 0) {
             switch ($resizeType) {
                 case BX_RESIZE_IMAGE_EXACT:
                     $bNeedCreatePicture = true;
                     $ratio = $sourceImageWidth / $sourceImageHeight < $arSize["width"] / $arSize["height"] ? $arSize["width"] / $sourceImageWidth : $arSize["height"] / $sourceImageHeight;
                     $x = max(0, round($sourceImageWidth / 2 - $arSize["width"] / 2 / $ratio));
                     $y = max(0, round($sourceImageHeight / 2 - $arSize["height"] / 2 / $ratio));
                     $arDestinationSize["width"] = $arSize["width"];
                     $arDestinationSize["height"] = $arSize["height"];
                     $arSourceSize["x"] = $x;
                     $arSourceSize["y"] = $y;
                     $arSourceSize["width"] = round($arSize["width"] / $ratio, 0);
                     $arSourceSize["height"] = round($arSize["height"] / $ratio, 0);
                     break;
                 default:
                     if ($resizeType == BX_RESIZE_IMAGE_PROPORTIONAL_ALT) {
                         $width = Max($sourceImageWidth, $sourceImageHeight);
                         $height = Min($sourceImageWidth, $sourceImageHeight);
                     } else {
                         $width = $sourceImageWidth;
                         $height = $sourceImageHeight;
                     }
                     $ResizeCoeff["width"] = $arSize["width"] / $width;
                     $ResizeCoeff["height"] = $arSize["height"] / $height;
                     $iResizeCoeff = Min($ResizeCoeff["width"], $ResizeCoeff["height"]);
                     $iResizeCoeff = 0 < $iResizeCoeff && $iResizeCoeff < 1 ? $iResizeCoeff : 1;
                     $bNeedCreatePicture = $iResizeCoeff != 1 ? true : false;
                     $arDestinationSize["width"] = max(1, intval($iResizeCoeff * $sourceImageWidth));
                     $arDestinationSize["height"] = max(1, intval($iResizeCoeff * $sourceImageHeight));
                     $arSourceSize["x"] = 0;
                     $arSourceSize["y"] = 0;
                     $arSourceSize["width"] = $sourceImageWidth;
                     $arSourceSize["height"] = $sourceImageHeight;
                     break;
             }
         } else {
             $arSourceSize = array("x" => 0, "y" => 0, "width" => $sourceImageWidth, "height" => $sourceImageHeight);
             $arDestinationSize = array("x" => 0, "y" => 0, "width" => $sourceImageWidth, "height" => $sourceImageHeight);
         }
     }
 }
コード例 #8
0
ファイル: ImageMagic.php プロジェクト: nilBora/konstruktor
 protected function _enlargeSafeResize($width, $height)
 {
     $imageWidth = $this->image->getImageWidth();
     $imageHeight = $this->image->getImageHeight();
     if ($imageWidth >= $imageHeight) {
         if ($imageWidth <= $width && $imageHeight <= $height) {
             return $this->_thumbnailImage($imageWidth, $imageHeight);
         }
         $wRatio = $width / $imageWidth;
         $hRatio = $height / $imageHeight;
     } else {
         if ($imageHeight <= $width && $imageWidth <= $height) {
             return $this->_thumbnailImage($imageWidth, $imageHeight);
         }
         // no resizing required
         $wRatio = $height / $imageWidth;
         $hRatio = $width / $imageHeight;
     }
     $resizeRatio = Min($wRatio, $hRatio);
     $newHeight = $imageHeight * $resizeRatio;
     $newWidth = $imageWidth * $resizeRatio;
     return $this->_thumbnailImage($newWidth, $newHeight);
 }
コード例 #9
0
ファイル: AccLinePlot.php プロジェクト: amenadiel/jpgraph
 public function Min()
 {
     $nmax = 0;
     list($xmin, $ysetmin) = $this->plots[0]->Min();
     $n = count($this->plots);
     for ($i = 0; $i < $n; ++$i) {
         $nc = count($this->plots[$i]->coords[0]);
         $nmax = max($nmax, $nc);
         list($x, $y) = $this->plots[$i]->Min();
         $xmin = Min($xmin, $x);
         $ysetmin = Min($y, $ysetmin);
     }
     for ($i = 0; $i < $nmax; $i++) {
         // Get y-value for line $i by adding the
         // individual bars from all the plots added.
         // It would be wrong to just add the
         // individual plots min y-value since that
         // would in most cases give to small y-value.
         $y = $this->plots[0]->coords[0][$i];
         for ($j = 1; $j < $this->nbrplots; $j++) {
             $y += $this->plots[$j]->coords[0][$i];
         }
         $ymin[$i] = $y;
     }
     $ymin = Min($ysetmin, Min($ymin));
     return array($xmin, $ymin);
 }
コード例 #10
0
ファイル: SQL.comp.php プロジェクト: carriercomm/jbs
$Count = DB_Count($TableID, array('Where' => $Where, 'GroupBy' => $Query['GroupBy']));
if (Is_Error($Count)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Source['Count'] = $Count;
//print_r($Count);
//die();
#-------------------------------------------------------------------------------
$Request = array('Where' => $Where, 'SortOn' => $Query['SortOn'], 'IsDesc' => $Query['IsDesc'], 'GroupBy' => $Query['GroupBy']);
#-------------------------------------------------------------------------------
$InPage = $Template['Query']['InPage'];
#-------------------------------------------------------------------------------
$Index =& $Query['Index'];
#-------------------------------------------------------------------------------
$Index = Min(Max(0, $Index), (int) (($Count > $InPage ? $Count : 0) / $InPage));
#-------------------------------------------------------------------------------
$Request['Limits'] = array('Start' => $Index * $InPage, 'Length' => $InPage);
#-------------------------------------------------------------------------------
$ColumnsIDs = $Source['ColumnsIDs'];
#-------------------------------------------------------------------------------
$Columns = $Template['Columns'];
#-------------------------------------------------------------------------------
foreach ($Template['Sequence'] as $ColumnID) {
    #-----------------------------------------------------------------------------
    $Column = $Columns[$ColumnID];
    #-----------------------------------------------------------------------------
    if (isset($Column['Alias'])) {
        $ColumnsIDs[] = SPrintF('%s as `%s`', $Column['Alias'], $ColumnID);
    }
}
コード例 #11
0
ファイル: ClassAttendance.php プロジェクト: jwigal/emcommdb
 function DrawAttendanceCalendar($nameX, $yTop, $aNames, $tTitle, $extraLines, $tFirstSunday, $tLastSunday, $tNoSchool1, $tNoSchool2, $tNoSchool3, $tNoSchool4, $tNoSchool5, $tNoSchool6, $tNoSchool7, $tNoSchool8, $rptHeader)
 {
     $startMonthX = 60;
     $dayWid = 7;
     $MaxLinesPerPage = 36;
     $yIncrement = 6;
     $yTitle = 20;
     $yTeachers = $yTitle + 6;
     $nameX = 10;
     unset($NameList);
     $numMembers = 0;
     $aNameCount = 0;
     //
     //  determine how many pages will be includes in this report
     //
     //
     // First cull the input names array to remove duplicates, then extend the array to include the requested
     // number of blank lines
     //
     $prevThisName = "";
     $aNameCount = 0;
     for ($row = 0; $row < count($aNames); $row++) {
         extract($aNames[$row]);
         $thisName = $per_LastName . ", " . $per_FirstName;
         // Special handling for person listed twice- only show once in the Attendance Calendar
         // This happens when a child is listed in two different families (parents divorced and
         // both active in the church)
         if ($thisName != $prevThisName) {
             $NameList[$aNameCount++] = $thisName;
             //			echo "adding {$thisName} to NameList at {$aNameCount}\n\r";
         }
         $prevThisName = $thisName;
     }
     //
     // add extra blank lines to the array
     //
     for ($i = 0; $i < $extraLines; $i++) {
         $NameList[] = "   ";
     }
     $numMembers = count($NameList);
     $nPages = ceil($numMembers / $MaxLinesPerPage);
     //	echo "nPages = {$nPages} \n\r";
     //
     // Main loop which draws each page
     //
     for ($p = 0; $p < $nPages; $p++) {
         //
         // 	Paint the title section- class name and year on the top, then teachers/liaison
         //
         if ($p > 0) {
             $this->AddPage();
         }
         $this->SetFont("Times", 'B', 16);
         $this->WriteAt($nameX, $yTitle, $rptHeader);
         $this->SetLineWidth(0.5);
         $this->Line($nameX, $yTeachers - 0.75, 195, $yTeachers - 0.75);
         $yMonths = $yTop;
         $yDays = $yTop + $yIncrement;
         $y = $yDays + $yIncrement;
         //
         //	put title on the page
         //
         $this->SetFont("Times", 'B', 12);
         $this->WriteAt($nameX, $yDays + 1, $tTitle);
         $this->SetFont("Times", '', 12);
         //
         // calculate the starting and ending rows for the page
         //
         $pRowStart = $p * $MaxLinesPerPage;
         $pRowEnd = Min(($p + 1) * $MaxLinesPerPage, $numMembers);
         //		echo "pRowStart = {$pRowStart} and pRowEnd= {$pRowEnd}\n\r";
         //
         // Write the names down the page and draw lines between
         //
         $this->SetLineWidth(0.25);
         for ($row = $pRowStart; $row < $pRowEnd; $row++) {
             $this->WriteAt($nameX, $y + 1, $NameList[$row]);
             $y += $yIncrement;
         }
         //
         // write a totals text at the bottom
         //
         $this->SetFont("Times", 'B', 12);
         $this->WriteAt($nameX, $y + 1, gettext("Totals"));
         $this->SetFont("Times", '', 12);
         $bottomY = $y + $yIncrement;
         //
         // Paint the calendar grid
         //
         $dayCounter = 0;
         $monthCounter = 0;
         $dayX = $startMonthX;
         $monthX = $startMonthX;
         $noSchoolCnt = 0;
         $heavyVerticalXCnt = 0;
         $lightVerticalXCnt = 0;
         $tWhichSunday = $tFirstSunday;
         $dWhichSunday = strtotime($tWhichSunday);
         $dWhichMonthDate = $dWhichSunday;
         $whichMonth = date("n", $dWhichMonthDate);
         $doneFlag = false;
         while (!$doneFlag) {
             $dayListX[$dayCounter] = $dayX;
             $dayListNum[$dayCounter] = date("d", $dWhichSunday);
             if ($tWhichSunday == $tNoSchool1) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if ($tWhichSunday == $tNoSchool2) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if ($tWhichSunday == $tNoSchool3) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if ($tWhichSunday == $tNoSchool4) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if ($tWhichSunday == $tNoSchool5) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if ($tWhichSunday == $tNoSchool6) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if ($tWhichSunday == $tNoSchool7) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if ($tWhichSunday == $tNoSchool8) {
                 $aNoSchoolX[$noSchoolCnt++] = $dayX;
             }
             if (date("n", $dWhichSunday) != $whichMonth) {
                 // Finish the previous month
                 $this->WriteAt($monthX, $yMonths + 1, date("F", $dWhichMonthDate));
                 $aHeavyVerticalX[$heavyVerticalXCnt++] = $monthX;
                 $whichMonth = date("n", $dWhichSunday);
                 $dWhichMonthDate = $dWhichSunday;
                 $monthX = $dayX;
             } else {
                 $aLightVerticalX[$lightVerticalXCnt++] = $dayX;
             }
             $dayX += $dayWid;
             ++$dayCounter;
             //         		if ($tWhichSunday == $tLastSunday) $doneFlag = true;
             //
             //			replaced this conditional to correct a problem where begin and end dates were not the same
             //			day of week
             //
             if (strtotime($tWhichSunday) >= strtotime($tLastSunday)) {
                 $doneFlag = true;
             }
             // 	Increment the date by one week
             //
             $sundayDay = date("d", $dWhichSunday);
             $sundayMonth = date("m", $dWhichSunday);
             $sundayYear = date("Y", $dWhichSunday);
             $dWhichSunday = mktime(0, 0, 0, $sundayMonth, $sundayDay + 7, $sundayYear);
             $tWhichSunday = date("Y-m-d", $dWhichSunday);
         }
         $aHeavyVerticalX[$heavyVerticalXCnt++] = $monthX;
         $this->WriteAt($monthX, $yMonths + 1, date("F", $dWhichMonthDate));
         $rightEdgeX = $dayX;
         // Draw vertical lines now that we know how far down the list goes
         // Draw the left-most vertical line heavy, through the month row
         $this->SetLineWidth(0.5);
         $this->Line($nameX, $yMonths, $nameX, $bottomY);
         // Draw the left-most line between the people and the calendar
         $lineTopY = $yMonths;
         $this->Line($startMonthX, $lineTopY, $startMonthX, $bottomY);
         // Draw the vertical lines in the grid based on X coords stored above
         $this->SetLineWidth(0.5);
         for ($i = 0; $i < $heavyVerticalXCnt; $i++) {
             $this->Line($aHeavyVerticalX[$i], $lineTopY, $aHeavyVerticalX[$i], $bottomY);
         }
         $lineTopY = $yDays;
         $this->SetLineWidth(0.25);
         for ($i = 0; $i < $lightVerticalXCnt; $i++) {
             $this->Line($aLightVerticalX[$i], $lineTopY, $aLightVerticalX[$i], $bottomY);
         }
         // Draw the right-most vertical line heavy, through the month row
         $this->SetLineWidth(0.5);
         $this->Line($dayX, $yMonths, $dayX, $bottomY);
         // Fill the no-school days
         $this->SetFillColor(200, 200, 200);
         $this->SetLineWidth(0.25);
         for ($i = 0; $i < count($aNoSchoolX); $i++) {
             $this->Rect($aNoSchoolX[$i], $yDays, $dayWid, $bottomY - $yDays, 'FD');
         }
         for ($i = 0; $i < $dayCounter; $i++) {
             $this->WriteAt($dayListX[$i], $yDays + 1, $dayListNum[$i]);
         }
         // Draw heavy lines to delimit the Months and totals
         $this->SetLineWidth(0.5);
         $this->Line($nameX, $yMonths, $rightEdgeX, $yMonths);
         $this->Line($nameX, $yMonths + $yIncrement, $rightEdgeX, $yMonths + $yIncrement);
         $this->Line($nameX, $yMonths + 2 * $yIncrement, $rightEdgeX, $yMonths + 2 * $yIncrement);
         $yBottom = $yMonths + ($numMembers - $phantomMembers + $extraLines + 2) * $yIncrement;
         $this->Line($nameX, $yBottom, $rightEdgeX, $yBottom);
         $this->Line($nameX, $yBottom + $yIncrement, $rightEdgeX, $yBottom + $yIncrement);
         //
         //	add in horizontal lines between names
         //
         $y = $yTop;
         for ($s = $pRowStart; $s < $pRowEnd + 4; $s++) {
             $this->Line($nameX, $y, $rightEdgeX, $y);
             $y += $yIncrement;
         }
         //		$this->AddPage();
     }
     return $bottomY;
 }
コード例 #12
0
ファイル: edit_ajax.php プロジェクト: davidkeen/railservice
function ajax_request()
{
    global $editor_types, $editor_tables;
    $xml = '';
    $msg = '';
    $rec_count = 0;
    $db = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    $pnum = clb_val(FALSE, $_REQUEST, 'pnum');
    if ($new_mark = preg_match('/^b(\\w{7})(\\w{7})/', $pnum, $m)) {
        $_REQUEST['lat'] = hexdec($m[1]) / 100000 - 180;
        $_REQUEST['lng'] = hexdec($m[2]) / 100000 - 180;
        $_REQUEST['coords'] = clb_b64e($_REQUEST['lat']) . clb_b64e($_REQUEST['lng']);
    }
    $ptype = clb_val(FALSE, $_REQUEST, 'ptype');
    //if the ptype is cust, default to the first table and type in the definitions that does or does not have a polyline
    if ($ptype == 'cust' && $new_mark) {
        foreach ($editor_types as $ptype => $spec) {
            if (clb_val(FALSE, $spec, 'polyline') == isset($_REQUEST['polyline'])) {
                break;
            }
        }
    }
    $table = FALSE;
    $prefixes = clb_column($editor_tables, 'prefix');
    if ($pnum && preg_match('/^(\\w+)_\\w+$/', $pnum, $m)) {
        $table = array_search($m[1], $prefixes);
    } else {
        if ($ptype) {
            $table = clb_val(FALSE, $editor_types, $ptype, 'table');
        }
    }
    $spec = clb_val(FALSE, $editor_tables, $table);
    $ajax = clb_val(FALSE, $_REQUEST, 'ajax');
    qlog(__LINE__, '>>>>', $ajax, $pnum, $ptype, $table, $new_mark ? 'new' : 'old');
    //, $spec);
    switch ($ajax) {
        case 'show':
            $sel = FALSE;
            if ($spec) {
                $select = clb_val(FALSE, $spec, 'select');
                $query = 'SELECT ' . clb_join($select, '`') . ' FROM ' . $table . ' WHERE pnum=' . clb_escape($pnum);
                $sel = $db->get_results($query, ARRAY_A);
            }
            //if not found via pnum, try title in each table.
            if (!$sel) {
                foreach ($editor_tables as $table => $spec) {
                    if (($select = clb_val(FALSE, $spec, 'select')) && in_array('title', $select)) {
                        $query = 'SELECT ' . clb_join($select, '`') . ' FROM ' . $table . ' WHERE title like ' . clb_escape($pnum . '%');
                        $sel = $db->get_results($query, ARRAY_A);
                        if ($sel) {
                            break;
                        }
                    }
                }
            }
            if (!$sel) {
                $msg = 'No matches found for: ' . $pnum;
            } else {
                $titles = clb_column($sel, 'title');
                $msg = count($sel) . ' matches found: ' . join(', ', $titles);
                $rec = reset($sel);
                $pnum = clb_val(FALSE, $rec, 'pnum');
                $xml .= clb_tag('response', '', '', array_merge(array('type' => 'centre'), array_intersect_key($rec, array('lat' => 0, 'lng' => 0)))) . "\n";
                $xml .= refesh_marker($db, $table, $pnum);
                $xml .= marker_bubble($db, $spec, $table, $pnum);
            }
            break;
        case 'route_list':
            //shows bubble on station showing list of routes
            $html = '';
            //find the route table and which field(s) hold the stop list
            $route_flds = '';
            foreach ($editor_tables as $route_tab => $info) {
                if ($route_flds = clb_val(FALSE, $info, 'routes')) {
                    break;
                }
            }
            if (!$route_flds) {
                break;
            }
            $route_flds = explode('/', $route_flds);
            //can be more than one field with '/' as a separator
            //build query to get route list
            $select = clb_val(FALSE, $editor_tables, $route_tab, 'select');
            $where = array();
            foreach ($route_flds as $fld) {
                $where[] = ' (`' . $fld . '` LIKE ' . clb_escape('%' . $pnum . '%') . ')';
            }
            $query = 'SELECT ' . clb_join(array_merge($select, $route_flds), '`') . ' FROM ' . $route_tab . ' WHERE ' . join(' OR ', $where);
            $sel = $db->get_results($query, ARRAY_A);
            if (clb_count($sel) == 0) {
                $msg = 'There are no routes for node: ' . $pnum;
            } else {
                $list = '';
                $alt = 0;
                foreach ($sel as $rec) {
                    foreach ($route_flds as $pos => $fld) {
                        $rnum = reset($rec);
                        $route_key = key($rec);
                        $script = 'map_ajax(the_map, \'show_route\', {\'pnum\':\'' . $rnum . '\',\'fld\':\'' . $fld . '\', \'stop\':\'' . $pnum . '\'});';
                        $name = $rnum . ':' . $pos . ': ' . clb_val(FALSE, $rec, 'title');
                        $list .= clb_tag('li', '', clb_tag('a', $name, '', array('onclick' => $script, 'href' => 'javascript:void(0);')), array('class' => 'alt' . $alt++ % 2));
                    }
                }
                $html .= clb_tag('ul', '', $list, array('class' => 'route_list')) . "\n";
                $form = clb_tag('form', '', $html, array('id' => 'info_win', 'action' => '', 'method' => 'get', 'onsubmit' => 'return false;')) . "\n";
                $xml .= clb_tag('response', '', htmlspecialchars($form), array('type' => 'bubble', 'pnum' => $pnum)) . "\n";
            }
            break;
        case 'new_route':
            //create new route
        //create new route
        case 'route_stop':
            //add stop to route
        //add stop to route
        case 'route_unstop':
            //remove stop from route
        //remove stop from route
        case 'show_route':
            //show route
            //		qlog(__LINE__, $table, $pnum, $spec);
            require_once CODE_DIR . 'pline_lib.php';
            //scan tables to find routes
            foreach ($editor_tables as $table => $info) {
                if ($routes = clb_val(FALSE, $info, 'routes')) {
                    break;
                }
            }
            if (!$routes) {
                break;
            }
            //did not find route table
            $routes = explode('/', $routes);
            $route_tab = $table;
            $select = clb_val(FALSE, $editor_tables, $route_tab, 'select');
            $route_key = reset($select);
            $stops = FALSE;
            $new_route = 'new_route' == $ajax;
            if ($new_route) {
                $fld = reset($routes);
                $newstop = $pnum;
                $stopindex = 0;
                $list = '';
                $title = clb_val(FALSE, $_REQUEST, 'title');
                $pnum = new_pnum($db, $table, $route_key);
                $ajax = 'route_stop';
            } else {
                $stopindex = clb_val(FALSE, $_REQUEST, 'stopindex');
                //this only come with route_stop and route_unstop
                $newstop = clb_val(FALSE, $_REQUEST, 'newstop');
                //this only come with route_stop
                $fld = clb_val(FALSE, $_REQUEST, 'fld');
                $select = array_merge($select, $routes);
                //select route record
                $query = 'SELECT ' . clb_join($select, '`') . ' FROM ' . $route_tab . ' WHERE ' . $route_key . '=' . clb_escape($pnum);
                $sel = $db->get_results($query, ARRAY_A);
                $rec = clb_count($sel) ? reset($sel) : FALSE;
                $list = clb_val(FALSE, $rec, $fld);
                $ptype = clb_val(FALSE, $rec, 'ptype');
                $title = clb_val(FALSE, $rec, 'title');
                //if (empty($list) && (reset($routes) == $fld) && ($fld
                if (empty($list)) {
                    $newstop = clb_val(FALSE, $_REQUEST, 'stop');
                    $stopindex = 0;
                    $ajax = 'route_stop';
                }
            }
            if (preg_match_all('/^(\\w+)\\s+(.*)/m', $list, $m)) {
                $stops = $m[1];
            }
            if (in_array($ajax, array('route_stop', 'route_unstop')) && is_numeric($stopindex)) {
                if (!$stops) {
                    $stops = array(FALSE);
                }
                //ensure loop runs at least once
                $new = '';
                foreach ($stops as $i => $stop_pnum) {
                    if ('route_unstop' == $ajax && $i == $stopindex) {
                        continue;
                    }
                    //skip the stop that is to be deleted
                    //add the stop on this line
                    if ($stop_pnum) {
                        $new .= $m[1][$i] . ' ' . trim($m[2][$i]) . "\n";
                    }
                    //add new station if this is the right position
                    if ('route_stop' == $ajax && $i == $stopindex && $newstop) {
                        //find maker table via ptype
                        $table = clb_val(FALSE, $editor_types, $ptype, 'table');
                        $query = 'SELECT lat, lng, pnum, ptype, title FROM ' . $table . ' WHERE pnum=' . clb_escape($newstop);
                        $sel = $db->get_results($query, ARRAY_A);
                        if ($sel) {
                            $new .= $newstop . ' ' . clb_val('', reset($sel), 'title') . "\n";
                        }
                    }
                }
                if (preg_match_all('/^(\\w+)\\s+(.*)/m', $new, $m)) {
                    $stops = $m[1];
                }
                //if forward direction and changing last item update orig, dest and title
                $rename = '';
                if (reset($routes) == $fld && clb_count($stops) <= $stopindex + 2) {
                    $orig = reset($m[2]);
                    $dest = end($m[2]);
                    $rename .= ', title=' . clb_escape($orig . ' - ' . $dest);
                    $rename .= ', orig=' . clb_escape($orig);
                    $rename .= ', dest=' . clb_escape($dest);
                }
                if ($new_route) {
                    $query = 'SELECT area, count(*) AS c FROM ' . $route_tab . ' WHERE ptype=' . clb_escape($ptype) . ' GROUP BY area';
                    $sel = $db->get_results($query, ARRAY_A);
                    $area = is_array($sel) ? clb_val('', reset($sel), 'area') : '';
                    $query = '';
                    $query .= ', ' . $route_key . '=' . clb_escape($pnum);
                    $query .= ', area=' . clb_escape($area);
                    $query .= ', ptype=' . clb_escape($ptype);
                    $query .= ', ' . $fld . '=' . clb_escape($new);
                    $query .= ', created=' . clb_escape(clb_now_utc());
                    $query = 'INSERT INTO ' . $route_tab . ' SET ' . trim($query, ', ') . $rename;
                } else {
                    $query = 'UPDATE ' . $route_tab . ' SET ' . $fld . '=' . clb_escape($new) . $rename . ' WHERE ' . $route_key . '=' . clb_escape($pnum);
                }
                $db->query($query);
            }
            if ($stops) {
                $index = array_search(clb_val(FALSE, $_REQUEST, 'stop'), $stops);
                //index of the stop we opened route from
                if (is_numeric($stopindex)) {
                    $index = Min($stopindex + ($newstop ? 1 : 0), clb_count($stops) - 1);
                }
                //use new index if provided and add one if new stop
                if (preg_match('/^(\\w+)_\\w+$/', reset($stops), $m)) {
                    $table = array_search($m[1], $prefixes);
                    $spec = clb_val(FALSE, $editor_tables, $table);
                    $points = array();
                    $names = array();
                    $pnums = array();
                    $query = 'SELECT lat, lng, pnum, ptype, title FROM ' . $table . ' WHERE pnum IN ' . clb_join($stops, TRUE);
                    $sel = $db->get_results($query, ARRAY_A);
                    //in theory could be multiple stop instances and need to give points in order so loop on $stops and look up record via xref
                    $xref = clb_column($sel, 'pnum');
                    if (clb_count($sel)) {
                        foreach ($stops as $stop_pnum) {
                            $rec = clb_val(FALSE, $sel, array_search($stop_pnum, $xref));
                            $points[] = array($rec['lat'], $rec['lng'], 0);
                            $names[] = str_replace('|', ',', $rec['title']);
                            $pnums[] = $rec['pnum'];
                            $rec['type'] = 'marker';
                            $xml .= clb_tag('response', '', '', $rec) . "\n";
                            $rec_count++;
                        }
                    }
                    foreach ($points as $i => $pt) {
                        if (!is_array($pt)) {
                            unset($points[$i]);
                        }
                    }
                    //remove non points if there are any
                    $line = pline_make($points, array('color' => '#FF0000'));
                    $line['names'] = join('|', $names);
                    $line['pnums'] = join('|', $pnums);
                    if ($line) {
                        $line = clb_join($line, '', '&', '=');
                    }
                    $attr = array('type' => 'route_pline', 'pnum' => $pnum, 'title' => $title, 'fld' => $fld, 'ptype' => $ptype, 'index' => $index);
                    if ($line) {
                        $xml .= clb_tag('response', '', htmlspecialchars($line), $attr) . "\n";
                    }
                }
            } else {
                $msg = 'This route (in this direction) has no stops. ';
            }
            break;
        case 'overlays':
            if (clb_val(FALSE, $_REQUEST, 'zm') < 9) {
                $msg = 'Zoom in to get markers to download.';
            } else {
                $rect = array();
                $rect[] = 'lat >= ' . clb_val(FALSE, $_REQUEST, 'bot');
                $rect[] = 'lng >= ' . clb_val(FALSE, $_REQUEST, 'lft');
                $rect[] = 'lat <= ' . clb_val(FALSE, $_REQUEST, 'top');
                $rect[] = 'lng <= ' . clb_val(FALSE, $_REQUEST, 'rgt');
                $qtypes = preg_split('/;/', clb_val(FALSE, $_REQUEST, 'types'), -1, PREG_SPLIT_NO_EMPTY);
                $tables = array();
                foreach ($qtypes as $ptype) {
                    $tables[clb_val('bad', $editor_types, $ptype, 'table')][] = $ptype;
                }
                if (!count($qtypes)) {
                    $msg = 'No marker types selected.';
                } else {
                    foreach ($tables as $table => $list) {
                        if ($table != 'bad' && count($list)) {
                            $prefix = clb_val(FALSE, $editor_tables, $table, 'prefix');
                            $types = preg_replace('/\\w+_/', '', clb_join($list, TRUE));
                            $query = '';
                            $query .= 'SELECT lat, lng, pnum, ptype, title FROM ' . $table . ' WHERE ';
                            $query .= ' ptype IN ' . $types . ' AND (' . join(' AND ', $rect) . ') ';
                            $sel = $db->get_results($query, ARRAY_A);
                            if (clb_count($sel)) {
                                foreach ($sel as $rec) {
                                    $rec['type'] = 'marker';
                                    if (!in_array($rec['ptype'], $list)) {
                                        $rec['ptype'] = $prefix . '_' . $rec['ptype'];
                                    }
                                    $xml .= clb_tag('response', '', '', $rec) . "\n";
                                    $rec_count++;
                                }
                            }
                        }
                    }
                }
                $msg = $rec_count ? count($sel) . ' markers loaded' : 'No markers found.';
                if ('purge' == clb_val(FALSE, $_REQUEST, 'purge')) {
                    $xml .= clb_tag('response', '', '', array('type' => 'purge')) . "\n";
                }
            }
            break;
        case 'saveline':
            require_once CODE_DIR . 'pline_lib.php';
            //fall through
        //fall through
        case 'save':
            //no real validation so just save and close
            if (!$spec) {
                $msg = 'could not identify the marker type.';
                break;
            }
            //('polyline'=>'line', 'select'=>' lat, lng, pnum, ptype, title, line, aoe_data')
            if ($new_mark) {
                $pnum = new_pnum($db, $table);
            }
            //get field names and types
            $def = array();
            $sel = $db->get_results('describe ' . $table, ARRAY_A);
            foreach ($sel as $rec) {
                $def[$rec['Field']] = $rec['Type'];
            }
            /*
            	normally save line is handled by the normal save 
            	but if we are saving a cut line, we need to save off the first part and 
            	then use the normal save to create the latter part as a new record
            	dont cut on first or last point of line
            */
            $points = FALSE;
            if ('saveline' == $ajax) {
                $points = pline_pts_arr(clb_val(FALSE, $_REQUEST, 'polyline'));
                //the rest of this is only for cutting a line
                if (($cut = clb_val(FALSE, $_REQUEST, 'cut')) && $cut + 1 < clb_count($points)) {
                    $first = array_slice($points, 0, $cut + 1);
                    //keep points up to and including cut
                    $points = array_slice($points, $cut);
                    //reduce points on and after cut for new record
                    $query = save_line_query($first, $spec);
                    $query .= '`' . 'lat' . '`=' . clb_escape($_REQUEST['lat']) . ',';
                    $query .= '`' . 'lng' . '`=' . clb_escape($_REQUEST['lng']) . ',';
                    $query .= '`' . 'end1' . '`=' . clb_escape($_REQUEST['end1']) . ',';
                    //adjusts mid point
                    $query .= '`' . 'end2' . '`=' . clb_escape($_REQUEST['end2']) . ',';
                    if ($new_mark) {
                        $query .= '`' . 'pnum' . '`=' . clb_escape($pnum) . ',';
                        $query .= '`' . 'ptype' . '`=' . clb_escape($ptype) . ',';
                        if (isset($def['created'])) {
                            $query .= '`' . 'created' . '`=' . clb_escape(clb_now_utc()) . ',';
                        }
                        $query = 'INSERT INTO ' . $table . ' SET ' . trim($query, ', ');
                    } else {
                        $query = 'UPDATE ' . $table . ' SET ' . trim($query, ', ') . ' WHERE pnum=' . clb_escape($pnum);
                    }
                    $res = $db->query($query);
                    $xml .= refesh_marker($db, $table, $pnum, $pnum);
                    unset($_REQUEST['pnum']);
                    //clear this so that the new marker does not remove the repositioned marker
                    $pnum = new_pnum($db, $table);
                    //new pnum for marker
                    $new_mark = TRUE;
                }
            }
            $query = '';
            if ('saveline' == $ajax && is_array($points)) {
                $query .= save_line_query($points, $spec);
            }
            foreach ($def as $fld => $type) {
                switch ($fld) {
                    case 'pnum':
                        if ($new_mark) {
                            $query .= '`' . $fld . '`=' . clb_escape($pnum) . ',';
                        }
                        break;
                    case 'created':
                        if ($new_mark) {
                            $query .= '`' . $fld . '`=' . clb_escape(clb_now_utc()) . ',';
                        }
                        break;
                    case 'ptype':
                        $query .= '`' . $fld . '`=' . clb_escape($ptype) . ',';
                        break;
                    default:
                        if (isset($_REQUEST[$fld])) {
                            $query .= '`' . $fld . '`=' . clb_escape($_REQUEST[$fld]) . ',';
                        }
                        break;
                }
            }
            qlog(__LINE__, $query);
            if ($new_mark) {
                $query = 'INSERT INTO ' . $table . ' SET ' . trim($query, ', ');
            }
            if (!$new_mark) {
                $query = 'UPDATE ' . $table . ' SET ' . trim($query, ', ') . ' WHERE pnum=' . clb_escape($pnum);
            }
            $res = $db->query($query);
            //when saving a marker remember the type to be used as the default for next new marker.
            $name = clb_val(FALSE, $spec, 'polyline') ? 'type_line' : 'type_mark';
            $xml .= clb_tag('response', '', $ptype, array('type' => 'state', 'pnum' => $name)) . "\n";
            //pnum is the "id" name is the "id" of the state we are setting
            $xml .= refesh_marker($db, $table, $pnum, clb_val(FALSE, $_REQUEST, 'pnum'));
            //want to fall through to show a bubble if saving a line
            //so break when either condition fails
            if ('saveline' == $ajax) {
                $xml .= marker_bubble($db, $spec, $table, $pnum);
            }
            break;
        case 'bubble':
            if (!$spec || !$pnum) {
                $msg = 'could not identify the marker type.';
                break;
            }
            $xml .= marker_bubble($db, $spec, $table, $pnum);
            break;
        case 'delete':
            $query = 'DELETE FROM ' . $table . ' WHERE pnum=' . clb_escape($pnum);
            $sel = $db->query($query);
            //remove old marker, which closes info box
            $xml .= clb_tag('response', '', '', array('type' => 'remove', 'pnum' => $_REQUEST['pnum'])) . "\n";
            break;
    }
    if ($ajax) {
        if ($msg) {
            $xml .= clb_tag('response', $msg, '', array('type' => 'info')) . "\n";
        }
        if (!$xml) {
            $xml .= clb_tag('response', '', '', array('type' => 'null')) . "\n";
        }
        // qlog(__LINE__, $xml);
        clb_response('xml', $xml);
    }
}
コード例 #13
0
ファイル: production.php プロジェクト: BrorHolm/Orkfia-2008
function getBankProduction(&$objUser)
{
    $production = array();
    $iAllianceId = $objUser->get_stat(ALLIANCE);
    $iLand = $objUser->get_build(LAND);
    $arrMines = getMineProduction($objUser);
    $strRace = $objUser->get_stat(RACE);
    $citizens = $objUser->get_pop(CITIZENS);
    $iBanks = $objUser->get_build(BANKS);
    // Bank Income Formula
    $landratio = $iLand / 2000;
    $citzacre = max($citizens / $iLand * Min(pow($landratio, 2), 1), 1);
    $gold = $arrMines['per_each'] * 2 * exp(-50 / $citzacre);
    // Lowest Possible value
    if ($strRace == "Dragon" && $gold < 60) {
        $gold = 60;
    } elseif ($gold < 250) {
        $gold = 250;
    }
    $raw = $iBanks * $gold;
    // Research Bonus - New code                        January 09, 2008, Martel
    $arrResearch = getResearchBonuses($objUser->get_alliance());
    $research_bonus = round($raw * $arrResearch['income']);
    $total = $raw + $research_bonus;
    $production['per_each'] = $gold;
    $production['raw'] = $raw;
    $production['research_bonus'] = $research_bonus;
    $production['total'] = $total;
    return $production;
}
コード例 #14
0
ファイル: Indexes.comp.php プロジェクト: carriercomm/jbs
 $Right = $Index + 3;
 #-----------------------------------------------------------------------------
 if ($Left < 1) {
     $Right -= $Left;
 }
 #-----------------------------------------------------------------------------
 if ($Right > ($Pages = Ceil($Count / $InPage))) {
     $Left -= $Right - $Pages;
 }
 #-----------------------------------------------------------------------------
 if ($Left > 0) {
     $Div->AddChild(new Tag('IMG', array('class' => 'Button', 'alt' => 'Прокрутить назад', 'width' => 12, 'height' => 10, 'onclick' => SPrintF('TableSuperSetIndex(%s);', $Index - 6), 'src' => 'SRC:{Images/ArrowLeft.gif}')));
 }
 #-----------------------------------------------------------------------------
 $Left = Max(0, $Left);
 $Right = Min($Pages, $Right);
 #-----------------------------------------------------------------------------
 for ($i = $Left; $i < $Right; $i++) {
     #---------------------------------------------------------------------------
     $Button = new Tag('BUTTON', array('class' => 'TableSuperIndexes', 'onclick' => SPrintF('TableSuperSetIndex(%s);', $i)), $i + 1);
     #---------------------------------------------------------------------------
     if ($i == $Index) {
         $Button->AddAttribs(array('disabled' => 'true'));
     }
     #---------------------------------------------------------------------------
     $Div->AddChild($Button);
 }
 #-----------------------------------------------------------------------------
 if ($Right < $Pages) {
     $Div->AddChild(new Tag('IMG', array('class' => 'Button', 'alt' => 'Прокрутить вперед', 'width' => 12, 'height' => 10, 'onclick' => SPrintF('TableSuperSetIndex(%s);', $Index + 6), 'src' => 'SRC:{Images/ArrowRight.gif}')));
 }
コード例 #15
0
ファイル: stats.php プロジェクト: BackupTheBerlios/verlihub
						<?}?>
					</TR><TR>
						<?FOR($i = 1; $i <= $days; $i++){?>
						<TD class="fs8px bg_light center"><?Print $i;?></TD>
						<?}?>
					</TR>
				</TABLE>
			</TD><TD>
	<!-- ------- Search stats ------- -->
				<TABLE class="b1 fs9px">
					</TR><TR>
						<TD class="h3 center b1" colspan=<?Print $days?>><?Print $text_search_stats;?></TD>
					</TR><TR>
						<TD class="bg_light" colspan=<?Print $days;?>>
							<?Print "<FONT class=\"b\"> ".$text_max."</FONT> : ".@Max($max_search);?>/s&nbsp;
							<?Print "<FONT class=\"b\"> ".$text_min."</FONT> : ".@Min($min_search);?>/s&nbsp;
							<?Print "<FONT class=\"b\"> ".$text_averange."</FONT> : ".$total['search'];?>/s
						</TD>
					</TR><TR>
						<?FOR($i = 1; $i <= $days; $i++){
						$info  = $text_averange." : ".$search[$i]."/s\n";
						$info .= $text_min." : ".$min_search[$i]."/s\n";
						$info .= $text_max." : ".$max_search[$i]."/s";?>
						<TD class="fs0px b1 center bottom" height=100 title="<?Print $info;?>">
							<?IF($search[$i]){?><IMG src="img/bar.gif" width=8 height=<?Print @Round($search[$i] / Max($search) * 100);?>><?}
							ELSE{?><IMG src="img/space.gif" width=8><?}?>
						</TD>
						<?}?>
					</TR><TR>
						<?FOR($i = 1; $i <= $days; $i++){?>
						<TD class="fs8px bg_light center"><?Print $i;?></TD>
コード例 #16
0
 function Resize_Image($src, $width = 0, $height = 0, $dst)
 {
     if ($height <= 0 && $width <= 0) {
         return false;
     }
     // Setting defaults and meta
     $image = '';
     $final_width = 0;
     $final_height = 0;
     list($width_old, $height_old, $image_type) = GetImageSize($src);
     // Calculating proportionality
     if ($width == 0) {
         $factor = $height / $height_old;
     } elseif ($height == 0) {
         $factor = $width / $width_old;
     } else {
         $factor = Min($width / $width_old, $height / $height_old);
     }
     $final_width = Round($width_old * $factor);
     $final_height = Round($height_old * $factor);
     // Loading image to memory according to type
     switch ($image_type) {
         case IMAGETYPE_GIF:
             $image = imagecreatefromgif($src);
             break;
         case IMAGETYPE_JPEG:
             $image = imagecreatefromjpeg($src);
             break;
         case IMAGETYPE_PNG:
             $image = imagecreatefrompng($src);
             break;
         default:
             return false;
     }
     // This is the resizing/resampling/transparency-preserving magic
     $image_resized = ImageCreateTrueColor($final_width, $final_height);
     if ($image_type == IMAGETYPE_GIF || $image_type == IMAGETYPE_PNG) {
         $transparency = ImageColorTransparent($image);
         if ($image_type == IMAGETYPE_GIF && $transparency >= 0) {
             list($r, $g, $b) = Array_Values(ImageColorsForIndex($image, $transparency));
             $transparency = ImageColorAllocate($image_resized, $r, $g, $b);
             Imagefill($image_resized, 0, 0, $transparency);
             ImageColorTransparent($image_resized, $transparency);
         } elseif ($image_type == IMAGETYPE_PNG) {
             ImageAlphaBlending($image_resized, false);
             $color = ImageColorAllocateAlpha($image_resized, 0, 0, 0, 127);
             ImageFill($image_resized, 0, 0, $color);
             ImageSaveAlpha($image_resized, true);
         }
     }
     ImageCopyResampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
     // Writing image
     switch ($image_type) {
         case IMAGETYPE_GIF:
             imagegif($image_resized, $dst);
             break;
         case IMAGETYPE_JPEG:
             imagejpeg($image_resized, $dst, 85);
             break;
         case IMAGETYPE_PNG:
             imagepng($image_resized, $dst);
             break;
         default:
             return false;
     }
 }
コード例 #17
0
ファイル: jpgraph_line.php プロジェクト: rrsc/freemed
 function Min()
 {
     list($xmin, $ymin) = $this->plots[0]->Min();
     foreach ($this->plots as $p) {
         list($xm, $ym) = $p->Min();
         $xmin = Min($xmin, $xm);
         $ymin = Min($ymin, $ym);
     }
     return array($xmin, $ymin);
 }
コード例 #18
0
ファイル: jpgraph.php プロジェクト: teammember8/roundcube
 function Stroke($aStrokeFileName = "")
 {
     // If the filename is the predefined value = '_csim_special_'
     // we assume that the call to stroke only needs to do enough
     // to correctly generate the CSIM maps.
     // We use this variable to skip things we don't strictly need
     // to do to generate the image map to improve performance
     // a best we can. Therefor you will see a lot of tests !$_csim in the
     // code below.
     $_csim = $aStrokeFileName === _CSIM_SPECIALFILE;
     // We need to know if we have stroked the plot in the
     // GetCSIMareas. Otherwise the CSIM hasn't been generated
     // and in the case of GetCSIM called before stroke to generate
     // CSIM without storing an image to disk GetCSIM must call Stroke.
     $this->iHasStroked = true;
     // Do any pre-stroke adjustment that is needed by the different plot types
     // (i.e bar plots want's to add an offset to the x-labels etc)
     for ($i = 0; $i < count($this->plots); ++$i) {
         $this->plots[$i]->PreStrokeAdjust($this);
         $this->plots[$i]->Legend($this);
     }
     // Any plots on the second Y scale?
     if ($this->y2scale != null) {
         for ($i = 0; $i < count($this->y2plots); ++$i) {
             $this->y2plots[$i]->PreStrokeAdjust($this);
             $this->y2plots[$i]->Legend($this);
         }
     }
     // Bail out if any of the Y-axis not been specified and
     // has no plots. (This means it is impossible to do autoscaling and
     // no other scale was given so we can't possible draw anything). If you use manual
     // scaling you also have to supply the tick steps as well.
     if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) {
         $e = "Can't draw unspecified Y-scale.<br>\nYou have either:<br>\n";
         $e .= "1. Specified an Y axis for autoscaling but have not supplied any plots<br>\n";
         $e .= "2. Specified a scale manually but have forgot to specify the tick steps";
         JpGraphError::Raise($e);
     }
     // Bail out if no plots and no specified X-scale
     if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) {
         JpGraphError::Raise("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>");
     }
     //Check if we should autoscale y-axis
     if (!$this->yscale->IsSpecified() && count($this->plots) > 0) {
         list($min, $max) = $this->GetPlotsYMinMax($this->plots);
         $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
     } elseif ($this->yscale->IsSpecified() && $this->yscale->auto_ticks) {
         // If the user has specified a min/max value for the scale we still use the
         // autoscaling to get a suitable tick distance. This might adjust the specified
         // min max values so they end up on a tick mark.
         $min = $this->yscale->scale[0];
         $max = $this->yscale->scale[1];
         $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
     }
     if ($this->y2scale != null) {
         if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) {
             list($min, $max) = $this->GetPlotsYMinMax($this->y2plots);
             $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
         } elseif ($this->y2scale->IsSpecified() && $this->y2scale->auto_ticks) {
             // If the user has specified a min/max value for the scale we still use the
             // autoscaling to get a suitable tick distance. This might adjust the specified
             // min max values so they end up on a tick mark.
             $min = $this->y2scale->scale[0];
             $max = $this->y2scale->scale[1];
             $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
         }
     }
     //Check if we should autoscale x-axis
     if (!$this->xscale->IsSpecified()) {
         if (substr($this->axtype, 0, 4) == "text") {
             $max = 0;
             foreach ($this->plots as $p) {
                 $max = max($max, $p->numpoints - 1);
             }
             $min = 0;
             if ($this->y2axis != null) {
                 foreach ($this->y2plots as $p) {
                     $max = max($max, $p->numpoints - 1);
                 }
             }
             $this->xscale->Update($this->img, $min, $max);
             $this->xscale->ticks->Set($this->xaxis->tick_step, 1);
             $this->xscale->ticks->SupressMinorTickMarks();
         } else {
             list($min, $ymin) = $this->plots[0]->Min();
             list($max, $ymax) = $this->plots[0]->Max();
             foreach ($this->plots as $p) {
                 list($xmin, $ymin) = $p->Min();
                 list($xmax, $ymax) = $p->Max();
                 $min = Min($xmin, $min);
                 $max = Max($xmax, $max);
             }
             if ($this->y2axis != null) {
                 foreach ($this->y2plots as $p) {
                     list($xmin, $ymin) = $p->Min();
                     list($xmax, $ymax) = $p->Max();
                     $min = Min($xmin, $min);
                     $max = Max($xmax, $max);
                 }
             }
             $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor);
         }
         //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale
         if (!is_numeric($this->yaxis->pos) && !is_string($this->yaxis->pos)) {
             $this->yaxis->SetPos($this->xscale->GetMinVal());
         }
         if ($this->y2axis != null) {
             if (!is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos)) {
                 $this->y2axis->SetPos($this->xscale->GetMaxVal());
             }
             $this->y2axis->SetTitleSide(SIDE_RIGHT);
         }
     }
     // If we have a negative values and x-axis position is at 0
     // we need to supress the first and possible the last tick since
     // they will be drawn on top of the y-axis (and possible y2 axis)
     // The test below might seem strange the reasone being that if
     // the user hasn't specified a value for position this will not
     // be set until we do the stroke for the axis so as of now it
     // is undefined.
     // For X-text scale we ignore all this since the tick are usually
     // much further in and not close to the Y-axis. Hence the test
     // for 'text'
     if (($this->yaxis->pos == $this->xscale->GetMinVal() || is_string($this->yaxis->pos) && $this->yaxis->pos == 'min') && !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 && substr($this->axtype, 0, 4) != 'text' && $this->xaxis->pos != "min") {
         //$this->yscale->ticks->SupressZeroLabel(false);
         $this->xscale->ticks->SupressFirst();
         if ($this->y2axis != null) {
             $this->xscale->ticks->SupressLast();
         }
     } elseif (!is_numeric($this->yaxis->pos) && $this->yaxis->pos == 'max') {
         $this->xscale->ticks->SupressLast();
     }
     if (!$_csim) {
         $this->StrokePlotArea();
         $this->StrokeAxis();
     }
     // Stroke bands
     if ($this->bands != null && !$_csim) {
         for ($i = 0; $i < count($this->bands); ++$i) {
             // Stroke all bands that asks to be in the background
             if ($this->bands[$i]->depth == DEPTH_BACK) {
                 $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale);
             }
         }
     }
     if ($this->grid_depth == DEPTH_BACK && !$_csim) {
         $this->ygrid->Stroke();
         $this->xgrid->Stroke();
     }
     // Stroke Y2-axis
     if ($this->y2axis != null && !$_csim) {
         $this->y2axis->Stroke($this->xscale);
         $this->y2grid->Stroke();
     }
     $oldoff = $this->xscale->off;
     if (substr($this->axtype, 0, 4) == "text") {
         $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step);
     }
     // Stroke all plots for Y1 axis
     for ($i = 0; $i < count($this->plots); ++$i) {
         $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale);
         $this->plots[$i]->StrokeMargin($this->img);
     }
     // Stroke all plots for Y2 axis
     if ($this->y2scale != null) {
         for ($i = 0; $i < count($this->y2plots); ++$i) {
             $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale);
         }
     }
     $this->xscale->off = $oldoff;
     if ($this->grid_depth == DEPTH_FRONT && !$_csim) {
         $this->ygrid->Stroke();
         $this->xgrid->Stroke();
     }
     // Stroke bands
     if ($this->bands != null) {
         for ($i = 0; $i < count($this->bands); ++$i) {
             // Stroke all bands that asks to be in the foreground
             if ($this->bands[$i]->depth == DEPTH_FRONT) {
                 $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale);
             }
         }
     }
     // Stroke any lines added
     if ($this->lines != null) {
         for ($i = 0; $i < count($this->lines); ++$i) {
             $this->lines[$i]->Stroke($this->img, $this->xscale, $this->yscale);
         }
     }
     // Finally draw the axis again since some plots may have nagged
     // the axis in the edges.
     if (!$_csim) {
         $this->StrokeAxis();
     }
     if ($this->y2scale != null && !$_csim) {
         $this->y2axis->Stroke($this->xscale);
     }
     if (!$_csim) {
         $this->StrokePlotBox();
         $this->footer->Stroke($this->img);
     }
     if (!$_csim) {
         // The titles and legends never gets rotated so make sure
         // that the angle is 0 before stroking them
         $aa = $this->img->SetAngle(0);
         $this->StrokeTitles();
     }
     $this->legend->Stroke($this->img);
     if (!$_csim) {
         $this->StrokeTexts();
         $this->img->SetAngle($aa);
         // Draw an outline around the image map
         if (JPG_DEBUG) {
             $this->DisplayClientSideaImageMapAreas();
         }
         // Adjust the appearance of the image
         $this->AdjustSaturationBrightnessContrast();
         // If the filename is given as the special "__handle"
         // then the image handler is returned and the image is NOT
         // streamed back
         if ($aStrokeFileName == _IMG_HANDLER) {
             return $this->img->img;
         } else {
             // Finally stream the generated picture
             $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
         }
     }
 }
コード例 #19
0
ファイル: jpgraph_gantt.php プロジェクト: jwigal/churchinfo
 function GetBarMinMax()
 {
     $max = $this->scale->NormalizeDate($this->iObj[0]->GetMaxDate());
     $min = $this->scale->NormalizeDate($this->iObj[0]->GetMinDate());
     for ($i = 1; $i < count($this->iObj); ++$i) {
         $max = Max($max, $this->scale->NormalizeDate($this->iObj[$i]->GetMaxDate()));
         $min = Min($min, $this->scale->NormalizeDate($this->iObj[$i]->GetMinDate()));
     }
     $minDate = date("Y-m-d", $min);
     $min = strtotime($minDate);
     $maxDate = date("Y-m-d 23:59", $max);
     $max = strtotime($maxDate);
     return array($min, $max);
 }
コード例 #20
0
ファイル: ClauseImage.comp.php プロジェクト: carriercomm/jbs
         if (Is_Error($Image)) {
             return ERROR | @Trigger_Error(500);
         }
         #-------------------------------------------------------------------------
     } elseif ($Height) {
         #-------------------------------------------------------------------------
         $Width = $Height / $Index;
         #-------------------------------------------------------------------------
         $Image = Image_Resize($Image, (int) $Width, (int) $Height);
         if (Is_Error($Image)) {
             return ERROR | @Trigger_Error(500);
         }
         #-------------------------------------------------------------------------
     } elseif ($Scale != 100) {
         #-------------------------------------------------------------------------
         $Scale = Min(Max(50, $Scale), 200);
         #-------------------------------------------------------------------------
         $Width = $Size['Width'] * ($Scale / 100);
         $Height = $Width * $Index;
         #-------------------------------------------------------------------------
         $Image = Image_Resize($Image, (int) $Width, (int) $Height);
         if (Is_Error($Image)) {
             return ERROR | @Trigger_Error(500);
         }
     }
     #---------------------------------------------------------------------------
     Header('Content-Type: image');
     Header('Cache-Control: private, max-age=86400');
     #---------------------------------------------------------------------------
     return $Image;
 default:
コード例 #21
0
ファイル: jpgraph.php プロジェクト: eguicciardi/ada
 function Stroke()
 {
     // Do any pre-stroke adjustment that is needed by the different plot types
     // (i.e bar plots want's to add an offset to the x-labels etc)
     for ($i = 0; $i < count($this->plots); ++$i) {
         $this->plots[$i]->PreStrokeAdjust($this);
         $this->plots[$i]->Legend($this);
     }
     if ($this->y2scale != null) {
         for ($i = 0; $i < count($this->y2plots); ++$i) {
             $this->y2plots[$i]->PreStrokeAdjust($this);
             $this->y2plots[$i]->Legend($this);
         }
     }
     // Bail out if any of the Y-axis not been specified and
     // has no plots. (This means it is impossible to do autoscaling and
     // no other scale was given so we can't possible draw anything). If you use manual
     // scaling you also have to supply the tick steps as well.
     if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) {
         die("<strong>JpGraph: Can't draw unspecified Y-scale.</strong><br>\n\t\t\t\tYou have either:\n\t\t\t\t<br>* Specified an Y axis for autoscaling but have not supplied any plots");
     }
     if ($this->yscale->IsSpecified() && !$this->yscale->ticks->IsSpecified() || $this->y2scale && ($this->y2scale->IsSpecified() && !$this->y2scale->ticks->IsSpecified())) {
         die("<strong>JpGraph: Can't draw unspecified Y-scale.</strong>\n\t\t\t\t<br>You have specified an Y axis with min and max but forgotten to specify tick steps.");
     }
     // Bail out if no plots and no specified X-scale
     if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) {
         die("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>");
     }
     //Check if we should autoscale y-axis
     if (!$this->yscale->IsSpecified() && count($this->plots) > 0) {
         list($min, $max) = $this->GetPlotsYMinMax($this->plots);
         $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
     }
     if ($this->y2scale != null) {
         if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) {
             list($min, $max) = $this->GetPlotsYMinMax($this->y2plots);
             $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
         }
     }
     //Check if we should autoscale x-axis
     if (!$this->xscale->IsSpecified()) {
         if (substr($this->axtype, 0, 4) == "text") {
             $max = 0;
             foreach ($this->plots as $p) {
                 $max = max($max, $p->numpoints - 1);
             }
             $min = 1;
             $this->xscale->Update($this->img, $min, $max + 1);
             $this->xscale->ticks->Set($this->xaxis->label_step, 1);
             $this->xscale->ticks->SupressMinorTickMarks();
         } else {
             list($min, $ymin) = $this->plots[0]->Min();
             list($max, $ymax) = $this->plots[0]->Max();
             foreach ($this->plots as $p) {
                 list($xmin, $ymin) = $p->Min();
                 list($xmax, $ymax) = $p->Max();
                 $min = Min($xmin, $min);
                 $max = Min($xmax, $max);
             }
             $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor);
         }
         //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale
         $this->yaxis->SetPos($this->xscale->GetMinVal());
         if ($this->y2axis != null) {
             $this->y2axis->SetPos($this->xscale->GetMaxVal());
             $this->y2axis->SetTitleSide(SIDE_RIGHT);
         }
     }
     // If we have a negative values and x-axis position is at 0
     // we need to supress the first and possible the last tick since
     // they will be drawn on top of the y-axis (and possible y2 axis)
     // The test below might seem strange the reasone being that if
     // the user hasn't specified a value for position this will not
     // be set until we do the stroke for the axis so as of now it
     // is undefined.
     if (!$this->xaxis->pos && $this->yscale->GetMinVal() < 0) {
         $this->yscale->ticks->SupressZeroLabel(false);
         $this->xscale->ticks->SupressFirst();
         if ($this->y2axis != null) {
             $this->xscale->ticks->SupressLast();
         }
     }
     // Copy in background image
     if ($this->background_image != "") {
         $bkgimg = $this->LoadBkgImage($this->background_image_format);
         $bw = ImageSX($bkgimg);
         $bh = ImageSY($bkgimg);
         $aa = $this->img->SetAngle(0);
         switch ($this->background_image_type) {
             case 1:
                 // Resize to just fill the plotarea
                 $this->StrokeFrame();
                 imagecopyresized($this->img->img, $bkgimg, $this->img->left_margin, $this->img->top_margin, 0, 0, $this->img->plotwidth, $this->img->plotheight, $bw, $bh);
                 break;
             case 2:
                 // Fill the whole area from upper left corner, resize to just fit
                 imagecopyresized($this->img->img, $bkgimg, 0, 0, 0, 0, $this->img->width, $this->img->height, $bw, $bh);
                 $this->StrokeFrame();
                 break;
             case 3:
                 // Just fill the image from left corner, no resizing
                 imagecopyresized($this->img->img, $bkgimg, 0, 0, 0, 0, $bw, $bh, $bw, $bh);
                 $this->StrokeFrame();
                 break;
             default:
                 die("JpGraph Error: Unknown background image layout");
         }
         $this->img->SetAngle($aa);
     } else {
         $aa = $this->img->SetAngle(0);
         $this->StrokeFrame();
         $this->img->SetAngle($aa);
         $this->img->SetColor($this->plotarea_color);
         $this->img->FilledRectangle($this->img->left_margin, $this->img->top_margin, $this->img->width - $this->img->right_margin, $this->img->height - $this->img->bottom_margin);
     }
     $this->xaxis->Stroke($this->yscale);
     $this->xgrid->Stroke();
     $this->yaxis->Stroke($this->xscale);
     $this->ygrid->Stroke();
     if ($this->y2axis != null) {
         $this->y2axis->Stroke($this->xscale);
         $this->y2grid->Stroke();
     }
     //
     $oldoff = $this->xscale->off;
     if (substr($this->axtype, 0, 4) == "text") {
         $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step);
     }
     foreach ($this->plots as $p) {
         $p->Stroke($this->img, $this->xscale, $this->yscale);
         $p->StrokeMargin($this->img);
     }
     if ($this->y2scale != null) {
         foreach ($this->y2plots as $p) {
             $p->Stroke($this->img, $this->xscale, $this->y2scale);
         }
     }
     $this->xscale->off = $oldoff;
     // Finally draw the axis again since some plots may have nagged
     // the axis in the edges.
     $this->yaxis->Stroke($this->xscale);
     $this->xaxis->Stroke($this->yscale);
     if ($this->y2scale != null) {
         $this->y2axis->Stroke($this->xscale);
     }
     // Should we draw a box around the plot area?
     if ($this->boxed) {
         $this->img->SetLineWeight($this->box_weight);
         $this->img->SetColor($this->box_color);
         $this->img->Rectangle($this->img->left_margin, $this->img->top_margin, $this->img->width - $this->img->right_margin, $this->img->height - $this->img->bottom_margin);
     }
     $aa = $this->img->SetAngle(0);
     // Stroke title
     $this->title->Center($this->img->left_margin, $this->img->width - $this->img->right_margin, 5);
     $this->title->Stroke($this->img);
     // Stroke legend
     $this->legend->Stroke($this->img);
     // Stroke any user added text objects
     if ($this->texts != null) {
         foreach ($this->texts as $t) {
             $t->x *= $this->img->width;
             $t->y *= $this->img->height;
             $t->Stroke($this->img);
         }
     }
     $this->img->SetAngle($aa);
     // Finally stream the generated picture
     $this->cache->PutAndStream($this->img, $this->cache_name);
 }
コード例 #22
0
ファイル: upnpplayer.class.php プロジェクト: bl00m/ampache
 /**
  * SetVolume
  */
 public function SetVolume($value)
 {
     $desiredVolume = Max(0, Min(100, $value));
     $instanceId = 0;
     $channel = 'Master';
     $response = $this->Device()->sendRequestToDevice('SetVolume', array('InstanceID' => $instanceId, 'Channel' => $channel, 'DesiredVolume' => $desiredVolume));
     return true;
 }
コード例 #23
0
 function GetBarMinMax()
 {
     $start = 0;
     $n = count($this->iObj);
     while ($start < $n && $this->iObj[$start]->GetMaxDate() === false) {
         ++$start;
     }
     if ($start >= $n) {
         JpgraphError::RaiseL(6006);
         //('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]');
     }
     $max = $this->scale->NormalizeDate($this->iObj[$start]->GetMaxDate());
     $min = $this->scale->NormalizeDate($this->iObj[$start]->GetMinDate());
     for ($i = $start + 1; $i < $n; ++$i) {
         $rmax = $this->scale->NormalizeDate($this->iObj[$i]->GetMaxDate());
         if ($rmax != false) {
             $max = Max($max, $rmax);
         }
         $rmin = $this->scale->NormalizeDate($this->iObj[$i]->GetMinDate());
         if ($rmin != false) {
             $min = Min($min, $rmin);
         }
     }
     $minDate = date("Y-m-d", $min);
     $min = strtotime($minDate);
     $maxDate = date("Y-m-d 23:59", $max);
     $max = strtotime($maxDate);
     return array($min, $max);
 }
コード例 #24
0
ファイル: jpgraph.php プロジェクト: rrsc/freemed
 function Stroke($aStrokeFileName = "")
 {
     // Do any pre-stroke adjustment that is needed by the different plot types
     // (i.e bar plots want's to add an offset to the x-labels etc)
     for ($i = 0; $i < count($this->plots); ++$i) {
         $this->plots[$i]->PreStrokeAdjust($this);
         $this->plots[$i]->Legend($this);
     }
     // Any plots on the second Y scale?
     if ($this->y2scale != null) {
         for ($i = 0; $i < count($this->y2plots); ++$i) {
             $this->y2plots[$i]->PreStrokeAdjust($this);
             $this->y2plots[$i]->Legend($this);
         }
     }
     // Bail out if any of the Y-axis not been specified and
     // has no plots. (This means it is impossible to do autoscaling and
     // no other scale was given so we can't possible draw anything). If you use manual
     // scaling you also have to supply the tick steps as well.
     if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) {
         JpGraphError::Raise("<strong>JpGraph: Can't draw unspecified Y-scale.</strong><br>\n\t\t\t\tYou have either:\n\t\t\t\t<br>* Specified an Y axis for autoscaling but have not supplied any plots\n\t\t\t\t<br>* Specified a scale manually but have forgot to specify the tick steps");
     }
     // Bail out if no plots and no specified X-scale
     if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) {
         JpGraphError::Raise("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>");
     }
     //Check if we should autoscale y-axis
     if (!$this->yscale->IsSpecified() && count($this->plots) > 0) {
         list($min, $max) = $this->GetPlotsYMinMax($this->plots);
         $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
     }
     if ($this->y2scale != null) {
         if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) {
             list($min, $max) = $this->GetPlotsYMinMax($this->y2plots);
             $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor);
         }
     }
     //Check if we should autoscale x-axis
     if (!$this->xscale->IsSpecified()) {
         if (substr($this->axtype, 0, 4) == "text") {
             $max = 0;
             foreach ($this->plots as $p) {
                 $max = max($max, $p->numpoints - 1);
             }
             $min = 0;
             if ($this->y2axis != null) {
                 foreach ($this->y2plots as $p) {
                     $max = max($max, $p->numpoints - 1);
                 }
             }
             $this->xscale->Update($this->img, $min, $max);
             $this->xscale->ticks->Set($this->xaxis->tick_step, 1);
             $this->xscale->ticks->SupressMinorTickMarks();
         } else {
             list($min, $ymin) = $this->plots[0]->Min();
             list($max, $ymax) = $this->plots[0]->Max();
             foreach ($this->plots as $p) {
                 list($xmin, $ymin) = $p->Min();
                 list($xmax, $ymax) = $p->Max();
                 $min = Min($xmin, $min);
                 $max = Max($xmax, $max);
             }
             if ($this->y2axis != null) {
                 foreach ($this->y2plots as $p) {
                     list($xmin, $ymin) = $p->Min();
                     list($xmax, $ymax) = $p->Max();
                     $min = Min($xmin, $min);
                     $max = Max($xmax, $max);
                 }
             }
             $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor);
         }
         //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale
         $this->yaxis->SetPos($this->xscale->GetMinVal());
         if ($this->y2axis != null) {
             $this->y2axis->SetPos($this->xscale->GetMaxVal());
             $this->y2axis->SetTitleSide(SIDE_RIGHT);
         }
     }
     // If we have a negative values and x-axis position is at 0
     // we need to supress the first and possible the last tick since
     // they will be drawn on top of the y-axis (and possible y2 axis)
     // The test below might seem strange the reasone being that if
     // the user hasn't specified a value for position this will not
     // be set until we do the stroke for the axis so as of now it
     // is undefined.
     if (!$this->xaxis->pos && $this->yscale->GetMinVal() < 0) {
         $this->yscale->ticks->SupressZeroLabel(false);
         $this->xscale->ticks->SupressFirst();
         if ($this->y2axis != null) {
             $this->xscale->ticks->SupressLast();
         }
     }
     $this->StrokePlotArea();
     // Stroke axis
     $this->xaxis->Stroke($this->yscale);
     $this->yaxis->Stroke($this->xscale);
     // Stroke bands
     if ($this->bands != null) {
         for ($i = 0; $i < count($this->bands); ++$i) {
             // Stroke all bands that asks to be in the background
             if ($this->bands[$i]->depth == DEPTH_BACK) {
                 $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale);
             }
         }
     }
     if ($this->grid_depth == DEPTH_BACK) {
         $this->ygrid->Stroke();
         $this->xgrid->Stroke();
     }
     // Stroke Y2-axis
     if ($this->y2axis != null) {
         $this->y2axis->Stroke($this->xscale);
         $this->y2grid->Stroke();
     }
     $oldoff = $this->xscale->off;
     if (substr($this->axtype, 0, 4) == "text") {
         $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step);
     }
     // Stroke all plots for Y1 axis
     for ($i = 0; $i < count($this->plots); ++$i) {
         $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale);
         $this->plots[$i]->StrokeMargin($this->img);
     }
     // Stroke all plots for Y2 axis
     if ($this->y2scale != null) {
         for ($i = 0; $i < count($this->y2plots); ++$i) {
             $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale);
         }
     }
     $this->xscale->off = $oldoff;
     if ($this->grid_depth == DEPTH_FRONT) {
         $this->ygrid->Stroke();
         $this->xgrid->Stroke();
     }
     // Stroke bands
     if ($this->bands != null) {
         for ($i = 0; $i < count($this->bands); ++$i) {
             // Stroke all bands that asks to be in the foreground
             if ($this->bands[$i]->depth == DEPTH_FRONT) {
                 $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale);
             }
         }
     }
     // Stroke any lines added
     if ($this->lines != null) {
         for ($i = 0; $i < count($this->lines); ++$i) {
             $this->lines[$i]->Stroke($this->img, $this->xscale, $this->yscale);
         }
     }
     // Finally draw the axis again since some plots may have nagged
     // the axis in the edges.
     $this->yaxis->Stroke($this->xscale);
     $this->xaxis->Stroke($this->yscale);
     if ($this->y2scale != null) {
         $this->y2axis->Stroke($this->xscale);
     }
     $this->StrokePlotBox();
     // The titles and legends never gets rotated so make sure
     // that the angle is 0 before stroking them
     $aa = $this->img->SetAngle(0);
     $this->StrokeTitles();
     $this->legend->Stroke($this->img);
     $this->StrokeTexts();
     $this->img->SetAngle($aa);
     // Draw an outline around the image map
     if (JPG_DEBUG) {
         $this->DisplayClientSideaImageMapAreas();
     }
     // Adjust the appearance of the image
     $this->AdjustSaturationBrightnessContrast();
     // Finally stream the generated picture
     $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
 }
コード例 #25
0
ファイル: jpgraph.php プロジェクト: sudogem/brcms
 function GetXMinMax()
 {
     list($min, $ymin) = $this->plots[0]->Min();
     list($max, $ymax) = $this->plots[0]->Max();
     foreach ($this->plots as $p) {
         list($xmin, $ymin) = $p->Min();
         list($xmax, $ymax) = $p->Max();
         $min = Min($xmin, $min);
         $max = Max($xmax, $max);
     }
     if ($this->y2axis != null) {
         foreach ($this->y2plots as $p) {
             list($xmin, $ymin) = $p->Min();
             list($xmax, $ymax) = $p->Max();
             $min = Min($xmin, $min);
             $max = Max($xmax, $max);
         }
     }
     $n = count($this->ynaxis);
     for ($i = 0; $i < $n; ++$i) {
         if ($this->ynaxis[$i] != null) {
             foreach ($this->ynplots[$i] as $p) {
                 list($xmin, $ymin) = $p->Min();
                 list($xmax, $ymax) = $p->Max();
                 $min = Min($xmin, $min);
                 $max = Max($xmax, $max);
             }
         }
     }
     return array($min, $max);
 }
コード例 #26
0
ファイル: VPSOrderPay.comp.php プロジェクト: carriercomm/jbs
     #-------------------------------------------------------------
     $eDay = (int) Date('t', MkTime(0, 0, 0, $Month, 1, $Year));
     #-------------------------------------------------------------
     for ($Day = 1; $Day <= $eDay; $Day++) {
         #-----------------------------------------------------------
         $CurrentStamp = MkTime(0, 0, 0, $Month, $Day, $Year);
         #-----------------------------------------------------------
         if ($CurrentStamp >= $sTime && $CurrentStamp <= $eTime) {
             #---------------------------------------------------------
             $Script[] = SPrintF('Calendar[%u][%u] = {Start:%u,Stop:%u}', $Year, $Month - 1, $Day, MkTime(0, 0, 0, $Month, $eDay, $Year) > $eTime ? Date('j', $eTime) : $eDay);
             #---------------------------------------------------------
             break;
         }
     }
     #-------------------------------------------------------------
     $CurrentStamp = MkTime(0, 0, 0, $Month, Min(Date('j', $ExpirationDate), Date('t', MkTime(0, 0, 0, $Month, 1, $Year))), $Year);
     #-------------------------------------------------------------
     if ($CurrentStamp >= $sTime && $CurrentStamp <= $eTime) {
         #-----------------------------------------------------------
         $Period = Date('n', $CurrentStamp) + Date('Y', $CurrentStamp) * 12 - (Date('n', $ExpirationDate) + Date('Y', $ExpirationDate) * 12);
         #-----------------------------------------------------------
         if ($Period < 4 || $Period % 3 == 0 && $Period < 13 || $Period % 12 == 0) {
             #---------------------------------------------------------
             $Script[] = SPrintF('Periods[%u] = {Year:%u,Month:%u,Day:%u}', $Period, $Year, $Month - 1, Date('j', $ExpirationDate));
             #---------------------------------------------------------
             $Periods[$Period] = SPrintF('%u мес.', $Period);
         }
     }
 }
 #---------------------------------------------------------------
 $Years[] = $Year;
コード例 #27
0
ファイル: jpgraph.php プロジェクト: hostellerie/nexpro
 function GetXMinMax()
 {
     list($min, $ymin) = $this->plots[0]->Min();
     list($max, $ymax) = $this->plots[0]->Max();
     foreach ($this->plots as $p) {
         list($xmin, $ymin) = $p->Min();
         list($xmax, $ymax) = $p->Max();
         $min = Min($xmin, $min);
         $max = Max($xmax, $max);
     }
     if ($this->y2axis != null) {
         foreach ($this->y2plots as $p) {
             list($xmin, $ymin) = $p->Min();
             list($xmax, $ymax) = $p->Max();
             $min = Min($xmin, $min);
             $max = Max($xmax, $max);
         }
     }
     return array($min, $max);
 }
コード例 #28
0
ファイル: wp-thumb.php プロジェクト: RichyVN/RST-Intranet
 function Resample_Image()
 {
     if ($this->dst_height <= 0 && $this->dst_width <= 0) {
         return False;
     }
     # Setting defaults and meta
     $image = $this->image;
     $final_width = 0;
     $final_height = 0;
     # Get File Information
     if ($arr_image_size = GetImageSize($this->attachment_file)) {
         list($width_old, $height_old, $image_type) = $arr_image_size;
     } else {
         return False;
     }
     if ($this->crop) {
         $factor = Max($this->dst_width / $width_old, $this->dst_height / $height_old);
         $final_width = $this->dst_width;
         $final_height = $this->dst_height;
     } else {
         # Calculating proportionality
         if ($this->dst_width == 0) {
             $factor = $this->dst_height / $height_old;
         } elseif ($this->dst_height == 0) {
             $factor = $this->dst_width / $width_old;
         } else {
             $factor = Min($this->dst_width / $width_old, $this->dst_height / $height_old);
         }
         $final_width = $width_old * $factor;
         $final_height = $height_old * $factor;
     }
     # Resample the image
     if (!Function_Exists('ImageCreateTrueColor')) {
         return False;
     }
     if (!($this->image = ImageCreateTrueColor($final_width, $final_height))) {
         return False;
     }
     # Copy the Transparency properties
     if ($image_type == IMAGETYPE_GIF || $image_type == IMAGETYPE_PNG) {
         if ($image_type == IMAGETYPE_GIF && $transparency >= 0) {
             $transparency = ImageColorTransparent($image);
             list($r, $g, $b) = Array_Values(ImageColorsForIndex($image, $transparency));
             ImageColorAllocate($this->image, $r, $g, $b);
             Imagefill($this->image, 0, 0, $transparency);
             ImageColorTransparent($this->image, $transparency);
         } elseif ($image_type == IMAGETYPE_PNG) {
             ImageAlphaBlending($this->image, False);
             ImageSaveAlpha($this->image, True);
         }
     }
     if (!Function_Exists('ImageCopyResampled')) {
         return False;
     }
     if ($this->crop) {
         # Crop the image
         ImageCopyResampled($this->image, $image, 0, 0, ($width_old * $factor - $final_width) / (2 * $factor), ($height_old * $factor - $final_height) / (2 * $factor), $final_width, $final_height, $final_width / $factor, $final_height / $factor);
         // int $src_w , int $src_h
     } else {
         # Resample aspect ratio
         ImageCopyResampled($this->image, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
     }
     return True;
 }