[Typo3-dev] HELP!

Gregor Kaczmarczyk gregor at crazes.de
Wed Feb 11 12:34:32 CET 2004


hi,

some time ago, i also need the correct recognition of IFSUB in multilanguage
sites and found some info and made changes to
pk_limitmenutolang/pi1/class.ux_t3lib_page.php
the mysql errors are also gone.

checkout if it works for you :)

ciao, gregor

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2003 pekue (peter at kuehn.com)
*  All rights reserved
*
*  This script is part of the Typo3 project. The Typo3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
 * Plugin 'limit menu to lang' for the 'pk_limitmenutolang' extension.
 *
 * @author pekue <peter at kuehn.com>
 */

class ux_t3lib_pageSelect extends t3lib_pageSelect {
 function getMenu ($uid,$fields="*",$sortField="sorting",$addWhere="") {
  //echo "lang is: ".$GLOBALS["TSFE"]->sys_page->sys_language_uid;
  // Returns an array with pagerows for subpages with pid=$uid (which is pid
here!). This is used for menus
  $output = Array();
  $res = mysql(TYPO3_db, "SELECT ".$fields." FROM pages WHERE
pid=".intval($uid).$this->where_hid_del." ".$addWhere." ORDER BY
".$sortField);
  while ($row = mysql_fetch_assoc($res)){
   $overlay=$this->getPageOverlay($row);
   if($this->sys_language_uid){
    if($row!=$overlay)$output[$row["uid"]]=$overlay;
   }else{
    $output[$row["uid"]]=$overlay;
   }
  }
  return $output;
 }
 function getPageOverlay($pageInput,$lUid=-1){
  if ($lUid<0) $lUid=$this->sys_language_uid;
  if ($lUid) {

$fieldArr=explode(",","title,subtitle,media,keywords,description,abstract,au
thor,author_email");
   if (is_array($pageInput)) {
    $page_id=$pageInput["uid"]; // Was the whole record
//    $fieldArr=array_intersect($fieldArr,array_keys($pageInput));  // Make
sure that only fields which exist in the incoming record are overlaid!
    /********* the following lines I added in the files ***************/

$checkfieldArray=implode(",",array_intersect($fieldArr,array_keys($pageInput
)));
    if ($checkfieldArray) {
    /****************************************************/
     $fieldArr=array_intersect($fieldArr,array_keys($pageInput)); // Make
sure that only fields which exist in the incoming record are overlaid!
    } /************** Of course close it :-)) *****************/
   } else {
    $page_id=$pageInput; // Was the id
   }
   $query = "SELECT ".implode(",",$fieldArr)."
   FROM pages_language_overlay
   WHERE pid=".intval($page_id)."
    AND sys_language_uid=".intval($lUid).
    $this->enableFields("pages_language_overlay")." LIMIT 1";
   $res = mysql(TYPO3_db,$query);
   if ($res) $row = mysql_fetch_assoc($res);
   if(is_array($row))$row["langOverlayed"]=1;
  }

  if (is_array($pageInput)) {
   return is_array($row) ? array_merge($pageInput,$row) : $pageInput; // If
the input was an array, simply overlay the newfound array and return...
  } else {
   return is_array($row) ? $row : array(); // always an array in return
  }
 }
}

?>
"Chi Hoang" <hoang at planb-media.de> schrieb im Newsbeitrag
news:mailman.1.1076495520.18570.typo3-dev at lists.netfielders.de...
> Peter Niederlag wrote:
> > That is what I had in mind. Something is kind of broken in extension
> > pk_limitmenutolang as you stated(I got a lot of "no result" errors
> > from mysql), I never digged into I just turned of mysql-errors in
> > php.ini which is a rather crude "hack" but works for me.
>
> I got this mysql errors aswell. The modified function getpageoverlay
> sql-command isnt feed correctly resulting in an illegal sql result
throwing
> mysql-erros when working with it without checking for proper validation.
> Their is a post from Dan reporting and workarounding this. I did myself
the
> same and check for a valid sql ressource (probably a better solution then
> turning off all mysql-errors!?)  Personally I'm wondering a bit, why Peter
> didnt do it himself, and Kasper neither. I compared other sql codes in
typo
> 3 and it seems to me that never sql ressources are checked for proper
> validation. Is this a bug or a feature?
>
>
> > Hopefully my posting didn't offend you but I am just in the process of
> > getting a real grip into all this object and extend stuff of php/typo3
> > and writing it down this way helps me really understanding it.
>
> Not at all, your are welcome :)
>
> Best Regards,
>
> Chi
>
>






More information about the TYPO3-dev mailing list