当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Rest_Client::getGraph方法代码示例

本文整理汇总了PHP中Zend_Rest_Client::getGraph方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Rest_Client::getGraph方法的具体用法?PHP Zend_Rest_Client::getGraph怎么用?PHP Zend_Rest_Client::getGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Rest_Client的用法示例。


在下文中一共展示了Zend_Rest_Client::getGraph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show


//.........这里部分代码省略.........
     // whole lists, and not elements in the lists, because if they were
     // in the list, they'd be connected, so we wouldn't be removing them.
     // In prunemode 1 or 2, we may have to remove stuff from the list, because
     // you can have an edge to a node that didn't end up connected.
     foreach (array("edge_list", "rvrs_list", "node_list") as $l) {
         foreach (${$l} as $n => $list) {
             if (!isset($connected[$n])) {
                 unset(${$l}[$n]);
             }
             if ($prunemode != 0 && $l != "node_list" && isset(${$l}[$n])) {
                 // Only keep entries that appear in the $connected_nodes list
                 ${$l}[$n] = array_intersect(${$l}[$n], $connected_nodes);
             }
         }
     }
     // Now we've got everything we need... let's draw the pretty pictures
     //Open the graph, and print global options
     $lj = 'n';
     // label justification - l, r, or n (for center)
     $graphname = "task_{$id}_dependencies";
     $dotgraph = "digraph {$graphname} {\n" . "node [width=1.1, shape=ellipse, border=10, color=\"#00E11E\", style=\"filled\", " . "fontsize=10.0, pencolor=black, margin=\"0.1, 0.0\"];\n";
     // define the nodes
     foreach ($node_list as $n => $r) {
         $col = "";
         if ($r['clsd'] && $n != $id) {
             $r['pct'] = 120;
         }
         // color code: shades of gray for % done
         $x = dechex(255 - ($r['pct'] + 10));
         $col = "#{$x}{$x}{$x}";
         // Make sure label terminates in \n!
         $label = $r['ppx'] . '#' . $r['pxid'] . " \n" . ($useLocal ? addslashes(utf8_substr($r['sum'], 0, 15)) . "\n" : '') . ($r['clsd'] ? L('closed') : "{$r['pct']}% " . L('complete'));
         $tooltip = $r['clsd'] ? L('closed') . ": {$r['res']}" . (!empty($r['clsdby']) ? " ({$r['clsdby']})" : '') . ($r['com'] != '' ? ' - ' . str_replace(array("\r", "\n"), '', $r['com']) : '') : $r['pct'];
         $dotgraph .= "FS{$n} [label=\"" . str_replace("\n", "\\{$lj}", $label) . "\", " . ($r['clsd'] ? 'color=black,' : '') . ($r['clsd'] ? 'fillcolor=white,' : "fillcolor=\"{$col}\",") . ($n == $id ? 'shape=box,' : '') . "href=\"javascript:top.window.location.href='" . CreateURL(array("details", 'task' . $n)) . "'\", target=\"_top\" " . "tooltip=\"{$tooltip}\"];\n";
     }
     // Add edges
     foreach ($edge_list as $src => $dstlist) {
         foreach ($dstlist as $dst) {
             $dotgraph .= "FS{$src} -> FS{$dst};\n";
         }
     }
     // all done
     $dotgraph .= "}\n";
     // All done with the graph. Save it to a temp file (new name if the data has changed)
     $dotfilename = sprintf('cache/fs_depends_dot_%d_%s.dot', $id, md5($dotgraph));
     $imgfilename = sprintf('%s/%s.%s', BASEDIR, $dotfilename, $fmt);
     $mapfilename = sprintf('%s/%s.%s', BASEDIR, $dotfilename, 'map');
     //cannot use tempnam( ) as file has to end with $ftm extension
     if (!$useLocal) {
         //cannot use tempnam() as file has to end with $ftm extension
         $tname = $dotfilename;
     } else {
         // we are operating on the command line, avoid races.
         $tname = tempnam(Flyspray::get_tmp_dir(), md5(uniqid(mt_rand(), true)));
     }
     //get our dot done..
     file_put_contents($tname, $dotgraph, LOCK_EX);
     // Now run dot on it, if target file does not already exist
     if (!is_file($imgfilename)) {
         if (!$useLocal) {
             require_once 'Zend/Rest/Client.php';
             $client = new Zend_Rest_Client('http://webdot.flyspray.org/');
             $data = base64_decode($client->getGraph(base64_encode($dotgraph), $fmt)->post());
             file_put_contents($imgfilename, $data, LOCK_EX);
             $data = base64_decode($client->getGraph(base64_encode($dotgraph), 'cmapx')->post());
             file_put_contents($mapfilename, $data, LOCK_EX);
         } else {
             $tfn = escapeshellarg($tname);
             shell_exec(sprintf('%s -T %s -o %s %s', $path_to_dot, escapeshellarg($fmt), escapeshellarg($imgfilename), $tfn));
             $data['map'] = shell_exec(sprintf('%s -T cmapx %s', $path_to_dot, $tfn));
             file_put_contents($mapfilename, $data['map'], LOCK_EX);
             // Remove files so that they are not exposed to the public
             unlink($tname);
         }
     }
     $page->assign('map', file_get_contents($mapfilename));
     $page->assign('image', sprintf('%s%s.%s', $baseurl, $dotfilename, $fmt));
     // we have to find out the image size if it is SVG
     if ($fmt == 'svg') {
         if (!$remote) {
             $data = file_get_contents(BASEDIR . '/' . $file_name . '.' . $fmt);
         }
         preg_match('/<svg width="([0-9.]+)([a-zA-Z]+)" height="([0-9.]+)([a-zA-Z]+)"/', $data, $matches);
         $page->assign('width', round($matches[1] * ($matches[2] == 'pt' ? 1.4 : ($matches[2] == 'in' ? 1.33 * 72.27 : 1)), 0));
         $page->assign('height', round($matches[3] * ($matches[4] == 'pt' ? 1.4 : ($matches[4] == 'in' ? 1.35 * 72.27 : 1)), 0));
     }
     /*
     [TC] We cannot have this stuff outputting here, so I put it in a quick template
     */
     $page->assign('taskid', $id);
     $page->assign('fmt', $fmt);
     $page->assign('graphname', $graphname);
     $endtime = microtime();
     list($startusec, $startsec) = explode(' ', $starttime);
     list($endusec, $endsec) = explode(' ', $endtime);
     $diff = $endsec - $startsec + ($endusec - $startusec);
     $page->assign('time', round($diff, 2));
     $page->setTitle($this->task['project_prefix'] . '#' . $this->task['prefix_id'] . ': ' . L('dependencygraph'));
     $page->pushTpl('depends.tpl');
 }
开发者ID:negram,项目名称:flyspray,代码行数:101,代码来源:depends.php


注:本文中的Zend_Rest_Client::getGraph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。