Seite 1 von 1

Inkonsistenzen in cAPI

Verfasst: Di 1. Jan 2008, 22:31
von tono
Laut API-Dokumentation und laut Implementierung in Item sollte LoadByPrimaryKey() einen Rückgabewert über den Erfolg liefern. Diverse überladene Implementierungen tun das nicht.

classes/contenido/class.client.php Zeile 151-157:

Code: Alles auswählen

	function loadByPrimaryKey ($value)
	{
		if (parent::loadByPrimaryKey($value) == true)
		{
			$this->idclient = $value;
		}
	}
muss heißen:

Code: Alles auswählen

	function loadByPrimaryKey ($value)
	{
		if (parent::loadByPrimaryKey($value) == true)
		{
			$this->idclient = $value;
			return true;
		}
		return false;
	}

Dasselbe auch in classes/contenido/class.clientlang.php Zeile 70-76:

Code: Alles auswählen

	function loadByPrimaryKey ($iID)
	{
		if (parent::loadByPrimaryKey($iID) == true)
		{
			$this->idclient = $this->get("idclient");
		}
	}
muss heißen:

Code: Alles auswählen

	function loadByPrimaryKey ($iID)
	{
		if (parent::loadByPrimaryKey($iID) == true)
		{
			$this->idclient = $this->get("idclient");
			return true;
		}
		return false;
	}
classes/contenido/class.module.php Zeile 85-100:

Code: Alles auswählen

	function loadByPrimaryKey ($id)
	{
		parent::loadByPrimaryKey($id);
		
		if ($this->_shouldLoadFromFiles())
		{
			global $cfg;
			$sRootPath = $cfg['path']['contenido'] . $cfg['path']['modules'] . $this->get("idclient")."/" . $this->get("idmod").".xml";

			if (file_exists($sRootPath))
			{
				$this->import($sRootPath);		
			}
			
		}
	}
vielleicht so:

Code: Alles auswählen

    function loadByPrimaryKey ($id)
    {
        if (parent::loadByPrimaryKey($id)){

            if ($this->_shouldLoadFromFiles())
            {
                global $cfg;
                $sRootPath = $cfg['path']['contenido'] . $cfg['path']['modules'] . $this->get("idclient")."/" . $this->get("idmod").".xml";

                if (file_exists($sRootPath))
                {
                    $this->import($sRootPath);
                }

            }
            return true;
        }
        return false;
    }
und schließlich noch classes/class.category.php Zeile 46-85

Code: Alles auswählen

	function loadByPrimaryKey ($key)
	{
		parent::loadByPrimaryKey($key);
		
		/* Load all child language items */
		$catlangs = new CategoryLanguageCollection;
		$catlangs->select("idcat = '$key'");
		
		while ($item = $catlangs->next())
		{
			$this->lang[$item->get("idlang")] = $item;	
		}
	}
so:

Code: Alles auswählen

	function loadByPrimaryKey ($key)
	{
	    if (parent::loadByPrimaryKey($key))
	    {

	        /* Load all child language items */
	        $catlangs = new CategoryLanguageCollection;
	        $catlangs->select("idcat = '$key'");

	        while ($item = $catlangs->next())
	        {
	            $this->lang[$item->get("idlang")] = $item;
	        }
	        return true;
	    }
	    return false;
	}

Verfasst: Mi 2. Jan 2008, 09:07
von Dodger77
verschoben

Verfasst: Di 8. Jan 2008, 19:57
von HerrB
Done.

Gruß
HerrB