function smarty_function_init_article($params, &$smarty)
{
    global $site, $leht, $template, $class_path;
    $content_template =& $leht->content_template;
    ##############
    # default values
    extract($params);
    if (!isset($id)) {
        $id = $leht->id;
    }
    if ($system_message || $system_alias) {
        $system_message = $system_alias ? $system_alias : $system_message;
        $id = $site->alias(array('key' => translate_ee($system_message), 'keel' => $site->keel));
    }
    if (!isset($name)) {
        $name = "article";
    }
    // on_create statements:
    $on_create = explode(',', $on_create);
    // default on_create statements:
    $publish = 0;
    $allow_comments = $site->CONF['default_comments'];
    // cycle statements
    foreach ($on_create as $on_create_statement) {
        $on_create_statement = trim($on_create_statement);
        switch ($on_create_statement) {
            case 'publish':
                $publish = 1;
                break;
            case 'hide':
                $publish = 0;
                break;
            case 'allow_comments':
                $allow_comments = 1;
                break;
        }
    }
    # if parameter "get_object_fields" is given (may be comma sep.list), then split it to array
    if (isset($get_object_fields)) {
        $get_object_fields_arr = split(",", $get_object_fields);
        $i = 0;
        foreach ($get_object_fields_arr as $tmp) {
            $get_object_fields_arr[$i] = trim($tmp);
            $i++;
        }
    }
    ###############
    # action-buttons
    # by default show all
    if (!isset($buttons)) {
        $buttons = array("new", "edit", "hide", "move", "delete");
    } else {
        $buttons = split(",", $buttons);
    }
    if (!isset($ttyyp_id)) {
        $ttyyp_id = 0;
    }
    // system alias given but no such article, can be created under system section
    if (!$id) {
        $parent_id = $site->alias('system');
        $alamlist = new Alamlist(array('parent' => $parent_id, 'klass' => 'artikkel', 'asukoht' => $position, 'start' => 0, 'limit' => 1));
        $new_button = $alamlist->get_edit_buttons(array('tyyp_idlist' => 2, 'publish' => $publish, 'allow_comments' => $allow_comments, 'sys_alias' => $system_message));
        $smarty->assign($name . '_newbutton', $new_button);
        return;
    }
    ##############
    # luua objekt
    $objSettings = array();
    $objSettings['objekt_id'] = $id;
    $obj = new Objekt($objSettings);
    $allObjParents = $obj->get_obj_all_parents($objSettings['objekt_id']);
    if (in_array($leht->parents->list[0]->parent_id, $allObjParents)) {
        $objSettings['parent_id'] = $leht->parents->list[0]->parent_id;
        $obj = new Objekt($objSettings);
    }
    ##############
    # minna edasi vaid siis kui tegemist on artikliga
    if (!$obj->all[klass] == "artikkel") {
        # error pealkirja or smth
        # assign
        # exit;
    }
    ##############
    # load variables
    #PREVIOUS ARTICLE
    $alamlistSQL = new AlamlistSQL(array(parent => $obj->parent_id, klass => "artikkel", asukoht => 0, order => "objekt_objekt.sorteering ASC"));
    $alamlistSQL->add_where("sorteering>'" . $obj->all['sorteering'] . "'");
    $alamlist = new Alamlist(array(alamlistSQL => $alamlistSQL, start => 0, limit => 1));
    #NEXT ARTICLE
    $alamlistSQL2 = new AlamlistSQL(array(parent => $obj->parent_id, klass => "artikkel", asukoht => 0));
    $alamlistSQL2->add_where("sorteering<'" . $obj->all['sorteering'] . "'");
    $alamlist2 = new Alamlist(array(alamlistSQL => $alamlistSQL2, start => 0, limit => 1));
    $prev_art = $alamlist->next();
    $next_art = $alamlist2->next();
    $obj->id = $obj->objekt_id;
    $obj->get_object_href();
    $obj->is_selected = $leht->parents->on_parent($obj->objekt_id);
    $obj->title = $obj->pealkiri;
    $obj->date = $site->db->MySQL_ee_short($obj->all['aeg']);
    $obj->datetime = $site->db->MySQL_ee($obj->all['aeg']);
    $obj->fdate = substr($obj->all['aeg'], 0, strpos($obj->all['aeg'], ' '));
    $obj->fdatetime = $obj->all['aeg'];
    $obj->show_headline = $obj->all['on_pealkiri'];
    $obj->details_link = $site->self . '?id=' . $obj->objekt_id;
    $obj->details_title = $site->sys_sona(array(sona => "loe edasi", tyyp => "kujundus"));
    $obj->printgif = '<a href="' . $obj->href . '&op=print" onClick="avaprintaken(this.href, 600, 400, \'print\'); return false;" target=_blank><img src="' . $site->img_path . '/print_it.gif" border=0 width=19 height=18></a>';
    $obj->printlink = $site->self . '?id=' . $obj->objekt_id . '&op=print';
    # added 08.11.2002:
    $obj->comment_link = $site->self . '?id=' . $obj->objekt_id . '#comm';
    $obj->comment_title = $site->sys_sona(array(sona => "Kommentaarid", tyyp => "kujundus"));
    $obj->add_comment_link = $site->self . '?id=' . $obj->objekt_id . '#cbox';
    $obj->add_comment_title = $site->sys_sona(array(sona => "Add", tyyp => "kujundus"));
    # existing already by default: $obj->comment_count
    $obj->forum_allowed = $obj->all[on_foorum];
    $obj->last_commented_time = $site->db->MySQL_ee($obj->all['last_commented_time']);
    $obj->comment_count = $obj->all['comment_count'];
    # added 21.01.2003:
    $obj->author = $obj->all[author];
    $obj->class = translate_en($obj->all[klass]);
    # translate it to english
    $obj->next_id = $next_art->objekt_id;
    $obj->prev_id = $prev_art->objekt_id;
    $obj->hit_count = $obj->all['count'];
    ##############
    # load sisu
    $obj->load_sisu();
    if (0 && $context_start) {
        $obj->lead = $context_start . $obj->lyhi->get_text() . '</editor:context>';
        $obj->body = $context_start . $obj->sisu->get_text() . '</editor:context>';
    } else {
        $obj->lead = $obj->lyhi->get_text();
        $obj->body = $obj->sisu->get_text();
    }
    if (!$site->in_editor && $site->CONF['use_aliases'] && $site->CONF['replace_links_with_alias']) {
        $hostUrl = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $site->wwwroot . '/';
        //body urls enclosed with "
        preg_match_all('{<a[^>]+href="((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))"[^>]*>.+</a>}Ui', $obj->body, $searchResults, PREG_SET_ORDER);
        //body urls enclosed with '
        preg_match_all("{<a[^>]+href='((" . str_replace('.', '\\.', $hostUrl) . "[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))'[^>]*>.+</a>}Ui", $obj->body, $searchResults2, PREG_SET_ORDER);
        $searchResults = array_merge($searchResults, $searchResults2);
        //non-enclosed body urls
        preg_match_all('{<a[^>]+href=((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>\\s0-9]*))(\\s+[^>]*|)>.+</a>}Ui', $obj->body, $searchResults2, PREG_SET_ORDER);
        $searchResults = array_merge($searchResults, $searchResults2);
        //lead urls enclosed with "
        preg_match_all('{<a[^>]+href="((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))"[^>]*>.+</a>}Ui', $obj->lead, $searchResults2, PREG_SET_ORDER);
        $searchResults = array_merge($searchResults, $searchResults2);
        //lead urls enclosed with '
        preg_match_all("{<a[^>]+href='((" . str_replace('.', '\\.', $hostUrl) . "[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>0-9]*))'[^>]*>.+</a>}Ui", $obj->lead, $searchResults2, PREG_SET_ORDER);
        $searchResults = array_merge($searchResults, $searchResults2);
        //non-enclosed lead urls
        preg_match_all('{<a[^>]+href=((' . str_replace('.', '\\.', $hostUrl) . '[^>]*|/[^>]*|index.php|)\\?([^>]*id=([0-9]+)[^>\\s0-9]*))(\\s+[^>]*|)>.+</a>}Ui', $obj->lead, $searchResults2, PREG_SET_ORDER);
        $searchResults = array_merge($searchResults, $searchResults2);
        foreach ($searchResults as $key => $value) {
            //create an object with the id found in url
            $linkObj = new Objekt(array(objekt_id => $value[4]));
            $variables = array();
            $separator = strpos($value[3], '&amp;') !== false ? '&amp;' : '&';
            foreach (explode($separator, $value[3]) as $param) {
                $paramArray = explode('=', $param);
                if ($paramArray[0] != 'id') {
                    $variables[] = $param;
                }
            }
            if (count($variables) > 0) {
                $param = '?' . implode('&amp;', $variables);
            } else {
                $param = '';
            }
            $replaceValue = str_replace($value[1], (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $linkObj->get_object_href() . $param, $value[0]);
            $obj->lead = str_replace($value[0], $replaceValue, $obj->lead);
            $obj->body = str_replace($value[0], $replaceValue, $obj->body);
        }
    }
    #############
    # buttons (must be after load_sisu(), Bug #1963)
    $obj->buttons = $obj->get_edit_buttons(array(tyyp_idlist => $obj->all['tyyp_id'], nupud => $buttons, ttyyp_id => $ttyyp_id, profile_id => $obj->all['profile_id'], publish => $publish, 'allow_comments' => $allow_comments));
    ########## KUI artiklil on Mļæ½ļæ½RATUD mļæ½ni PROFIIL, siis korja andmed "->" omadustena kokku
    if ($obj->all['profile_id']) {
        #printr($obj->objekt_id.' PROFILE_ID: '.$obj->all['profile_id']);
        include_once $class_path . 'profile.class.php';
        $obj_profile = new Profile(array("id" => $obj->all['profile_id']));
        #### 1. set profile fields as object attributes
        $obj_profile->set_obj_general_fields(array("obj" => &$obj, "get_object_fields" => $get_object_fields));
        ###################
        # get selectlist values - 1 extra sql per function; sql is fast
        if (is_array($obj_profile->selectlist)) {
            $obj_profile->selectlist = array_unique($obj_profile->selectlist);
            #printr($obj_profile->selectlist);
        }
        # go on if object values needs changing:
        if (sizeof($obj_profile->selectlist) > 0) {
            #### 2. save array "->asset_names"  human readable NAME-s:
            $obj_profile->get_asset_names(array("selectlist" => $obj_profile->selectlist));
            #printr($obj_profile->asset_names);
            #printr($obj_profile->change_fields);
            ### 3. save object rest of attributes
            #print "<br>muuta ID: ".$obj->id;
            $obj_profile->set_obj_selectlist_fields(array("obj" => &$obj, "change_fields" => $obj_profile->change_fields));
        }
        # if any selectvalue exist & need to change
        # / get selectlist values
        ###################
    }
    ####### / profile is set
    $obj->created_user_id = $obj->all['created_user_id'];
    $obj->created_user_name = $obj->all['created_user_name'];
    $obj->changed_user_id = $obj->all['changed_user_id'];
    $obj->changed_user_name = $obj->all['changed_user_name'];
    $obj->created_time = $site->db->MySQL_ee($obj->all['created_time']);
    $obj->fcreated_time = $obj->all['created_time'];
    $obj->changed_time = $site->db->MySQL_ee($obj->all['changed_time']);
    $obj->fchanged_time = $obj->all['changed_time'];
    ##############
    # assign to template variables
    $smarty->assign($name, $obj);
    //return $obj; # bug #1921 # for {init_object} tag
}
 function Parents()
 {
     $args = func_get_arg(0);
     $this->ObjektArray();
     $this->meta = array();
     if (is_object($args['parent']) && !strcasecmp(get_class($args['parent']), 'Objekt')) {
         # parent on objekt
         $this->parent_id = $args["parent"]->objekt_id;
         $this->debug->msg("Parents. Antud on objekt: parent_id = " . $this->parent_id);
     } elseif (preg_match("/^\\d+\$/", $args["parent"])) {
         # parent on objekti ID
         $this->parent_id = $args["parent"];
         $this->debug->msg("Parents. Antud on objekti ID: parent_id = " . $this->parent_id);
     } else {
         # parent on vigane
         $this->debug->msg("vigased algandmed: \"{$args['parent']}\" pole objekt ega objekti ID");
     }
     # merle h�mar kommentaar "lisa_objekt"-ile: mulle tundub, et see on vajalik situatsioonis,
     # kus URL-i peal id puudub JA tegu on vana fiks. op-malliga: siis "on meil eriobjekt"
     # ja oleks vaja seda op-malli n�idata HOME rubriigi all ja seep�rast lisatakse parentsi l�ppu objekt HOME.
     if ($args["lisa_objekt"]) {
         $this->add($args["lisa_objekt"]);
     }
     if ($this->parent_id) {
         $id = $this->parent_id;
         $this->debug->msg("Parents. Alguses parent_id = " . $this->parent_id);
         $idid = array();
         # juhul kui HOME, on vaja �he sammu v�rra alla minna
         if ($args["on_esileht"]) {
             $this->debug->msg("Antud HOME rubriik, h�ppame �he taseme v�rra alla");
             $alamlist = new Alamlist(array("parent" => $id, "start" => 0, "limit" => 1, "klass" => 'rubriik', "order" => "objekt.kesk asc, sorteering DESC"));
             $this->debug->msg($alamlist->debug->get_msgs());
             if ($alamlist->size) {
                 $obj = $alamlist->get(0);
                 $id = $obj->objekt_id;
                 $this->debug->msg("Uus ID = {$id}");
             } else {
                 $this->debug->msg("Kahjuks alla h�pata ei saa... Pole sobivat kohta");
             }
         }
         $this->aktiivne_id = $id;
         #############################
         # allah�ppamine
         $this->debug->msg("JUMP: ================START================");
         $this->debug->msg("Jump down? " . ($this->site->in_editor || $this->site->in_admin ? "We are in editor-area or admin-area => abort mission" : "We are in public area => start mission"));
         # We are in public area => start missio:
         if (!($this->site->in_editor || $this->site->in_admin)) {
             do {
                 $last_id = $id;
                 $obj = new Objekt(array("objekt_id" => $id));
                 $this->debug->msg($obj->debug->get_msgs());
                 #####################
                 # kui objekt on rubriik JA talle pole ei lehe- ega sisumalli m��ratud
                 # siis tuleb objekti auto avanemine ise otsustada.
                 # variante on 2:
                 if ($obj->all[klass] == "rubriik" && !$obj->all["page_ttyyp_id"] && !$obj->all["ttyyp_id"]) {
                     $obj->all["on_auto_avanev"] = $this->site->master_tpl["on_auto_avanev"];
                     $this->debug->msg("JUMP: Auto avanemise m��rab saidi p�himall (ID=" . $this->site->master_tpl[ttyyp_id] . ")" . $this->site->master_tpl["on_auto_avanev"]);
                 } elseif ($obj->all["page_ttyyp_id"] && !$obj->all["ttyyp_id"]) {
                     $sql = $this->site->db->prepare("SELECT on_auto_avanev FROM templ_tyyp WHERE ttyyp_id=?", $obj->all["page_ttyyp_id"]);
                     $sth = new SQL($sql);
                     $obj->all["on_auto_avanev"] = $sth->fetchsingle();
                 }
                 $this->debug->msg("JUMP: Tulemus: objekt " . $obj->objekt_id . " " . ($obj->all["on_auto_avanev"] ? "ON" : "EI OLE") . " auto avanev ");
                 # juhul, kui malli on_auto_avanev = 1,
                 # siis hakka pihta
                 if ($obj->all["on_auto_avanev"]) {
                     # kontrollime objektide olemasolu
                     $alamlist = new Alamlist(array("parent" => $obj->objekt_id, "on_counter" => 1, "not_klass" => "rubriik,loginkast,kogumik,link", "order" => "sorteering DESC"));
                     $this->debug->msg($alamlist->debug->get_msgs());
                     # alamlist on tyhi
                     if ($alamlist->rows == 0) {
                         $this->debug->msg("JUMP: Otsime esimest alamrubriiki, kuhu v�iks h�pata");
                         $alamlist = new Alamlist(array("parent" => $obj->objekt_id, "start" => 0, "klass" => "rubriik", "not_tyyp_nimi" => "Lingikast"));
                         $this->debug->msg($alamlist->debug->get_msgs());
                         # kui leiti alamrubriik vaata talle otsa ja p��a teda lisada
                         if ($alamlist->rows > 0) {
                             $obj = $alamlist->next();
                             $this->debug->msg($alamlist->debug->get_msgs());
                             # kui ei �nnestunud objekti korralikult k�tte saada (polnud �iguseid)
                             # siis nendi fakti ja �ra h�ppa alla
                             if (!$obj->objekt_id) {
                                 $this->debug->msg("JUMP: Objekti ei tehtud, ei h�ppa alla");
                             } else {
                                 # JUMP REALLY DOWN here:
                                 $this->debug->msg("JUMP: H�ppasime alla ja n��d on aktiivne id = " . $obj->objekt_id);
                                 $id = $obj->objekt_id;
                             }
                             # kas objekt on vaatamiseks tibens
                         } else {
                             $this->debug->msg("JUMP: Ei h�ppa alla, sest polnud rubriiki, kuhu h�pata");
                         }
                     } else {
                         $this->debug->msg("JUMP: Ei h�ppa alla, sest leiti alamobjekte!");
                     }
                 }
             } while ($last_id !== $id);
         }
         # to jump or not to jump
         $this->aktiivne_id = $id;
         $this->debug->msg("JUMP: ================END================");
         # / allah�ppamine
         #############################
         #############################
         # loop over parents
         $first = 1;
         $i = 0;
         while ($id) {
             # hakkame antud objektist �lesse minna
             #######################
             # if current object, do extra checks:
             # 1) decide which parent to use from now on
             # 2) check if object's language matches with site language
             if ($first || $i == 1) {
                 # if first or second (if we have sub-article as current object, Bug #1955)
                 $obj_parent = "";
                 # 1. ja 2. objekti p�ritakse 2 korda (pole ilus lahendus, hetkel h�davajadus):
                 # 1. kord selleks, et teada saada tema klass
                 $obj = new Objekt(array("objekt_id" => $id, "no_cache" => 1));
                 #################
                 # 1) if current object is article, then start searching parents (we have to find correct parent)
                 if ($obj->all["klass"] == "artikkel") {
                     $this->debug->msg("Current object" . ($i == 1 ? "'s parent" : "") . " is article. Start doing extra check.");
                     # find all parent id-s of this object
                     #####################
                     # 1a. if found more than 1 parent => go on and find right parent
                     if ($obj->all['parents_count'] > 1) {
                         $all_parents = $obj->get_obj_all_parents($obj->objekt_id);
                         # v6ttame maha prygikasti rubriik parenti listist:
                         if ($this->site->alias("trash")) {
                             if (in_array($this->site->alias("trash"), $all_parents)) {
                                 $all_parents = array_diff($all_parents, array($this->site->alias("trash")));
                             }
                         }
                         $this->debug->msg("Object " . $obj->objekt_id . " has " . sizeof($all_parents) . " parents: " . join(",", $all_parents));
                         # get cookie with previous page current section value
                         #$cookie_parent = $this->site->sess_get("current_section");
                         $cookie_parent = $_COOKIE["current_section"];
                         ###################
                         # parent_id in URL (Bug #538)
                         # new feature: parameter "parent_id" in URL, it overrides "current_section" cookie settings
                         if ($this->site->fdat['parent_id']) {
                             $obj_parent = $this->site->fdat['parent_id'];
                             $this->debug->msg("Parent found in URL. Parent set to: " . $obj_parent);
                         } elseif (is_array($_SESSION['alias'])) {
                             #Alias being used and a direct path to the object is being shown.
                             foreach ($_SESSION['alias'] as $cuuki) {
                                 if ($cuuki['objekt_id'] == $obj->objekt_id) {
                                     $obj_parent = $cuuki['parent_id'];
                                 }
                             }
                         }
                         ###################
                         # if cookie has value, go on
                         if ($cookie_parent && $obj_parent == "") {
                             $this->debug->msg("Found current_section cookie: " . $cookie_parent);
                             # if 1 object parent is same as cookie, take this for parent
                             if (in_array($cookie_parent, $all_parents)) {
                                 $obj_parent = $cookie_parent;
                                 $this->debug->msg("Parent set to:" . $obj_parent);
                             } else {
                                 $this->debug->msg("Cookie doesn't match. Searching match from parents...");
                                 foreach ($all_parents as $par) {
                                     # find all parents for parent
                                     $all_parents = $obj->get_obj_all_parents($par);
                                     # if 1 object parent is same as cookie, take this for parent
                                     if (in_array($cookie_parent, $all_parents)) {
                                         $obj_parent = $par;
                                         $this->debug->msg("Parent set to:" . $obj_parent);
                                         break;
                                     }
                                 }
                                 # foreach
                                 if (!$obj_parent) {
                                     $this->debug->msg("No match found in parents. Parent not set.");
                                 }
                             }
                             # if not match
                         } else {
                             $this->debug->msg("I have no idea, which parent to prefer => choosing just the first one");
                         }
                         # / just pick first parent - we have no info which one to prefer
                         ###################
                     }
                     # / if found more than 1 parent, go on
                     #####################
                 }
                 # / if current object is article, then start searching parents
                 #################
                 # 2) check if object's language matches with site language
                 # bug #2398 : skip language check and automatic langchange for folders, files.
                 # bug #2661 : Sisuobjekti detailvaate lingile lisatud ?lang=en parameeter peab alati m�juma (site classis v�etakse fdat->keel m�lemast parameetrist juba)
                 if ($obj->objekt_id && !in_array($obj->all['tyyp_id'], array(21, 22)) && !isset($this->site->fdat['keel'])) {
                     $this->debug->msg("Language check: current object (ID=" . $obj->objekt_id . ") language is: " . $obj->all[keel] . "; site language is: " . $this->site->keel);
                     # if they differ, change site language
                     if ($obj->all[keel] != $this->site->keel) {
                         $this->site->change_keel($obj->all[keel]);
                         $this->debug->msg("Site language set to: " . $obj->all[keel]);
                     }
                 }
                 $no_cache = 1;
             } else {
                 $obj_parent = "";
                 $no_cache = 0;
             }
             # / if current object, decide which parent to use from now on
             #######################
             ###################
             # create object
             $obj = new Objekt(array("objekt_id" => $id, "parent_id" => $obj_parent, "no_cache" => $no_cache));
             $this->debug->msg($obj->debug->get_msgs());
             # if creating object fails (because of wrong parent), do it without parent
             if (!$obj->objekt_id) {
                 $obj = new Objekt(array("objekt_id" => $id, "no_cache" => 1));
                 $this->debug->msg($obj->debug->get_msgs());
             }
             ############# if creating object still fails then QUIT because PARENT IS FORBIDDEN
             if (!$obj->objekt_id) {
                 $this->debug->msg("PARENTS: Kuna �ks parentitest on keelatud siis l�peta kogu t�� ja reseti parents");
                 $this->list = array();
                 $this->objekts = array();
                 $this->set_size();
                 $this->index = -1;
                 return;
             } elseif (!$idid["id" . $id]) {
                 # viimases rubriigis vaatame on_peida_vmenyy v��rtus
                 if ($obj->all["klass"] == "rubriik" && !isset($on_peida_vmenyy)) {
                     $obj->load_sisu();
                     $on_peida_vmenyy = $obj->all["on_peida_vmenyy"];
                     $this->debug->msg("Aktiivse rubriigi on_peida_vmenyy is: " . $obj->all["on_peida_vmenyy"]);
                 }
                 # lisame objekt
                 $this->add($obj);
                 # meta
                 if ($this->meta["keywords"] == "" && $obj->all["meta_keywords"] != "") {
                     $this->meta["keywords"] = $obj->all["meta_keywords"];
                     $this->debug->msg("meta keyword = " . $this->meta["keywords"]);
                 }
                 if ($this->meta["description"] == "" && $obj->all["meta_description"] != "") {
                     $this->meta["description"] = $obj->all["meta_description"];
                     $this->debug->msg("meta description = " . $this->meta["description"]);
                 }
                 if ($this->meta["title"] == "" && $obj->all["meta_title"] != "") {
                     $this->meta["title"] = $obj->all["meta_title"];
                     $this->debug->msg("meta title = " . $this->meta["title"]);
                 }
                 $idid["id" . $id] = 1;
                 ############################
                 # set next ID
                 $id = $obj->parent_id;
                 ############################
                 # set next ID exception: 18.05.03 by merle
                 # force another parent for system article:
                 # if object is system article, then dont proceed with its real parent (system section)
                 # but force its parent to be first page in the site
                 if ($first && $obj->parent_id == $this->site->alias("system") && $obj->all["klass"] == "artikkel") {
                     $this->debug->msg("Current object is system article: " . $obj->all[sys_alias]);
                     $home_alamlist = new Alamlist(array("parent" => $this->site->alias("rub_home_id"), "start" => 0, "limit" => 1, "tyyp" => 'rubriik'));
                     if ($home_alamlist->size) {
                         $home_obj = $home_alamlist->get(0);
                         $id = $home_obj->objekt_id;
                         $this->debug->msg("Because its system article, parent is forced to be: {$id}");
                     } else {
                         $this->debug->msg("Setting new parent for system article failed - not found any section");
                     }
                 }
                 # force another parent for system article:
                 ############################
             } else {
                 $idid["id" . $id] = 1;
                 $id = '';
             }
             $i++;
             $first = 0;
         }
         # while obj
         # / loop over parents
         ####################
         $this->on_peida_vmenyy = $on_peida_vmenyy;
         #defined("on_peida_vmenyy") ? constant("on_peida_vmenyy"):0;
     }
     # if parent
 }