Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
irandoct
Hangin' Around



Joined: Dec 01, 2003
Posts: 39

PostPosted: Fri Aug 05, 2005 9:13 am Reply with quote

I'm adding multi lingual feature to the download and web link modules. When I post a main category and then I try to post a sub category I see Arrayenglish word instead of English in the language selection menu ?! Can any one help me in this case ?
I changed the portal language to another one from admin panel but the problem exists .
this is my code for download module :
Code:
function downloads() {

    global $prefix, $db, $admin_file, $multilingual, $currentlang;
    if ($multilingual == 1) {
    $querylang = "AND (dmlang='$currentlang' OR dmlang='')";
    } else {
    $querylang = "";
    }
    if ($multilingual == 1) {
    $querylang2 = "WHERE clang='$currentlang' OR clang=''";
    } else {
    $querylang2 = "";
  }
  if ($multilingual == 1) {
    $querylang3 = "WHERE dlang='$currentlang' OR dlang=''";
    } else {
    $querylang3 = "";
    }
    include ("header.php");
    GraphicAdmin();
    OpenTable();
    $ThemeSel = get_theme();
    if (file_exists("themes/$currentlang/$ThemeSel/images/down-logo.gif")) {
   echo "<center><a href=\"downloads.html\"><img src=\"themes/$currentlang/$ThemeSel/images/down-logo.gif\" border=\"0\" alt=\"\"></a><br><br>";
    } else {
   echo "<center><a href=\"downloads.html\"><img src=\"modules/Downloads/images/down-logo.gif\" border=\"0\" alt=\"\"></a><br><br>";
    }
    $result = $db->sql_query("SELECT * from " . $prefix . "_downloads_downloads");
    $numrows = $db->sql_numrows($result);
    echo "<font class=\"content\">" . _THEREARE . " <b>$numrows</b> " . _DOWNLOADSINDB . "</font></center>";
    CloseTable();
    echo "<br>";
   
/* Temporarily 'homeless' downloads functions (to be revised in admin.php breakup) */
    $result2 = $db->sql_query("SELECT * from " . $prefix . "_downloads_modrequest where brokendownload='1' $querylang");
    $totalbrokendownloads = $db->sql_numrows($result2);
    $result3 = $db->sql_query("SELECT * from " . $prefix . "_downloads_modrequest where brokendownload='0' $querylang");
    $totalmodrequests = $db->sql_numrows($result3);

/* List Downloads waiting for validation */
    $result4 = $db->sql_query("SELECT lid, cid, sid, dlang, title, url, description, name, email, submitter, filesize, version, homepage from " . $prefix . "_downloads_newdownload $querylang3 order by lid");
    $numrows = $db->sql_numrows($result4);
    if ($numrows>0) {
   OpenTable();
   echo "<center><font class=\"content\"><b>" . _DOWNLOADSWAITINGVAL . "</b></font></center><br><br>";
   while($row4 = $db->sql_fetchrow($result4)) {
       $lid = intval($row4['lid']);
       $cid = intval($row4['cid']);
       $sid = intval($row4['sid']);
       $dlang = $row4['dlang'];
       $title = $row4['title'];
       $url = $row4['url'];
       $description = stripslashes($row4['description']);
       $name = trim($row4['name']);
       $email = $row4['email'];
       $submitter = $row4['submitter'];
       $filesize = $row4['filesize'];
       $version = $row4['version'];
       $homepage = $row4['homepage'];
       if ($submitter == "") {
      $submitter = _NONE;
       }
           $homepage = ereg_replace("http://","",$homepage);
       echo "<form action=\"".$admin_file.".php\" method=\"post\">"
      ."<b>" . _DOWNLOADID . ": $lid</b><br><br>"
      ."" . _SUBMITTER . ": <b>$submitter</b><br>"
      ."" . _DOWNLOADNAME . ": <input type=\"text\" name=\"title\" value=\"$title\" size=\"50\" maxlength=\"100\"><br>"
      ."" . _FILEURL . ": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\" maxlength=\"100\">&nbsp;[ <a href=\"index.php?url=$url\" target=\"_blank\">" . _CHECK . "</a> ]<br>"
      ."" . _DESCRIPTION . ": <br><textarea name=\"description\" cols=\"70\" rows=\"15\">$description</textarea><br>";
                if ($multilingual == 1) {
           echo "<b>"._LANGUAGE."</b>:<br>"
           ."<select name=\"dlang\">";
           $handle=opendir('language');
           while ($file = readdir($handle)) {
           if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
           $langFound = $matches[1];
           $languageslist .= "$langFound ";
                }
           }
           closedir($handle);
           $languageslist = explode(" ", $languageslist);
           sort($languageslist);
           for ($i=0; $i < sizeof($languageslist); $i++) {
           if($languageslist[$i]!="") {
      echo "<option value=\"$languageslist[$i]\" ";
      if($languageslist[$i]==$dlang) echo "selected";
      echo ">".ucfirst($languageslist[$i])."</option>\n";
           }
           }
           if ($dlang != "") {
          $sel3 = "";
          } else {
          $sel3 = "selected";
          }
          echo "<option value=\"\" $sel3>"._ALL."</option></select><br><br>";
               } else {
          echo "<input type=\"hidden\" name=\"dlang\" value=\"\">";
               }
      echo "" . _AUTHORNAME . ": <input type=\"text\" name=\"name\" size=\"20\" maxlength=\"100\" value=\"$name\">&nbsp;&nbsp;"
      ."" . _AUTHOREMAIL . ": <input type=\"text\" name=\"email\" size=\"20\" maxlength=\"100\" value=\"$email\"><br>"
      ."" . _FILESIZE . ": <input type=\"text\" name=\"filesize\" size=\"12\" maxlength=\"11\" value=\"$filesize\"><br>"
      ."" . _VERSION . ": <input type=\"text\" name=\"version\" size=\"11\" maxlength=\"10\" value=\"$version\"><br>"
      ."" . _HOMEPAGE . ": <input type=\"text\" name=\"homepage\" size=\"30\" maxlength=\"200\" value=\"http://$homepage\"> [ <a href=\"index.php?url=http://$homepage\">" . _VISIT . "</a> ]<br>";
       echo "<input type=\"hidden\" name=\"new\" value=\"1\">";
       echo "<input type=\"hidden\" name=\"hits\" value=\"0\">";
       echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
       echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">";
       echo "" . _CATEGORY . ": <select name=\"cat\">";
    $result5 = $db->sql_query("SELECT cid, title, parentid from " . $prefix . "_downloads_categories $querylang2 order by title");
    while ($row5 = $db->sql_fetchrow($result5)) {
   $cid2 = intval($row5['cid']);
   $ctitle2 = $row5['title'];
   $parentid2 = $row5['parentid'];
      if ($cid2==$cid) {
         $sel = "selected";
      } else {
         $sel = "";
      }
      if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
       echo "<option value=\"$cid2\" $sel>$ctitle2</option>";
   }

       echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">";
       echo "</select><input type=\"hidden\" name=\"op\" value=\"DownloadsAddDownload\"><input type=\"submit\" value=" . _ADD . "> [ <a href=\"".$admin_file.".php?op=DownloadsDelNew&amp;lid=$lid\">" . _DELETE . "</a> ]</form><br><hr noshade><br>";
   }
   CloseTable();
   echo "<br>";
    } else {
    }

