Changeset 649 for trunk/web/addons/job_monarch/libtoga.php
- Timestamp:
- 11/13/09 15:13:29 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/addons/job_monarch/libtoga.php
r648 r649 1739 1739 } 1740 1740 1741 // Turn it into a regexp /something/ search pattern 1742 // 1743 $skan_str = '/' . $skan_str . '/'; 1744 1741 1745 // Now replace our {x} and {y} with %d for sscanf parsing 1742 1746 // 1743 1747 if(( $x_first ) && ( $x_present && $y_present ) ) 1744 1748 { 1745 $skan_str = str_replace( $x_str, " %d", $skan_str );1746 $skan_str = str_replace( $y_str, " %d", $skan_str );1749 $skan_str = str_replace( $x_str, "(?<x>\d+)", $skan_str ); 1750 $skan_str = str_replace( $y_str, "(?<y>\d+)", $skan_str ); 1747 1751 } 1748 1752 else if( $x_present) 1749 1753 { 1750 $skan_str = str_replace( $x_str, " %d", $skan_str );1754 $skan_str = str_replace( $x_str, "(?<x>\d+)", $skan_str ); 1751 1755 } 1752 1756 else if( $y_present) 1753 1757 { 1754 $skan_str = str_replace( $y_str, " %d", $skan_str );1758 $skan_str = str_replace( $y_str, "(?<y>\d+)", $skan_str ); 1755 1759 } 1756 1760 … … 1772 1776 if( $x_present && $y_present ) 1773 1777 { 1774 if( $x_first ) 1775 { 1776 $n = sscanf( $hostname, $skan_str, $x, $y ); 1777 } 1778 else if( $y_first ) 1779 { 1780 $n = sscanf( $hostname, $skan_str, $y, $x ); 1781 } 1778 preg_match( $skan_str, $hostname, $matches ); 1782 1779 1783 1780 // Remove nodes that don't match 1784 1781 // 1785 if( $n < 2)1782 if( !array_key_exists( 'x', $matches ) && !array_key_exists( 'y', $matches ) ) 1786 1783 { 1787 1784 // This node hostname has no match for: {x} and {y} … … 1789 1786 unset( $nodes[$hostname] ); 1790 1787 } 1788 else 1789 { 1790 $x = $matches['x']; 1791 $y = $matches['y']; 1792 } 1791 1793 } 1792 1794 else if( $x_present && !$y_present ) 1793 1795 { 1794 $n = sscanf( $hostname, $skan_str, $x);1796 preg_match( $skan_str, $hostname, $matches ); 1795 1797 1796 1798 // Remove nodes that don't match 1797 1799 // 1798 if( $n < 1)1800 if( !array_key_exists( 'x', $matches ) ) 1799 1801 { 1800 1802 // This node hostname has no match for: {x} … … 1802 1804 unset( $nodes[$hostname] ); 1803 1805 } 1804 $y = 1; 1806 else 1807 { 1808 $x = $matches['x']; 1809 $y = 1; 1810 } 1805 1811 } 1806 1812 else if( $y_present && !$x_present ) 1807 1813 { 1808 $n = sscanf( $hostname, $skan_str, $y);1814 preg_match( $skan_str, $hostname, $matches ); 1809 1815 1810 1816 // Remove nodes that don't match 1811 1817 // 1812 if( $n < 1)1818 if( !array_key_exists( 'y', $matches ) ) 1813 1819 { 1814 1820 // This node hostname has no match for: {y} … … 1816 1822 unset( $nodes[$hostname] ); 1817 1823 } 1818 $x = 1; 1824 else 1825 { 1826 $y = $matches['y']; 1827 $x = 1; 1828 } 1819 1829 } 1820 1830 … … 1902 1912 } 1903 1913 1904 $image_width = $x_offset + ($node_width * ($x_max-$x_min+2)); 1914 //$image_width = $x_offset + ($node_width * ($x_max-$x_min+2)); 1915 $image_width = $x_offset + ($node_width * (count($x_columns))); 1905 1916 1906 1917 if( $this->isSmall() ) … … 2033 2044 if( $x_present && $y_present ) 2034 2045 { 2035 if( $x_first ) 2036 { 2037 $nn = sscanf( $host, $skan_str, $rx, $ry ); 2038 } 2039 else if( $y_first ) 2040 { 2041 $nn = sscanf( $host, $skan_str, $ry, $rx ); 2042 } 2043 if ( $nn < 2 ) 2046 //if( $x_first ) 2047 //{ 2048 // $nn = sscanf( $host, $skan_str, $rx, $ry ); 2049 //} 2050 //else if( $y_first ) 2051 //{ 2052 // $nn = sscanf( $host, $skan_str, $ry, $rx ); 2053 //} 2054 //if ( $nn < 2 ) 2055 //{ 2056 // //printf( "skipping node %s - y present & x present + <2 x,y matchs\n", $host); 2057 // continue; 2058 //} 2059 2060 preg_match( $skan_str, $host, $matches ); 2061 $rx = $matches['x']; 2062 $ry = $matches['y']; 2063 2064 if( !array_key_exists( 'x', $matches ) && !array_key_exists( 'y', $matches ) ) 2044 2065 { 2045 2066 //printf( "skipping node %s - y present & x present + <2 x,y matchs\n", $host); 2046 2067 continue; 2047 2068 } 2069 2048 2070 if( intval( $rx ) > $n ) 2049 2071 { … … 2063 2085 else if( $x_present ) 2064 2086 { 2065 $nn = sscanf( $host, $skan_str, $rx ); 2087 //$nn = sscanf( $host, $skan_str, $rx ); 2088 preg_match( $skan_str, $host, $matches ); 2089 $rx = $matches['x']; 2066 2090 } 2067 2091 else if( $y_present ) 2068 2092 { 2069 $nn = sscanf( $host, $skan_str, $ry ); 2093 //$nn = sscanf( $host, $skan_str, $ry ); 2094 preg_match( $skan_str, $host, $matches ); 2095 $ry = $matches['y']; 2070 2096 } 2071 2097 … … 2454 2480 if( $x_present && $y_present ) 2455 2481 { 2456 if( $x_first ) 2457 { 2458 $n = sscanf( $a, $skan_str, $a_x, $a_y ); 2459 $n = sscanf( $b, $skan_str, $b_x, $b_y ); 2460 } 2461 else if( $y_first ) 2462 { 2463 $n = sscanf( $a, $skan_str, $a_y, $a_x ); 2464 $n = sscanf( $b, $skan_str, $b_y, $b_x ); 2465 } 2482 //if( $x_first ) 2483 //{ 2484 // $n = sscanf( $a, $skan_str, $a_x, $a_y ); 2485 // $n = sscanf( $b, $skan_str, $b_x, $b_y ); 2486 //} 2487 //else if( $y_first ) 2488 //{ 2489 // $n = sscanf( $a, $skan_str, $a_y, $a_x ); 2490 // $n = sscanf( $b, $skan_str, $b_y, $b_x ); 2491 //} 2492 2493 preg_match( $skan_str, $a, $matches ); 2494 $a_x = $matches['x']; 2495 $a_y = $matches['y']; 2496 preg_match( $skan_str, $b, $matches ); 2497 $b_x = $matches['x']; 2498 $b_y = $matches['y']; 2466 2499 } 2467 2500 else if( $x_present && !$y_present ) 2468 2501 { 2469 $n = sscanf( $a, $skan_str, $a_x ); 2470 $n = sscanf( $b, $skan_str, $b_x ); 2502 //$n = sscanf( $a, $skan_str, $a_x ); 2503 //$n = sscanf( $b, $skan_str, $b_x ); 2504 2505 preg_match( $skan_str, $a, $matches ); 2506 $a_x = $matches['x']; 2507 preg_match( $skan_str, $b, $matches ); 2508 $b_x = $matches['x']; 2471 2509 } 2472 2510 else if( $y_present && !$x_present ) 2473 2511 { 2474 $n = sscanf( $a, $skan_str, $a_y ); 2475 $n = sscanf( $b, $skan_str, $b_y ); 2512 //$n = sscanf( $a, $skan_str, $a_y ); 2513 //$n = sscanf( $b, $skan_str, $b_y ); 2514 2515 preg_match( $skan_str, $a, $matches ); 2516 $a_y = $matches['y']; 2517 preg_match( $skan_str, $b, $matches ); 2518 $b_y = $matches['y']; 2476 2519 } 2477 2520 … … 2526 2569 } 2527 2570 } 2571 else if( !$y_present && !$x_present ) 2572 { 2573 if ($a < $b) 2574 { 2575 return 1; 2576 } 2577 else if ($a > $b) 2578 { 2579 return -1; 2580 } 2581 } 2528 2582 } 2529 2583 else if ( $SORT_ORDER == "asc" ) … … 2573 2627 } 2574 2628 else if ($a_y < $b_y) 2629 { 2630 return -1; 2631 } 2632 } 2633 else if( !$y_present && !$x_present ) 2634 { 2635 if ($a > $b) 2636 { 2637 return 1; 2638 } 2639 else if ($a < $b) 2575 2640 { 2576 2641 return -1;
Note: See TracChangeset
for help on using the changeset viewer.