MagpieFromSimplePie::normalize_element PHP 메소드

normalize_element() 공개 메소드

MagpieFromSimplePie::normalize_element Simplify the logic for normalize(). Makes sure that count of elements and each of multiple elements is normalized properly. If you need to mess with things like attributes or change formats or the like, pass it a callback to handle each element.
public normalize_element ( &$source, string $from, &$dest, string $to, mixed $via = NULL )
$from string
$to string
$via mixed
    function normalize_element(&$source, $from, &$dest, $to, $via = NULL)
    {
        if (isset($source[$from]) or isset($source["{$from}#"])) {
            if (isset($source["{$from}#"])) {
                $n = $source["{$from}#"];
                $dest["{$to}#"] = $source["{$from}#"];
            } else {
                $n = 1;
            }
            for ($i = 1; $i <= $n; $i++) {
                if (isset($via) and is_callable(array($this, $via))) {
                    // custom callback for ninja attacks
                    $this->{$via}($source, $from, $dest, $to, $i);
                } else {
                    // just make it the same
                    $from_id = $this->element_id($from, $i);
                    $to_id = $this->element_id($to, $i);
                    if (isset($source[$from_id])) {
                        // Avoid PHP notice nastygrams
                        $dest[$to_id] = $source[$from_id];
                    }
                }
            }
        }
    }