<?php
/*$pageinfo = PageInfoOperations::LoadPageInfoByContentAlias($params["page"]);
print_r($pageinfo);
 <li><em>(optional)</em> goback - Set to "true" to show a "Go Back" link on the page to print.</li>
                <li><em>(optional)</em> popup - Set to "true" and page for printing will by opened in new window.</li>
                <li><em>(optional)</em> script - Set to "true" and in print page will by used java script for run print of page.</li>
                <li><em>(optional)</em> showbutton - Set to "true" and will show a printer graphic instead of a text link.</li>
                <li><em>(optional)</em> class - class for the link, defaults to "noprint".</li>
                <li><em>(optional)</em> text - Text to use instead of "Print This Page" for the print link.
                <li><em>(optional)</em> title - Text to show for title attribute. If blank show text parameter.</li>
                <li><em>(optional)</em> more - Place additional options inside the &lt;a&gt; link.</li>
                <li><em>(optional)</em> src_img - Show this image file. Default images/cms/printbutton.gif.</li>
                <li><em>(optional)</em> class_img - Class of &lt;img&gt; tag if showbutton is sets.</li>

*/
//print_r($params);
global $config;
$target="";
if (isset($params["popup"])) {
  if ($params["popup"]=="true" || $params["popup"]=="1") {
    $target="target='_blank'";
    $params["goback"]="0";
  }
}
$this->smarty->assign("target", $target);
$onlyurl=false;
if (isset($params["onlyurl"])) {
  if ($params["onlyurl"]=="true" || $params["onlyurl"]=="1") $onlyurl=true;
}


$includetemplate=false;
  if (isset($params['includetemplate']) && (($params["includetemplate"]=="true") || $params["includetemplate"]=="1")) {
    $includetemplate=true;
  }
$url=$this->GetCurrentURL($includetemplate);
//echo "<pre>".$url."</pre>";
$url=base64_encode($url);
$params["url"]=$url;
$href=$config["root_url"]."/modules/Printing/output.php?url=".$url;
if ($gCms->variables["content_id"]!="") {
  $href.="&amp;".$config["query_var"]."=".$gCms->variables["content_id"];
}
//$href=$this->CreateLink($id, $action, $returnid, "", $params,"",true, true);
/*if (isset($params['pdf']) && ($params["pdf"]=="true" || $params["pdf"]=="1")) {
  if (!isset($params["mact"])) {
    $href=$GLOBALS["config"]["root_url"]."/modules/Printing/createpdf.php?pageid=".$gCms->variables["content_id"]."&amp;returnid=".$returnid;
  } else {
      
  }
}*/
$pdf=false;
if (isset($params['pdf']) && (($params["pdf"]=="true") || $params["pdf"]=="1")) {
  if ($this->GetPreference("pdfenable")!="1") return;
  $pdf=true;
  $href.="&amp;pdf=true";

}

//only include the below if printing
if (!$pdf) {
  if (isset($params['script']) && (($params["script"]=="true") || $params["script"]=="1")) {
    $href.="&amp;script=true";
  }
  if (isset($params['includetemplate']) && (($params["includetemplate"]=="true") || $params["includetemplate"]=="1")) {
    $href.="&amp;includetemplate=true";
  }

 /* if (isset($params['goback']) && (($params["goback"]=="true") || $params["goback"]=="1")) {
    $href.="&amp;goback=true";
  }*/
}


//print_r($gCms->variables);
//echo $gCms->variables->pageinfo["content_alias"];



$this->smarty->assign("href", $href);
//$this->smarty->assign("url", $url);
$linktext="";
if (isset($params["text"])) {
  $linktext=$params["text"];
} else {
  $linktext=$this->Lang("defaultlinktext");
  if (isset($params['pdf']) && ($params["pdf"]=="true" || $params['pdf']=='1')) {
    $linktext=$this->Lang("defaultpdflinktext");
  }
}
$this->smarty->assign("linktext", $linktext);

if (isset($params["showbutton"])) {
  if ($params["showbutton"]=="true" || $params["showbutton"]=="1") {
    $linkimage="";
    $imgclass="";
    $imgsrc="";

    $imgsrc="modules/Printing/printbutton.gif";
    if (isset($params['pdf']) && ($params["pdf"]=="true" || $params['pdf']=='1')) {
       $imgsrc="modules/Printing/pdfbutton.gif";
    }
    if (isset($params["src_img"])) $imgsrc=$params["src_img"];
    if (isset($params["class_img"])) $imgclass=$params["class_img"];
    $linkimage='<img src="'.$imgsrc.'" alt="'.$linktext.'" ';
    $linkimage.=' title="'.$linktext.'" ';
    if ($imgclass!="") $linkimage.='class="'.$imgclass.'" ';
    $linkimage.="/>";

    $this->smarty->assign('imgsrc',$imgsrc);
    $this->smarty->assign('imgclass',$imgclass);
    $this->smarty->assign("linkimage", $linkimage);
  }
}
if (isset($params["more"])) $this->smarty->assign("more", $params["more"]);


$class="noprint";
if (isset($params["class"])) $class=$params["class"];
$this->smarty->assign("class", $class);

if ($onlyurl) {
  echo $href; 
} else {
  if ($this->GetTemplate("linktemplate")=="") $this->ResetLinkTemplate();
  echo $this->ProcessTemplateFromDatabase("linktemplate");
}
//phpinfo();
?>
