How to use getLocale method of generator class

Best Atoum code snippet using generator.getLocale

StatGenerator.php

Source:StatGenerator.php Github

copy

Full Screen

...433 $others += $num[$i];434 } //for each data.435 //Make new numbers and texts.436 $newNum = array($others);437 $newTxt = array($this->locale->getLocale('sgLatestOthers'));438 for ($i = 0; $i < count($sums); $i++) {439 $newNum[] = $sums[$i];440 $newTxt[] = $schema[$i][0];441 }442 443 $this->numberArray = $newNum;444 $this->textArray = $newTxt;445 }446 /**447 * May be overwritten to be called just before the stats are generated.448 *449 * @public450 * @version 0.0.1451 * @since 0.0.1452 * @return void453 */454 function init()455 {456 //Do nothing457 }458 /**459 * Get the with of the table. 100% is 1.0.460 *461 * @public462 * @version 0.0.1463 * @return long the with of the table.464 * @since 0.0.1465 */466 function getTableWith() {467 return $this->tableWith;468 }469 /**470 * Set the with of the table. 100% is 1.0.471 *472 * @public473 * @version 0.0.1474 * @return void475 * @param the with of the table.476 * @since 0.0.1477 */478 function setTableWith($tableWith) {479 $this->tableWith = $tableWith;480 }481 /**482 * Returns an array of the headers for the graph.483 * The indexes corresponds to the following:<br>484 * <code>0</code>: Headline for the text<br>485 * <code>1</code>: Headline for the numbers<br>486 * <code>2</code>: Headline for the percents<br>487 * <code>3</code>: Headline for the graph<br>488 *489 * @public490 * @version 0.0.1491 * @since 0.0.1492 * @return String[] the array of headers.493 */494 function getHeaderArray()495 {496 return $this->headerArray;497 }498 /**499 * Sets an array of the headers for the graph.500 * The indexes should correspond to the following:<br>501 * <code>0</code>: Headline for the text<br>502 * <code>1</code>: Headline for the numbers<br>503 * <code>2</code>: Headline for the percents<br>504 * <code>3</code>: Headline for the graph<br>505 * <p>If a non array <code>String</code> is given this will be506 * split/exploded with &quot;<code>::</code>&quot; as seperator.507 *508 * @public509 * @version 0.0.1510 * @since 0.0.1511 * @param $headerArray an array of headlines.512 * @return void513 */514 function setHeaderArray($headerArray)515 {516 if (is_array($headerArray))517 $this->headerArray = $headerArray;518 else519 $this->headerArray = explode("::", $headerArray);520 }521 /**522 * Returns if the graph sould be sorted.523 * Returns <code>1</code> if the graph should be sorted, else <code>0</code>.524 *525 * @public526 * @version 0.0.1527 * @since 0.0.1528 * @return int <code>1</code> if the graph should be sorted, else <code>0</code>.529 */530 function getSort()531 {532 return $this->sort;533 }534 /**535 * Sets if the graph sould be sorted.536 * Set to <code>1</code> if the graph should be sorted, else <code>0</code>.537 * Other values will produce an error.538 *539 * @public540 * @version 0.0.1541 * @since 0.0.1542 * @param $sort if the graph sould be sorted.543 * @return void544 */545 function setSort($sort)546 {547 $this->sort = $sort;548 }549 /**550 * Returns the value text of the row which should be emphasized.551 * An empty <code>String</code> is returned if no text should be552 * emphasized.553 *554 * @public555 * @version 0.0.1556 * @since 0.0.1557 * @return String the text that should be emphasized.558 */559 function getEmphasize()560 {561 return $this->emphasize;562 }563 /**564 * Sets the value text of the row which should be emphasized.565 * An empty <code>String</code> should be giben if no text should be566 * emphasized.567 *568 * @public569 * @version 0.0.1570 * @since 0.0.1571 * @param $emphasize the text to emphasize.572 * @return void573 */574 function setEmphasize($emphasize)575 {576 $this->emphasize = $emphasize;577 }578 /**579 * Returns an array containing the numbers for this stat.580 * The indexes should match the indexes in the array given by581 * {@link #getTextArray}.582 *583 * @public584 * @version 0.0.1585 * @since 0.0.1586 * @return Stirng[] the numbers in an array.587 */588 function getNumberArray()589 {590 return $this->numberArray;591 }592 /**593 * Returns an array containing the numbers for this stat.594 * The indexes should match the indexes in the array set by595 * {@link #setTextArray}.596 *597 * @public598 * @version 0.0.1599 * @since 0.0.1600 * @return void601 * @param $numberArray the array fo the numbers for this stat.602 */603 function setNumberArray($numberArray)604 {605 $this->numberArray = $numberArray;606 }607 /**608 * Returns an array containing the text for this stat.609 * The indexes should match the indexes in the array returned by610 * {@link #getNumberArray}.611 *612 * @public613 * @version 0.0.1614 * @since 0.0.1615 * @return String[] the text in an array.616 */617 function getTextArray()618 {619 return $this->textArray;620 }621 /**622 * Sets an array containing the text for this stat.623 * The indexes should match the indexes in the array returned by624 * {@link #getNumberArray}.625 *626 * @public627 * @version 0.0.1628 * @since 0.0.1629 * @return void630 * @param $textArray the text array for this stat.631 */632 function setTextArray($textArray)633 {634 $this->textArray = $textArray;635 }636 /**637 * Returns the description of the stat.638 *639 * @public640 * @version 0.0.1641 * @since 0.0.1642 * @return String the description.643 */644 function getDescription()645 {646 return $this->description;647 }648 /**649 * Sets the description of the stat.650 *651 * @public652 * @version 0.0.1653 * @since 0.0.1654 * @return void655 * @param $description the description of the stat.656 */657 function setDescription($description)658 {659 $this->description = $description;660 }661 /**662 * Returns the main headline for the stat.663 *664 * @public665 * @version 0.0.1666 * @since 0.0.1667 * @return String the headline.668 */669 function getMainHeadline()670 {671 return $this->mainHeadline;672 }673 /**674 * Sets the main headline for the stat.675 *676 * @public677 * @version 0.0.1678 * @since 0.0.1679 * @return void680 * @param $mainHeadline the headline.681 */682 function setMainHeadline($mainHeadline)683 {684 $this->mainHeadline = $mainHeadline;685 }686 /**687 * Returns if numbers shall be shown on the graph. @c true for yes, @c false for no.688 *689 * @public690 * @return if numbers shall be shown on the graph.691 */692 function getShowNumbers() {693 return $this->showNumbers;694 }695 /**696 * Sets if numbers shall be shown on the graph. @c true for yes, @c false for no.697 *698 * @public699 * @param $showNumbers if numbers shall be shown on the graph.700 */701 function setShowNumbers($showNumbers) {702 $this->showNumbers = $showNumbers;703 }704 705 /**706 * Sets the lowest value in percent (between 0 and 1) of rows to707 * show. Rows with a value lesser than this one will not be shown.708 * 709 * @public710 * @param $minPercent the lowest value in percent of rows to show.711 */712 function setMinPercent($minPercent) {713 $this->minPercent = $minPercent;714 }715 /**716 * Returns the lowest value in percent (between 0 and 1) of rows to717 * show. Rows with a value lesser than this one will not be shown.718 * 719 * @public720 * @return the lowest value in percent of rows to show.721 */722 function getMinPercent() {723 return $this->minPercent;724 }725} //End of class GraphStatGenerator726/**727 * Generates the basic stats, or728 * &quot;Enkeltstende statistikker&quot; in danish.729 * The {@link SiteGenerator} must be an instance of the subclass730 * <code>SiteTable</code>.731 * <p><b>File:</b> StatGenerator.php</p>732 *733 * @public734 * @version 0.0.1735 * @author Simon Mikkelsen736 */737class BasicStatsGenerator extends StatGenerator738{739 /**740 * Fills in a {@link SiteElement} so it is ready to generate741 * code.742 *743 * @protected744 * @version 0.0.1745 * @since 0.0.1746 * @return SiteElement747 */748 function &generateStat()749 {750 if (strtolower($this->siteGenerator->getParentClass()) != "sitegenerator")751 { /*It's not a SiteGenerator*/752 echo "<b>Error:</b> The class <code>BasicStatsGenerator</code> only acepts instances of <code>SiteGenerator</code>.<br>";753 exit;754 }755 $this->setName("BasicStat");756 //Creates a rounder for rounding numbers757 $rounder = &$this->lib->getRounder();758 $rounder->setGoForDecimalsVisible(2);759 $rounder->setMaxDecimalsVisible(2);760 $rounder->setZeroDotToPercent(0);761 $rounder->setAddPercent(0);762 //Get the locale object763 $locale = &$this->siteContext->getLocalizer();764 //Create a table765 $table = &$this->siteGenerator->newElement("table");766 $tableHeadline = &$this->siteGenerator->newElement("headline");767 $tableHeadline->setSize(2);768 $tableHeadline->setHeadline($locale->getLocale($this->getHeadlineKey()));769 $table->addHeadElement($tableHeadline);770 $table->setElementClass('enkelttabel');771 $table->setElementName('BasicStats');772 $table->setHeaderClass('enkeltA');773 $table->setHeadersAre(1); /*1 = The top row is header.*/774 $table->setColumnClassArray(array('enkeltB','enkeltB','enkeltB'));775 //Add the top headers776 $table->addRow(array(777 $locale->getLocale('basicStatsType'),778 $locale->getLocale('basicStatsData'),779 $locale->getLocale('basicStatsDate')780 ));781 //Count up with this number782 $countUp = $this->dataSource->getLine(82);783 784 //Hits since start785 if ($countUp > 0) {786 $totalHits = $this->getHitsSinceStart() + $countUp;787 $totalText = $locale->getLocale('basicSHitsSStart')788 . " (+ ".$countUp.")";789 } else {790 $totalHits = $this->getHitsSinceStart();791 $totalText = $locale->getLocale('basicSHitsSStart');792 }793 $table->addRow(array(794 $totalText,795 $totalHits,796 $this->getHitsSinceStartResetdate()797 ));798 //Hits since799 if ($countUp > 0) {800 $totalHits = $this->getHitsSince() + $countUp;801 $totalText = $locale->getLocale('basicSHitsS')802 . " (+ ".$countUp.")";803 } else {804 $totalHits = $this->getHitsSince() + $countUp;805 $totalText = $locale->getLocale('basicSHitsS');806 }807 $table->addRow(array(808 $totalText,809 $totalHits,810 $this->getHitsSinceResetdate()811 ));812 //Uniqe hits813 $table->addRow(array(814 $locale->getLocale('basicSUniq'),815 $this->getHitsUniqe(),816 $this->getHitsUniqeResetdate(),817 ));818 //Hits per user, in dahisn: "Hits pr. bruger"819 $table->addRow(array(820 $locale->getLocale('basicSHitsPrUser'),821 $rounder->formatNumber($this->lib->hpb()),822 ""823 ));824 //Add e.g. a line825 $table->addSeperator();826 //Maximum hits on a day827 $table->addRow(array(828 $locale->getLocale('basicSMaxHitsDay'),829 $this->getMaxHitsDay(),830 $this->getMaxHitsDayDate()831 ));832 //Maximum number of hits in a month833 $table->addRow(array(834 $locale->getLocale('basicSMaxHitsMonth'),835 $this->getMaxHitsMonth(),836 $this->getMaxHitsMonthDate()837 ));838 //Maximum uniqe hits on a day839 $table->addRow(array(840 $locale->getLocale('basicSMaxUniqHDay'),841 $this->getMaxUniqHitsDay(),842 $this->getMaxUniqHitsDayDate()843 ));844 //Maximum uniqe hits on a month845 $table->addRow(array(846 $locale->getLocale('basicSMaxUniqHMonth'),847 $this->getMaxUniqHitsMonth(),848 $this->getMaxUniqHitsMonthDate()849 ));850 //Add e.g. a line851 $table->addSeperator();852 //Max uniq hits today853 $table->addRow(array(854 $locale->getLocale('basicSUniqHToday'),855 $this->getUniqHitsToday(),856 ""857 ));858 //Uniqe hits this month859 $table->addRow(array(860 $locale->getLocale('baticSUIniqHThisMonth'),861 $this->getUniqHitsThisMonth(),862 ""863 ));864 //Uniqe hits per day865 $table->addRow(array(866 $locale->getLocale('basicSUniqPerDay'),867 $rounder->formatNumber($this->getUniqHPerDay()),868 ""869 ));870 //Uniqe hits per hour871 $table->addRow(array(872 $locale->getLocale('basicSUniqPerHour'),873 $rounder->formatNumber($this->getUniqeHPerHour()),874 ""875 ));876 //Add e.g. a line877 $table->addSeperator();878 //Hits per month calculated and hits per month inser here!879 //Hits per day880 $table->addRow(array(881 $locale->getLocale('basicSHitsDay'),882 $rounder->formatNumber($this->getHitsPerDay()),883 "",884 ));885 //Hits per hour886 $table->addRow(array(887 $locale->getLocale('basicSHitsHour'),888 $rounder->formatNumber($this->getHitsPerHour()),889 ""890 ));891 //Each site is seen - the time each site is seen, in average.892 $table->addRow(array(893 $locale->getLocale('basicSeSiteSeen'),894 //$locale->secsToReadable(round($this->timePerVisitor())),895 $locale->secsToReadable(round($this->timePerVisitor())),896 ""897 ));898 //Number of visitors looking at the site899 $table->addRow(array(900 $locale->getLocale('basicSVisitorsNow'),901 $this->getVisitorsNow(),902 ""903 ));904 //$p = new Projection($this->siteContext, $this->siteGenerator);905 return $table;906 }907 /**908 * Returns a string which identifies this stat. This is always the same909 * for this class, and can / shall not be set line in {@link #getName}.910 *911 * @public912 * @since 0.0.1913 * @version 0.0.1914 * @return String an identifier of this stat.915 */916 function getIdentifier()917 {918 return "BasicStats";919 }920 /**921 * Returns the key used to get the headline from the {@link Localizer}.922 *923 * @public924 * @version 0.0.1925 * @return String the key used to get the headline from the {@link Localizer}.926 */927 function getHeadlineKey()928 {929 return "basicStats";930 }931 /**932 * Returns the average time in seconds a visitor is looking at one933 * site (html file).934 *935 * @public936 * @version 0.0.1937 * @since 0.0.1938 * @return float939 */940 function timePerVisitor()941 {942 $secsVisitors = explode(":",$this->dataSource->getLine(73));943 if ($secsVisitors[1] != 0)944 $timePerVisitor = ($secsVisitors[0])/$secsVisitors[1]; /*Time per visitor*/945 else946 $timePerVisitor = 0;947 return $timePerVisitor;948 }949 /**950 * Returns the number of visitors looking at the site951 * &quot;right now&quot;.952 *953 * @public954 * @version 0.0.1955 * @since 0.0.1956 * @return int957 */958 function getVisitorsNow()959 {960 $timePerVisitor = $this->timePerVisitor();961 $visitorsNow = 0;962 $iper = ":";963 $unixtimes = explode(":",$this->dataSource->getLine(72)); /*Unix time for line 45*/964 $ip = explode(":",$this->dataSource->getLine(45)); /*IP-adresses for visitors*/965 //Count how many IP-adresses that have visited the site in the time966 //the average visitor looks at a site.967 for ($i = 0;$i < sizeof($unixtimes);$i++)968 {969 if (($unixtimes[$i] + $timePerVisitor > time()) and (strpos($iper,":".$ip[$i].":") === false))970 {971 $visitorsNow++;972 $iper .= $ip[$i].":";973 }974 }975 return $visitorsNow;976 }977 /**978 * Returns the number of hits per hour.979 * In danish: &quot;Hits pr. time&quot;.980 *981 * @public982 * @version 0.0.1983 * @since 0.0.1984 * @return float985 */986 function getHitsPerHour()987 {988 return $this->getHitsPerDay()/24;989 }990 /**991 * Returns the number of uniqe hits per hour.992 * In danish: &quot;Unikke htis pr. time&quot;.993 *994 * @public995 * @version 0.0.1996 * @since 0.0.1997 * @return float998 */999 function getUniqeHPerHour()1000 {1001 return $this->getUniqHPerDay() / 24;1002 }1003 /**1004 * Returns the number of uniqe hits per day.1005 * In dahish: &quot;Unikke hits pr. dag&quot;.1006 *1007 * @public1008 * @version 0.0.11009 * @since 0.0.11010 * @return float1011 */1012 function getUniqHPerDay()1013 {1014 $hitsPerDay = $this->getHitsPerDay();1015 $hitsPerUser = $this->lib->hpb();1016 if ($hitsPerUser > 0)1017 return $hitsPerDay/$hitsPerUser;1018 else1019 return 0;1020 }1021 /**1022 * Returns the number of hits per day.1023 * In dahisn: &quot;Hits pr. dag&quot;.1024 *1025 * @public1026 * @version 0.0.11027 * @since 0.0.11028 * @return float1029 */1030 function getHitsPerDay()1031 {1032 //Hits per day, start1033 $n = 0;1034 $mday = date('j'); /*Day of month*/1035 $latest31days = explode("::",$this->dataSource->getLine(11));1036 $max = -1;1037 $min = -1;1038 $hitsPerDay = 0;1039 for ($i = 0; $i < 31;$i++)1040 {1041 if (($latest31days[$i] > 0) and ($i != $mday-1))1042 {1043 $hitsPerDay += $latest31days[$i];1044 $n++;1045 if (($max < $latest31days[$i]) or ($max == -1))1046 { $max = $latest31days[$i]; }1047 if (($min > $latest31days[$i]) or ($min == -1))1048 {$min = $latest31days[$i]; }1049 }1050 }1051 if ($max > 0)1052 {1053 $hitsPerDay -= $max;1054 $n--;1055 }1056 if ($min > 0)1057 {1058 $hitsPerDay -= $min;1059 $n--;1060 }1061 if ($n > 0)1062 {$hitsPerDay = $hitsPerDay / $n;}1063 else {$hitsPerDay = 0;}1064 return $hitsPerDay;1065 }1066 /**1067 * Returns the number of uniqe hits &quot;this month&quot;.1068 * In danish: &quot;Unikke hits denne mned&quot;.1069 *1070 * @public1071 * @version 0.0.11072 * @since 0.0.11073 * @return String1074 */1075 function getUniqHitsThisMonth()1076 {1077 return $this->dataSource->getLine(79);1078 }1079 /**1080 * Returns the number of uniqe hits &quot;today&quot;.1081 * In danish: &quot;Unikke hits i dag&quot;.1082 *1083 * @public1084 * @version 0.0.11085 * @since 0.0.11086 * @return String1087 */1088 function getUniqHitsToday()1089 {1090 return $this->dataSource->getLine(76);1091 }1092 /**1093 * Returns the date for the maximum number of uniqe hits that has1094 * occured in a month.1095 * In danish: &quot;Max unikke hits p en mned&quot;.1096 *1097 * @public1098 * @version 0.0.11099 * @since 0.0.11100 * @return String1101 */1102 function getMaxUniqHitsMonthDate()1103 {1104 return $this->locale->localizeDate($this->dataSource->getLine(81));1105 }1106 /**1107 * Returns the maximum number of uniqe hits that has occured in a month.1108 * In danish: &quot;Max unikke hits p en mned&quot;.1109 *1110 * @public1111 * @version 0.0.11112 * @since 0.0.11113 * @return String1114 */1115 function getMaxUniqHitsMonth()1116 {1117 return $this->dataSource->getLine(80);1118 }1119 /**1120 * Returns the date for the maximum number of uniqe hits that has1121 * occured in a day.1122 * In danish: &quot;Max unikke hits p en dag&quot;.1123 *1124 * @public1125 * @version 0.0.11126 * @since 0.0.11127 * @return String1128 */1129 function getMaxUniqHitsDayDate()1130 {1131 return $this->locale->localizeDate($this->dataSource->getLine(78));1132 }1133 /**1134 * Returns the maximum number of uniqe hits that has occured in a day.1135 * In danish: &quot;Max unikke hits p en dag&quot;.1136 *1137 * @public1138 * @version 0.0.11139 * @since 0.0.11140 * @return String1141 */1142 function getMaxUniqHitsDay()1143 {1144 return $this->dataSource->getLine(77);1145 }1146 /**1147 * Returns the date where the maximum number of hits came in a month.1148 *1149 * @public1150 * @version 0.0.11151 * @since 0.0.11152 * @return String1153 */1154 function getMaxHitsMonthDate()1155 {1156 return $this->locale->localizeDate($this->dataSource->getLine(19));1157 }1158 /**1159 * Returns the maximum number of hits that have ever occured on a month.1160 * Danish: &quot;Max hits p en mned&quot;.1161 *1162 * @public1163 * @version 0.0.11164 * @since 0.0.11165 * @return int1166 */1167 function getMaxHitsMonth()1168 {1169 return $this->dataSource->getLine(18);1170 }1171 /**1172 * Returns the date where the maximum number of hits came in a day.1173 *1174 * @public1175 * @version 0.0.11176 * @since 0.0.11177 * @return String1178 */1179 function getMaxHitsDayDate()1180 {1181 return $this->locale->localizeDate($this->dataSource->getLine(17));1182 }1183 /**1184 * Returns the maximum number of hits that have ever occured on a day.1185 * Danish: &quot;Max hits p en dag&quot;.1186 *1187 * @public1188 * @version 0.0.11189 * @since 0.0.11190 * @return int1191 */1192 function getMaxHitsDay()1193 {1194 return $this->dataSource->getLine(16);1195 }1196 /**1197 * Returns the value of the counter counting uniqer hits.1198 * In danish &quot;Heraf unikke&quot;.1199 *1200 * @public1201 * @version 0.0.11202 * @since 0.0.11203 * @return int1204 */1205 function getHitsUniqe()1206 {1207 return $this->dataSource->getLine(44);1208 }1209 /**1210 * Returns the reset date for {@link #getHitsUniqe}.1211 *1212 * @public1213 * @version 0.0.11214 * @since 0.0.11215 * @return String the reset date for {@link #getHitsUniqe}.1216 */1217 function getHitsUniqeResetdate()1218 {1219 $dates = $this->dataSource->getLineObj(51);1220 return $dates->getDateString(44,$this->locale);1221 }1222 /**1223 * Returns the value of the counter that can be retset.1224 * In danish &quot;Hits siden&quot;.1225 *1226 * @public1227 * @version 0.0.11228 * @since 0.0.11229 * @return int1230 */1231 function getHitsSince()1232 {1233 return $this->dataSource->getLine(7);1234 }1235 /**1236 * Returns the formated date where the counter in1237 * {@link #getHitsSince} were reset.1238 *1239 * @public1240 * @version 0.0.11241 * @since 0.0.11242 * @return String the formated date where the counter in1243 * {@link #getHitsSince} were reset.1244 */1245 function getHitsSinceResetdate()1246 {1247 return $this->locale->localizeDate($this->dataSource->getLine(8));1248 }1249 /**1250 * Returns the value of the counter that can't be reset.1251 * In danish &quot;Hits siden start&quot;.1252 *1253 * @public1254 * @version 0.0.11255 * @since 0.0.11256 * @return String the value of the counter that can't be reset.1257 */1258 function getHitsSinceStart()1259 {1260 return $this->dataSource->getLine(13);1261 }1262 /**1263 * Returns the formated date where the counter in1264 * {@link #getHitsSinceStart} were reset.1265 *1266 * @public1267 * @todo complete this. Only "" is returned now.1268 * @version 0.0.11269 * @since 0.0.11270 * @return String the formated date where the counter in1271 * {@link #getHitsSinceStart} were reset.1272 */1273 function getHitsSinceStartResetdate()1274 {1275 return ""; //$this->locale->localizeDate($this->dataSource->getLine());1276 }1277}1278/**1279 * Calculates a number of projections on how many visitors wil visit1280 * the site.1281 * <p><b>File:</b> StatGenerator.php</p>1282 *1283 * @public1284 * @version 0.0.11285 * @author Simon Mikkelsen1286 */1287class Projection extends StatGenerator1288{1289 function generateStat()1290 {1291 if (strtolower($this->siteGenerator->getParentClass()) != "sitegenerator")1292 { /*It's not a SiteGenerator*/1293 echo "<b>Error:</b> The class <code>BasicStatsGenerator</code> only acepts instances of <code>SiteGenerator</code>.<br>";1294 exit;1295 }1296 $this->setName("Projection");1297 //Creates a rounder for rounding percents1298 $percentRounder = &$this->lib->getRounder();1299 $percentRounder->setGoForDecimalsVisible(2);1300 $percentRounder->setMaxDecimalsVisible(2);1301 $percentRounder->setZeroDotToPercent(1);1302 $percentRounder->setAddPercent(1);1303 //Creates a rounder for rounding numbers1304 $rounder = $this->lib->getRounder();1305 $rounder->setGoForDecimalsVisible(2);1306 $rounder->setMaxDecimalsVisible(2);1307 $rounder->setZeroDotToPercent(0);1308 $rounder->setAddPercent(0);1309 //Get the locale object1310 $locale = &$this->siteContext->getLocalizer();1311 //Create a table1312 $text = &$this->siteGenerator->newElement("text");1313 $headline = &$this->siteGenerator->newElement("headline");1314 $headline->setSize(2);1315 $headline->setHeadline($locale->getLocale($this->getHeadlineKey()));1316 $text->addHeadElement($headline);1317/*Eftersom %1$s1318af sidens hits plejer at komme fr %2$s,1319vil der komme ca. %3$s hits mere, hvilket bringer siden op p %4$s1320hits i dag. Yderligere, vil der komme ca. %5$s hits mere i denne mned,1321hvilket bringer siden op p i alt %6$s i denne mned.*/1322 $text->addText(sprintf($locale->getLocale("projTheText"),1323 $percentRounder->formatNumber($this->percentHits(1)),1324 $this->locale->localizeDate(time(),2),1325 $rounder->formatNumber($this->hitsToComeToday()),1326 $rounder->formatNumber($this->hitsSumToday()),1327 $rounder->formatNumber($this->hitsToComeMonth()),1328 $rounder->formatNumber($this->hitsSumMonth())1329 ));1330 return $text;1331 }1332 /**1333 * Returns a string which identifies this stat. This is always the same1334 * for this class, and can / shall not be set line in {@link #getName}.1335 *1336 * @public1337 * @since 0.0.11338 * @version 0.0.11339 * @return String an identifier of this stat.1340 */1341 function getIdentifier()1342 {1343 return "Projection";1344 }1345 /**1346 * Returns the key used to get the headline from the {@link Localizer}.1347 *1348 * @public1349 * @version 0.0.11350 * @return String the key used to get the headline from the {@link Localizer}.1351 */1352 function getHeadlineKey()1353 {1354 return "proj";1355 }1356 /**1357 * If 1 is given as parameter, the percentage of visits that normally1358 * have occured on this time of the day (<code>$ptn</code>). If 2 is given as parameter,1359 * the percentage of visitors that normally will come the rest of the day.1360 *1361 * @public1362 * @version 0.0.11363 * @since 0.0.11364 * @return float1365 */1366 function percentHits($witch)1367 {1368 //Counts the sum of registered hits in hours and1369 //the sum of hits in hours up to this time of the day1370 $date = getdate();1371 $hour = $date['hours'];1372 $min = $date['minutes'];1373 $hours = explode("::",$this->dataSource->getLine(14));1374 $hrsToNow = 0;1375 $sumHrs = 0;1376 for ($i = 0;$i < 24;$i++)1377 {1378 if ($i < sizeof($hours)) {1379 if ($i < $hour)1380 $hrsToNow += $hours[$i];1381 $sumHrs += $hours[$i];1382 } //End if $i < sizeof..1383 }1384 //Interpolate the number of hits that normally would have come this hour.1385 $hrsToNow += $hours[$hour]*(1-((60-$min)/60));1386 //Calculates the percent of hits in hours hours left today ($ptt),1387 //and the percent of hits in hours hours that have come undtil now ($hrsNow).1388 if ($sumHrs != 0)1389 {1390 $hrsLeft = ( ($sumHrs - $hrsToNow) /$sumHrs);1391 $hrsNow = 1 - $hrsLeft;1392 }1393 else1394 {1395 $hrsLeft = 0;1396 $hrsNow = 0;1397 }1398 if ($witch === 1)1399 return $hrsNow;1400 elseif ($witch === 2)1401 return $hrsLeft;1402 }1403 /**1404 * The number of hits that proberbly will come today.1405 * (<code>$ti</code>)1406 * @public1407 * @version 0.0.11408 * @since 0.0.11409 * @return float1410 */1411 function hitsToComeToday()1412 {1413 //Calculates the sum of hits the latest 31 days1414 //Some dates are ignored in the sum, so the total number of1415 //days counted is in $sumDays.1416 $dates = getDate();1417 $mday = $dates['mday'];1418 $wday = $dates['wday'];1419 $days = explode("::",$this->dataSource->getLine(11));1420 $daysInSum = 0;1421 $maxDay = 0;1422 $minDay = 0;1423 $sumDays = 0;1424 for ($i = 0;$i < 31;$i++)1425 {1426 if (($i != $mday -1) and ($days[$i] != 0))1427 {1428 $sumDays += $days[$i];1429 $daysInSum++;1430 if ($days[$i] > $maxDay)1431 $maxDay = $days[$i];1432 if ($days[$i] < $minDay)1433 $minDay = $days[$i];1434 }1435 } /*End for i...*/1436 if ($daysInSum > 1)1437 {1438 if ($maxDay)1439 {1440 $sumDays -= $maxDay;1441 $daysInSum--;1442 }1443 if ($minDay)1444 {1445 $sumDays -= $maxDay;1446 $daysInSum--;1447 }1448 } /*End if $sumDays > 1*/1449 //Calculates the percentage of hits in the week that comes in this day.1450 $hitsInWeek = explode("::",$this->dataSource->getLine(15));1451 $daysCounted = 0;1452 $sumWeekHits = 0;1453 for ($i = 0;$i < 7;$i++)1454 {1455 if ($hitsInWeek[$i] != 0)1456 {1457 $sumWeekHits += $hitsInWeek[$i];1458 $daysCounted++;1459 }1460 }1461 if ($sumWeekHits != 0)1462 $percentWeekDay = 1 - ( ($sumWeekHits - $hitsInWeek[$wday - 1]) /$sumWeekHits);1463 else1464 $percentWeekDay = 0;1465 //Calculates an average day, with week days taken in1466 if ($daysInSum != 0)1467 $avgDay = ( $sumDays /$daysInSum) * $daysCounted * $percentWeekDay;1468 else1469 $avgDay = 0;1470 //Calculates the deviation from normal today,1471 //based on hits from the latest 31 days1472 $days = explode("::",$this->dataSource->getLine(11));1473 $hrsNow = $this->percentHits(1);1474 $hrsLeft = $this->percentHits(2);1475 if (($avgDay * $hrsNow) != 0)1476 $deviation = 1 - ( (($avgDay * $hrsNow) - $days[$mday-1]) / ($avgDay * $hrsNow) );1477 else1478 $deviation = 0;1479 //The number of users that will come today1480 return $avgDay * $hrsLeft *(($deviation) / 1);1481 }1482 /**1483 * The estimated sum of total hits today.1484 * (<code>$hits_ialt_timer</code>)1485 * @public1486 * @version 0.0.11487 * @since 0.0.11488 * @return float the estimated sum of total hits today.1489 */1490 function hitsSumToday()1491 {1492 $dates = getDate();1493 $mday = $dates['mday'];1494 //What came today + hitsToComeToday()1495 $days = explode("::",$this->dataSource->getLine(11));1496 return $days[$mday] + $this->hitsToComeToday();1497 }1498 /**1499 * The estimated number of hits that will come this month.1500 * (<code>$htm</code>)1501 * @public1502 * @version 0.0.11503 * @since 0.0.11504 * @return float1505 */1506 function hitsToComeMonth()1507 {1508 $dates = getDate();1509 $mday = $dates['mday'];1510 $days = explode("::",$this->dataSource->getLine(11));1511 $n = 0;1512 //Count the number of days we can use1513 for ($i = 0;$i <= $mday;$i++)1514 if ($days[$i] != 0)1515 $n++;1516 $months = explode("::",$this->dataSource->getLine(9));1517 if ($n != 0)1518 {1519 return ($months[$dates['mon']] + $this->hitsToComeToday()) *1520 ($this->lib->lengthOfMont($dates['mon']) / $n);1521 }1522 else1523 return $this->hitsToComeToday();1524 }1525 /**1526 * The estimated sum of total hits this month.1527 * (<code>$hits_ialt_maaned</code>)1528 * @public1529 * @version 0.0.11530 * @since 0.0.11531 * @return int the estimated sum of total hits this month.1532 */1533 function hitsSumMonth()1534 {1535 $dates = getDate();1536 //What comes the rest of this month + what have come.1537 $months = explode("::",$this->dataSource->getLine(9));1538 return $months[$dates['mon']-1] + $this->hitsToComeMonth();1539 }1540} /*End of class Projection*/1541/**1542 * Creates a stat of hits for every month for a year.1543 * <p><b>File:</b> StatGenerator.php</p>1544 *1545 * @public1546 * @version 0.0.11547 * @author Simon Mikkelsen1548 */1549class MonthStats extends GraphStatGenerator1550{1551 /**1552 * Init the object.1553 *1554 * @public1555 * @version 0.0.11556 * @since 0.0.11557 * @return void1558 */1559 function init()1560 {1561 $this->setName("MonthStats");1562 $locale = &$this->locale;1563 $dataSource = $this->dataSource;1564 $this->setHeaderArray(array(1565 $locale->getLocale('month'),1566 $locale->getLocale('hits'),1567 $locale->getLocale('percent'),1568 $locale->getLocale('graph')1569 ));1570 $this->setSort(0);1571 $months = $locale->getLocale('months');1572 $dates = getDate();1573 $this->setEmphasize($months[$dates['mon']]);1574 if ($dataSource != NULL) {1575 $this->setNumberArray($dataSource->getLineAsArray(9));1576 }1577 //Get the months1578 //$months = $locale->getMonths();1579 $text = $locale->getLocale('months');1580 for ($i = 0; $i < sizeof($text); $i++)1581 {1582 //Makes first char upper case, rest lower1583 $text[$i] = ucfirst(strtolower($text[$i]));1584 }1585 $this->setTextArray($text);1586 $this->setDescription($locale->getLocale('sgMonthDesc'));1587 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));1588 }1589 /**1590 * Returns a string which identifies this stat. This is always the same1591 * for this class, and can / shall not be set line in {@link #getName}.1592 *1593 * @public1594 * @since 0.0.11595 * @version 0.0.11596 * @return String an identifier of this stat.1597 */1598 function getIdentifier()1599 {1600 return "MonthStats";1601 }1602 /**1603 * Returns the key used to get the headline from the {@link Localizer}.1604 *1605 * @public1606 * @version 0.0.11607 * @return String the key used to get the headline from the {@link Localizer}.1608 */1609 function getHeadlineKey()1610 {1611 return "sgMonthStat";1612 }1613} /*End of class MonthStats*/1614/**1615 * Creates a stat of hits for every day of the month.1616 * <p><b>File:</b> StatGenerator.php</p>1617 *1618 * @public1619 * @version 0.0.11620 * @author Simon Mikkelsen1621 */1622class HitsDay extends GraphStatGenerator1623{1624 /**1625 * Init the object.1626 *1627 * @public1628 * @version 0.0.11629 * @since 0.0.11630 * @return void1631 */1632 function init()1633 {1634 $this->setName("HitsDay");1635 $locale = &$this->locale;1636 $dataSource = &$this->dataSource;1637 $this->setHeaderArray(array(1638 $locale->getLocale('day'),1639 $locale->getLocale('hits'),1640 $locale->getLocale('percent'),1641 $locale->getLocale('graph')1642 ));1643 $this->setSort(0);1644 /*day of the month without leading zeros; i.e. "1" to "31"*/1645 $this->setEmphasize(date('j'));1646 if ($dataSource != NULL) {1647 $this->setNumberArray($dataSource->getLineAsArray(11));1648 $days = array();1649 $numDays = date('t'); /* number of days in the given month; i.e. "28" to "31"*/1650 for ($i = 1; $i <= $numDays; $i++) {1651 $days[] = $i;1652 }1653 $this->setTextArray($days);1654 }1655 $this->setDescription($locale->getLocale('sgDayDesc'));1656 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));1657 }1658 /**1659 * Returns a string which identifies this stat. This is always the same1660 * for this class, and can / shall not be set line in {@link #getName}.1661 *1662 * @public1663 * @since 0.0.11664 * @version 0.0.11665 * @return String an identifier of this stat.1666 */1667 function getIdentifier()1668 {1669 return "HitsDay";1670 }1671 /**1672 * Returns the key used to get the headline from the {@link Localizer}.1673 *1674 * @public1675 * @version 0.0.11676 * @return String the key used to get the headline from the {@link Localizer}.1677 */1678 function getHeadlineKey()1679 {1680 return "sgDayStat";1681 }1682} /*End of class HitsDay*/1683/**1684 * Creates a stat for every hour of the day.1685 * <p><b>File:</b> StatGenerator.php</p>1686 *1687 * @public1688 * @version 0.0.11689 * @author Simon Mikkelsen1690 */1691class HitsHour extends GraphStatGenerator1692{1693 /**1694 * Init the object.1695 *1696 * @public1697 * @version 0.0.11698 * @since 0.0.11699 * @return void1700 */1701 function init()1702 {1703 $this->setName("HitsHour");1704 $locale = $this->locale;1705 $dataSource = $this->dataSource;1706 $this->setHeaderArray(array(1707 $locale->getLocale('hour'),1708 $locale->getLocale('hits'),1709 $locale->getLocale('percent'),1710 $locale->getLocale('graph')1711 ));1712 $this->setSort(0);1713 /*hour, 24-hour format; i.e. "00" to "23"*/1714 $this->setEmphasize(date('H'));1715 if ($dataSource != NULL) {1716 $this->setNumberArray($dataSource->getLineAsArray(14));1717 }1718 $hrs = array();1719 for ($i = 1; $i <= 24; $i++)1720 {1721 if ($i <= 9)1722 $hr = "0".$i;1723 else1724 $hr = $i;1725 $hrs[] = $hr;1726 } /*End for $i = 1*/1727 $this->setTextArray($hrs);1728 $this->setDescription($locale->getLocale('sgHourDesc'));1729 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));1730 }1731 /**1732 * Returns a string which identifies this stat. This is always the same1733 * for this class, and can / shall not be set line in {@link #getName}.1734 *1735 * @public1736 * @since 0.0.11737 * @version 0.0.11738 * @return String an identifier of this stat.1739 */1740 function getIdentifier()1741 {1742 return "HitsHour";1743 }1744 /**1745 * Returns the key used to get the headline from the {@link Localizer}.1746 *1747 * @public1748 * @version 0.0.11749 * @return String the key used to get the headline from the {@link Localizer}.1750 */1751 function getHeadlineKey()1752 {1753 return "sgHourStat";1754 }1755} /*End of class HitsHour*/1756/**1757 * Creates a stat of the hits for every day og the week.1758 * <p><b>File:</b> StatGenerator.php</p>1759 *1760 * @public1761 * @version 0.0.11762 * @since 0.0.11763 */1764class HitsWeek extends GraphStatGenerator1765{1766 /**1767 * Init the object.1768 *1769 * @public1770 * @version 0.0.11771 * @since 0.0.11772 * @return void1773 */1774 function init()1775 {1776 $this->setName("HitsWeek");1777 $locale = &$this->locale;1778 $dataSource = &$this->dataSource;1779 $this->setHeaderArray(array(1780 $locale->getLocale('week'),1781 $locale->getLocale('hits'),1782 $locale->getLocale('percent'),1783 $locale->getLocale('graph')1784 ));1785 $this->setSort(0);1786 $weekDays = $locale->getLocale('weekDays');1787 /*w = day of week 0-6*/1788 $this->setEmphasize($weekDays[date('w')]);1789 if ($dataSource != NULL) {1790 $wCounts = $dataSource->getLineAsArray(15);1791 }1792 1793 $wdays = $locale->getLocale('weekDays');1794 if ($locale->getLocale('weekStarts') === 1)1795 { /*Monday is first*/1796 $sunday = array_shift($wdays);1797 $wdays[] = $sunday;1798 $sundayCnt = array_shift($wCounts);1799 $wCounts[] = $sundayCnt;1800 }1801 $this->setNumberArray($wCounts);1802 $this->setTextArray($wdays);1803 $this->setDescription($locale->getLocale('sgWeekDesc'));1804 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));1805 }1806 /**1807 * Returns a string which identifies this stat. This is always the same1808 * for this class, and can / shall not be set line in {@link #getName}.1809 *1810 * @public1811 * @since 0.0.11812 * @version 0.0.11813 * @return String an identifier of this stat.1814 */1815 function getIdentifier()1816 {1817 return "HitsWeek";1818 }1819 /**1820 * Returns the key used to get the headline from the {@link Localizer}.1821 *1822 * @public1823 * @version 0.0.11824 * @return String the key used to get the headline from the {@link Localizer}.1825 */1826 function getHeadlineKey()1827 {1828 return "sgWeekStat";1829 }1830} /*End of class HitsWeek*/1831/**1832 * Creates a stat of the users top domains.1833 * <p><b>File:</b> StatGenerator.php</p>1834 *1835 * @public1836 * @version 0.0.11837 * @since 0.0.11838 */1839class HitsTopdomain extends GraphStatGenerator1840{1841 /**1842 * Inits the object.1843 *1844 * @param $locale an instance of the <code>Localizer</code>.1845 * @param $dataSource the data source to get the data from.1846 * @public1847 * @version 0.0.11848 * @since 0.0.11849 * @return void1850 */1851 function init()1852 {1853 $this->setName("HitsTopdomain");1854 $locale = &$this->locale;1855 $dataSource = &$this->dataSource;1856 $this->setHeaderArray(array(1857 $locale->getLocale('topdomain'),1858 $locale->getLocale('hits'),1859 $locale->getLocale('percent'),1860 $locale->getLocale('graph')1861 ));1862 $this->setSort(1);1863 $this->setEmphasize("");1864 if ($dataSource != NULL) {1865 $this->setNumberArray($dataSource->getLineAsArray(23));1866 $this->setTextArray($dataSource->getLineAsArray(22));1867 }1868 $this->setDescription($locale->getLocale('sgTopdomainDesc'));1869 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));1870 }1871 /**1872 * Returns a string which identifies this stat. This is always the same1873 * for this class, and can / shall not be set line in {@link #getName}.1874 *1875 * @public1876 * @since 0.0.11877 * @version 0.0.11878 * @return String an identifier of this stat.1879 */1880 function getIdentifier()1881 {1882 return "HitsTopdomain";1883 }1884 /**1885 * Returns the key used to get the headline from the {@link Localizer}.1886 *1887 * @public1888 * @version 0.0.11889 * @return String the key used to get the headline from the {@link Localizer}.1890 */1891 function getHeadlineKey()1892 {1893 return "sgTopdomainStat";1894 }1895} /*End of class HitsTopdomain*/1896/**1897 * Creates a stat of the users domains.1898 * <p><b>File:</b> StatGenerator.php</p>1899 *1900 * @public1901 * @version 0.0.11902 * @since 0.0.11903 */1904class HitsDomain extends GraphStatGenerator1905{1906 /**1907 * Inits the object.1908 *1909 * @param $locale an instance of the <code>Localizer</code>.1910 * @param $dataSource the data source to get the data from.1911 * @public1912 * @version 0.0.11913 * @since 0.0.11914 * @return void1915 */1916 function init()1917 {1918 $this->setName("HitsDomain");1919 $locale = &$this->locale;1920 $dataSource = &$this->dataSource;1921 $this->setHeaderArray(array(1922 $locale->getLocale('domain'),1923 $locale->getLocale('hits'),1924 $locale->getLocale('percent'),1925 $locale->getLocale('graph')1926 ));1927 $this->setSort(1);1928 $this->setEmphasize("");1929 if ($dataSource != NULL) {1930 $this->setNumberArray($dataSource->getLineAsArray(21));1931 $this->setTextArray($dataSource->getLineAsArray(20));1932 }1933 $this->setDescription($locale->getLocale('sgDomainDesc'));1934 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));1935 }1936 /**1937 * Returns a string which identifies this stat. This is always the same1938 * for this class, and can / shall not be set line in {@link #getName}.1939 *1940 * @public1941 * @since 0.0.11942 * @version 0.0.11943 * @return String an identifier of this stat.1944 */1945 function getIdentifier()1946 {1947 return "HitsDomain";1948 }1949 /**1950 * Returns the key used to get the headline from the {@link Localizer}.1951 *1952 * @public1953 * @version 0.0.11954 * @return String the key used to get the headline from the {@link Localizer}.1955 */1956 function getHeadlineKey()1957 {1958 return "sgDomainStat";1959 }1960} /*End of class HitsDomain*/1961/**1962 * Creates a stat of the users browsers.1963 * <p><b>File:</b> StatGenerator.php</p>1964 *1965 * @public1966 * @version 0.0.11967 * @since 0.0.11968 */1969class HitsBrowser extends GraphStatGenerator1970{1971 /**1972 * Inits the object.1973 *1974 * @param $locale an instance of the <code>Localizer</code>.1975 * @param $dataSource the data source to get the data from.1976 * @public1977 * @version 0.0.11978 * @since 0.0.11979 * @return void1980 */1981 function init()1982 {1983 $this->setName("HitsBrowser");1984 $locale = &$this->locale;1985 $dataSource = &$this->dataSource;1986 $this->setHeaderArray(array(1987 $locale->getLocale('browser'),1988 $locale->getLocale('hits'),1989 $locale->getLocale('percent'),1990 $locale->getLocale('graph')1991 ));1992 $this->setSort(1);1993 $this->setEmphasize("");1994 if ($dataSource != NULL) {1995 $this->setNumberArray($dataSource->getLineAsArray(25));1996 $this->setTextArray($dataSource->getLineAsArray(24));1997 }1998 $this->setDescription($locale->getLocale('sgBrowserDesc'));1999 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2000 }2001 /**2002 * Returns a string which identifies this stat. This is always the same2003 * for this class, and can / shall not be set line in {@link #getName}.2004 *2005 * @public2006 * @since 0.0.12007 * @version 0.0.12008 * @return String an identifier of this stat.2009 */2010 function getIdentifier()2011 {2012 return "HitsBrowser";2013 }2014 /**2015 * Returns the key used to get the headline from the {@link Localizer}.2016 *2017 * @public2018 * @version 0.0.12019 * @return String the key used to get the headline from the {@link Localizer}.2020 */2021 function getHeadlineKey()2022 {2023 return "sgBrowserStat";2024 }2025} /*End of class HitsBrowser*/2026/**2027 * Creates a stat of the makers of the users browsers.2028 * This is basically the ordinary HitsBrowser stat, grouped into e.g.2029 * Opera, Mozilla, Safari and a few minor makers etc.2030 */2031class HitsBrowserMaker extends GraphStatGenerator {2032 /**2033 * Inits the object.2034 *2035 * @param $locale an instance of the <code>Localizer</code>.2036 * @param $dataSource the data source to get the data from.2037 * @public2038 * @version 0.0.12039 * @since 0.0.12040 * @return void2041 */2042 function init()2043 {2044 $this->setName("HitsBrowserMaker");2045 $locale = &$this->locale;2046 $dataSource = &$this->dataSource;2047 $this->setHeaderArray(array(2048 $locale->getLocale('browser'),2049 $locale->getLocale('hits'),2050 $locale->getLocale('percent'),2051 $locale->getLocale('graph')2052 ));2053 $this->setSort(1);2054 $this->setEmphasize("");2055 if ($dataSource != NULL) {2056 $this->setNumberArray($dataSource->getLineAsArray(25));2057 $this->setTextArray($dataSource->getLineAsArray(24));2058 }2059 2060 //Transform the data.2061 //We will hard code the categories - sorry.2062 //Each inner array represents a maker. Index 0 of this is the label - sorry.2063 //All values but the label MUST be lower case!!2064 $schema = array(2065 array('Opera', 'opera'),2066 array('Mozilla', 'mozilla', 'netscape', 'firefox', 'galeon', 'iceweasel', 'iceape'),2067 array('Microsoft', 'msie', 'microsoft', 'frontpage'),2068 array('Safari', 'safari'),2069 array('Google', 'chrome', 'chromium'),2070 array('Konqueror', 'konqueror')2071 );2072 //Summarize the data.2073 $this->summarize($schema);2074 $this->setDescription($locale->getLocale('sgBrowserMakerDesc'));2075 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2076 }2077 /**2078 * Returns a string which identifies this stat. This is always the same2079 * for this class, and can / shall not be set line in {@link #getName}.2080 *2081 * @public2082 * @since 0.0.12083 * @version 0.0.12084 * @return String an identifier of this stat.2085 */2086 function getIdentifier()2087 {2088 return "HitsBrowserMaker";2089 }2090 /**2091 * Returns the key used to get the headline from the {@link Localizer}.2092 *2093 * @public2094 * @version 0.0.12095 * @return String the key used to get the headline from the {@link Localizer}.2096 */2097 function getHeadlineKey()2098 {2099 return "sgBrowserMakerStat";2100 }2101} /*End of class HitsBrowserMaker */2102 2103/**2104 * Creates a stat of the users operating system.2105 * <p><b>File:</b> StatGenerator.php</p>2106 *2107 * @public2108 * @version 0.0.12109 * @since 0.0.12110 */2111class HitsOs extends GraphStatGenerator2112{2113 /**2114 * Init the object.2115 *2116 * @public2117 * @version 0.0.12118 * @since 0.0.12119 * @return void2120 */2121 function init()2122 {2123 $this->setName("HitsOs");2124 $locale = &$this->locale;2125 $dataSource = &$this->dataSource;2126 $this->setHeaderArray(array(2127 $locale->getLocale('os'),2128 $locale->getLocale('hits'),2129 $locale->getLocale('percent'),2130 $locale->getLocale('graph')2131 ));2132 $this->setSort(1);2133 $this->setEmphasize("");2134 if ($dataSource != NULL) {2135 $this->setNumberArray($dataSource->getLineAsArray(27));2136 $this->setTextArray($dataSource->getLineAsArray(26));2137 }2138 $this->setDescription($locale->getLocale('sgOsDesc'));2139 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2140 }2141 /**2142 * Returns a string which identifies this stat. This is always the same2143 * for this class, and can / shall not be set line in {@link #getName}.2144 *2145 * @public2146 * @since 0.0.12147 * @version 0.0.12148 * @return String an identifier of this stat.2149 */2150 function getIdentifier()2151 {2152 return "HitsOs";2153 }2154 /**2155 * Returns the key used to get the headline from the {@link Localizer}.2156 *2157 * @public2158 * @version 0.0.12159 * @return String the key used to get the headline from the {@link Localizer}.2160 */2161 function getHeadlineKey()2162 {2163 return "sgOsStat";2164 }2165} /*End of class HitsOs*/2166/**2167 * Creates a stat of the users operating system, summarized into the makers2168 * of the OSes.2169 */2170class HitsOsMaker extends GraphStatGenerator2171{2172 /**2173 * Init the object.2174 *2175 * @public2176 * @version 0.0.12177 * @since 0.0.12178 * @return void2179 */2180 function init()2181 {2182 $this->setName("HitsOsMaker");2183 $locale = &$this->locale;2184 $dataSource = &$this->dataSource;2185 $this->setHeaderArray(array(2186 $locale->getLocale('os'),2187 $locale->getLocale('hits'),2188 $locale->getLocale('percent'),2189 $locale->getLocale('graph')2190 ));2191 $this->setSort(1);2192 $this->setEmphasize("");2193 if ($dataSource != NULL) {2194 $this->setNumberArray($dataSource->getLineAsArray(27));2195 $this->setTextArray($dataSource->getLineAsArray(26));2196 }2197 2198 //We will hard code the categories - sorry.2199 //Each inner array represents a maker. Index 0 of this is the label - sorry.2200 //All values but the label MUST be lower case!!2201 $schema = array(2202 array('Linux', 'linux'),2203 array('Unix', 'unix'),2204 array('Apple', 'macintosh', 'appel', 'mac'),2205 array('Microsoft', 'win', 'windows')2206 );2207 //Summarize the data.2208 $this->summarize($schema);2209 $this->setDescription($locale->getLocale('sgOsMakerDesc'));2210 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2211 }2212 /**2213 * Returns a string which identifies this stat. This is always the same2214 * for this class, and can / shall not be set line in {@link #getName}.2215 *2216 * @public2217 * @since 0.0.12218 * @version 0.0.12219 * @return String an identifier of this stat.2220 */2221 function getIdentifier()2222 {2223 return "HitsOsMaker";2224 }2225 /**2226 * Returns the key used to get the headline from the {@link Localizer}.2227 *2228 * @public2229 * @version 0.0.12230 * @return String the key used to get the headline from the {@link Localizer}.2231 */2232 function getHeadlineKey()2233 {2234 return "sgOsMakerStat";2235 }2236} /*End of class HitsOsMaker*/2237/**2238 * Creates a stat of the users languages.2239 * <p><b>File:</b> StatGenerator.php</p>2240 *2241 * @public2242 * @version 0.0.12243 * @since 0.0.12244 */2245class HitsLanguage extends GraphStatGenerator2246{2247 /**2248 * Init the object.2249 *2250 * @public2251 * @version 0.0.12252 * @since 0.0.12253 * @return void2254 */2255 function init()2256 {2257 $this->setName("HitsLanguage");2258 $locale = &$this->locale;2259 $dataSource = &$this->dataSource;2260 $this->setHeaderArray(array(2261 $locale->getLocale('lang'),2262 $locale->getLocale('hits'),2263 $locale->getLocale('percent'),2264 $locale->getLocale('graph')2265 ));2266 $this->setSort(1);2267 $this->setEmphasize("");2268 if ($dataSource !== NULL) {2269 $this->setNumberArray($dataSource->getLineAsArray(30));2270 $this->setTextArray($dataSource->getLineAsArray(29));2271 }2272 //Convert the cuntry codes into readable text2273 if ($dataSource != NULL) {2274 $this->setDescription($locale->getLocale('sgLangDesc'));2275 }2276 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2277 }2278 /**2279 * Sets an array containing the text for this stat.2280 * The indexes should match the indexes in the array returned by2281 * {@link #getNumberArray}.2282 *2283 * This method overwrites the implemention in the super class to provide2284 * transformation from internal to display text.2285 *2286 * @public2287 * @version 0.0.12288 * @since 0.0.12289 * @return void2290 * @param $textArray the text array for this stat.2291 */2292 function setTextArray($textArray)2293 {2294 //Convert the language codes to real languages.2295 $languages = $this->locale->getLocale('languages');2296 $otherLangs = $this->locale->getLocale('otherLangs');2297 for ($i = 0; $i < sizeof($textArray); $i++)2298 {2299 if (isset($textArray[$i]) and array_key_exists($textArray[$i], $languages))2300 $lang = $languages[$textArray[$i]];2301 else2302 $lang = '';2303 if (strlen($lang) > 0)2304 $textArray[$i] = $lang;2305 else if (strlen($textArray[$i]) > 0)2306 $textArray[$i] = $otherLangs." (".$textArray[$i].")";2307 }2308 2309 //Now set the values in the super class method2310 GraphStatGenerator::setTextArray($textArray);2311 }2312 2313 /**2314 * Returns a string which identifies this stat. This is always the same2315 * for this class, and can / shall not be set line in {@link #getName}.2316 *2317 * @public2318 * @since 0.0.12319 * @version 0.0.12320 * @return String an identifier of this stat.2321 */2322 function getIdentifier()2323 {2324 return "HitsLanguage";2325 }2326 /**2327 * Returns the key used to get the headline from the {@link Localizer}.2328 *2329 * @public2330 * @version 0.0.12331 * @return String the key used to get the headline from the {@link Localizer}.2332 */2333 function getHeadlineKey()2334 {2335 return "sgLangStat";2336 }2337} /*End of class HitsLanguage*/2338/**2339 * Creates a stat of the monitor resolutions.2340 * <p><b>File:</b> StatGenerator.php</p>2341 *2342 * @public2343 * @version 0.0.12344 * @since 0.0.12345 */2346class HitsResolution extends GraphStatGenerator2347{2348 /**2349 * Init the object.2350 *2351 * @public2352 * @version 0.0.12353 * @since 0.0.12354 * @return void2355 */2356 function init()2357 {2358 $this->setName("HitsResolution");2359 $locale = &$this->locale;2360 $dataSource = &$this->dataSource;2361 $this->setHeaderArray(array(2362 $locale->getLocale('resolution'),2363 $locale->getLocale('hits'),2364 $locale->getLocale('percent'),2365 $locale->getLocale('graph')2366 ));2367 $this->setSort(1);2368 $this->setEmphasize("");2369 if ($dataSource != NULL) {2370 $this->setNumberArray($dataSource->getLineAsArray(32));2371 $this->setTextArray($dataSource->getLineAsArray(31));2372 }2373 $this->setDescription($locale->getLocale('sgResDesc'));2374 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2375 }2376 /**2377 * Returns a string which identifies this stat. This is always the same2378 * for this class, and can / shall not be set line in {@link #getName}.2379 *2380 * @public2381 * @since 0.0.12382 * @version 0.0.12383 * @return String an identifier of this stat.2384 */2385 function getIdentifier()2386 {2387 return "HitsResolution";2388 }2389 /**2390 * Returns the key used to get the headline from the {@link Localizer}.2391 *2392 * @public2393 * @version 0.0.12394 * @return String the key used to get the headline from the {@link Localizer}.2395 */2396 function getHeadlineKey()2397 {2398 return "sgResStat";2399 }2400} /*End of class HitsResolution*/2401/**2402 * Creates a stat of the numbers of supported colors.2403 * <p><b>File:</b> StatGenerator.php</p>2404 *2405 * @public2406 * @version 0.0.12407 * @since 0.0.12408 */2409class HitsColor extends GraphStatGenerator2410{2411 /**2412 * Init the object.2413 *2414 * @public2415 * @version 0.0.12416 * @since 0.0.12417 * @return void2418 */2419 function init()2420 {2421 $this->setName("HitsColor");2422 $locale = &$this->locale;2423 $dataSource = &$this->dataSource;2424 $this->setHeaderArray(array(2425 $locale->getLocale('colours'),2426 $locale->getLocale('hits'),2427 $locale->getLocale('percent'),2428 $locale->getLocale('graph')2429 ));2430 $this->setSort(1);2431 $this->setEmphasize("");2432 if ($dataSource != NULL) {2433 $this->setNumberArray($dataSource->getLineAsArray(34));2434 $this->setTextArray($dataSource->getLineAsArray(33));2435 }2436 $this->setDescription($locale->getLocale('sgColoursDesc'));2437 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2438 }2439 /**2440 * Returns a string which identifies this stat. This is always the same2441 * for this class, and can / shall not be set line in {@link #getName}.2442 *2443 * @public2444 * @since 0.0.12445 * @version 0.0.12446 * @return String an identifier of this stat.2447 */2448 function getIdentifier()2449 {2450 return "HitsColor";2451 }2452 /**2453 * Returns the key used to get the headline from the {@link Localizer}.2454 *2455 * @public2456 * @version 0.0.12457 * @return String the key used to get the headline from the {@link Localizer}.2458 */2459 function getHeadlineKey()2460 {2461 return "sgColoursStat";2462 }2463} /*End of class HitsColor*/2464/**2465 * Creates a stat of the clients which supports Java (not Java-script).2466 * <p><b>File:</b> StatGenerator.php</p>2467 *2468 * @public2469 * @version 0.0.12470 * @since 0.0.12471 */2472class HitsJava extends GraphStatGenerator2473{2474 /**2475 * Init the object.2476 *2477 * @public2478 * @version 0.0.12479 * @since 0.0.12480 * @return void2481 */2482 function init()2483 {2484 $this->setName("HitsJava");2485 $locale = &$this->locale;2486 $dataSource = &$this->dataSource;2487 $this->setHeaderArray(array(2488 $locale->getLocale('enabledJava'),2489 $locale->getLocale('hits'),2490 $locale->getLocale('percent'),2491 $locale->getLocale('graph')2492 ));2493 $this->setSort(1);2494 $this->setEmphasize("");2495 //Text 35, numbers 362496 if ($dataSource != NULL) {2497 $this->setNumberArray($dataSource->getLineAsArray(36));2498 $this->setTextArray($dataSource->getLineAsArray(35));2499 }2500 $this->setDescription($locale->getLocale('sgJavaDesc'));2501 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2502 }2503 2504 /**2505 * Sets an array containing the text for this stat.2506 * The indexes should match the indexes in the array returned by2507 * {@link #getNumberArray}.2508 *2509 * This method overwrites the implemention in the super class to provide2510 * transformation from internal to display text.2511 *2512 * @public2513 * @version 0.0.12514 * @since 0.0.12515 * @return void2516 * @param $textArray the text array for this stat.2517 */2518 function setTextArray($textArray)2519 {2520 //Convert true/false to local yes/no2521 for ($i = 0; $i < sizeof($textArray); $i++)2522 {2523 $val = $this->lib->toBool($textArray[$i]);2524 if ($val == 1)2525 $textArray[$i] = $this->locale->getLocale('yes');2526 elseif ($val == 0)2527 $textArray[$i] = $this->locale->getLocale('no');2528 else2529 $textArray[$i] = $this->locale->getLocale('dontKnow');2530 }2531 2532 //Now set the values in the super class method2533 GraphStatGenerator::setTextArray($textArray);2534 }2535 /**2536 * Returns a string which identifies this stat. This is always the same2537 * for this class, and can / shall not be set line in {@link #getName}.2538 *2539 * @public2540 * @since 0.0.12541 * @version 0.0.12542 * @return String an identifier of this stat.2543 */2544 function getIdentifier()2545 {2546 return "HitsJava";2547 }2548 2549 /**2550 * Returns the key used to get the headline from the {@link Localizer}.2551 *2552 * @public2553 * @version 0.0.12554 * @return String the key used to get the headline from the {@link Localizer}.2555 */2556 function getHeadlineKey()2557 {2558 return "sgJavaStat";2559 }2560} /*End of class HitsJava*/2561/**2562 * Creates a stat of the counters.2563 * <p><b>File:</b> StatGenerator.php</p>2564 *2565 * @public2566 * @version 0.0.12567 * @since 0.0.12568 */2569class HitsCounter extends UrlGraphStatGenerator2570{2571 /**2572 * Init the object.2573 *2574 * @public2575 * @version 0.0.12576 * @since 0.0.12577 * @return void2578 */2579 function init()2580 {2581 $this->setName("Counters");2582 $locale = &$this->locale;2583 $dataSource = &$this->dataSource;2584 $this->setHeaderArray(array(2585 $locale->getLocale('counters'),2586 $locale->getLocale('hits'),2587 $locale->getLocale('percent'),2588 $locale->getLocale('graph')2589 ));2590 $this->setSort(1);2591 $this->setEmphasize("");2592 //Text 35, numbers 362593 $this->setNumberArray($dataSource->getLineAsArray(37));2594 $urlArray = $dataSource->getLineAsArray(38);2595 if (strlen($urlArray[0]) === 0)2596 $urlArray[0] = $locale->getLocale('sgStdCounter');2597 $this->setUrlArray($urlArray);2598 $this->setDescription(2599 sprintf($locale->getLocale('sgCountersDesc'),2600 $locale->getLocale('sgStdCounter')));2601 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2602 }2603 /**2604 * Returns a string which identifies this stat. This is always the same2605 * for this class, and can / shall not be set line in {@link #getName}.2606 *2607 * @public2608 * @since 0.0.12609 * @version 0.0.12610 * @return String an identifier of this stat.2611 */2612 function getIdentifier()2613 {2614 return "HitsCounter";2615 }2616 /**2617 * Returns the key used to get the headline from the {@link Localizer}.2618 *2619 * @public2620 * @version 0.0.12621 * @return String the key used to get the headline from the {@link Localizer}.2622 */2623 function getHeadlineKey()2624 {2625 return "sgCountersStat";2626 }2627} /*End of class HitsCounter*/2628/**2629 * Creates a stat of the clients which supports Java-script.2630 * <p><b>File:</b> StatGenerator.php</p>2631 *2632 * @public2633 * @version 0.0.12634 * @since 0.0.12635 */2636class HitsJavaScript extends GraphStatGenerator2637{2638 /**2639 * Init the object.2640 *2641 * @public2642 * @version 0.0.12643 * @since 0.0.12644 * @return void2645 */2646 function init()2647 {2648 $this->setName("HitsJavaScript");2649 $locale = &$this->locale;2650 $dataSource = &$this->dataSource;2651 $this->setHeaderArray(array(2652 $locale->getLocale('enabledJavaScript'),2653 $locale->getLocale('hits'),2654 $locale->getLocale('percent'),2655 $locale->getLocale('graph')2656 ));2657 $this->setSort(1);2658 $this->setEmphasize("");2659 //JAVA-script enabled text 39, numbers 402660 if ($dataSource != NULL) {2661 $this->setNumberArray($dataSource->getLineAsArray(40));2662 $this->setTextArray($dataSource->getLineAsArray(39));2663 }2664 $this->setDescription($locale->getLocale('sgJavaScriptDesc'));2665 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2666 }2667 /**2668 * Sets an array containing the text for this stat.2669 * The indexes should match the indexes in the array returned by2670 * {@link #getNumberArray}.2671 *2672 * This method overwrites the implemention in the super class to provide2673 * transformation from internal to display text.2674 *2675 * @public2676 * @version 0.0.12677 * @since 0.0.12678 * @return void2679 * @param $textArray the text array for this stat.2680 */2681 function setTextArray($textArray)2682 {2683 //Convert true/false to local yes/no2684 for ($i = 0; $i < sizeof($textArray); $i++)2685 {2686 $val = $this->lib->toBool($textArray[$i]);2687 if ($val == 1)2688 $textArray[$i] = $this->locale->getLocale('yes');2689 elseif ($val == 0)2690 $textArray[$i] = $this->locale->getLocale('no');2691 else2692 $textArray[$i] = $this->locale->getLocale('dontKnow');2693 }2694 2695 //Now set the values in the super class method2696 GraphStatGenerator::setTextArray($textArray);2697 }2698 /**2699 * Returns a string which identifies this stat. This is always the same2700 * for this class, and can / shall not be set line in {@link #getName}.2701 *2702 * @public2703 * @since 0.0.12704 * @version 0.0.12705 * @return String an identifier of this stat.2706 */2707 function getIdentifier()2708 {2709 return "HitsJavaScript";2710 }2711 /**2712 * Returns the key used to get the headline from the {@link Localizer}.2713 *2714 * @public2715 * @version 0.0.12716 * @return String the key used to get the headline from the {@link Localizer}.2717 */2718 function getHeadlineKey()2719 {2720 return "sgJavaScriptStat";2721 }2722} /*End of class HitsJavaScript*/2723/**2724 * Creates a stat of the reference pages2725 * <p><b>File:</b> StatGenerator.php</p>2726 *2727 * @public2728 * @version 0.0.12729 * @author Simon Mikkelsen2730 */2731class HitsReferer extends StatGenerator2732{2733 function generateStat()2734 {2735 $this->setName("HitsReferer");2736 //Get the locale object2737 $locale = &$this->siteContext->getLocalizer();2738 //Create a table2739 $list = &$this->siteGenerator->newElement("list");2740 $headline = &$this->siteGenerator->newElement("headline");2741 $headline->setSize(2);2742 $headline->setHeadline($locale->getLocale($this->getHeadlineKey()));2743 $list->addHeadElement($headline);2744 $description = &$this->siteGenerator->newElement("text");2745 $description->addText($locale->getLocale("sgRefererDesc"));2746 $list->addHeadElement($description);2747 //Format: url;;hits2748 $refMixed = $this->dataSource->getLineAsArray(46);2749 $urlArray = array();2750 $hitArray = array();2751 for ($i = 0; $i < sizeof($refMixed); $i++)2752 {2753 list($urlArray[$i], $hitArray[$i]) = explode(";;", $refMixed[$i]);2754 }2755 array_multisort($hitArray, SORT_NUMERIC, SORT_DESC, $urlArray, SORT_ASC, SORT_STRING);2756 for ($i = 0; $i < sizeof($hitArray); $i++)2757 {2758 $hiturl = &$this->siteGenerator->newElement("hiturl");2759 $hiturl->setHits($hitArray[$i]);2760 $hiturl->setUrl("http://".$urlArray[$i]);2761 $list->addListElement($hiturl);2762 }2763 return $list;2764 }2765 /**2766 * Returns a string which identifies this stat. This is always the same2767 * for this class, and can / shall not be set line in {@link #getName}.2768 *2769 * @public2770 * @since 0.0.12771 * @version 0.0.12772 * @return String an identifier of this stat.2773 */2774 function getIdentifier()2775 {2776 return "HitsReferer";2777 }2778 /**2779 * Returns the key used to get the headline from the {@link Localizer}.2780 *2781 * @public2782 * @version 0.0.12783 * @return String the key used to get the headline from the {@link Localizer}.2784 */2785 function getHeadlineKey()2786 {2787 return "sgRefererStat";2788 }2789} /*End of class HitsReferer*/2790/**2791 * Extention of {@link GraphStatGenerator} to allow creation of stats2792 * which have an url as text.2793 * <p><b>File:</b> StatGenerator.php</p>2794 *2795 * @public2796 * @version 0.0.12797 * @author Simon Mikkelsen2798 */2799class UrlGraphStatGenerator extends GraphStatGenerator2800{2801 /**2802 * Sets the <code>$textArray</code> and converts every pice of text2803 * into an url using instances of {@link urlWrapper}.2804 * If the text array is set before this, it is used for texts in the2805 * urls, else the urls are used.2806 *2807 * @public2808 * @version 0.0.12809 * @since 0.0.12810 * @param $urlArray the array of text to make urls and set.2811 * @return void2812 */2813 function setUrlArray($urlArray)2814 {2815 if (sizeof($this->getTextArray()) > 0)2816 $textArray = $this->getTextArray();2817 else2818 $textArray = $urlArray;2819 //Create wrapper and text objects to use for all the entries to process.2820 $urlCutWrapper = new UrlCutWrapper($this->siteContext);2821 $urlCutWrapper->setMaxLength(30);2822 $urlCutWrapper->setCutProtocol(0);2823 $urlCutWrapper->setCutWww(2);2824 $urlCutWrapper->setCutSearch(2);2825 $urlCutWrapper->setCutUrl(2);2826 $text = &$this->siteGenerator->newElement("text");2827 $text->setParagraph(0); /*Don't put the text in a paragraph*/2828 $urlWrapper = &$this->siteGenerator->newElement("urlWrapper");2829 $urlWrapper->setWrapped($urlCutWrapper);2830 $urlCutWrapper->setWrapped($text);2831 //Iterate over all entries and process them.2832 $resultAray = array();2833 $urlForViewing = $this->siteGenerator->isUrlsForViewing();2834 for ($i = 0; $i < sizeof($urlArray); $i++)2835 {2836 if ($urlArray[$i] == $textArray[$i] and ! $this->lib->okurl($urlArray[$i])) {2837 //Url and text are equal, and is not a proper url anyway.2838 //This will actually be true when displaying old counter names.2839 $resultAray[$i] = $urlArray[$i];2840 } else {2841 //Make an url with link and text.2842 $text->setText($textArray[$i]);2843 $urlWrapper->setTitle($urlArray[$i]);2844 if (! $urlForViewing)2845 $url = "redir.php?url=".urlencode($urlArray[$i]);2846 else2847 $url = $urlArray[$i];2848 $urlWrapper->setUrl($url);2849 $resultAray[$i] = $urlWrapper->getCode();2850 }2851 }2852 $this->setTextArray($resultAray);2853 }2854} /*End of class UrlGraphStatGenerator*/2855/**2856 * Creates a stat of the entry urls.2857 * <p><b>File:</b> StatGenerator.php</p>2858 *2859 * @public2860 * @version 0.0.12861 * @since 0.0.12862 */2863class HitsEntryUrls extends UrlGraphStatGenerator2864{2865 /**2866 * Init the object.2867 *2868 * @public2869 * @version 0.0.12870 * @since 0.0.12871 */2872 function init()2873 {2874 $this->setName("HitsEntryUrls");2875 $locale = &$this->locale;2876 $dataSource = &$this->dataSource;2877 $this->setHeaderArray(array(2878 $locale->getLocale('sgEntryUrl'),2879 $locale->getLocale('hits'),2880 $locale->getLocale('percent'),2881 $locale->getLocale('graph')2882 ));2883 $this->setSort(1);2884 $this->setEmphasize("");2885 //112-Entry urls, 113-Hits2886 $this->setNumberArray($dataSource->getLineAsArray(113));2887 $this->setUrlArray($dataSource->getLineAsArray(112));2888 $this->setDescription($locale->getLocale('sgEntryDesc'));2889 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2890 }2891 /**2892 * Returns a string which identifies this stat. This is always the same2893 * for this class, and can / shall not be set line in {@link #getName}.2894 *2895 * @public2896 * @since 0.0.12897 * @version 0.0.12898 * @return String an identifier of this stat.2899 */2900 function getIdentifier()2901 {2902 return "HitsEntryUrls";2903 }2904 /**2905 * Returns the key used to get the headline from the {@link Localizer}.2906 *2907 * @public2908 * @version 0.0.12909 * @return String the key used to get the headline from the {@link Localizer}.2910 */2911 function getHeadlineKey()2912 {2913 return "sgEntryStat";2914 }2915} /*End of class HitsEntryUrls*/2916/**2917 * Creates a stat of the exit urls.2918 * <p><b>File:</b> StatGenerator.php</p>2919 *2920 * @public2921 * @version 0.0.12922 * @since 0.0.12923 */2924class HitsExitUrls extends UrlGraphStatGenerator2925{2926 /**2927 * Init the object.2928 *2929 * @public2930 * @version 0.0.12931 * @since 0.0.12932 */2933 function init()2934 {2935 $this->setName("HitsExitUrls");2936 $locale = &$this->locale;2937 $dataSource = &$this->dataSource;2938 $this->setHeaderArray(array(2939 $locale->getLocale('sgExitUrl'),2940 $locale->getLocale('hits'),2941 $locale->getLocale('percent'),2942 $locale->getLocale('graph')2943 ));2944 $this->setSort(1);2945 $this->setEmphasize("");2946 //114-Url, 115-hits2947 $this->setNumberArray($dataSource->getLineAsArray(115));2948 $this->setUrlArray($dataSource->getLineAsArray(114));2949 $this->setDescription($locale->getLocale('sgExitDesc'));2950 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));2951 }2952 /**2953 * Returns a string which identifies this stat. This is always the same2954 * for this class, and can / shall not be set line in {@link #getName}.2955 *2956 * @public2957 * @since 0.0.12958 * @version 0.0.12959 * @return String an identifier of this stat.2960 */2961 function getIdentifier()2962 {2963 return "HitsExitUrls";2964 }2965 /**2966 * Returns the key used to get the headline from the {@link Localizer}.2967 *2968 * @public2969 * @version 0.0.12970 * @return String the key used to get the headline from the {@link Localizer}.2971 */2972 function getHeadlineKey()2973 {2974 return "sgExitStat";2975 }2976} /*End of class HitsExitUrls*/2977/**2978 * Creates a stat of the movements to and from pages.2979 * <p><b>File:</b> StatGenerator.php</p>2980 *2981 * @public2982 * @version 0.0.12983 * @since 0.0.12984 */2985class HitsMovements extends GraphStatGenerator2986{2987 /**2988 * Init the object.2989 *2990 * @public2991 * @version 0.0.12992 * @since 0.0.12993 */2994 function init()2995 {2996 $this->setName("HitsMovements");2997 $locale = &$this->locale;2998 $dataSource = &$this->dataSource;2999 $this->setHeaderArray(array(3000 $locale->getLocale('sgMovePages'),3001 $locale->getLocale('hits'),3002 $locale->getLocale('percent'),3003 $locale->getLocale('graph')3004 ));3005 $this->setSort(1);3006 $this->setEmphasize("");3007 //Movements 74, hits 753008 $this->setNumberArray($dataSource->getLineAsArray(75));3009 $this->setTextArray($dataSource->getLineAsArray(74));3010 $this->setDescription($locale->getLocale('sgMoveDesc'));3011 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));3012 }3013 /**3014 * Returns a string which identifies this stat. This is always the same3015 * for this class, and can / shall not be set line in {@link #getName}.3016 *3017 * @public3018 * @since 0.0.13019 * @version 0.0.13020 * @return String an identifier of this stat.3021 */3022 function getIdentifier()3023 {3024 return "HitsMovements";3025 }3026 /**3027 * Returns the key used to get the headline from the {@link Localizer}.3028 *3029 * @public3030 * @version 0.0.13031 * @return String the key used to get the headline from the {@link Localizer}.3032 */3033 function getHeadlineKey()3034 {3035 return "sgMoveStat";3036 }3037} /*End of class HitsMovements*/3038/**3039 * Creates a stat of the click counters.3040 * <p><b>File:</b> StatGenerator.php</p>3041 *3042 * @public3043 * @version 0.0.13044 * @since 0.0.13045 */3046class HitsClickCounter extends UrlGraphStatGenerator3047{3048 /**3049 * Init the object.3050 *3051 * @public3052 * @version 0.0.13053 * @since 0.0.13054 */3055 function init()3056 {3057 $this->setName("ClickCounters");3058 $locale = &$this->locale;3059 $dataSource = &$this->dataSource;3060 $this->setHeaderArray(array(3061 $locale->getLocale('sgClicks'),3062 $locale->getLocale('hits'),3063 $locale->getLocale('percent'),3064 $locale->getLocale('graph')3065 ));3066 $this->setSort(1);3067 $this->setEmphasize("");3068 //69- hits3069 //70- names3070 //71- URLs3071 $this->setNumberArray($dataSource->getLineAsArray(69));3072 //Put the counter no. in front of the names3073 $names = $dataSource->getLineAsArray(70);3074 for ($i = 0; $i < sizeof($names); $i++)3075 {3076 if (strlen($names[$i]) > 0)3077 $names[$i] = $i." ".$names[$i];3078 else3079 $names[$i] = $i." ".$locale->getLocale('sgNoName');3080 } /*End for*/3081 $this->setTextArray($names);3082 $this->setUrlArray($dataSource->getLineAsArray(71));3083 $this->setDescription($locale->getLocale('sgClickCountDesc'));3084 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));3085 }3086 /**3087 * Returns a string which identifies this stat. This is always the same3088 * for this class, and can / shall not be set line in {@link #getName}.3089 *3090 * @public3091 * @since 0.0.13092 * @version 0.0.13093 * @return String an identifier of this stat.3094 */3095 function getIdentifier()3096 {3097 return "HitsClickCounter";3098 }3099 /**3100 * Returns the key used to get the headline from the {@link Localizer}.3101 *3102 * @public3103 * @version 0.0.13104 * @return String the key used to get the headline from the {@link Localizer}.3105 */3106 function getHeadlineKey()3107 {3108 return "sgClickCountStat";3109 }3110} /*End of class HitsClickCounter*/3111/**3112 * Creates a stat of the search keywords the visitors have used to find3113 * the page.3114 * <p><b>File:</b> StatGenerator.php</p>3115 *3116 * @public3117 * @version 0.0.13118 * @since 0.0.13119 */3120class HitsSearchWord extends GraphStatGenerator3121{3122 /**3123 * Init the object.3124 *3125 * @public3126 * @version 0.0.13127 * @since 0.0.13128 */3129 function init()3130 {3131 $this->setName("HitsSearchWord");3132 $locale = &$this->locale;3133 $dataSource = &$this->dataSource;3134 $this->setHeaderArray(array(3135 $locale->getLocale('sgSearchWord'),3136 $locale->getLocale('hits'),3137 $locale->getLocale('percent'),3138 $locale->getLocale('graph')3139 ));3140 $this->setSort(1);3141 $this->setEmphasize("");3142 //Search words 47, hits 483143 if ($dataSource != NULL) {3144 $this->setNumberArray($dataSource->getLineAsArray(48));3145 $this->setTextArray($dataSource->getLineAsArray(47));3146 }3147 $this->setDescription($locale->getLocale('sgSearchWordDesc'));3148 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));3149 }3150 /**3151 * Sets an array containing the text for this stat.3152 * The indexes should match the indexes in the array returned by3153 * {@link #getNumberArray}.3154 *3155 * This method overwrites the implemention in the super class to provide3156 * transformation from internal to display text.3157 *3158 * @public3159 * @version 0.0.13160 * @since 0.0.13161 * @return void3162 * @param $textArray the text array for this stat.3163 */3164 function setTextArray($textArray)3165 {3166 //Clean known bad chars.3167 $textArray = str_replace(array("æ", "ø", "å"), array("", "", ""), $textArray);3168 3169 //Now set the values in the super class method3170 GraphStatGenerator::setTextArray($textArray);3171 }3172 /**3173 * Returns a string which identifies this stat. This is always the same3174 * for this class, and can / shall not be set line in {@link #getName}.3175 *3176 * @public3177 * @since 0.0.13178 * @version 0.0.13179 * @return String an identifier of this stat.3180 */3181 function getIdentifier()3182 {3183 return "HitsSearchWord";3184 }3185 /**3186 * Returns the key used to get the headline from the {@link Localizer}.3187 *3188 * @public3189 * @version 0.0.13190 * @return String the key used to get the headline from the {@link Localizer}.3191 */3192 function getHeadlineKey()3193 {3194 return "sgSearchWordStat";3195 }3196} /*End of class HitsSearchWord*/3197/**3198 * Creates a stat of the search engines the visitors have used to find3199 * the page.3200 * <p><b>File:</b> StatGenerator.php</p>3201 *3202 * @public3203 * @version 0.0.13204 * @since 0.0.13205 */3206class HitsSearchEngines extends GraphStatGenerator3207{3208 /**3209 * Init the object.3210 *3211 * @public3212 * @version 0.0.13213 * @since 0.0.13214 */3215 function init()3216 {3217 $this->setName("HitsSearchEngines");3218 $locale = &$this->locale;3219 $dataSource = &$this->dataSource;3220 $this->setHeaderArray(array(3221 $locale->getLocale('sgSearchEngine'),3222 $locale->getLocale('hits'),3223 $locale->getLocale('percent'),3224 $locale->getLocale('graph')3225 ));3226 $this->setSort(1);3227 $this->setEmphasize("");3228 //Search engins 49, numbers 503229 if ($dataSource !== NULL) {3230 $this->setNumberArray($dataSource->getLineAsArray(50));3231 $this->setTextArray($dataSource->getLineAsArray(49));3232 }3233 $this->setDescription($locale->getLocale('sgSearchEngineDesc'));3234 $this->setMainHeadline($locale->getLocale($this->getHeadlineKey()));3235 }3236 /**3237 * Sets an array containing the text for this stat.3238 * The indexes should match the indexes in the array returned by3239 * {@link #getNumberArray}.3240 *3241 * This method overwrites the implemention in the super class to provide3242 * transformation from internal to display text.3243 *3244 * @public3245 * @version 0.0.13246 * @since 0.0.13247 * @return void3248 * @param $engineIds the text array for this stat.3249 */3250 function setTextArray($engineIds)3251 {3252 $engines = new SearchEngines();3253 $text = &$this->siteGenerator->newElement("text");3254 $text->setParagraph(0); /*Don't put the text in a paragraphw*/3255 $urlWrapper = &$this->siteGenerator->newElement("urlWrapper");3256 //Translate the engine ids to urls and names.3257 $urlForViewing = $this->siteGenerator->isUrlsForViewing();3258 for ($i = 0; $i < sizeof($engineIds); $i++)3259 {3260 $engText = "";3261 $engineUrls = $engines->getUrls($engineIds[$i]);3262 $engineNames = $engines->getNames($engineIds[$i]);3263 for ($n = 0; $n < sizeof($engineUrls); $n++)3264 {3265 $text->setText($engineNames[$n]);3266 $urlWrapper->setWrapped($text);3267 $urlWrapper->setTitle($engineUrls[$n]);3268 if (! $urlForViewing)3269 $url = "redir.php?url=".urlencode($engineUrls[$n]);3270 else3271 $url = $engineUrls[$n];3272 $urlWrapper->setUrl($url);3273 if ($n > 0)3274 $engText .= " / ";3275 $engText .= $urlWrapper->getCode();3276 } /*End for $n...*/3277 $engineIds[$i] = $engText;3278 } /*End for $i...*/3279 //Now set the values in the super class method3280 GraphStatGenerator::setTextArray($engineIds);3281 }3282 /**3283 * Returns a string which identifies this stat. This is always the same3284 * for this class, and can / shall not be set line in {@link #getName}.3285 *3286 * @public3287 * @since 0.0.13288 * @version 0.0.13289 * @return String an identifier of this stat.3290 */3291 function getIdentifier()3292 {3293 return "HitsSearchEngines";3294 }3295 /**3296 * Returns the key used to get the headline from the {@link Localizer}.3297 *3298 * @public3299 * @version 0.0.13300 * @return String the key used to get the headline from the {@link Localizer}.3301 */3302 function getHeadlineKey()3303 {3304 return "sgSearchEngineStat";3305 }3306} /*End of class HitsSearchEngines*/3307/**3308 * Creates a stat of each question and anwsers.3309 * <p><b>File:</b> StatGenerator.php</p>3310 *3311 * @public3312 * @version 0.0.13313 * @since 0.0.13314 */3315class HitsVotes extends StatGenerator3316{3317 /**3318 * Creates a new instance.3319 *3320 * @public3321 * @version 0.0.13322 * @since 0.0.13323 */3324 function HitsVotes(&$siteContext, &$siteGenerator) {3325 parent::StatGenerator($siteContext, $siteGenerator);3326 $this->setName("Votes");3327 }3328 /**3329 * Fills in the {@link SiteGenerator} so it is ready to generate3330 * code.3331 *3332 * @protected3333 * @version 0.0.13334 * @since 0.0.13335 * @return SiteElement3336 */3337 function generateStat()3338 {3339 if (strtolower($this->siteGenerator->getParentClass()) != "sitegenerator")3340 { /*It's not a SiteGenerator*/3341 echo "<b>Error:</b> The class <code>HitsVotes</code> only acepts instances of <code>SiteGenerator</code>.<br>";3342 exit;3343 }3344 //Get the locale object3345 $locale = &$this->siteContext->getLocalizer();3346 /*41: Questions :: separated3347 42: Anwsers main groups ,, separated; each anwser in group3348 separated by ::. A group of anwsers corresponds to a question.3349 43: Hits for each anwser, separated as line 42.3350 Example:3351 41:This is question A?::This is question B?::This is question C?3352 42:Anwser 1 for question A.::Ans 2 for q A.,,Ans 1 for q B.::Ans 2 for q B.,,Ans 1 for q C.::Ans 2 for q C.::Ans 3 for q C.3353 43:12::23,,45::56,,67::78::893354 */3355 //The main container it all is put in3356 $mainContainer = &$this->siteGenerator->newElement("text");3357 $mainContainer->setParagraph(0); /*Don't put the text in a paragraph*/3358 //Create the headline3359 $headline = &$this->siteGenerator->newElement("headline");3360 $headline->setSize(2);3361 $headline->setHeadline($locale->getLocale($this->getHeadlineKey()));3362 $mainContainer->addHeadElement($headline);3363 $lib = &$this->siteContext->getCodeLib();3364 $dataSource = &$lib->getDataSource();3365 $qtnArr = explode("::", $dataSource->getLine(41));3366 $ansArr = explode(",,", $dataSource->getLine(42));3367 $hitArr = explode(",,", $dataSource->getLine(43));3368 if (sizeof($qtnArr) === 0 or (sizeof($qtnArr) === 1 and strlen($qtnArr[0]) === 0))3369 {3370 $noPolls = &$this->siteGenerator->newElement("text");3371 $noPolls->addText($locale->getLocale('sgNoVotes'));3372 $mainContainer->addHeadElement($noPolls);3373 }3374 //else3375 for ($i = 0; $i < sizeof($qtnArr); $i++)3376 {3377 $table = &$this->createTable($locale, $qtnArr[$i], $ansArr[$i], $hitArr[$i]);3378 $table->setElementName($this->getName());3379 $mainContainer->addHeadElement($table);3380 } /*End for i (all questions)*/3381 return $mainContainer;3382 }3383 /**3384 * Creates and returns a table representing a question/answer.3385 * This method should only be called from within this class.3386 *3387 * @private3388 * @version 0.0.13389 * @since 0.0.13390 * @param $locale the {@link Localizer} to use3391 * @param $questionStr the question as a stirng.3392 * @param $answers the answers separated by <code>::</code>s.3393 * @param $hits the hits separated by <code>::</code>s.3394 * @return SiteTable a table representing a question/answer3395 */3396 function createTable(&$locale, $questionStr, $answers, $hits)3397 {3398 //if (strlen($questionStr) === 0)3399 // continue;3400 //Create graph3401 $table = &$this->siteGenerator->newElement("graphTable");3402 $table->setElementClass("stattabel");3403 //Create the description3404 $question = &$this->siteGenerator->newElement("text");3405 $question->setParagraph(1);3406 $question->addText($questionStr);3407 $table->addHeadElement($question);3408 //Create the question list3409 $aList = &$this->siteGenerator->newElement("list");3410 $aSiteElements = array();3411 $aStrs = explode("::", $answers);3412 $cutWrapper = new CutWrapper($this->siteContext);3413 $cutWrapper->setMaxLength(25);3414 for ($n = 0; $n < sizeof($aStrs); $n++)3415 {3416 $aSiteElements[$n] = &$this->siteGenerator->newElement("text");3417 $aSiteElements[$n]->setParagraph(0);3418 $aSiteElements[$n]->setText(($n+1)." ".$aStrs[$n]);3419 $cutWrapper->setWrapped($aSiteElements[$n]);3420 $aStrs[$n] = $cutWrapper->getCode();3421 $aList->addListElement($aSiteElements[$n]);3422 }3423 $table->addHeadElement($aList);3424 //Create the graph and table3425 $table->setEmphasize("");3426 $table->setShowNumbers(1);3427 $table->setSorted(1);3428 $table->setTextArray($aStrs);3429 $table->setNumArray(explode("::", $hits));3430 $table->setHeaderArray(array(3431 $locale->getLocale('sgQuestion'),3432 $locale->getLocale('hits'),3433 $locale->getLocale('percent'),3434 $locale->getLocale('graph')3435 ));3436 return $table;3437 }3438 /**3439 * Returns a string which identifies this stat. This is always the same3440 * for this class, and can / shall not be set line in {@link #getName}.3441 *3442 * @public3443 * @since 0.0.13444 * @version 0.0.13445 * @return String an identifier of this stat.3446 */3447 function getIdentifier()3448 {3449 return "HitsVotes";3450 }3451 /**3452 * Returns the key used to get the headline from the {@link Localizer}.3453 *3454 * @public3455 * @version 0.0.13456 * @return String the key used to get the headline from the {@link Localizer}.3457 */3458 function getHeadlineKey()3459 {3460 return "sgVoteStat";3461 }3462} /*End of class HitsVotes*/3463/**3464 * Creates a stat over the latest visitors.3465 * <p><b>File:</b> StatGenerator.php</p>3466 *3467 * @public3468 * @version 0.0.13469 * @since 0.0.13470 */3471class HitsLatestsVisits extends StatGenerator3472{3473 /**3474 * Creates a new instance.3475 *3476 * @public3477 * @version 0.0.13478 * @since 0.0.13479 */3480 function HitsLatestsVisits(&$siteContext, &$siteGenerator) {3481 parent::StatGenerator($siteContext, $siteGenerator);3482 $this->setName("LatestsVisits");3483 }3484 /**3485 * Fills in the {@link SiteGenerator} so it is ready to generate3486 * code.3487 *3488 * @protected3489 * @version 0.0.13490 * @since 0.0.13491 * @return SiteElement3492 */3493 function generateStat()3494 {3495 if (strtolower($this->siteGenerator->getParentClass()) != "sitegenerator")3496 { /*It's not a SiteGenerator*/3497 echo "<b>Error:</b> The class <code>HitsVotes</code> only acepts instances of <code>SiteGenerator</code>.<br>";3498 exit;3499 }3500 //Get the locale object3501 $dataSource = &$this->dataSource;3502 $locale = &$this->locale;3503 //Create the table3504 $table = &$this->siteGenerator->newElement("table");3505 $table->setHeadersAre(1); /*The top row is headers.*/3506 $table->setHeaderClass('sinfo');3507 //Create headline and description3508 $headline = &$this->siteGenerator->newElement("headline");3509 $headline->setSize(2);3510 $headline->setHeadline($locale->getLocale('sgLatestStat'));3511 $table->addHeadElement($headline);3512 $desc = &$this->siteGenerator->newElement("text");3513 $desc->setParagraph(1);3514 $desc->setText($locale->getLocale('sgLatestDesc'));3515 $table->addHeadElement($desc);3516 $table->setElementName($this->getName());3517 $table->setElementClass('stattabel');3518 //Create the headlines for the columns3519 //column, row3520 $tableContent[0][0] = $locale->getLocale('sgLatestTime');3521 $tableContent[0][1] = $locale->getLocale('sgLatestBrowser');3522 $tableContent[0][2] = $locale->getLocale('sgLatestOs');3523 $tableContent[0][3] = $locale->getLocale('sgLatestRes');3524 $tableContent[0][4] = $locale->getLocale('sgLatestColours');3525 $tableContent[0][5] = $locale->getLocale('sgLatestLang');3526 $tableContent[0][6] = $locale->getLocale('sgLatestPage');3527 $tableContent[0][7] = $locale->getLocale('sgLatestRefpage');3528 // $tableContent[0][8] = $locale->getLocale('sgLatestDomain');3529 // $tableContent[0][9] = $locale->getLocale('sgLatestIp');3530 //Set the class name for the columns3531 $columnClass = array_fill(0, sizeof($tableContent[0]), 'sinfo');3532/* for ($i = 0; $i < sizeof($tableContent); $i++)3533 $columnClass[] = 'sinfo';3534*/3535 $table->setColumnClassArray($columnClass);3536 //Fill in the data3537 /*Line 28:3538 Each row separated by ::3539 Each pice of data separated by ;;3540 Order of pices:3541 0: Browser3542 1: Os3543 // 2: IP-adr - empty as of GDPR3544 // 3: Domain - empty as of GDPR3545 4: Time3546 5: Screen resolution3547 6: Screen color depth (in bits)3548 7: Language (iso code)3549 8: Url of page with hit3550 9: Referer url3551 Display in the order:3552 4, 0, 1, 2, 3, 5, 6, 7, 8, 93553 */3554 $displayOrder = array(4, 0, 1, 5, 6, 7, 8, 9);3555 $rows = $dataSource->getLineAsArray(28);3556 $urlCutWrapper = new UrlCutWrapper($this->siteContext);3557 $urlCutWrapper->setMaxLength(25);3558 $urlCutWrapper->setCutProtocol(0);3559 $urlCutWrapper->setCutWww(2);3560 $urlCutWrapper->setCutSearch(2);3561 $urlCutWrapper->setCutUrl(2);3562 $text = &$this->siteGenerator->newElement("text");3563 $text->setParagraph(0); /*Don't put the text in a paragraph*/3564 $urlWrapper = &$this->siteGenerator->newElement("urlWrapper");3565 $urlWrapper->setWrapped($urlCutWrapper);3566 $urlCutWrapper->setWrapped($text);3567 3568 //Set up cutting and presentation of domain3569 $domainCutWrapper = new CutWrapper($this->siteContext);3570 $domainCutWrapper->setMaxLength(15);3571 $domainText = &$this->siteGenerator->newElement("text");3572 $domainText->setParagraph(0);3573 $domainLabel = &$this->siteGenerator->newElement("text");3574 $domainLabel->setParagraph(-1);3575 $domainCutWrapper->setWrapped($domainText);3576 $domainCutWrapper->setCutFrom(1);3577 //Set up parser for converting dates3578 $dateParser = new LegacyDateParser();3579 $dateFormatter = new DateFormatter($locale->getLocale('dateShort'));3580 $dateFormatter->setCurrentYear(date("Y"), $locale->getLocale('dateReallyShort'));3581 3582 $urlForViewing = $this->siteGenerator->isUrlsForViewing();3583 $rows = array_reverse($rows);3584 for ($i = 0; $i < sizeof($rows); $i++)3585 {3586 $column = explode(",,", $rows[$i]);3587 //Handle non existing data3588 if (!isset($column[0]) or $column[0] === "Andre browsere")3589 $column[0] = $locale->getLocale('sgLatestNA');3590 3591 if (! $urlForViewing) {3592 //For cutting3593 $domainText->setText($column[3]);3594 3595 //For label3596 $domainLabel->setLabel($column[3]);3597 $domainLabel->setText($domainCutWrapper->getCode());3598 $column[3] = $domainLabel->getCode();3599 }3600 3601 $column[4] = $dateParser->parseToView($column[4], $dateFormatter);3602 3603 $column[1] = str_replace("Windows", "Win", $column[1]);3604 if (!isset($column[1]) or $column[1] === "Andre styresystemer")3605 $column[1] = $locale->getLocale('sgLatestNA');3606 3607 if (!isset($column[6]) or $column[6] === "Andre bit")3608 $column[6] = $locale->getLocale('sgLatestNA');3609 if (!isset($column[7]) or $column[7] === "Andet (Andre)")3610 $column[7] = $locale->getLocale('sgLatestNA');3611 if (isset($column[6]) and $column[6] !== "")3612 $column[6] .= " ".$locale->getLocale('sgLatestBit');3613 for ($m = 8; $m <= 9; $m++)3614 {3615 if (strlen($column[$m]) > 0)3616 {3617 //Convert urls to links3618 if ($this->lib->okUrl($column[$m]))3619 {3620 $text->setText($column[$m]);3621 $urlWrapper->setTitle($column[$m]);3622 if (! $urlForViewing)3623 $url = "redir.php?url=".urlencode($column[$m]);3624 else3625 $url = $column[$m];3626 $urlWrapper->setUrl($url);3627 $column[$m] = $urlWrapper->getCode();3628 }3629 }3630 else3631 {3632 $column[$m] = $locale->getLocale('sgLatestNA');3633 }3634 } /*End for $m = 8*/3635 //Translate the language, if known3636 $languages = $locale->getLocale('languages');3637 if (isset($languages[$column[7]]) and strlen($languages[$column[7]]) > 0)3638 $column[7] = $languages[$column[7]];3639 else3640 $column[7] = $locale->getLocale('sgLatestOthers')." (".$column[7].")";3641 //Map between place in data and display3642 for ($j = 0; $j < sizeof($displayOrder); $j++)3643 $tableContent[$i+1][$j] = $column[$displayOrder[$j]];3644 } /*End for $i*/3645 $table->setTableContent($tableContent);3646 return $table;3647 }3648 /**3649 * Returns a string which identifies this stat. This is always the same3650 * for this class, and can / shall not be set line in {@link #getName}.3651 *3652 * @public3653 * @since 0.0.13654 * @version 0.0.1...

