本文整理汇总了PHP中SMWQueryResult::getColumnCount方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryResult::getColumnCount方法的具体用法?PHP SMWQueryResult::getColumnCount怎么用?PHP SMWQueryResult::getColumnCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQueryResult
的用法示例。
在下文中一共展示了SMWQueryResult::getColumnCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResultText
protected function getResultText(SMWQueryResult $res, $outputmode)
{
$this->isHTML = true;
$t = "";
$n = "";
// if there is only one column in the results then stop right away
if ($res->getColumnCount() == 1) {
return "";
}
// print all result rows
$first = true;
$max = 0;
// the biggest value. needed for scaling
while ($row = $res->getNext()) {
$name = $row[0]->getNextDataValue()->getShortWikiText();
foreach ($row as $field) {
while (($object = $field->getNextDataValue()) !== false) {
// use numeric sortkey
if ($object->isNumeric()) {
$nr = $object->getDataItem()->getSortKey();
$max = max($max, $nr);
if ($first) {
$first = false;
$t .= $nr;
$n = $name;
} else {
$t = $nr . ',' . $t;
$n = $name . '|' . $n;
}
}
}
}
}
return '<img src="http://chart.apis.google.com/chart?cht=p3&chs=' . $this->m_width . 'x' . $this->m_height . '&chds=0,' . $max . '&chd=t:' . $t . '&chl=' . $n . '" width="' . $this->m_width . '" height="' . $this->m_height . '" />';
}
示例2: getResultText
protected function getResultText( SMWQueryResult $res, $outputmode ) {
$this->isHTML = true;
$t = "";
$n = "";
// if there is only one column in the results then stop right away
if ($res->getColumnCount() == 1) return "";
// print all result rows
$first = true;
$count = 0; // How many bars will they be? Needed to calculate the height of the image
$max = 0; // the biggest value. needed for scaling
while ( $row = $res->getNext() ) {
$name = $row[0]->getNextDataValue()->getShortWikiText();
foreach ( $row as $field ) {
while ( ( $object = $field->getNextDataValue() ) !== false ) {
// use numeric sortkey
if ( $object->isNumeric() ) {
$nr = $object->getDataItem()->getSortKey();
$count++;
$max = max( $max, $nr );
if ( $first ) {
$first = false;
$t .= $nr;
$n = $name;
} else {
$t = $nr . ',' . $t;
$n .= '|' . $name; // yes, this is correct, it needs to be the other way
}
}
}
}
}
$barwidth = 20; // width of each bar
$bardistance = 4; // distance between two bars
$height = $count * ( $barwidth + $bardistance ) + 15; // calculates the height of the image
return '<img src="http://chart.apis.google.com/chart?cht=bhs&chbh=' . $barwidth . ',' . $bardistance . '&chs=' . $this->m_width . 'x' . $height . '&chds=0,' . $max . '&chd=t:' . $t . '&chxt=y&chxl=0:|' . $n . '" width="' . $this->m_width . '" height="' . $height . '" />';
}