本文整理匯總了PHP中FabrikHelperHTML::a方法的典型用法代碼示例。如果您正苦於以下問題:PHP FabrikHelperHTML::a方法的具體用法?PHP FabrikHelperHTML::a怎麽用?PHP FabrikHelperHTML::a使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FabrikHelperHTML
的用法示例。
在下文中一共展示了FabrikHelperHTML::a方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
/**
* Draws the html form element
*
* @param array $data to pre-populate element with
* @param int $repeatCounter repeat group counter
*
* @return string elements html
*/
public function render($data, $repeatCounter = 0)
{
$name = $this->getHTMLName($repeatCounter);
$id = $this->getHTMLId($repeatCounter);
$params = $this->getParams();
$bits = $this->inputProperties($repeatCounter);
$value = $this->getValue($data, $repeatCounter);
$opts = array();
if ($value == '') {
$value = array('label' => '', 'link' => '');
} else {
if (!is_array($value)) {
$value = FabrikWorker::JSONtoData($value, true);
/**
* In some legacy case, data is like ...
* [{"label":"foo","link":"bar"}]
* ... I think if it came from 2.1. So lets check to see if we need
* to massage that into the right format
*/
if (array_key_exists(0, $value) && is_object($value[0])) {
$value = JArrayHelper::fromObject($value[0]);
} elseif (array_key_exists(0, $value)) {
$value['label'] = $value[0];
}
}
}
if (count($value) == 0) {
$value = array('label' => '', 'link' => '');
}
if (FabrikWorker::getMenuOrRequestVar('rowid') == 0 && FArrayHelper::getValue($value, 'link', '') === '') {
$value['link'] = $params->get('link_default_url');
}
if (!$this->isEditable()) {
$lbl = trim(FArrayHelper::getValue($value, 'label'));
$href = trim(FArrayHelper::getValue($value, 'link'));
$w = new FabrikWorker();
$href = is_array($data) ? $w->parseMessageForPlaceHolder($href, $data) : $w->parseMessageForPlaceHolder($href);
$opts['target'] = trim($params->get('link_target', ''));
$opts['smart_link'] = $params->get('link_smart_link', false);
$opts['rel'] = $params->get('rel', '');
$title = $params->get('link_title', '');
if ($title !== '') {
$opts['title'] = strip_tags($w->parseMessageForPlaceHolder($title, $data));
}
return FabrikHelperHTML::a($href, $lbl, $opts);
}
$labelname = FabrikString::rtrimword($name, '[]') . '[label]';
$linkname = FabrikString::rtrimword($name, '[]') . '[link]';
$bits['name'] = $labelname;
$bits['placeholder'] = FText::_('PLG_ELEMENT_LINK_LABEL');
$bits['value'] = $value['label'];
$bits['class'] .= ' fabrikSubElement';
unset($bits['id']);
$layout = $this->getLayout('form');
$layoutData = new stdClass();
$layoutData->id = $id;
$layoutData->name = $name;
$layoutData->linkAttributes = $bits;
$bits['placeholder'] = FText::_('PLG_ELEMENT_LINK_URL');
$bits['name'] = $linkname;
$bits['value'] = FArrayHelper::getValue($value, 'link');
if (is_a($bits['value'], 'stdClass')) {
$bits['value'] = $bits['value']->{0};
}
$layoutData->labelAttributes = $bits;
return $layout->render($layoutData);
}
示例2: _guessLinkType
/**
* Format guess link type
*
* @param string &$value Original field value
* @param array $data Record data
*
* @return void
*/
protected function _guessLinkType(&$value, $data)
{
$params = $this->getParams();
if ($params->get('guess_linktype') == '1') {
$w = new FabrikWorker();
$opts = $this->linkOpts();
$title = $params->get('link_title', '');
if (FabrikWorker::isEmail($value) || JString::stristr($value, 'http')) {
} elseif (JString::stristr($value, 'www.')) {
$value = 'http://' . $value;
}
if ($title !== '') {
$opts['title'] = strip_tags($w->parseMessageForPlaceHolder($title, $data));
}
$label = FArrayHelper::getValue($opts, 'title', '') !== '' ? $opts['title'] : $value;
$value = FabrikHelperHTML::a($value, $label, $opts);
}
}
示例3: _guessLinkType
/**
* Format guess link type
*
* @param string &$value Original field value
* @param array $data Record data
* @param int $repeatCounter Repeat counter
*
* @return void
*/
protected function _guessLinkType(&$value, $data, $repeatCounter = 0)
{
$params = $this->getParams();
$guessed = false;
if ($params->get('guess_linktype') == '1') {
$w = new FabrikWorker();
$opts = $this->linkOpts();
$title = $params->get('link_title', '');
if (FabrikWorker::isEmail($value) || JString::stristr($value, 'http')) {
$guessed = true;
} elseif (JString::stristr($value, 'www.')) {
$value = 'http://' . $value;
$guessed = true;
}
if ($title !== '') {
$opts['title'] = strip_tags($w->parseMessageForPlaceHolder($title, $data));
}
$value = FabrikHelperHTML::a($value, $value, $opts);
}
}