/* Add a New Main Category */

    OpenTable();
    echo "<center><font class=\"content\">[ <a href=\"".$admin_file.".php?op=DownloadsCleanVotes\">" . _CLEANDOWNLOADSDB . "</a> | "
   ."<a href=\"".$admin_file.".php?op=DownloadsListBrokenDownloads\">" . _BROKENDOWNLOADSREP . " ($totalbrokendownloads)</a> | "
   ."<a href=\"".$admin_file.".php?op=DownloadsListModRequests\">" . _DOWNLOADMODREQUEST . " ($totalmodrequests)</a> | "
   ."<a href=\"".$admin_file.".php?op=DownloadsDownloadCheck\">" . _VALIDATEDOWNLOADS . "</a> ]</font></center>";
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<form method=\"post\" action=\"".$admin_file.".php\">"
   ."<font class=\"content\"><b>" . _ADDMAINCATEGORY . "</b><br><br>"
   ."" . _NAME . ": <input type=\"text\" name=\"title\" size=\"30\" maxlength=\"100\"><br>"
   ."" . _DESCRIPTION . ":<br><textarea name=\"cdescription\" cols=\"70\" rows=\"15\"></textarea><br>";
        if ($multilingual == 1) {
   echo ""._LANGUAGE.":<br>"
        ."<select name=\"clang\">";
   $handle=opendir('language');
   while ($file = readdir($handle)) {
        if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
        $langFound = $matches[1];
        $languageslist .= "$langFound ";
        }
   }
   closedir($handle);
   $languageslist = explode(" ", $languageslist);
   sort($languageslist);
   for ($i=0; $i < sizeof($languageslist); $i++) {
        if($languageslist[$i]!="") {
        echo "<option value=\"$languageslist[$i]\" ";
   if($languageslist[$i]==$currentlang) echo "selected";
   echo ">".ucfirst($languageslist[$i])."</option>\n";
        }
   }
   echo "<option value=\"\">"._ALL."</option></select><br><br>";
        } else {
   echo "<input type=\"hidden\" name=\"clang\" value=\"\">";
        }
   echo "<input type=\"hidden\" name=\"op\" value=\"DownloadsAddCat\">"
   ."<input type=\"submit\" value=\"" . _ADD . "\"><br>"
   ."</form>";
    CloseTable();
    echo "<br>";

