Link to _blank page

Hi

I was wondering how to open pdf file in a new window by clicking on Link="paht/file.pdf" (which holds the path to the file)int the <Element....> of EasyForm. There is a HTML "injection" possible, where you can use single quotes to simulate target="_blank" html attribute , so the result is:

<Element Name="name" Class="ColumnText" FieldName="pdf" Label="Open pdf" Link='/path/file.pdf" target="_blank'>

This is translated by OpenBiz to <a href="www/path/file.pdf" target="blank">Open pdf</a>

Question: is there other way to achieve this?

thomaz

 

 

Many thanks Agus. This is a

Many thanks Agus. This is a good enhancement.

- support

I add this functionality on

I add this functionality on LabelText, so automaticaly ColumnText have this feature (ColumnText extends LabelText)

please copy this LabelText.php to  openbiz/bin/easy/element

<?PHP
include_once("Element.php");

/**
 * FieldControl - class FieldControl is the base class of field control who binds with a bizfield
 *
 * @package BizView
 * @author rocky swen
 * @copyright Copyright (c) 2005
 * @version 1.2
 * @access public
 */
class LabelText extends Element
{
   public $m_FieldName;
   public $m_Label;
   public $m_Text;
   public $m_Link;
   public $m_Target;

   protected function ReadMetaData(&$xmlArr)
   {
      parent::ReadMetaData($xmlArr);
      $this->m_FieldName = isset($xmlArr["ATTRIBUTES"]["FIELDNAME"]) ? $xmlArr["ATTRIBUTES"]["FIELDNAME"] : null;
      $this->m_Label = isset($xmlArr["ATTRIBUTES"]["LABEL"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["LABEL"])  : null;
      $this->m_Text = isset($xmlArr["ATTRIBUTES"]["TEXT"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["TEXT"])  : null;
      $this->m_Link = isset($xmlArr["ATTRIBUTES"]["LINK"]) ? $xmlArr["ATTRIBUTES"]["LINK"] : null;
      $this->m_Target = isset($xmlArr["ATTRIBUTES"]["TARGET"]) ? $xmlArr["ATTRIBUTES"]["TARGET"] : null;
   }

    protected function GetTarget()
{
if ($this->m_Target == null)
return null;

return "target='" . $this->m_Target ."'";;
}
protected function GetLink() { if ($this->m_Link == null) return null; $formobj = $this->GetFormObj(); return Expression::EvaluateExpression($this->m_Link, $formobj); } protected function GetText() { if ($this->m_Text == null) return null; $formobj = $this->GetFormObj(); return Expression::EvaluateExpression($this->m_Text, $formobj); } /** * FieldControl::RenderLabel() - When render table, it return the table header; when render array, it return the display name * * @return string HTML text */ public function RenderLabel() { return $this->m_Label; } /** * FieldControl::Render() - Draw the control according to the mode * * @returns stirng HTML text */ public function Render() { $val = $this->m_Value ? $this->m_Value : $this->GetText(); if ($val == null || $val =="") return ""; $style = $this->GetStyle(); $func = $this->GetFunction(); if($this->m_Translatable=='Y'){ if(defined($val)){ $val = constant($val); } $val = I18n::getInstance()->translate($val); } if($val){ if ($this->m_Link) { $link = $this->GetLink(); $target = $this->GetTarget(); //$sHTML = "<a href=\"$link\" onclick=\"SetOnLoadNewView();\" $style>" . $val . "</a>"; $sHTML = "<a href=\"$link\" $target $func $style>" . $val . "</a>"; } else{ $sHTML = "<span $style $func>" . $val . "</span>";} } return $sHTML; } } ?>
Agus Suhartono | ThePhpEnterprise.Com
 

Thank you! It works well. I

Thank you! It works well. I also tryied the HTNLAttr thing but did not work.

 

Thomaz

You can try HTMLAttr in the

You can try HTMLAttr in the element. Also you can check the code of openbiz/bin/easy/element/ColumnText and LabelText. - support