* @copyright 2006, Cataev Oleg Alexandrovich * @license * @version * @link * путь по сайту для index.php от 26 июля 2006 * ****************************************************************************/ function getPath($httpID,$cpu) { $Item=false; $pathArray=array(); $flag=true; $parentID=$httpID; //данные о главной странице $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['documetHomeAttr'],NORMAL); $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['documetHomeAttr'],NORMAL); $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['_httpLang'],NORMAL); $GLOBALS['DB']->execute("SELECT sections.ID,Head As caption,StructID,cpu FROM sections, structure WHERE sections.StructID=structure.ID AND structure.Attr&?=? AND langID=? AND Translated=1"); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows>0)) { /*$row=$GLOBALS['DB']->getRecords(); $rootURL=create_user_url($GLOBALS['_httpLangL'],$row['cpu']); $rootTitle=$row['caption'];*/ } //собственно путь while (true) { $row=threadUserContent($parentID,$GLOBALS['_httpLang']); if (is_array($row)) { $cpu=$row['cpu']; $pathArrayValue=($parentID==$httpID)?false:create_user_url($GLOBALS['_httpLangL'],$cpu); if ($row['ParentID']!==0) { $pathArray[$row['head']]=$pathArrayValue; $parentID=$row['ParentID']; if ($GLOBALS['back_url']==false) $GLOBALS['back_url']=$pathArrayValue; } else { $pathArray[$row['head']]=$pathArrayValue; if ($GLOBALS['back_url']==false) $GLOBALS['back_url']=$pathArrayValue; break; } } else { break; } } $pathArray[$rootTitle]=$rootURL; $pathArray=array_reverse($pathArray); if (sizeof($pathArray)>2) { $Item=getXMLUserPath($pathArray); } unset($pathArray); return $Item; } function threadUserContent($id,$langID) { $GLOBALS['DB']->addParam(adNumeric,$langID,NORMAL); $GLOBALS['DB']->addParam(adNumeric,$id,NORMAL); $GLOBALS['DB']->execute("SELECT structure.ID,structure.ParentID,sections.Head, cpu FROM structure,sections WHERE (sections.StructID=structure.ID AND sections.LangID=? AND sections.StructID=? AND Translated=1)"); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows>0)) { $row=$GLOBALS['DB']->getRecords(); $ret=array('ParentID'=>$row['ParentID'],'head'=>$row['Head'],'cpu'=>$row['cpu']); unset($row); } else { unset($ret); $ret=false; } return $ret; } ?> * @copyright 2006, Cataev Oleg Alexandrovich * @license * @version * @link * контент для index.php от 26 июля 2006 * 21 ноя 2006 - включаем человеческую поддержку чпу и выносим языки наружу * ****************************************************************************/ function getForms($row) { $curr_lang=$GLOBALS['_httpLang']; //три буквы языка $sendmail_info=$GLOBALS['_httpLangL']."_sendmail_info"; $contact_person=$GLOBALS['_httpLangL']."_contact_person"; $contact_phone=$GLOBALS['_httpLangL']."_contact_phone"; $contact_email=$GLOBALS['_httpLangL']."_contact_email"; $contact_message=$GLOBALS['_httpLangL']."_contact_message"; $contact_send=$GLOBALS['_httpLangL']."_contact_send"; $contact_reset=$GLOBALS['_httpLangL']."_contact_reset"; $SendMail=$GLOBALS['XML']->create_element("SendMailForm"); if (is_array($row)) { if ($row['Attr'] & $GLOBALS['documentSendMail']) { //форма обратной связи $SendMail->set_attribute("form","yes"); $SendMail->set_attribute("sendmail_info",c($GLOBALS[$sendmail_info])); $SendMail->set_attribute("form_action",c($GLOBALS['cfg']['Server']['wwwroot']."/forms.php")); $SendMail->set_attribute("faction","sendmail"); $SendMail->set_attribute("contact_person",c($GLOBALS[$contact_person])); $SendMail->set_attribute("contact_phone",c($GLOBALS[$contact_phone])); $SendMail->set_attribute("contact_email",c($GLOBALS[$contact_email])); $SendMail->set_attribute("contact_message",c($GLOBALS[$contact_message])); $SendMail->set_attribute("contact_send",c($GLOBALS[$contact_send])); $SendMail->set_attribute("contact_reset",c($GLOBALS[$contact_reset])); } } return Array($SendMail); } function getSection($httpID,$StructID,$attr=0) { $Item=false; if ($attr & 1) { //отображаем содержимое $Item=$GLOBALS['XML']->create_element("ContentList"); $GLOBALS['DB']->addParam(adNumeric,$StructID,NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['_httpLang'],NORMAL); $GLOBALS['DB']->addParam(adNumeric,($GLOBALS['_httpPage']-1)*$GLOBALS['cfg']['docsPerPage'],SMALL); $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['cfg']['docsPerPage'],SMALL); if (($attr & $GLOBALS['sectionNewsAttr'])) { $thisisnews=true; $GLOBALS['DB']->execute("SELECT structure.ID, sections.Head as caption, sections.Translated, SDate, Descr as `text`, structure.SortOrder, structure.Attr AS Attr, FolderDoc, Icon as icon, sections.ftxt, extlink, cpu FROM sections, structure WHERE sections.StructID=structure.ID AND structure.ParentID=? AND structure.Attr&?=? AND sections.LangID=? AND Translated=1 ORDER BY sections.SDate DESC, FolderDoc ASC LIMIT ?,?"); } else { $thisisnews=false; $GLOBALS['DB']->execute("SELECT structure.ID, sections.Head as caption, sections.Translated, SDate,Descr as `text`, structure.SortOrder, structure.Attr AS Attr, FolderDoc, Icon as icon, sections.ftxt, extlink, cpu FROM sections,structure WHERE sections.StructID=structure.ID AND structure.ParentID=? AND structure.Attr&?=? AND sections.LangID=? AND Translated=1 ORDER BY structure.SortOrder ASC LIMIT ?,?"); } $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows)) { //$Item->set_attribute("caption",c($row['caption'])); if ($thisisnews) { $Item->set_attribute("news","yes"); $GLOBALS['Root']->set_attribute("news","yes"); $GLOBALS['news_flag']=true; } while ($row=$GLOBALS['DB']->getRecords()) { if (""!==$row['extlink']) { $url=$row['extlink']; } else { $url=create_user_url($GLOBALS['_httpLangL'],$row['cpu'],$GLOBALS['_httpPage']); } if (0==$row['FolderDoc']) { $SubItem=createNode("SectionShort",$row); } else { $SubItem=createNode("DocumentShort",$row); if ($row['Attr'] & $GLOBALS['documentProduct']) { /* это предмет который можно добавить в корзину */ $SubItem->set_attribute("product", "yes"); $cart_url=$GLOBALS['cfg']['Server']['wwwroot']."/index.php?lang=".$GLOBALS['_httpLangL']."&apage=add2cart&catid=".$row['ID']; $SubItem->set_attribute("cartlink",c($cart_url)); } } $SubItem->set_attribute("link",c($url)); $d=dateFromBase($row['SDate']); $d=date($GLOBALS['_date_fotmat'],mktime($d['hour'],$d['minute'],$d['second'],$d['month'],$d['day'],$d['year'])); $SubItem->set_attribute("SDate",$d); if ($row['Attr'] & 64) { $SubItem->set_attribute("newwind","1"); } $Item->append_child($SubItem); unset($SubItem); } } else { // нет такой страницы ? _throw(1404,1); } } else { //показываем первый документ в разделе $GLOBALS['DB']->addParam(adNumeric,$StructID,NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric,$GLOBALS['_httpLang'],NORMAL); $GLOBALS['DB']->execute("SELECT sections.ID, Head as caption, Icon As icon, structure.ID, StructID, SDate, Text AS text, Descr AS description, FolderDoc, structure.Attr, structure.SortOrder, sections.ftxt, cpu FROM sections, structure WHERE sections.StructID=structure.ID AND structure.ParentID=? AND structure.Attr&?=? AND LangID=? AND Translated=1 ORDER BY SortOrder ASC LIMIT 0,1"); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows>0)) { $row=$GLOBALS['DB']->getRecords(); $url=create_user_url($GLOBALS['_httpLangL'],$row['cpu'],$GLOBALS['_httpPage']); $Item=createNode("Document",$row); $Item->set_attribute("link",c($url)); $forms=getForms($row); foreach ($forms as $key=>$value) { $Item->append_child($value); } unset($forms); } else { // нет такой страницы ? _throw(1404,1); } } return $Item; } function getContent($httpID,$httpLang,$httpPage=1) { $Item=false; //echo "
getContent:
"; $GLOBALS['DB']->addParam(adNumeric,$httpID,NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric, $GLOBALS['documenPublic'], NORMAL); $GLOBALS['DB']->addParam(adNumeric,$httpLang,NORMAL); $GLOBALS['DB']->execute("SELECT sections.ID as sid, Head as caption, Icon As icon, structure.ID, StructID, SDate, Text as text, Descr as description, FolderDoc, structure.Attr, sections.ftxt, cpu FROM sections, structure WHERE sections.StructID=structure.ID AND structure.ID=? AND structure.Attr&?=? AND LangID=? AND Translated=1"); $GLOBALS['DB']->clearParams(); if ((!$GLOBALS['DB']->err) && ($GLOBALS['DB']->n_rows>0)) { $row=$GLOBALS['DB']->getRecords(); $GLOBALS['Root']->set_attribute("ContentHeader",c($row['caption'])); if (0==$row['FolderDoc']) { //это раздел $Item=getSection($httpID, $row['StructID'], $row['Attr']); if (false!==$Item) { $Item->set_attribute("caption",c($row['caption'])); $Item->set_attribute("description", c($row['description'])); } } else { //это документ $url=create_user_url($GLOBALS['_httpLangL'],$row['cpu'],$GLOBALS['_httpPage']); $d=dateFromBase($row['SDate']); $row['SDate']=date($GLOBALS['_date_fotmat'],mktime($d['hour'],$d['minute'],$d['second'],$d['month'],$d['day'],$d['year'])); $Item=createNode("Document",$row); if ($row['Attr'] & $GLOBALS['documetHomeAttr']) $GLOBALS['Root']->set_attribute("mainpage","yes"); if ($row['Attr'] & $GLOBALS['documentProduct']) { /* это предмет который можно добавить в корзину */ $Item->set_attribute("product", "yes"); $cart_url=$GLOBALS['cfg']['Server']['wwwroot']."/index.php?lang=".$GLOBALS['_httpLangL']."&apage=add2cart&catid=".$row['ID']; $Item->set_attribute("cartlink",c($cart_url)); } $Item->set_attribute("link",c($url)); $forms=getForms($row); foreach ($forms as $key=>$value) { $Item->append_child($value); } unset($forms); //галерея /* нам нужны все картинки, которые относятся к этому документу */ //echo $row['ID']; $GLOBALS['DB']->addParam(adNumeric,$row['sid'],NORMAL); $GLOBALS['DB']->execute("select galery_structure.id, galery_structure.icon_url, galery_structure.image_url, galery_structure.flags, galery_structure.caption from galery_structure where galery_structure.struct_id=? "); $GLOBALS['DB']->clearParams(); if (!$GLOBALS['DB']->err && $GLOBALS['DB']->n_rows>0) { $Galery=$GLOBALS['XML']->create_element("Galery"); $rows=$GLOBALS['DB']->getAllRecords(); foreach ($rows as $key=>$value) { $SubItem=$GLOBALS['XML']->create_element("GaleryItem"); $SubItem->set_attribute("xml:id", $value['id']); $SubItem->set_attribute("gal_struct_id", $value['id']); $SubItem->set_attribute("icon_url", $value['icon_url']); $SubItem->set_attribute("image_url", $value['image_url']); $SubItem->set_attribute("caption", c($value['caption'])); $Galery->append_child($SubItem); unset($SubItem); } $Item->append_child($Galery); unset($Galery); } } } else { // нет такой страницы ? _throw(1404,1); } return($Item); }