當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SpoonFilter::isOdd方法代碼示例

本文整理匯總了PHP中SpoonFilter::isOdd方法的典型用法代碼示例。如果您正苦於以下問題:PHP SpoonFilter::isOdd方法的具體用法?PHP SpoonFilter::isOdd怎麽用?PHP SpoonFilter::isOdd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SpoonFilter的用法示例。


在下文中一共展示了SpoonFilter::isOdd方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parseBody

 /**
  * Parses the body.
  *
  * @return	void
  * @param	array $records
  */
 private function parseBody(array $records)
 {
     // init var
     $rows = array();
     // columns sequence
     $sequence = $this->getColumnsSequence();
     // loop records
     foreach ($records as $i => &$record) {
         // replace possible variables
         $record = $this->parseRecord($record);
         // parse column functions
         $record = $this->parseColumnFunctions($record);
         // reset row
         $row = array('attributes' => '', 'oddAttributes' => '', 'evenAttributes' => '', 'columns' => array());
         // row attributes
         $row['attributes'] = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->attributes['row']));
         // odd row attributes (reversed since the first $i = 0)
         if (!SpoonFilter::isOdd($i)) {
             $row['oddAttributes'] = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->attributes['row_odd']));
         } else {
             $row['evenAttributes'] = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->attributes['row_even']));
         }
         // define the columns
         $columns = array();
         // loop columns
         foreach ($sequence as $name) {
             // column
             $column = $this->columns[$name];
             // has overwrite enabled
             if ($column->getOverwrite()) {
                 // fetch key
                 $iKey = array_search('[' . $column->getName() . ']', $record['labels']);
                 // parse the actual value
                 $columnValue = $record['values'][$iKey];
             } else {
                 // default value
                 $columnValue = '';
                 // has an url
                 if ($column->getURL() !== null) {
                     // open url tag
                     $columnValue .= '<a href="' . str_replace($record['labels'], $record['values'], $column->getURL()) . '"';
                     // add title
                     $columnValue .= ' title="' . str_replace($record['labels'], $record['values'], $column->getURLTitle()) . '"';
                     // confirm
                     if ($column->getConfirm() && $column->getConfirmMessage() !== null) {
                         // default confirm
                         if ($column->getConfirmCustom() == '') {
                             $columnValue .= ' onclick="return confirm(\'' . str_replace($record['labels'], $record['values'], $column->getConfirmMessage()) . '\');"';
                         } else {
                             // replace the message
                             $tmpValue = str_replace('%message%', $column->getConfirmMessage(), $column->getConfirmCustom());
                             // make vars available
                             $tmpValue = str_replace($record['labels'], $record['values'], $tmpValue);
                             // add id
                             $columnValue .= ' ' . $tmpValue;
                         }
                     }
                     // close start tag
                     $columnValue .= '>';
                 }
                 // has an image
                 if ($column->getImage() !== null) {
                     // open img tag
                     $columnValue .= '<img src="' . str_replace($record['labels'], $record['values'], $column->getImage()) . '"';
                     // add title & alt
                     $columnValue .= ' alt="' . str_replace($record['labels'], $record['values'], $column->getImageTitle()) . '"';
                     $columnValue .= ' title="' . str_replace($record['labels'], $record['values'], $column->getImageTitle()) . '"';
                     // close img tag
                     $columnValue .= ' />';
                 } else {
                     // fetch key
                     $iKey = array_search('[' . $column->getName() . ']', $record['labels']);
                     // parse value
                     $columnValue .= $record['values'][$iKey];
                 }
                 // has an url (close the tag)
                 if ($column->getURL() !== null) {
                     $columnValue .= '</a>';
                 }
             }
             // fetch column attributes
             $columnAttributes = $this->getHtmlAttributes($column->getAttributes());
             // visible & iteration
             if (!$column->getHidden()) {
                 // add this column
                 $columns[] = array('attributes' => $columnAttributes, 'value' => $columnValue);
                 // add to custom list
                 $row['column'][$name] = $columnValue;
             }
         }
         // add the columns to the rows
         $row['columns'] = $columns;
         // add the row
         $rows[] = $row;
//.........這裏部分代碼省略.........
開發者ID:ss23,項目名稱:ECommerce,代碼行數:101,代碼來源:datagrid.php

示例2: testIsOdd

 public function testIsOdd()
 {
     $this->assertFalse(SpoonFilter::isOdd(0));
     $this->assertTrue(SpoonFilter::isOdd(1));
     $this->assertFalse(SpoonFilter::isOdd(10901920));
     $this->assertTrue(SpoonFilter::isOdd(-1337));
 }