// Add a New Sub-Category
    $result6 = $db->sql_query("SELECT * from " . $prefix . "_downloads_categories");
    $numrows = $db->sql_numrows($result6);
    if ($numrows>0) {
   OpenTable();
   echo "<form method=\"post\" action=\"".$admin_file.".php\">"
       ."<font class=\"content\"><b>" . _ADDSUBCATEGORY . "</b></font><br><br>"
       ."" . _NAME . ": <input type=\"text\" name=\"title\" size=\"30\" maxlength=\"100\">&nbsp;" . _IN . "&nbsp;";
        $result7 = $db->sql_query("SELECT cid, title, parentid from " . $prefix . "_downloads_categories $querylang2 order by parentid,title");
   echo "<select name=\"cid\">";
   while($row7 = $db->sql_fetchrow($result7)) {
       $cid2 = intval($row7['cid']);
       $ctitle2 = $row7['title'];
       $parentid2 = intval($row7['parentid']);
      if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
       echo "<option value=\"$cid2\">$ctitle2</option>";
   }
   echo "</select><br>"
       ."" . _DESCRIPTION . ":<br><textarea name=\"cdescription\" cols=\"70\" rows=\"15\"></textarea><br>";
        if ($multilingual == 1) {
   echo ""._LANGUAGE.":<br>"
        ."<select name=\"clang\">";
   $handle=opendir('language');
   while ($file = readdir($handle)) {
        if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
        $langFound = $matches[1];
        $languageslist .= "$langFound ";
        }
   }
   closedir($handle);
   $languageslist = explode(" ", $languageslist);
   sort($languageslist);
   for ($i=0; $i < sizeof($languageslist); $i++) {
        if($languageslist[$i]!="") {
        echo "<option value=\"$languageslist[$i]\" ";
   if($languageslist[$i]==$currentlang) echo "selected";
   echo ">".ucfirst($languageslist[$i])."</option>\n";
        }
   }
   echo "<option value=\"\">"._ALL."</option></select><br><br>";
        } else {
   echo "<input type=\"hidden\" name=\"clang\" value=\"\">";
        }
       echo "<input type=\"hidden\" name=\"op\" value=\"DownloadsAddSubCat\">"
       ."<input type=\"submit\" value=\"" . _ADD . "\"><br>"
       ."</form>";
   CloseTable();
   echo "<br>";
    } else {
    }

