本文整理汇总了PHP中plgFabrik_Element类的典型用法代码示例。如果您正苦于以下问题:PHP plgFabrik_Element类的具体用法?PHP plgFabrik_Element怎么用?PHP plgFabrik_Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了plgFabrik_Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeParentElement
/**
* For processing repeat elements we need to make its
* parent id element during the form process
*
* @param plgFabrik_Element $baseElement repeat element (e.g. db join rendered as checkbox)
*
* @return plgFabrik_ElementField
*/
public static function makeParentElement($baseElement)
{
$pluginManager = FabrikWorker::getPluginManager();
$groupModel = $baseElement->getGroupModel();
$elementModel = $pluginManager->getPlugIn('field', 'element');
$elementModel->getElement()->name = 'parent_id';
$elementModel->getParams()->set('repeat', $baseElement->isJoin());
$elementModel->getElement()->group_id = $groupModel->getId();
$elementModel->setGroupModel($baseElement->getGroupModel());
$elementModel->_joinModel = $groupModel->getJoinModel();
return $elementModel;
}
示例2: makeParentElement
/**
* For processing repeat elements we need to make its
* parent id element during the form process
*
* @param plgFabrik_Element $baseElement repeat element (e.g. db join rendered as checkbox)
*
* @return plgFabrik_ElementField
*/
public function makeParentElement($baseElement)
{
$pluginManager = FabrikWorker::getPluginManager();
$groupModel = $baseElement->getGroupModel();
$elementModel = $pluginManager->getPlugIn('field', 'element');
$elementModel->getElement()->name = 'parent_id';
$elementModel->getParams()->set('repeat', $baseElement->isJoin());
$elementModel->getElement()->group_id = $groupModel->getId();
$elementModel->setGroupModel($baseElement->getGroupModel());
// @TODO wrong when element in repeat group
$oJoin = $groupModel->getJoinModel()->getJoin();
$elementModel->_aFullNames['parent_id1_1__1_'] = $oJoin->table_join . '___parent_id';
return $elementModel;
}
示例3: makeDateTimeElement
/**
* @since Fabrik 3.0
* make datetime element
* @param int $groupId
*/
public function makeDateTimeElement($groupId)
{
$now = JFactory::getDate()->toMySQL();
$dispatcher = JDispatcher::getInstance();
$elementModel = new plgFabrik_Element($dispatcher);
$user = JFactory::getUser();
$element = FabTable::getInstance('Element', 'FabrikTable');
$element->name = "date_time";
$element->label = "date";
$element->plugin = 'date';
$element->hidden = 1;
$element->eval = 1;
$element->default = "return date('Y-m-d h:i:s');";
$element->group_id = $groupId;
$element->primary_key = 0;
$element->auto_increment = 0;
$element->created = $now;
$element->created_by = $user->get('id');
$element->created_by_alias = $user->get('username');
$element->published = '1';
$element->show_in_list_summary = '1';
$element->width = '10';
$element->ordering = 1;
$element->params = $elementModel->getDefaultAttribs();
if (!$element->store()) {
JError::raiseWarning(500, $element->getError());
return false;
}
return true;
}
示例4: cacheAutoCompleteOptions
/**
* Cache method to populate autocomplete options
*
* @param plgFabrik_Element $elementModel Element model
* @param string $search Search string
* @param array $opts Options, 'label' => field to use for label (db join)
*
* @since 3.0.7
*
* @return string Json encoded search results
*/
public static function cacheAutoCompleteOptions($elementModel, $search, $opts = array())
{
$app = JFactory::getApplication();
$listModel = $elementModel->getListModel();
$label = FArrayHelper::getValue($opts, 'label', '');
$rows = $elementModel->filterValueList(true, '', $label);
$v = $app->input->get('value', '', 'string');
// Search for every word separately in the result rather than the single string (of multiple words)
$regex = "/(?=.*" . implode(")(?=.*", array_filter(explode(" ", addslashes($v)))) . ").*/i";
$start = count($rows) - 1;
for ($i = $start; $i >= 0; $i--) {
$rows[$i]->text = strip_tags($rows[$i]->text);
// Check that search strings are not in the HTML we just stripped
if (!preg_match($regex, $rows[$i]->text)) {
unset($rows[$i]);
}
}
$rows = array_values($rows);
echo json_encode($rows);
}
示例5: formJavascriptClass
/**
* load the javascript class that manages interaction with the form element
* should only be called once
* @return string javascript class file
*/
function formJavascriptClass(&$srcs)
{
plgFabrik_Element::formJavascriptClass($srcs, 'plugins/fabrik_element/databasejoin/databasejoin.js');
parent::formJavascriptClass($srcs);
}
示例6: formJavascriptClass
/**
* @param array already loaded plugin scripts
* load the javascript class that manages interaction with the form element
* should only be called once
* @since 3.0
*/
function formJavascriptClass(&$srcs)
{
plgFabrik_Element::formJavascriptClass($srcs, 'media/com_fabrik/js/window.js');
parent::formJavascriptClass($srcs);
}
示例7: formJavascriptClass
/**
* load the javascript class that manages interaction with the form element
* should only be called once
* @return string javascript class file
*/
function formJavascriptClass(&$srcs)
{
static $jsloaded;
if (!isset($jsloaded)) {
$document = JFactory::getDocument();
$params = $this->getParams();
$document->addScript("http://www.openlayers.org/api/OpenLayers.js");
parent::formJavascriptClass($srcs);
FabrikHelperHTML::script('components/com_fabrik/libs/openlayers/openlayers_ext.js', true);
if ($params->get('fb_osm_virtualearthlayers')) {
$document->addScript('http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1');
}
if ($params->get('fb_osm_gmlayers')) {
$src = "http://maps.google.com/maps?file=api&v=2&key=" . $params->get('fb_osm_gm_key');
$document->addScript($src);
}
if ($params->get('fb_osm_yahoolayers')) {
$yahooid = $params->get('fb_yahoo_key');
$document->addScript('http://api.maps.yahoo.com/ajaxymap?v=3.8&appid='.$yahooid);
}
$document->addScript('http://www.openstreetmap.org/openlayers/OpenStreetMap.js');
$jsloaded = true;
}
}
示例8: renderListData
/**
* shows the data formatted for the table view
* @param string data
* @param object all the data in the tables current row
* @return string formatted value
*/
function renderListData($data, $oAllRowsData)
{
$data = parent::renderListData($data, $oAllRowsData);
$params = $this->getParams();
if ($params->get('textarea-tagify') == true) {
$data = $this->tagify($data);
}
//$$$rob dont strip slashes here - this is done when saving to db now
if ($params->get('use_wysiwyg', 0) == 0) {
if (is_array($data)) {
for ($i = 0; $i < count($data); $i++) {
$data[$i] = nl2br($data[$i]);
}
} else {
if (is_object($data)) {
$this->convertDataToString($data);
}
$data = nl2br($data);
}
}
if (!$params->get('textarea-tagify') && $data !== '' && (int) $params->get('textarea-truncate', 0) !== 0) {
$opts = array();
$opts['wordcount'] = (int) $params->get('textarea-truncate', 0);
$opts['tip'] = $params->get('textarea-hover');
$opts['position'] = $params->get('textarea_hover_location', 'top');
$data = fabrikString::truncate($data, $opts);
}
return $data;
}
示例9: getDefaultProperties
/**
* load a new set of default properites and params for the element
* @return object element (id = 0)
*/
public function getDefaultProperties()
{
$item = parent::getDefaultProperties();
$item->primary_key = true;
$item->width = 3;
$item->hidden = 1;
$item->auto_increment = 1;
return $item;
}
示例10: getLabel
/**
* write out the label for the form element
* @param object form
* @param bol encase label in <label> tag
* @param string id of element related to the label
*/
function getLabel($repeatCounter = 0, $tmpl = '')
{
$params = $this->getParams();
if ($params->get('display_showlabel', true)) {
return parent::getLabel($repeatCounter, $tmpl);
}
$bLabel = $this->get('hasLabel');
$element = $this->getElement();
$element->label = $this->getValue(array());
$elementHTMLId = $this->getHTMLId();
if ($element->hidden) {
return '';
}
$task = JRequest::getVar('task', '', 'default');
$view = JRequest::getVar('view', '', 'form');
if ($view == 'form' && ! ( $this->canUse() || $this->canView())) {
return '';
}
$params = $this->getParams();
$elementid = "fb_el_" . $elementHTMLId;
$this->_form->loadValidationRuleClasses();
$str = '';
$rollOver = JText::_($params->get('hover_text_title')) . "::" . JText::_($params->get('rollover'));
$rollOver = htmlspecialchars($rollOver, ENT_QUOTES);
if ($this->canView()) {
$str .= "<div class=\"fabrikLabel fabrikPluginElementDisplayLabel";
$validations = $this->getValidations();
if ($this->_editable) {
foreach ($validations as $validation) {
$vid = $validation->_pluginName;
if (array_key_exists($vid, $this->_form->_validationRuleClasses)) {
if ($this->_form->_validationRuleClasses[$vid] != '') {
$str .= " " . $this->_form->_validationRuleClasses[$vid];
}
}
}
}
if ($rollOver != '::') {
$str .= " fabrikHover";
}
$str .= "\" id=\"$elementid" . "_text\">";
if ($bLabel) {
$str .= "<label for=\"$elementHTMLId\">";
}
$str .= ($rollOver != '::') ? "<span class='hasTip' title='$rollOver'>{$element->label}</span>" : $element->label;
if ($bLabel) {
$str .= "</label>";
}
$str .= "</div>\n";
}
return $str;
}
示例11: renderListData
/**
* Shows the data formatted for the list view
*
* @param string $data elements data
* @param object &$thisRow all the data in the lists current row
*
* @return string formatted value
*/
public function renderListData($data, &$thisRow)
{
$params = $this->getParams();
$format = $params->get('text_format_string');
if ($format != '') {
$str = sprintf($format, $data);
$data = eval($str);
}
return parent::renderListData($data, $thisRow);
}
示例12: renderListData
/**
* shows the data formatted for the table view
* @param string data
* @param object all the data in the tables current row
* @return string formatted value
*/
function renderListData($data, $oAllRowsData)
{
static $range;
static $fullName;
if (!isset($range)) {
$range = $this->getRange();
$fullName = $this->getDataElementFullName();
}
$data = $oAllRowsData->{$fullName};
$data = $this->_renderListData($data, $range);
return parent::renderListData($data, $oAllRowsData);
}
示例13: renderListData
/**
* shows the data formatted for the table view
* @param string data
* @param object all the data in the tables current row
* @return string formatted value
*/
function renderListData($data, $oAllRowsData)
{
$params =& $this->getParams();
$data = $this->numberFormat($data);
$format = $params->get('text_format_string');
if ($format != '') {
$data = sprintf($format, $data);
}
if ($params->get('password') == "1") {
$data = str_pad('', strlen($data), '*');
}
$this->_guessLinkType($data, $oAllRowsData, 0);
return parent::renderListData($data, $oAllRowsData);
}
示例14: renderListData
/**
* Shows the data formatted for the list view
*
* @param string $data elements data
* @param object &$thisRow all the data in the lists current row
*
* @return string formatted value
*/
public function renderListData($data, &$thisRow)
{
$user = JFactory::getUser();
$params = $this->getParams();
$ext = $params->get('rating-pngorgif', '.png');
$imagepath = JUri::root() . '/plugins/fabrik_element/rating/images/';
$data = FabrikWorker::JSONtoData($data, true);
$url = COM_FABRIK_LIVESITE . 'index.php?option=com_fabrik&format=raw&view=plugin&task=pluginAjax&g=element&plugin=rating&method=ajax_rate&element_id=' . $this->getElement()->id;
FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/rating/images/', 'image', 'list', false);
$insrc = FabrikHelperHTML::image("star_in{$ext}", 'list', @$this->tmpl, array(), true);
$outsrc = FabrikHelperHTML::image("star_out{$ext}", 'list', @$this->tmpl, array(), true);
$url .= '&row_id=' . $thisRow->__pk_val;
$url .= '&elementname=' . $this->getElement()->id;
$url .= '&userid=' . $user->get('id');
$url .= '&nonajax=1';
$row_id = isset($thisRow->__pk_val) ? $thisRow->__pk_val : $thisRow->id;
$ids = JArrayHelper::getColumn($this->getListModel()->getData(), '__pk_val');
$canRate = $this->canRate($row_id, $ids);
for ($i = 0; $i < count($data); $i++) {
$avg = $this->_renderListData($data[$i], $thisRow);
if (!$canRate) {
$atpl = '';
$a2 = '';
} else {
$atpl = "<a href=\"{$url}&rating={r}\">";
$a2 = "</a>";
}
$str = array();
$str[] = '<div style="width:101px">';
for ($s = 0; $s < $avg; $s++) {
$r = $s + 1;
$a = str_replace('{r}', $r, $atpl);
$str[] = $a . '<img src="' . $imagepath . 'star_in' . $ext . '" style="padding-left:1px;" alt="' . $r . '" class="starRating rate_' . $r . '"/>' . $a2;
}
for ($s = $avg; $s < 5; $s++) {
$r = $s + 1;
$a = str_replace('{r}', $r, $atpl);
$str[] = $a . '<img src="' . $imagepath . 'star_out' . $ext . '" style="padding-left:1px;" alt="' . $r . '" class="starRating rate_' . $r . '"/>' . $a2;
}
if ($params->get('rating-mode') != 'creator-rating') {
$str[] = '<div class="ratingMessage">' . $avg . '</div>';
}
$str[] = '</div>';
$data[$i] = implode("\n", $str);
}
$data = json_encode($data);
return parent::renderListData($data, $thisRow);
}
示例15: renderListData
/**
* shows the data formatted for the table view
* @param string data
* @param object all the data in the tables current row
* @return string formatted value
*/
function renderListData($data, $oAllRowsData)
{
$user =& JFactory::getUser();
$params =& $this->getParams();
$ext = $params->get('rating-pngorgif', '.png');
$imagepath = JUri::root() . '/plugins/fabrik_element/rating/images/';
$data = FabrikWorker::JSONtoData($data, true);
$url = COM_FABRIK_LIVESITE . 'index.php?option=com_fabrik&format=raw&view=plugin&task=pluginAjax&g=element&plugin=rating&method=ajax_rate&element_id=' . $this->getElement()->id;
FabrikHelperHTML::addPath(JPATH_SITE . DS . 'plugins/fabrik_element/rating/images/', 'image', 'list', false);
$insrc = FabrikHelperHTML::image("star_in{$ext}", 'list', @$this->tmpl, '', true);
$outsrc = FabrikHelperHTML::image("star_out{$ext}", 'list', @$this->tmpl, '', true);
$url .= '&row_id=' . $oAllRowsData->__pk_val;
$url .= '&elementname=' . $this->getElement()->id;
$url .= '&userid=' . $user->get('id');
$url .= '&nonajax=1';
$row_id = isset($oAllRowsData->__pk_val) ? $oAllRowsData->__pk_val : $oAllRowsData->id;
$ids = JArrayHelper::getColumn($this->getListModel()->getData(), '__pk_val');
$canRate = $this->canRate($row_id, $ids);
for ($i = 0; $i < count($data); $i++) {
$avg = $this->_renderListData($data[$i], $oAllRowsData);
if (!$canRate) {
$atpl = '';
$a2 = '';
} else {
$atpl = "<a href=\"{$url}&rating={r}\">";
$a2 = "</a>";
}
$str = '<div style="width:100px">';
for ($s = 0; $s < $avg; $s++) {
$r = $s + 1;
$a = str_replace('{r}', $r, $atpl);
$str .= "{$a}<img src=\"{$imagepath}" . "star_in{$ext}\" style=\"padding-left:1px;\" alt=\"{$r}\" class=\"starRating rate_{$r}\"/>{$a2}";
}
for ($s = $avg; $s < 5; $s++) {
$r = $s + 1;
$a = str_replace('{r}', $r, $atpl);
$str .= "{$a}<img src=\"{$imagepath}" . "star_out{$ext}\" style=\"padding-left:1px;\" alt=\"{$r}\" class=\"starRating rate_{$r}\"/>{$a2}";
}
if ($params->get('rating-mode') != 'creator-rating') {
$str .= "<div class=\"ratingMessage\">{$avg}</div>";
}
$str .= '</div>';
$data[$i] = $str;
}
//$data = implode(GROUPSPLITTER, $data);
$data = json_encode($data);
return parent::renderListData($data, $oAllRowsData);
}