開發者ID:jeroendesloovere,項目名稱:library,代碼行數:7,代碼來源:SpoonFilterTest.php

示例3: parseBody

 /**
  * Parses the body.
  *
  * @param	array $records	The rows.
  */
 private function parseBody(array $records)
 {
     // init var
     $rows = array();
     // columns sequence
     $sequence = $this->getColumnsSequence();
     // loop records
     foreach ($records as $i => &$record) {
         // replace possible variables
         $record = $this->parseRecord($record);
         // parse column functions
         $record = $this->parseColumnFunctions($record);
         // parse custom row functions
         $this->parseRowFunctions($record, $this->attributes['row']);
         // reset row
         $row = array('attributes' => '', 'columns' => array());
         // row attributes
         $row['attributes'] = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->attributes['row']));
         // add custom row functions
         if (!empty($this->rowFunctionsParsed)) {
             // reset attributes
             $row['attributes'] = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->rowFunctionsParsed));
             // clear for the next row
             $this->rowFunctionsParsed = array();
         } else {
             $row['attributes'] = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->attributes['row']));
         }
         // odd row attributes (reversed since the first $i = 0)
         if (!SpoonFilter::isOdd($i)) {
             $cycleAttributes = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->attributes['row_odd']));
         } else {
             $cycleAttributes = str_replace($record['labels'], $record['values'], $this->getHtmlAttributes($this->attributes['row_even']));
         }
         // no longer overwrite default attributes with odd/even attributes.
         if (!empty($row['attributes'])) {
             $cycleData = array();
             $rowData = array();
             preg_match_all('/( (.*?)=\\"(.*?)\\")/', $row['attributes'], $rowData);
             preg_match_all('/( (.*?)=\\"(.*?)\\")/', $cycleAttributes, $cycleData);
             // go trough the attribute data to see if anything matches
             foreach ($cycleData[2] as $cycleAttribute => $cycleValue) {
                 if (in_array($cycleValue, $rowData[2])) {
                     $rowData[3][$cycleAttribute] .= ' ' . $cycleData[3][$cycleAttribute];
                     // remove the data so we can use the others to merge the arrays
                     unset($cycleData[2][$cycleAttribute], $cycleData[3][$cycleAttribute]);
                 }
             }
             // merge all the values, so we get everything we need
             $rowData[2] = array_merge($rowData[2], $cycleData[2]);
             $rowData[3] = array_merge($rowData[3], $cycleData[3]);
             // rebuild the data
             $row['attributes'] = $this->getHTMLAttributes(array_combine($rowData[2], $rowData[3]));
         } else {
             $row['attributes'] = $cycleAttributes;
         }
         // define the columns
         $columns = array();
         // loop columns
         foreach ($sequence as $name) {
             // column
             $column = $this->columns[$name];
             // has overwrite enabled
             if ($column->getOverwrite()) {
                 // fetch key
                 $iKey = array_search('[' . $column->getName() . ']', $record['labels']);
                 // parse the actual value
                 $columnValue = $record['values'][$iKey];
             } else {
                 // default value
                 $columnValue = '';
                 // has an url
                 if ($column->getURL() !== null) {
                     // open url tag
                     $columnValue .= '<a href="' . str_replace($record['labels'], $record['values'], $column->getURL()) . '"';
                     // add title
                     $columnValue .= ' title="' . str_replace($record['labels'], $record['values'], $column->getURLTitle()) . '"';
                     // confirm
                     if ($column->getConfirm() && $column->getConfirmMessage() !== null) {
                         // default confirm
                         if ($column->getConfirmCustom() == '') {
                             $columnValue .= ' onclick="return confirm(\'' . str_replace($record['labels'], $record['values'], $column->getConfirmMessage()) . '\');"';
                         } else {
                             // replace the message
                             $tmpValue = str_replace('%message%', $column->getConfirmMessage(), $column->getConfirmCustom());
                             // make vars available
                             $tmpValue = str_replace($record['labels'], $record['values'], $tmpValue);
                             // add id
                             $columnValue .= ' ' . $tmpValue;
                         }
                     }
                     // close start tag
                     $columnValue .= '>';
                 }
                 // has an image
                 if ($column->getImage() !== null) {
//.........這裏部分代碼省略.........
開發者ID:naujasdizainas,項目名稱:forkcms,代碼行數:101,代碼來源:datagrid.php


注:本文中的SpoonFilter::isOdd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。