// Add a New Download to Database
    $result8 = $db->sql_query("SELECT cid, title from " . $prefix . "_downloads_categories");
    $numrows = $db->sql_numrows($result8);
    if ($numrows>0) {
   OpenTable();
   echo "<form method=\"post\" action=\"".$admin_file.".php\">"
       ."<font class=\"content\"><b>" . _ADDNEWDOWNLOAD . "</b><br><br>"
       ."" . _DOWNLOADNAME . ": <input type=\"text\" name=\"title\" size=\"50\" maxlength=\"100\"><br>"
       ."" . _FILEURL . ": <input type=\"text\" name=\"url\" size=\"50\" maxlength=\"100\" value=\"http://\"><br>";
        $result9 = $db->sql_query("SELECT cid, title, parentid from " . $prefix . "_downloads_categories $querylang2 order by title");
   echo "" . _CATEGORY . ": <select name=\"cat\">";
   while($row9 = $db->sql_fetchrow($result9)) {
       $cid2 = intval($row9['cid']);
       $ctitle2 = $row9['title'];
       $parentid2 = intval($row9['parentid']);
       if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
       echo "<option value=\"$cid2\">$ctitle2</option>";
   }
   echo "</select><br><br><br>"
       ."" . _DESCRIPTION255 . "<br><textarea name=\"description\" cols=\"70\" rows=\"15\"></textarea><br><br><br>";
     if ($multilingual == 1) {
   echo ""._LANGUAGE.":<br>"
        ."<select name=\"dlang\">";
   $handle=opendir('language');
   while ($file = readdir($handle)) {
        if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
        $langFound = $matches[1];
        $languageslist .= "$langFound ";
        }
   }
   closedir($handle);
   $languageslist = explode(" ", $languageslist);
   sort($languageslist);
   for ($i=0; $i < sizeof($languageslist); $i++) {
        if($languageslist[$i]!="") {
        echo "<option value=\"$languageslist[$i]\" ";
   if($languageslist[$i]==$currentlang) echo "selected";
   echo ">".ucfirst($languageslist[$i])."</option>\n";
        }
   }
   echo "<option value=\"\">"._ALL."</option></select><br><br>";
        } else {
   echo "<input type=\"hidden\" name=\"dlang\" value=\"\">";
        }
       echo "" . _AUTHORNAME . ": <input type=\"text\" name=\"name\" size=\"30\" maxlength=\"60\"><br><br>"
       ."" . _AUTHOREMAIL . ": <input type=\"text\" name=\"email\" size=\"30\" maxlength=\"60\"><br><br>"
       ."" . _FILESIZE . ": <input type=\"text\" name=\"filesize\" size=\"12\" maxlength=\"11\"> (" . _INBYTES . ")<br><br>"
       ."" . _VERSION . ": <input type=\"text\" name=\"version\" size=\"11\" maxlength=\"10\"><br><br>"
       ."" . _HOMEPAGE . ": <input type=\"text\" name=\"homepage\" size=\"30\" maxlength=\"200\" value=\"http://\"><br><br>"
       ."" . _HITS . ": <input type=\"text\" name=\"hits\" size=\"12\" maxlength=\"11\"><br><br>"
       ."<input type=\"hidden\" name=\"op\" value=\"DownloadsAddDownload\">"
           ."<input type=\"hidden\" name=\"new\" value=\"0\">"
       ."<input type=\"hidden\" name=\"lid\" value=\"0\">"
       ."<center><input type=\"submit\" value=\"" . _ADDURL . "\"><br>"
       ."</form>";
   CloseTable();
   echo "<br>";
    } else {
    }

// Modify Category
    $result10 = $db->sql_query("SELECT * from " . $prefix . "_downloads_categories");
    $numrows = $db->sql_numrows($result10);
    if ($numrows>0) {
   OpenTable();
   echo "<form method=\"post\" action=\"".$admin_file.".php\">"
       ."<font class=\"content\"><b>" . _MODCATEGORY . "</b></font><br><br>";
   $result11 = $db->sql_query("SELECT cid, title, parentid from " . $prefix . "_downloads_categories $querylang2 order by title");
   echo "" . _CATEGORY . ": <select name=\"cat\">";
   while($row11 = $db->sql_fetchrow($result11)) {
       $cid2 = intval($row11['cid']);
       $ctitle2 = $row11['title'];
       $parentid2 = intval($row11['parentid']);
       if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
       echo "<option value=\"$cid2\">$ctitle2</option>";
   }
   echo "</select>"
       ."<input type=\"hidden\" name=\"op\" value=\"DownloadsModCat\">"
       ."<input type=\"submit\" value=\"" . _MODIFY . "\">"
       ."</form>";
   CloseTable();
   echo "<br>";
    } else {
    }

// Modify Downloads
    $result12 = $db->sql_query("SELECT * from " . $prefix . "_downloads_downloads");
    $numrows = $db->sql_numrows($result12);
    if ($numrows>0) {
    OpenTable();
    echo "<form method=\"post\" action=\"".$admin_file.".php\">"
   ."<font class=\"content\"><b>" . _MODDOWNLOAD . "</b><br><br>"
   ."" . _DOWNLOADID . ": <input type=\"text\" name=\"lid\" size=\"12\" maxlength=\"11\">&nbsp;&nbsp;"
   ."<input type=\"hidden\" name=\"op\" value=\"DownloadsModDownload\">"
   ."<input type=\"submit\" value=\"" . _MODIFY . "\">"
   ."</form>";
    CloseTable();
    echo "<br>";
    } else {
    }

// Transfer Categories
    $result13 = $db->sql_query("SELECT * from " . $prefix . "_downloads_downloads");
    $numrows = $db->sql_numrows($result13);
    if ($numrows>0) {
    OpenTable();
   echo "<form method=\"post\" action=\"".$admin_file.".php\">"
       ."<font class=\"option\"><b>" . _EZTRANSFERDOWNLOADS . "</b></font><br><br>"
       ."" . _CATEGORY . ": "
       ."<select name=\"cidfrom\">";
   $result14 = $db->sql_query("SELECT cid, title, parentid from " . $prefix . "_downloads_categories $querylang2 order by parentid,title");
   while($row14 = $db->sql_fetchrow($result14)) {
       $cid2 = intval($row14['cid']);
       $ctitle2 = $row14['title'];
       $parentid2 = intval($row14['parentid']);
      if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
       echo "<option value=\"$cid2\">$ctitle2</option>";
   }
   echo "</select><br>"
       ."" . _IN . "&nbsp;" . _CATEGORY . ": ";
   $result15 = $db->sql_query("SELECT cid, title, parentid from " . $prefix . "_downloads_categories $querylang2 order by parentid,title");
   echo "<select name=\"cidto\">";
   while($row15 = $db->sql_fetchrow($result15)) {
       $cid2 = intval($row15['cid']);
       $ctitle2 = $row15['title'];
       $parentid2 = intval($row15['parentid']);
      if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
       echo "<option value=\"$cid2\">$ctitle2</option>";
   }
   echo "</select><br>"
       ."<input type=\"hidden\" name=\"op\" value=\"DownloadsTransfer\">"
       ."<input type=\"submit\" value=\"" . _EZTRANSFER . "\"><br>"
       ."</form>";
    CloseTable();
    echo "<br>";
    } else {
    }

    include ("footer.php");
}

Your help highly appereciated !
Regards
 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri Aug 05, 2005 11:50 am Reply with quote

You have MANY errors in this, but this is an example of what your problem is
Code:
$querylang = "AND (dmlang='$currentlang' OR dmlang='')";
should be
Code:
$querylang = "AND ($dmlang=='$currentlang' OR $dmlang=='')";
 
View user's profile Send private message
irandoct







PostPosted: Fri Aug 05, 2005 12:30 pm Reply with quote

Hello Raven,
I applied the changes. however the problem exist yet ! can you please explain me what's the errors that you mean ?
I think my problem is related to wrong loop when the scripts list available languages ! However i don't know what's exactly the case !
Regards
 
Raven







PostPosted: Fri Aug 05, 2005 2:06 pm Reply with quote

So you changed all the "if" test operators from = to == and added the "$" to all the variables? If so, please edit your original post and post your corrected code.
 
irandoct







PostPosted: Fri Aug 05, 2005 7:34 pm Reply with quote

Dear Raven,
I uploaded a copy of entire download module included it's sql structure . so you can take a look at all codes and see the error in action . I tested it on a phpnuke version 7.8 . As i said all parts of the code works well . only when i try to add sub-category and download link to the site i see Arrayenglish instead of english in language selection menu .
Please let me know the error !
Thanks
http://www.tabasheer.com/Downloads.tar.gz
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©