Full Screen

Full Screen

utf8String.php

Source:utf8String.php Github

copy

Full Screen

...19 $this20 ->if($asserter = new sut())21 ->then22 ->object($asserter->getGenerator())->isEqualTo(new asserter\generator())23 ->object($asserter->getLocale())->isIdenticalTo($asserter->getGenerator()->getLocale())24 ->object($asserter->getAdapter())->isEqualTo(new atoum\adapter())25 ->variable($asserter->getValue())->isNull()26 ->boolean($asserter->wasSet())->isFalse()27 ->if($asserter = new sut($generator = new asserter\generator()))28 ->then29 ->object($asserter->getGenerator())->isIdenticalTo($generator)30 ->object($asserter->getLocale())->isIdenticalTo($generator->getLocale())31 ->object($asserter->getAdapter())->isEqualTo(new atoum\adapter())32 ->variable($asserter->getValue())->isNull()33 ->boolean($asserter->wasSet())->isFalse()34 ->if($adapter = new atoum\test\adapter())35 ->and($adapter->extension_loaded = true)36 ->and($asserter = new sut($generator = new asserter\generator(), $adapter))37 ->then38 ->object($asserter->getGenerator())->isIdenticalTo($generator)39 ->object($asserter->getLocale())->isIdenticalTo($generator->getLocale())40 ->object($asserter->getAdapter())->isEqualTo($adapter)41 ->variable($asserter->getValue())->isNull()42 ->boolean($asserter->wasSet())->isFalse()43 ->if($adapter->extension_loaded = false)44 ->then45 ->exception(function() use ($adapter) { new sut(new asserter\generator(), $adapter); })46 ->isInstanceOf('mageekguy\atoum\exceptions\runtime')47 ->hasMessage('mbstring PHP extension is mandatory to use utf8String asserter')48 ;49 }50 public function test__toString()51 {52 $this53 ->if($asserter = new sut($generator = new asserter\generator()))54 ->and($asserter->setWith($value = $this->getRandomUtf8String()))55 ->then56 ->castToString($asserter)->isEqualTo('string(' . mb_strlen($value, 'UTF-8') . ') \'' . $value . '\'')57 ->if($asserter->setWith($value = "\010" . $this->getRandomUtf8String() . "\010", null, $charlist = "\010"))58 ->then59 ->castToString($asserter)->isEqualTo('string(' . mb_strlen($value, 'UTF-8') . ') \'' . addcslashes($value, "\010") . '\'')60 ;61 }62 public function testSetWith()63 {64 $this65 ->if($asserter = new sut($generator = new asserter\generator()))66 ->then67 ->exception(function() use ($asserter, & $value) { $asserter->setwith($value = rand(- PHP_INT_MAX, PHP_INT_MAX)); })68 ->isinstanceof('mageekguy\atoum\asserter\exception')69 ->hasmessage(sprintf($generator->getlocale()->_('%s is not a string'), $asserter->gettypeof($value)))70 ->exception(function() use ($asserter, & $value) { $asserter->setwith("\xf0\x28\x8c\xbc"); })71 ->isinstanceof('mageekguy\atoum\asserter\exception')72 ->hasmessage(sprintf($generator->getlocale()->_('\'%s\' is not an UTF-8 string'), "\xf0\x28\x8c\xbc"))73 ->exception(function() use ($asserter, & $value) { $asserter->setwith("\xf8\xa1\xa1\xa1\xa1"); })74 ->isinstanceof('mageekguy\atoum\asserter\exception')75 ->hasmessage(sprintf($generator->getlocale()->_('\'%s\' is not an UTF-8 string'), "\xf8\xa1\xa1\xa1\xa1"))76 ->object($asserter->setWith(uniqid()))->isIdenticalTo($asserter)77 ;78 }79 public function testIsEqualTo()80 {81 $this82 ->if($asserter = new sut($generator = new asserter\generator()))83 ->then84 ->boolean($asserter->wasSet())->isFalse()85 ->exception(function() use ($asserter) { $asserter->isEqualTo(uniqid()); })86 ->isInstanceOf('mageekguy\atoum\exceptions\logic')87 ->hasMessage('Value is undefined')88 ->if($asserter->setWith($firstString = $this->getRandomUtf8String()))89 ->and($diff = new diffs\variable())90 ->and($secondString = $this->getRandomUtf8String())91 ->then92 ->exception(function() use ($asserter, $secondString) { $asserter->isEqualTo($secondString); })93 ->isInstanceOf('mageekguy\atoum\asserter\exception')94 ->hasMessage($generator->getLocale()->_('strings are not equals') . PHP_EOL . $diff->setExpected($secondString)->setActual($firstString))95 ->object($asserter->isEqualTo($firstString))->isIdenticalTo($asserter)96 ;97 }98 public function testIsEqualToFileContents()99 {100 $this101 ->if($asserter = new sut($generator = new asserter\generator(), $adapter = new atoum\test\adapter()))102 ->then103 ->boolean($asserter->wasSet())->isFalse()104 ->exception(function() use ($asserter) { $asserter->isEqualToContentsOfFile(uniqid()); })105 ->isInstanceOf('mageekguy\atoum\exceptions\logic')106 ->hasMessage('Value is undefined')107 ->if($asserter->setWith($firstString = $this->getRandomUtf8String()))108 ->and($adapter->file_get_contents = false)109 ->then110 ->exception(function() use ($asserter, & $path) { $asserter->isEqualToContentsOfFile($path = uniqid()); })111 ->isInstanceOf('mageekguy\atoum\asserter\exception')112 ->hasMessage(sprintf($generator->getLocale()->_('Unable to get contents of file %s'), $path))113 ->if($adapter->file_get_contents = $fileContents = $this->getRandomUtf8String())114 ->and($diff = new diffs\variable())115 ->then116 ->exception(function() use ($asserter, & $path) { $asserter->isEqualToContentsOfFile($path); })117 ->isInstanceOf('mageekguy\atoum\asserter\exception')118 ->hasMessage(sprintf($generator->getLocale()->_('string is not equals to contents of file %s'), $path) . PHP_EOL . $diff->setExpected($fileContents)->setActual($firstString))119 ->if($adapter->file_get_contents = $firstString)120 ->then121 ->object($asserter->isEqualToContentsOfFile($this->getRandomUtf8String()))->isIdenticalTo($asserter)122 ;123 }124 public function testIsEmpty()125 {126 $this127 ->if($asserter = new sut($generator = new asserter\generator()))128 ->then129 ->exception(function() use ($asserter) { $asserter->isEmpty(); })130 ->isInstanceOf('mageekguy\atoum\exceptions\logic')131 ->hasMessage('Value is undefined')132 ->if($asserter->setWith($string = $this->getRandomUtf8String()))133 ->and($diff = new diffs\variable())134 ->then135 ->exception(function() use ($asserter) { $asserter->isEmpty(); })136 ->isInstanceOf('mageekguy\atoum\asserter\exception')137 ->hasMessage($generator->getLocale()->_('strings are not equals') . PHP_EOL . $diff->setExpected('')->setActual($string))138 ->if($asserter->setWith(''))139 ->then140 ->object($asserter->isEmpty())->isIdenticalTo($asserter)141 ;142 }143 public function testIsNotEmpty()144 {145 $this146 ->if($asserter = new sut($generator = new asserter\generator()))147 ->then148 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })149 ->isInstanceOf('mageekguy\atoum\exceptions\logic')150 ->hasMessage('Value is undefined')151 ->if($asserter->setWith(''))152 ->and($diff = new diffs\variable())153 ->then154 ->exception(function() use ($asserter) { $asserter->isNotEmpty(); })155 ->isInstanceOf('mageekguy\atoum\asserter\exception')156 ->hasMessage($generator->getLocale()->_('string is empty'))157 ->if($asserter->setWith($string = $this->getRandomUtf8String()))158 ->then159 ->object($asserter->isNotEmpty())->isIdenticalTo($asserter)160 ;161 }162 public function testHasLength()163 {164 $this165 ->if($asserter = new sut($generator = new asserter\generator()))166 ->then167 ->exception(function() use ($asserter) { $asserter->hasLength(rand(0, PHP_INT_MAX)); })168 ->isInstanceOf('mageekguy\atoum\exceptions\logic')169 ->hasMessage('Value is undefined')170 ->if($asserter->setWith(''))171 ->and($diff = new diffs\variable())172 ->then173 ->exception(function() use ($asserter, & $requiredLength) { $asserter->hasLength($requiredLength = rand(1, PHP_INT_MAX)); })174 ->isInstanceOf('mageekguy\atoum\asserter\exception')175 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not %d'), $asserter->getTypeOf(''), $requiredLength))176 ->object($asserter->hasLength(0))->isIdenticalTo($asserter)177 ->if($asserter->setWith($string = $this->getRandomUtf8String()))178 ->then179 ->object($asserter->hasLength(mb_strlen($string, 'UTF-8')))->isIdenticalTo($asserter)180 ;181 }182 public function testHasLengthGreaterThan()183 {184 $this185 ->if($asserter = new sut($generator = new asserter\generator()))186 ->then187 ->exception(function() use ($asserter) { $asserter->hasLengthGreaterThan(rand(0, PHP_INT_MAX)); })188 ->isInstanceOf('mageekguy\atoum\exceptions\logic')189 ->hasMessage('Value is undefined')190 ->if($asserter->setWith($string = $this->getRandomUtf8String()))191 ->and($diff = new diffs\variable())192 ->then193 ->exception(function() use ($asserter, $string) { $asserter->hasLengthGreaterThan(mb_strlen($string, 'UTF-8')); })194 ->isInstanceOf('mageekguy\atoum\asserter\exception')195 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not greater than %d'), $asserter->getTypeOf($string), mb_strlen($string, 'UTF-8')))196 ->object($asserter->hasLengthGreaterThan(0))->isIdenticalTo($asserter)197 ->if($asserter->setWith($string = $this->getRandomUtf8String()))198 ->then199 ->object($asserter->hasLengthGreaterThan(mb_strlen($string, 'UTF-8') - 1))->isIdenticalTo($asserter)200 ;201 }202 public function testHasLengthLessThan()203 {204 $this205 ->if($asserter = new sut($generator = new asserter\generator()))206 ->then207 ->exception(function() use ($asserter) { $asserter->hasLengthLessThan(rand(0, PHP_INT_MAX)); })208 ->isInstanceOf('mageekguy\atoum\exceptions\logic')209 ->hasMessage('Value is undefined')210 ->if($asserter->setWith($string = $this->getRandomUtf8String()))211 ->and($diff = new diffs\variable())212 ->then213 ->exception(function() use ($asserter, $string) { $asserter->hasLengthLessThan(mb_strlen($string, 'UTF-8')); })214 ->isInstanceOf('mageekguy\atoum\asserter\exception')215 ->hasMessage(sprintf($generator->getLocale()->_('length of %s is not less than %d'), $asserter->getTypeOf($string), mb_strlen($string, 'UTF-8')))216 ->object($asserter->hasLengthLessThan(20))->isIdenticalTo($asserter)217 ->if($asserter->setWith($string = $this->getRandomUtf8String()))218 ->then219 ->object($asserter->hasLengthLessThan(mb_strlen($string, 'UTF-8') + 1))->isIdenticalTo($asserter)220 ;221 }222 public function testContains()223 {224 $this225 ->if($asserter = new sut($generator = new asserter\generator()))226 ->then227 ->exception(function() use ($asserter) { $asserter->contains(uniqid()); })228 ->isInstanceOf('mageekguy\atoum\exceptions\logic')229 ->hasMessage('Value is undefined')230 ->if($asserter->setWith($string = $this->getRandomUtf8String()))231 ->and($diff = new diffs\variable())232 ->and($fragment = $this->getRandomUtf8String())233 ->then234 ->exception(function() use ($asserter, $fragment) { $asserter->contains($fragment); })235 ->isInstanceOf('mageekguy\atoum\asserter\exception')236 ->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment))237 ->object($asserter->contains($string))->isIdenticalTo($asserter)238 ->if($asserter->setWith($this->getRandomUtf8String() . $string . $this->getRandomUtf8String()))239 ->then240 ->object($asserter->contains($string))->isIdenticalTo($asserter)241 ->exception(function() use ($asserter, $string, & $fragment) { $asserter->contains($fragment = mb_strtoupper($string, 'UTF-8')); })242 ->isInstanceOf('mageekguy\atoum\asserter\exception')243 ->hasMessage(sprintf($this->getLocale()->_('String does not contain %s'), $fragment))244 ->exception(function() use ($asserter) {245 $asserter->contains("\xf0\x28\x8c\xbc");246 }247 )248 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')249 ->hasMessage('Fragment \'' . "\xf0\x28\x8c\xbc" . '\' is not an UTF-8 string')250 ;251 }252 public function testNotContains()253 {254 $this255 ->if($asserter = new sut($generator = new asserter\generator()))256 ->then257 ->exception(function() use ($asserter) { $asserter->notContains(uniqid()); })258 ->isInstanceOf('mageekguy\atoum\exceptions\logic')259 ->hasMessage('Value is undefined')260 ->if($asserter->setWith($string = 'FreeAgent scans the field'))261 ->and($fragment = 'Agent')262 ->then263 ->exception(function() use ($asserter, $fragment) { $asserter->notContains($fragment); })264 ->isInstanceOf('mageekguy\atoum\asserter\exception')265 ->hasMessage(sprintf($this->getLocale()->_('String contains %s'), $fragment))266 ->object($asserter->notContains('coach'))->isIdenticalTo($asserter)267 ->exception(function() use ($asserter) {268 $asserter->notContains("\xf0\x28\x8c\xbc");269 }270 )271 ->isInstanceOf('mageekguy\atoum\exceptions\logic\invalidArgument')272 ->hasMessage('Fragment \'' . "\xf0\x28\x8c\xbc" . '\' is not an UTF-8 string')273 ;274 }275 public function testStartWith()276 {277 $this278 ->if($asserter = new sut($generator = new asserter\generator()))279 ->then280 ->exception(function() use ($asserter) { $asserter->startWith(uniqid()); })281 ->isInstanceOf('mageekguy\atoum\exceptions\logic')282 ->hasMessage('Value is undefined')283 ->if($asserter->setWith($string = $this->getRandomUtf8String()))284 ->and($diff = new diffs\variable())285 ->and($fragment = $this->getRandomUtf8String())286 ->then287 ->exception(function() use ($asserter, $fragment) { $asserter->startWith($fragment); })288 ->isInstanceOf('mageekguy\atoum\asserter\exception')289 ->hasMessage(sprintf($this->getLocale()->_('String does not start with %s'), $fragment))290 ->object($asserter->startWith($string))->isIdenticalTo($asserter)291 ->if($asserter->setWith(uniqid() . $string))292 ->then293 ->exception(function() use ($asserter, $string) { $asserter->startWith($string); })294 ->isInstanceOf('mageekguy\atoum\asserter\exception')295 ->hasMessage(sprintf($this->getLocale()->_('String does not start with %s'), $string))296 ->if($asserter->setWith($string . uniqid()))297 ->then298 ->object($asserter->startWith($string))->isIdenticalTo($asserter)299 ->exception(function() use ($asserter, $string, & $fragment) { $asserter->startWith($fragment = mb_strtoupper($string, 'UTF-8')); })300 ->isInstanceOf('mageekguy\atoum\asserter\exception')301 ->hasMessage(sprintf($this->getLocale()->_('String does not start with %s'), $fragment))302 ;303 }304 public function testNotStartWith()305 {306 $this307 ->if($asserter = new sut($generator = new asserter\generator()))308 ->then309 ->exception(function() use ($asserter) { $asserter->notStartWith(uniqid()); })310 ->isInstanceOf('mageekguy\atoum\exceptions\logic')311 ->hasMessage('Value is undefined')312 ->if($asserter->setWith($string = $this->getRandomUtf8String()))313 ->then314 ->exception(function() use ($asserter, $string) { $asserter->notStartWith($string); })315 ->isInstanceOf('mageekguy\atoum\asserter\exception')316 ->hasMessage(sprintf($this->getLocale()->_('String start with %s'), $string))317 ->object($asserter->notStartWith(uniqid()))->isIdenticalTo($asserter)318 ;319 }320 public function testEndWith()321 {322 $this323 ->if($asserter = new sut($generator = new asserter\generator()))324 ->then325 ->exception(function() use ($asserter) { $asserter->endWith(uniqid()); })326 ->isInstanceOf('mageekguy\atoum\exceptions\logic')327 ->hasMessage('Value is undefined')328 ->if($asserter->setWith($string = $this->getRandomUtf8String()))329 ->and($diff = new diffs\variable())330 ->and($fragment = $this->getRandomUtf8String())331 ->then332 ->exception(function() use ($asserter, $fragment) { $asserter->endWith($fragment); })333 ->isInstanceOf('mageekguy\atoum\asserter\exception')334 ->hasMessage(sprintf($this->getLocale()->_('String does not end with %s'), $fragment))335 ->object($asserter->endWith($string))->isIdenticalTo($asserter)336 ->if($asserter->setWith($string . uniqid()))337 ->then338 ->exception(function() use ($asserter, $string) { $asserter->endWith($string); })339 ->isInstanceOf('mageekguy\atoum\asserter\exception')340 ->hasMessage(sprintf($this->getLocale()->_('String does not end with %s'), $string))341 ->if($asserter->setWith(uniqid() . $string))342 ->then343 ->object($asserter->endWith($string))->isIdenticalTo($asserter)344 ->exception(function() use ($asserter, $string, & $fragment) { $asserter->endWith($fragment = mb_strtoupper($string, 'UTF-8')); })345 ->isInstanceOf('mageekguy\atoum\asserter\exception')346 ->hasMessage(sprintf($this->getLocale()->_('String does not end with %s'), $fragment))347 ;348 }349 public function testNotEndWith()350 {351 $this352 ->if($asserter = new sut($generator = new asserter\generator()))353 ->then354 ->exception(function() use ($asserter) { $asserter->notEndWith(uniqid()); })355 ->isInstanceOf('mageekguy\atoum\exceptions\logic')356 ->hasMessage('Value is undefined')357 ->if($asserter->setWith($string = $this->getRandomUtf8String()))358 ->then359 ->exception(function() use ($asserter, $string) { $asserter->notEndWith($string); })360 ->isInstanceOf('mageekguy\atoum\asserter\exception')361 ->hasMessage(sprintf($this->getLocale()->_('String end with %s'), $string))362 ->object($asserter->notEndWith(uniqid()))->isIdenticalTo($asserter)363 ;364 }365 public function testLength()366 {367 $this368 ->if($asserter = new sut($generator = new asserter\generator()))369 ->then370 ->exception(function() use ($asserter) { $asserter->length; })371 ->isInstanceOf('mageekguy\atoum\exceptions\logic')372 ->hasMessage('Value is undefined')373 ->if($asserter->setWith(''))374 ->then375 ->object($integer = $asserter->length)...

Full Screen

Full Screen

asserter.php

Source:asserter.php Github

copy

Full Screen

...45 public function getScore()46 {47 return $this->generator->getScore();48 }49 public function getLocale()50 {51 return $this->generator->getLocale();52 }53 public function getGenerator()54 {55 return $this->generator;56 }57 public function getTypeOf($mixed)58 {59 switch (true)60 {61 case is_bool($mixed):62 return sprintf($this->getLocale()->_('boolean(%s)'), ($mixed == false ? $this->getLocale()->_('false') : $this->getLocale()->_('true')));63 case is_integer($mixed):64 return sprintf($this->getLocale()->_('integer(%s)'), $mixed);65 case is_float($mixed):66 return sprintf($this->getLocale()->_('float(%s)'), $mixed);67 case is_null($mixed):68 return 'null';69 case is_object($mixed):70 return sprintf($this->getLocale()->_('object(%s)'), get_class($mixed));71 case is_resource($mixed):72 return sprintf($this->getLocale()->_('resource(%s)'), $mixed);73 case is_string($mixed):74 return sprintf($this->getLocale()->_('string(%s) \'%s\''), strlen($mixed), $mixed);75 case is_array($mixed):76 return sprintf($this->getLocale()->_('array(%s)'), sizeof($mixed));77 }78 }79 public function setWithTest(test $test)80 {81 return $this;82 }83 public function setWithArguments(array $arguments)84 {85 if (sizeof($arguments) > 0)86 {87 call_user_func_array(array($this, 'setWith'), $arguments);88 }89 return $this;90 }...

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1require_once 'generator.php';2$generator = new Generator();3echo $generator->getLocale();4require_once 'generator.php';5$generator = new Generator();6$generator->setLocale('fr_FR');7echo $generator->getLocale();8require_once 'generator.php';9$generator = new Generator();10echo $generator->generate();

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$generator = new \Faker\Generator();2echo $generator->getLocale();3$generator = new \Faker\Generator();4$generator->setLocale('en_US');5echo $generator->getLocale();6$generator = new \Faker\Generator();7$providers = $generator->getProviders();8print_r($providers);9$generator = new \Faker\Generator();10$generator->addProvider(new \Faker\Provider\en_US\Person($generator));11$providers = $generator->getProviders();12print_r($providers);13$generator = new \Faker\Generator();14$generator->seed(1234);15echo $generator->randomNumber();16$generator = new \Faker\Generator();17echo $generator->format('Hello {{name}}', array('name' => 'John'));18$generator = new \Faker\Generator();19echo $generator->parse('Hello {{name}}');20$generator = new \Faker\Generator();21echo $generator->numerify('Hello ###');22$generator = new \Faker\Generator();23echo $generator->lexify('Hello ???');24$generator = new \Faker\Generator();25echo $generator->bothify('Hello ##??');26$generator = new \Faker\Generator();27echo $generator->toLower('Hello');28$generator = new \Faker\Generator();29echo $generator->toUpper('Hello');

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$generator = new Generator();2$generator->getLocale();3$generator = new Generator();4$generator->getLocale();5$generator = new Generator();6$generator->getLocale();7$generator = new Generator();8$generator->getLocale();9$generator = new Generator();10$generator->getLocale();11$generator = new Generator();12$generator->getLocale();13$generator = new Generator();14$generator->getLocale();15$generator = new Generator();16$generator->getLocale();17$generator = new Generator();18$generator->getLocale();19$generator = new Generator();20$generator->getLocale();21$generator = new Generator();22$generator->getLocale();23$generator = new Generator();24$generator->getLocale();25$generator = new Generator();26$generator->getLocale();27$generator = new Generator();28$generator->getLocale();29$generator = new Generator();30$generator->getLocale();31$generator = new Generator();32$generator->getLocale();33$generator = new Generator();34$generator->getLocale();

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1require('generator.php');2$gen = new Generator();3echo $gen->getLocale();4require('generator.php');5$gen = new Generator();6echo $gen->setLocale('de_DE');7require('generator.php');8$gen = new Generator();9echo $gen->getCountryCode();10require('generator.php');11$gen = new Generator();12echo $gen->setCountryCode('IN');13require('generator.php');14$gen = new Generator();15echo $gen->getCurrencyCode();16require('generator.php');17$gen = new Generator();18echo $gen->setCurrencyCode('INR');19require('generator.php');20$gen = new Generator();21echo $gen->getCurrencySymbol();22require('generator.php');23$gen = new Generator();24echo $gen->setCurrencySymbol('INR');25require('generator.php');26$gen = new Generator();27echo $gen->getCurrencyName();28require('generator.php');29$gen = new Generator();30echo $gen->setCurrencyName('INR');31require('generator.php');32$gen = new Generator();33echo $gen->getCurrencyName();34require('generator.php');35$gen = new Generator();36echo $gen->setCurrencyName('INR');37require('generator.php');38$gen = new Generator();39echo $gen->getCurrencyName();

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);2echo $generator->getLocale();3$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);4echo $generator->setPattern("###.##");5$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);6echo $generator->setSymbol(NumberFormatter::CURRENCY_SYMBOL, "Rs.");7$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);8echo $generator->setAttribute(NumberFormatter::FRACTION_DIGITS, 2);9$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);10echo $generator->format(12345.67);11$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);12echo $generator->parse("12345.67");13$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);14echo $generator->formatCurrency(12345.67, "INR");15$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);16echo $generator->parseCurrency("12345.67", "INR");17$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);18echo $generator->getErrorCode();19$generator = new NumberFormatter("en", NumberFormatter::SPELLOUT);20echo $generator->getErrorMessage();21$parser = new NumberFormatter("en", NumberFormatter::SPELLOUT);22echo $parser->getLocale();23$parser = new NumberFormatter("en", NumberFormatter::SPELLOUT);24echo $parser->setPattern("###.##");25$parser = new NumberFormatter("en", NumberFormatter::SPELLOUT

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$generator = new \Faker\Generator();2$generator->addProvider(new \Faker\Provider\en_US\Person($generator));3echo $generator->locale;4$generator = new \Faker\Generator();5$generator->addProvider(new \Faker\Provider\en_US\Person($generator));6$generator->locale = 'en_US';7echo $generator->locale;8$generator = new \Faker\Generator();9$generator->addProvider(new \Faker\Provider\en_US\Person($generator));10$generator->setLocale('en_US');11echo $generator->locale;12$generator = new \Faker\Generator();13$generator->addProvider(new \Faker\Provider\en_US\Person($generator));14echo $generator->getLocale();15$generator = new \Faker\Generator();16$generator->addProvider(new \Faker\Provider\en_US\Person($generator));17$generator->setLocale('en_US');18echo $generator->getLocale();19Faker\Generator::getLocale() Method20public string getLocale()21Faker\Generator::setLocale() Method22public void setLocale(string $locale)

Full Screen

Full Screen

getLocale

Using AI Code Generation

copy

Full Screen

1$generator = new Generator();2$generator->getLocale();3$generator = new Generator();4$generator->setLocale('en_US');5$generator = new Generator();6$generator->getPattern();7(?<!\p{L})\p{L}8$generator = new Generator();9$generator->setPattern('(?<!\p{L})\p{L}');10(?<!\p{L})\p{L}11$generator = new Generator();12$generator->getFlags();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in generator

Trigger getLocale code on LambdaTest Cloud Grid

Execute automation tests with getLocale on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful