Adding country or language to WF-Links by small flag.This will describe how you can add an option to WF-Links 1.03 for showing the country of origin or a sites language, see pictures.
It will add a drop-down menu with the countrylist to the submit form for users and admin panel for modification by the administrator.
The following files have to be modified:
1. include/functions.php
2. include/linkload.php
3. submit.php
4. admin/index.php
5. admin/modifications.php
6. language/english/admin.php & language/english/main.php
7. templates/wflinks_singlelink.html
8. templates/wflinks_linkloadsimple.html
Further, one extra line has to be added to the database table wflinks_links and the small flags has to be uploaded to your server.
WF-Links 1.03b can be downloaded here:
http://members.lycos.nl/mcdonaldsstore/Please note that changing any part of the code of WF-Links is at your own risk! Not mine![size=x-large]FIRST: MAKE A BACKUP OF YOUR DATABASE!!![/size]Step 1.Open the file include/functions.php in a text editor and add the following function at the end but before ?> :
function wfl_countryname($countryn)
{
$country_array = array ( "" => "Unknown",
"-" => "Unknown",
"AD" => "Andorra",
"AE" => "United Arab Emirates",
"AF" => "Afghanistan",
"AG" => "Antigua And Barbuda",
"AI" => "Anguilla",
"AL" => "Albania",
"AM" => "Armenia",
"AN" => "Netherlands Antilles",
"AO" => "Angola",
"AQ" => "Antarctica",
"AR" => "Argentina",
"AS" => "American Samoa",
"AT" => "Austria",
"AU" => "Australia",
"AW" => "Aruba",
"AZ" => "Azerbaijan",
"BA" => "Bosnia And Herzegovina",
"BB" => "Barbados",
"BD" => "Bangladesh",
"BE" => "Belgium",
"BG" => "Bulgaria",
"BH" => "Bahrain",
"BI" => "Burundi",
"BJ" => "Benin",
"BM" => "Bermuda",
"BN" => "Brunei Darussalam",
"BO" => "Bolivia",
"BR" => "Brazil",
"BS" => "Bahamas",
"BT" => "Bhutan",
"BW" => "Botswana",
"BY" => "Belarus",
"BZ" => "Belize",
"CA" => "Canada",
"CD" => "The Democratic Republic Of The Congo",
"CF" => "Central African Republic",
"CG" => "Congo",
"CH" => "Switzerland",
"CI" => "Cote D'Ivoire",
"CK" => "Cook Islands",
"CL" => "Chile",
"CM" => "Cameroon",
"CN" => "China",
"CO" => "Colombia",
"CR" => "Costa Rica",
"CS" => "Serbia And Montenegro",
"CU" => "Cuba",
"CV" => "Cape Verde",
"CY" => "Cyprus",
"CZ" => "Czech Republic",
"DE" => "Germany",
"DJ" => "Djibouti",
"DK" => "Denmark",
"DM" => "Dominica",
"DO" => "Dominican Republic",
"DZ" => "Algeria",
"EC" => "Ecuador",
"EE" => "Estonia",
"EG" => "Egypt",
"ER" => "Eritrea",
"ES" => "Spain",
"ET" => "Ethiopia",
"EU" => "Europe",
"FI" => "Finland",
"FJ" => "Fiji",
"FK" => "Falkland Islands (Malvinas)",
"FM" => "Federated States Of Micronesia",
"FO" => "Faroe Islands",
"FR" => "France",
"GA" => "Gabon",
"GB" => "United Kingdom",
"GD" => "Grenada",
"GE" => "Georgia",
"GF" => "French Guiana",
"GH" => "Ghana",
"GI" => "Gibraltar",
"GL" => "Greenland",
"GM" => "Gambia",
"GN" => "Guinea",
"GP" => "Guadeloupe",
"GQ" => "Equatorial Guinea",
"GR" => "Greece",
"GT" => "Guatemala",
"GU" => "Guam",
"GW" => "Guinea-Bissau",
"GY" => "Guyana",
"HK" => "Hong Kong",
"HN" => "Honduras",
"HR" => "Croatia",
"HT" => "Haiti",
"HU" => "Hungary",
"ID" => "Indonesia",
"IE" => "Ireland",
"IL" => "Israel",
"IN" => "India",
"IO" => "British Indian Ocean Territory",
"IQ" => "Iraq",
"IR" => "Islamic Republic Of Iran",
"IS" => "Iceland",
"IT" => "Italy",
"JM" => "Jamaica",
"JO" => "Jordan",
"JP" => "Japan",
"KE" => "Kenya",
"KG" => "Kyrgyzstan",
"KH" => "Cambodia",
"KI" => "Kiribati",
"KM" => "Comoros",
"KN" => "Saint Kitts And Nevis",
"KR" => "Republic Of Korea",
"KW" => "Kuwait",
"KY" => "Cayman Islands",
"KZ" => "Kazakhstan",
"LA" => "Lao People'S Democratic Republic",
"LB" => "Lebanon",
"LC" => "Saint Lucia",
"LI" => "Liechtenstein",
"LK" => "Sri Lanka",
"LR" => "Liberia",
"LS" => "Lesotho",
"LT" => "Lithuania",
"LU" => "Luxembourg",
"LV" => "Latvia",
"LY" => "Libyan Arab Jamahiriya",
"MA" => "Morocco",
"MC" => "Monaco",
"MD" => "Republic Of Moldova",
"MG" => "Madagascar",
"MH" => "Marshall Islands",
"MK" => "The Former Yugoslav Republic Of Macedonia",
"ML" => "Mali",
"MM" => "Myanmar",
"MN" => "Mongolia",
"MO" => "Macao",
"MP" => "Northern Mariana Islands",
"MQ" => "Martinique",
"MR" => "Mauritania",
"MT" => "Malta",
"MU" => "Mauritius",
"MV" => "Maldives",
"MW" => "Malawi",
"MX" => "Mexico",
"MY" => "Malaysia",
"MZ" => "Mozambique",
"NA" => "Namibia",
"NC" => "New Caledonia",
"NE" => "Niger",
"NF" => "Norfolk Island",
"NG" => "Nigeria",
"NI" => "Nicaragua",
"NL" => "Netherlands",
"NO" => "Norway",
"NP" => "Nepal",
"NR" => "Nauru",
"NU" => "Niue",
"NZ" => "New Zealand",
"OM" => "Oman",
"PA" => "Panama",
"PE" => "Peru",
"PF" => "French Polynesia",
"PG" => "Papua New Guinea",
"PH" => "Philippines",
"PK" => "Pakistan",
"PL" => "Poland",
"PR" => "Puerto Rico",
"PS" => "Palestinian Territory, Occupied",
"PT" => "Portugal",
"PW" => "Palau",
"PY" => "Paraguay",
"QA" => "Qatar",
"RE" => "Reunion",
"RO" => "Romania",
"RU" => "Russian Federation",
"RW" => "Rwanda",
"SA" => "Saudi Arabia",
"SB" => "Solomon Islands",
"SC" => "Seychelles",
"SD" => "Sudan",
"SE" => "Sweden",
"SG" => "Singapore",
"SI" => "Slovenia",
"SK" => "Slovakia",
"SL" => "Sierra Leone",
"SM" => "San Marino",
"SN" => "Senegal",
"SO" => "Somalia",
"SR" => "Suriname",
"ST" => "Sao Tome And Principe",
"SV" => "El Salvador",
"SY" => "Syrian Arab Republic",
"SZ" => "Swaziland",
"TD" => "Chad",
"TF" => "French Southern Territories",
"TG" => "Togo",
"TH" => "Thailand",
"TJ" => "Tajikistan",
"TK" => "Tokelau",
"TL" => "Timor-Leste",
"TM" => "Turkmenistan",
"TN" => "Tunisia",
"TO" => "Tonga",
"TR" => "Turkey",
"TT" => "Trinidad And Tobago",
"TV" => "Tuvalu",
"TW" => "Taiwan",
"TZ" => "United Republic Of Tanzania",
"UA" => "Ukraine",
"UG" => "Uganda",
"UK" => "United Kingdom",
"US" => "United States",
"UY" => "Uruguay",
"UZ" => "Uzbekistan",
"VA" => "Holy See (Vatican City State)",
"VC" => "Saint Vincent And The Grenadines",
"VE" => "Venezuela",
"VG" => "Virgin Islands, British",
"VI" => "Virgin Islands, U.S.",
"VN" => "Viet Nam",
"VU" => "Vanuatu",
"WS" => "Samoa",
"YE" => "Yemen",
"YT" => "Mayotte",
"ZA" => "South Africa",
"ZM" => "Zambia",
"ZW" => "Zimbabwe"
);
return $country_array[$countryn];
}
Step 2.Open the file include/linkload.php in a text editor and add the following 3 blue lines to line 83 :
$link['publisher'] = ( isset( $link_arr['publisher'] ) && !empty( $link_arr['publisher'] ) ) ? $wfmyts -> htmlSpecialCharsStrip( $link_arr['publisher'] ) : _MD_WFL_NOTSPECIFIED;
[color=0000CC]$country=$link_arr['country'];
$link['country'] = XOOPS_URL . "/uploads/flags/flags_ani/".$country.".gif";
$link['countryname'] = wfl_countryname( $link_arr['country'] );[/color]
$link['mail_subject'] = rawurlencode( sprintf( _MD_WFL_INTFILEFOUND, $xoopsConfig['sitename'] ) );
Step 3.Open the file submit.form in a text editor and modify the following lines as mentioned:
Modify lines 62-63:
$sql = "INSERT INTO " . $xoopsDB -> prefix( WFLINKS_LINKS ) . " (lid, cid, title, url, submitter, status, date, hits, rating, votes, comments, forumid, published, expired, offline, description, ipaddress, notifypub, urlrating, country) ";
$sql .= " VALUES ('', $cid, '$title', '$url', '$submitter', '$status', '$date', 0, 0, 0, 0, '$forumid', '$publishdate', 0, '$offline', '$descriptionb', '$ipaddress', '$notifypub', '$urlrating', '$country')";
Modify line 110:
$sql = "UPDATE " . $xoopsDB -> prefix( WFLINKS_LINKS ) . " SET cid=$cid, title='$title', url='$url', updated='$updated', offline='$offline', description='$descriptionb', ipaddress='$ipaddress', notifypub='$notifypub', urlrating='$urlrating', country='$country' WHERE lid =" . $lid;
Modify lines 137-138:
$sql = "INSERT INTO " . $xoopsDB -> prefix( WFLINKS_MOD ) . " (requestid, lid, cid, title, url, forumid, description, modifysubmitter, requestdate, country, keywords)";
$sql .= " VALUES ('', $lid, $cid, '$title', '$url', '$forumid', '$descriptionb', '$urlrating' '$modifysubmitter', '$requestdate', '$country')";
Add this to line 206:
$country = $link_array['country'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['country'] ) : '-';
Add this line to line 225 after } but before ob_start():
$sform -> addElement( new XoopsFormSelectCountry( _MD_WFL_COUNTRY, 'country', $country ), false);
Step 4.Open the file admin/index.php in a editor and modify or add the following lines:
Add this to line 48:
$country = $link_array['country'] ? $wfmyts -> htmlSpecialCharsStrip( $link_array['country'] ) : '-';
Add this line between lines 104 and 105:
$sform -> addElement( new XoopsFormSelectCountry( _AM_WFL_COUNTRY, 'country', $country ), false);
Modify lines 435-436:
$sql = "INSERT INTO " . $xoopsDB -> prefix( WFLINKS_LINKS ) . " (lid, cid, title, url, screenshot, submitter, publisher, status, date, hits, rating, votes, comments, forumid, published, expired, updated, offline, description, ipaddress, notifypub, urlrating, country )";
$sql .= " VALUES ('', $cid, '$title', '$url', '$screenshot', '$submitter', '$publisher','$status', '$date', 0, 0, 0, 0, '$forumid', '$publishdate', 0, '$updated', '$offline', '$descriptionb', '$ipaddress', '0', '$urlrating', '$country')";
Step 5.Open the file admin/modifications.php and modify as follows:
Modify line 26:
$sql = "SELECT modifysubmitter, requestid, lid, cid, title, url, description, screenshot, forumid, urlrating, country FROM " . $xoopsDB -> prefix( WFLINKS_MOD ) . " WHERE requestid=" . $requestid;
modify line 30:
$sql = "SELECT submitter, lid, cid, title, url, description, screenshot, forumid, urlrating, country FROM " . $xoopsDB -> prefix( WFLINKS_LINKS ) . " WHERE lid=" . $mod_array['lid'] ;
Add the next line between the lines 157 and 158:
$country = $link_array['country'];
Modify line 161:
$xoopsDB -> query( "UPDATE " . $xoopsDB -> prefix( WFLINKS_LINKS ) . " SET cid = $cid, title='$title', url='$url', submitter='$submitter', screenshot='$screenshot', publisher='$publisher', status='2', updated='$updated', description='$description', urlrating='$urlrating', country='$country' WHERE lid = " . $lid );
Step 6.Open the files language/english/admin.php and language/english/main.php in a text editor.
Add the following line at the end of language/english/admin.php:
define( "_AM_WFL_COUNTRY", "Country:" );
Add the following line at the end of language/english/main.php:
define( "_MD_WFL_COUNTRY", "Country:" );
Step 7.Open the file templates/wflinks_singlelink.html in a text editor and add the blue line.
<div><small><{$link.hits|wordwrap:50:"n":true}>small>div>
[color=0000CC]<div><small><b><{$smarty.const._MD_WFL_COUNTRY}b> >small><img src="<{$link.country}>" alt="<{$link.countryname}>" align="middle" />a>div>[/color]
Step 8.Open the file templates/wflinks_linkloadsimple.html in a text editor and add the blue line.
<div><small><{$link.hits|wordwrap:50:"n":true}>small>div>
[color=0000CC]<div><small><b><{$smarty.const._MD_WFL_COUNTRY}b> >small><img src="<{$link.country}>" alt="<{$link.countryname}>" align="middle" />a>div>[/color]
Step 9.Create the following folder on your server: uploads/flags/flags_small/
Upload the little flags that can be downloaded from
http://members.lycos.nl/mcdonaldsstore/ to the created folder.
Step 10.Open your database table wflinks_links with phpMyAdmin and at the following row after urlrating:
name row: country
type : varchar
length : 5
null : not null
default : -
Do not forget to update the module once finished.This hack is also available in MS Word format here:
http://members.lycos.nl/mcdonaldsstore/Good luck!
McDonald