/** * Returns javascript which creates an instance of the class defined in formJavascriptClass() * * @param int $repeatCounter Repeat group counter * * @return array */ public function elementJavascript($repeatCounter) { if (!$this->isEditable()) { return array(); } FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/colourpicker/images/', 'image', 'form', false); $params = $this->getParams(); $id = $this->getHTMLId($repeatCounter); $data = $this->getFormModel()->data; $value = $this->getValue($data, $repeatCounter); if ($value == 'none') { $value = ''; } $vars = explode(",", $value); $vars = array_pad($vars, 3, 0); $opts = $this->getElementJSOptions($repeatCounter); $c = new stdClass(); // 14/06/2011 changed over to color param object from ind colour settings $c->red = (int) $vars[0]; $c->green = (int) $vars[1]; $c->blue = (int) $vars[2]; $opts->colour = $c; $opts->value = $vars; $opts->showPicker = (bool) $params->get('show_picker', 1); $opts->swatchSizeWidth = $params->get('swatch_size_width', '10px'); $opts->swatchSizeHeight = $params->get('swatch_size_height', '10px'); $opts->swatchWidth = $params->get('swatch_width', '160px'); $swatch = $params->get('colourpicker-swatch', 'default.js'); $swatchFile = JPATH_SITE . '/plugins/fabrik_element/colourpicker/swatches/' . $swatch; $opts->swatch = json_decode(file_get_contents($swatchFile)); return array('ColourPicker', $id, $opts); }
/** * Returns javascript which creates an instance of the class defined in formJavascriptClass() * * @param int $repeatCounter repeat group counter * * @return string */ public function elementJavascript($repeatCounter) { if (!$this->isEditable()) { return; } FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/colourpicker/images/', 'image', 'form', false); $params = $this->getParams(); $element = $this->getElement(); $id = $this->getHTMLId($repeatCounter); $data = $this->_form->_data; $value = $this->getValue($data, $repeatCounter); $vars = explode(",", $value); $vars = array_pad($vars, 3, 0); $opts = $this->getElementJSOptions($repeatCounter); $c = new stdClass(); // 14/06/2011 changed over to color param object from ind colour settings $c->red = (int) $vars[0]; $c->green = (int) $vars[1]; $c->blue = (int) $vars[2]; $opts->colour = $c; $swatch = $params->get('colourpicker-swatch', 'default.js'); $swatchFile = JPATH_SITE . '/plugins/fabrik_element/colourpicker/swatches/' . $swatch; $opts->swatch = json_decode(JFile::read($swatchFile)); $opts->closeImage = FabrikHelperHTML::image("close.gif", 'form', @$this->tmpl, array(), true); $opts->handleImage = FabrikHelperHTML::image("handle.gif", 'form', @$this->tmpl, array(), true); $opts->trackImage = FabrikHelperHTML::image("track.gif", 'form', @$this->tmpl, array(), true); $opts = json_encode($opts); return "new ColourPicker('{$id}', {$opts})"; }
/** * Draws the html form element * * @param array $data to preopulate element with * @param int $repeatCounter repeat group counter * * @return string elements html */ public function render($data, $repeatCounter = 0) { FabrikHelperHTML::stylesheet(COM_FABRIK_LIVESITE . 'media/com_fabrik/css/slider.css'); $name = $this->getHTMLName($repeatCounter); $id = $this->getHTMLId($repeatCounter); $params = $this->getParams(); $width = (int) $params->get('slider_width', 250); $element = $this->getElement(); $val = $this->getValue($data, $repeatCounter); if (!$this->isEditable()) { return $val; } $labels = array_filter(explode(',', $params->get('slider-labels'))); $str = array(); $str[] = '<div id="' . $id . '" class="fabrikSubElementContainer">'; FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/slider/images/', 'image', 'form', false); $outsrc = FabrikHelperHTML::image('clear_rating_out.png', 'form', $this->tmpl, array(), true); if ($params->get('slider-shownone')) { $str[] = '<div class="clearslider_cont"><img src="' . $outsrc . '" style="cursor:pointer;padding:3px;" alt="' . JText::_('PLG_ELEMENT_SLIDER_CLEAR') . '" class="clearslider" /></div>'; } $str[] = '<div class="slider_cont" style="width:' . $width . 'px;">'; if (count($labels) > 0) { $spanwidth = floor(($width - 2 * count($labels)) / count($labels)); $str[] = '<ul class="slider-labels" style="width:' . $width . 'px;">'; for ($i = 0; $i < count($labels); $i++) { if ($i == ceil(floor($labels) / 2)) { $align = 'center'; } switch ($i) { case 0: $align = 'left'; break; case 1: default: $align = 'center'; break; case count($labels) - 1: $align = 'right'; break; } $str[] = '<li style="width:' . $spanwidth . 'px;text-align:' . $align . ';">' . $labels[$i] . '</li>'; } $str[] = '</ul>'; } $str[] = '<div class="fabrikslider-line" style="width:' . $width . 'px">'; $str[] = '<div class="knob"></div>'; $str[] = '</div>'; $str[] = '<input type="hidden" class="fabrikinput" name="' . $name . '" value="' . $val . '" />'; $str[] = '<div class="slider_output">' . $val . '</div>'; $str[] = '</div>'; $str[] = '</div>'; return implode("\n", $str); }
public function button_result() { if ($this->canUse()) { $p = $this->onGetFilterKey_result(); FabrikHelperHTML::addPath('plugins/fabrik_list/' . $p . '/images/', 'image', 'list'); $name = $this->_getButtonName(); $label = $this->buttonLabel(); $imageName = $this->getParams()->get('list_' . $this->buttonPrefix . '_image_name', $this->buttonPrefix . '.png'); $img = FabrikHelperHTML::image($imageName, 'list', '', $label); return '<a href="#" class="' . $name . ' listplugin" title="' . $label . '">' . $img . '<span>' . $label . '</span></a>'; } return ''; }
/** * draws the form element * @param array data to preopulate element with * @param int repeat group counter * @return string returns element html */ function render($data, $repeatCounter = 0) { FabrikHelperHTML::stylesheet(COM_FABRIK_LIVESITE.'media/com_fabrik/css/slider.css'); $name = $this->getHTMLName($repeatCounter); $id = $this->getHTMLId($repeatCounter); $params =& $this->getParams(); $width = $params->get('slider_width', 250); $element = $this->getElement(); $val = $this->getValue($data, $repeatCounter); if (!$this->_editable) { return $val; } $imagepath = COM_FABRIK_LIVESITE.'/plugins/fabrik_element/slider/images/'; $labels = array_filter(explode(',', $params->get('slider-labels'))); $str = "<div class=\"fabrikSubElementContainer\" id=\"$id\">"; FabrikHelperHTML::addPath(JPATH_SITE.'/plugins/fabrik_element/slider/images/', 'image', 'form', false); $outsrc = FabrikHelperHTML::image('clear_rating_out.png', 'form', $this->tmpl, '', true); if ($params->get('slider-shownone')) { $str .= "<div class=\"clearslider_cont\"><img src=\"$outsrc\" style=\"cursor:pointer;padding:3px;\" alt=\"clear\" class=\"clearslider\" /></div>"; } $str .="<div class=\"slider_cont\" style=\"width:{$width}px;\">\n"; if (count($labels) > 0) { $spanwidth = floor(($width - (2 * count($labels))) /count($labels)); $str .= "<ul class=\"slider-labels\" style=\"width:{$width}px;\">\n"; for ($i=0; $i < count($labels); $i++) { if ($i == ceil(floor($labels)/2)) { $align = 'center'; } switch($i) { case 0: $align = 'left'; break; case 1: default: $align = 'center'; break; case count($labels) -1: $align = 'right'; break; } $str .= "<li style=\"width:{$spanwidth}px;text-align:$align;\">".$labels[$i]."</li>\n"; } $str .= "</ul>\n"; } $str .= "<div class=\"fabrikslider-line\" style=\"width:{$width}px\">\n<div class=\"knob\"></div>\n</div>\n"; $str .= "<input type=\"hidden\" class=\"fabrikinput\" name=\"$name\" value=\"$val\"/>\n"; $str .= "<div class=\"slider_output\">$val</div>\n"; $str .= "</div>"; return $str; }
/** * 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) { FabrikHelperHTML::stylesheet(COM_FABRIK_LIVESITE . 'media/com_fabrik/css/slider.css'); $params = $this->getParams(); $width = (int) $params->get('slider_width', 250); $val = $this->getValue($data, $repeatCounter); if (!$this->isEditable()) { return $val; } $labels = explode(',', $params->get('slider-labels')); FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/slider/images/', 'image', 'form', false); $layout = $this->getLayout('form'); $layoutData = new stdClass(); $layoutData->id = $this->getHTMLId($repeatCounter); $layoutData->name = $this->getHTMLName($repeatCounter); $layoutData->value = $val; $layoutData->width = $width; $layoutData->j3 = FabrikWorker::j3(); $layoutData->showNone = $params->get('slider-shownone'); $layoutData->outSrc = FabrikHelperHTML::image('clear_rating_out.png', 'form', $this->tmpl, array(), true); $layoutData->labels = $labels; $layoutData->spanWidth = floor(($width - 2 * count($labels)) / count($labels)); $layoutData->align = array(); for ($i = 0; $i < count($labels); $i++) { switch ($i) { case 0: $align = 'left'; break; case count($labels) - 1: $align = 'right'; break; case 1: default: $align = 'center'; break; } $layoutData->align[] = $align; } return $layout->render($layoutData); }
/** * Displays a calendar control field * * hacked from behaviour as you need to check if the element exists * it might not as you could be using a custom template * * @param string $value The date value (must be in the same format as supplied by $format) * @param string $name The name of the text field * @param string $id The id of the text field * @param string $format The date format (not used) * @param array $attribs Additional html attributes * @param int $repeatCounter Repeat group counter (not used) * * @deprecated - don't think its used * * @return string */ public function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null, $repeatCounter = 0) { FabrikHelperHTML::loadcalendar(); $j3 = FabrikWorker::j3(); if (is_array($attribs)) { $attribs = JArrayHelper::toString($attribs); } $paths = FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'media/system/images/', 'image', 'form', false); $opts = $j3 ? array('alt' => 'calendar') : array('alt' => 'calendar', 'class' => 'calendarbutton', 'id' => $id . '_cal_img'); $img = FabrikHelperHTML::image('calendar.png', 'form', @$this->tmpl, $opts); $html = array(); if ($j3) { $img = '<button id ="' . $id . '_cal_img" class="btn calendarbutton">' . $img . '</button>'; $html[] = '<div class="input-append">'; } $html[] = '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $attribs . ' />' . $img; if ($j3) { $html[] = '</div>'; } return implode("\n", $html); }
/** * @deprecated - should be in form view now as you can have > 1 element in inlineedit plugin */ public function inLineEdit() { $listModel = JModel::getInstance('List', 'FabrikFEModel'); $listid = JRequest::getInt('listid'); $rowid = JRequest::getVar('rowid'); $elementid = $this->getElement()->id; $listModel->setId($listid); $data = JArrayHelper::fromObject($listModel->getRow($rowid)); $className = JRequest::getVar('plugin'); if (!$this->canUse()) { if (JRequest::getVar('task') != 'element.save') { echo JText::_("JERROR_ALERTNOAUTHOR"); return; } $this->_editable = false; } else { $this->_editable = true; } $groupModel = $this->getGroup(); $repeatCounter = 0; $html = ''; $key = $this->getFullName(); $template = JFactory::getApplication()->getTemplate(); FabrikHelperHTML::addPath(JPATH_SITE . DS . 'administrator/templates/' . $template . '/images/', 'image', 'list'); //@TODO add acl checks here $task = JRequest::getVar('task'); $saving = $task == 'element.save' || $task == 'save' ? true : false; $htmlid = $this->getHTMLId($repeatCounter); if ($this->canToggleValue() && ($task !== 'element.save' && $task !== 'save')) { // ok for yes/no elements activating them (double clicking in cell) // should simply toggle the stored value and return the new html to show $toggleValues = $this->getOptionValues(); $currentIndex = array_search($data[$key], $toggleValues); if ($currentIndex === false || $currentIndex == count($toggleValues) - 1) { $nextIndex = 0; } else { $nextIndex = $currentIndex + 1; } $newvalue = $toggleValues[$nextIndex]; $data[$key] = $newvalue; $shortkey = array_pop(explode('___', $key)); $listModel->storeCell($rowid, $shortkey, $newvalue); $this->mode = 'readonly'; $html = $this->renderListData($data[$key], $data); $script = array(); $script[] = '<script type="text/javasript">'; $script[] = "Fabrik.fireEvent('fabrik.list.inlineedit.stopEditing');"; //makes the inlined editor stop editing the cell $script[] = '</script>'; echo $html . implode("\n", $script); return; } $listModel->clearCalculations(); $listModel->doCalculations(); $listRef = 'list_' . JRequest::getVar('listref'); $doCalcs = "\n\n\t\tFabrik.blocks['" . $listRef . "'].updateCals(" . json_encode($listModel->getCalculations()) . ')'; if (!$saving) { // so not an element with toggle values, so load up the form widget to enable user // to select/enter a new value //wrap in fabriKElement div to ensure element js code works $html .= '<div class="floating-tip" style="position:absolute"> <ul class="fabrikElementContainer">'; $html .= '<li class="fabrikElement">'; $html .= $this->_getElement($data, $repeatCounter, $groupModel); $html .= '</li>'; $html .= '</ul>'; if (JRequest::getBool('inlinesave') || JRequest::getBool('inlinecancel')) { $html .= '<ul class="fabrik_buttons">'; if (JRequest::getBool('inlinecancel') == true) { $html .= '<li class="ajax-controls inline-cancel">'; $html .= '<a href="#" class="">'; $html .= FabrikHelperHTML::image('delete.png', 'list', @$this->tmpl, array('alt' => JText::_('COM_FABRIK_CANCEL'))) . '<span></span></a>'; $html .= '</li>'; } if (JRequest::getBool('inlinesave') == true) { $html .= '<li class="ajax-controls inline-save">'; $html .= '<a href="#" class="">'; $html .= FabrikHelperHTML::image('save.png', 'list', @$this->tmpl, array('alt' => JText::_('COM_FABRIK_SAVE'))); $html .= '<span>' . JText::_('COM_FABRIK_SAVE') . '</span></a>'; $html .= '</li>'; } $html .= '</ul>'; } $html .= '</div>'; $onLoad = "Fabrik.inlineedit_{$elementid} = " . $this->elementJavascript($repeatCounter) . ";\n" . "Fabrik.inlineedit_{$elementid}.select();\n\t\t\tFabrik.inlineedit_{$elementid}.focus();\n\t\t\tFabrik.inlineedit_{$elementid}.token = '" . JUtility::getToken() . "';\n"; $onLoad .= "Fabrik.fireEvent('fabrik.list.inlineedit.setData');\n"; $srcs = array(); $this->formJavascriptClass($srcs); FabrikHelperHTML::script($srcs, $onLoad); } else { $html .= $this->renderListData($data[$key], $data); $html .= '<script type="text/javasript">'; $html .= $doCalcs; $html .= "</script>\n"; } echo $html; }
/** * Displays a calendar control field * * hacked from behaviour as you need to check if the element exists * it might not as you could be using a custom template * @param string The date value (must be in the same format as supplied by $format) * @param string The name of the text field * @param string The id of the text field * @param string The date format * @param array Additional html attributes * @param int repeat group counter */ function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null, $repeatCounter = 0) { FabrikHelperHTML::loadcalendar(); if (is_array($attribs)) { $attribs = JArrayHelper::toString($attribs); } $paths = FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'media/system/images/', 'image', 'form', false); $img = FabrikHelperHTML::image('calendar.png', 'form', @$this->tmpl, array('alt' => 'calendar', 'class' => 'calendarbutton', 'id' => $id . '_cal_img')); return '<input type="text" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . $img; }
/** * draws the form element * @param array data to preopulate element with * @param int repeat group counter * @return string returns element html */ function render($data, $repeatCounter = 0) { $name = $this->getHTMLName($repeatCounter); $id = $this->getHTMLId($repeatCounter); $params =& $this->getParams(); if (JRequest::getVar('view') == 'form' && $params->get('rating-rate-in-form', true) == 0) { return JText::_('PLG_ELEMENT_RATING_ONLY_ACCESSIBLE_IN_DETALS_VIEW'); } $ext = $params->get('rating-pngorgif', '.png'); $element = $this->getElement(); $css = $this->canRate() ? 'cursor:pointer;' : ''; $value = $this->getValue($data, $repeatCounter); $imagepath = JUri::root() . '/plugins/fabrik_element/rating/images/'; FabrikHelperHTML::addPath(JPATH_SITE . '/plugins/fabrik_element/rating/images/', 'image', 'form', false); $insrc = FabrikHelperHTML::image("star_in{$ext}", 'form', @$this->tmpl, '', true); $outsrc = FabrikHelperHTML::image("star_out{$ext}", 'form', @$this->tmpl, '', true); $clearsrc = FabrikHelperHTML::image("clear_rating_out{$ext}", 'form', @$this->tmpl, '', true); $str = "<div id=\"{$id}" . "_div\" class=\"fabrikSubElementContainer\">"; if ($params->get('rating-nonefirst') && $this->canRate()) { $str .= "<img src=\"{$imagepath}" . "clear_rating_out{$ext}\" style=\"" . $css . "padding:3px;\" alt=\"clear\" class=\"rate_-1\" />"; } $listid = $this->getlistModel()->getTable()->id; $formid = JRequest::getInt('formid'); $row_id = JRequest::getInt('rowid'); if ($params->get('rating-mode') == 'creator-rating') { $avg = $value; $this->avg = $value; } else { list($avg, $total) = $this->getRatingAverage($value, $listid, $formid, $row_id); } for ($s = 0; $s < $avg; $s++) { $r = $s + 1; $str .= "<img src=\"{$insrc}\" style=\"" . $css . "padding:3px;\" alt=\"{$r}\" class=\"starRating rate_{$r}\" />"; } for ($s = $avg; $s < 5; $s++) { $r = $s + 1; $str .= "<img src=\"{$outsrc}\" style=\"" . $css . "padding:3px;\" alt=\"{$r}\" class=\"starRating rate_{$r}\" />"; } if (!$params->get('rating-nonefirst')) { $str .= "<img src=\"{$clearsrc}\" style=\"" . $css . "padding:3px;\" alt=\"clear\" class=\"rate_-1\" />"; } $str .= "<span class=\"ratingScore\">{$this->avg}</span>"; $str .= "<div class=\"ratingMessage\">"; //$str .= $this->canRate() ? JText::_('PLG_ELEMENT_RATING_NO_RATING') : ''; $str .= "</div>"; $str .= "<input type=\"hidden\" name=\"{$name}\" id=\"{$id}\" value=\"{$value}\" />\n"; $str .= "</div>"; return $str; }
/** * Build the HTML for the plug-in button * * @return string */ public function button_result() { if ($this->canUse()) { $p = $this->onGetFilterKey_result(); $j3 = FabrikWorker::j3(); FabrikHelperHTML::addPath('plugins/fabrik_list/' . $p . '/images/', 'image', 'list'); $name = $this->_getButtonName(); $label = $this->buttonLabel(); $imageName = $this->getImageName(); $tmpl = $this->getModel()->getTmpl(); $properties = array(); $opts = array('forceImage' => false); if (FabrikWorker::isImageExtension($imageName)) { $opts['forceImage'] = true; } $img = FabrikHelperHTML::image($imageName, 'list', $tmpl, $properties, false, $opts); $text = $this->buttonAction == 'dropdown' ? $label : '<span class="hidden">' . $label . '</span>'; if ($j3 && $this->buttonAction != 'dropdown') { $layout = FabrikHelperHTML::getLayout('fabrik-button'); $layoutData = (object) array('tag' => 'a', 'attributes' => 'data-list="' . $this->context . '" title="' . $label . '"', 'class' => $name . ' listplugin btn-default', 'label' => $img . ' ' . $text); return $layout->render($layoutData); } else { $a = '<a href="#" data-list="' . $this->context . '" class="' . $name . ' listplugin" title="' . $label . '">'; return $a . $img . ' ' . $text . '</a>'; } } return ''; }
/** * Displays a calendar control field * * hacked from behaviour as you need to check if the element exists * it might not as you could be using a custom template * * @param string $value The date value (must be in the same format as supplied by $format) * @param string $name The name of the text field * @param string $id The id of the text field * @param string $format The date format (not used) * @param array $attribs Additional html attributes * @param int $repeatCounter Repeat group counter (not used) * * @deprecated - use JLayouts instead * * @return string */ public function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null, $repeatCounter = 0) { $j3 = FabrikWorker::j3(); if (is_array($attribs)) { $attribs = ArrayHelper::toString($attribs); } FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'media/system/images/', 'image', 'form', false); $opts = $j3 ? array('alt' => 'calendar') : array('alt' => 'calendar', 'class' => 'calendarbutton', 'id' => $id . '_cal_img'); $img = FabrikHelperHTML::image('calendar.png', 'form', @$this->tmpl, $opts); $html = array(); if ($j3) { $btnLayout = FabrikHelperHTML::getLayout('fabrik-button'); $layoutData = (object) array('class' => 'calendarbutton', 'id' => $id . '_cal_img', 'label' => $img); $img = $btnLayout->render($layoutData); $html[] = '<div class="input-append">'; } $html[] = '<input type="text" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $attribs . ' />' . $img; if ($j3) { $html[] = '</div>'; } return implode("\n", $html); }
/** * format the read only output for the page * @param string $value * @param string label * @return string value */ protected function getReadOnlyOutput($value, $label) { FabrikHelperHTML::addPath(JPATH_SITE . DS . 'plugins/fabrik_element/yesno/images/', 'image', 'form', false); $img = $value == '1' ? "1.png" : "0.png"; return FabrikHelperHTML::image($img, 'form', @$this->tmpl, array('alt' => $label)); }
/** * Layout: Yes/No field list view * * @package Joomla * @subpackage Fabrik * @copyright Copyright (C) 2005-2015 fabrikar.com - All rights reserved. * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html * @since 3.2 */ // No direct access defined('_JEXEC') or die('Restricted access'); $d = $displayData; $data = $d->value; $tmpl = $d->tmpl; $format = $d->format; $j3 = FabrikWorker::j3(); $opts = array(); $properties = array(); if ($d->format == 'pdf') { $opts['forceImage'] = true; FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/yesno/images/', 'image', 'list', false); } if ($data == '1') { $icon = $j3 && $format != 'pdf' ? 'checkmark.png' : '1.png'; $properties['alt'] = FText::_('JYES'); echo FabrikHelperHTML::image($icon, 'list', $tmpl, $properties, false, $opts); } else { $icon = $j3 && $format != 'pdf' ? 'remove.png' : '0.png'; $properties['alt'] = FText::_('JNO'); echo FabrikHelperHTML::image($icon, 'list', $tmpl, $properties, false, $opts); }
/** * draws the form element * @param array data to preopulate element with * @param int repeat group counter * @return string returns element html */ function render($data, $repeatCounter = 0) { $name = $this->getHTMLName($repeatCounter); $id = $this->getHTMLId($repeatCounter); $params = $this->getParams(); if (JRequest::getVar('view') == 'form' && $params->get('rating-rate-in-form', true) == 0) { return JText::_('PLG_ELEMENT_RATING_ONLY_ACCESSIBLE_IN_DETALS_VIEW'); } $ext = $params->get('rating-pngorgif', '.png'); $element = $this->getElement(); $css = $this->canRate() ? 'cursor:pointer;' : ''; $value = $this->getValue($data, $repeatCounter); $imagepath = JUri::root() . '/plugins/fabrik_element/rating/images/'; FabrikHelperHTML::addPath(JPATH_SITE . DS . 'plugins/fabrik_element/rating/images/', 'image', 'form', false); $insrc = FabrikHelperHTML::image("star_in{$ext}", 'form', @$this->tmpl, array(), true); $outsrc = FabrikHelperHTML::image("star_out{$ext}", 'form', @$this->tmpl, array(), true); $clearsrc = FabrikHelperHTML::image("clear_rating_out{$ext}", 'form', @$this->tmpl, array(), true); $str = array(); $str[] = '<div id="' . $id . '_div" class="fabrikSubElementContainer">'; if ($params->get('rating-nonefirst') && $this->canRate()) { $str[] = '<img src="' . $imagepath . 'clear_rating_out' . $ext . '" style="' . $css . 'padding:3px;" alt="clear" class="rate_-1" />'; } $listid = $this->getlistModel()->getTable()->id; $formid = JRequest::getInt('formid'); $row_id = JRequest::getInt('rowid'); if ($params->get('rating-mode') == 'creator-rating') { $avg = $value; $this->avg = $value; } else { list($avg, $total) = $this->getRatingAverage($value, $listid, $formid, $row_id); } for ($s = 0; $s < $avg; $s++) { $r = $s + 1; $str[] = '<img src="' . $insrc . '" style="' . $css . 'padding:3px;" alt="' . $r . '" class="starRating rate_' . $r . '" />'; } for ($s = $avg; $s < 5; $s++) { $r = $s + 1; $str[] = '<img src="' . $outsrc . '" style="' . $css . 'padding:3px;" alt="' . $r . '" class="starRating rate_' . $r . '" />'; } if (!$params->get('rating-nonefirst') && $this->canRate()) { $str[] = '<img src="' . $clearsrc . '" style="' . $css . 'padding:3px;" alt="clear" class="rate_-1" />'; } $str[] = '<span class="ratingScore">' . $this->avg . '</span>'; $str[] = '<div class="ratingMessage">'; $str[] = '</div>'; $str[] = '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . $value . '" />'; $str[] = '</div>'; return implode("\n", $str); }
function writeComment(&$params, $comment) { $user = JFactory::getUser(); $name = (int) $comment->annonymous == 0 ? $comment->name : JText::_('PLG_FORM_COMMENT_ANONYMOUS_SHORT'); $data = "<div class=\"metadata\">\n{$name} " . JText::_('PLG_FORM_COMMENT_WROTE_ON') . " <small>" . JHTML::date($comment->time_date) . "</small>\n"; FabrikHelperHTML::addPath(JPATH_SITE . DS . 'plugins/fabrik_form/comment/images/', 'image', 'form', false); $insrc = FabrikHelperHTML::image("star_in.png", 'form', @$this->tmpl, array(), true); if ($params->get('comment-internal-rating') == 1) { $data .= "<div class=\"rating\">\n"; $r = (int) $comment->rating; for ($i = 0; $i < $r; $i++) { $data .= "<img src=\"{$insrc}\" alt=\"star\" />"; } $data .= "\n</div>"; } if ($this->doDigg()) { $digg = $this->getDigg(); $digg->_editable = true; $digg->commentDigg = true; $digg->commentId = $comment->id; if (JRequest::getVar('listid') == '') { JRequest::setVar('listid', $this->getListId()); } JRequest::setVar('commentId', $comment->id); $id = "digg_" . $comment->id; $data .= "<div id=\"{$id}\"class=\"digg fabrik_row fabrik_row___" . $this->formModel->getId() . "\">\n" . $digg->render(array()) . "\n</div>\n"; } $data .= "</div>\n"; $data .= "<div class=\"comment\" id=\"comment-{$comment->id}\">\r\n\t\t<div class=\"comment-content\">{$comment->comment}</div>"; $data .= "<div class=\"reply\">"; if (!$this->commentsLocked) { $data .= "<a href=\"#\" class=\"replybutton\">" . JText::_('PLG_FORM_COMMENT_REPLY') . "</a>\n"; } if ($user->authorise('core.delete', 'com_fabrik')) { $data .= "<div class=\"admin\">\n<a href=\"#\" class=\"del-comment\">" . JText::_('PLG_FORM_COMMENT_DELETE') . "</a>\n</div>\n"; } $data .= "</div>\n"; $data .= "</div>\n"; if (!$this->commentsLocked) { $data .= $this->getAddCommentForm($params, $comment->id); } return $data; }
/** * Displays a calendar control field * * hacked from behaviour as you need to check if the element exists * it might not as you could be using a custom template * @param string The date value (must be in the same format as supplied by $format) * @param string The name of the text field * @param string The id of the text field * @param string The date format * @param array Additional html attributes * @param int repeat group counter */ function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null, $repeatCounter = 0) { FabrikHelperHTML::loadcalendar(); if (is_array($attribs)) { $attribs = JArrayHelper::toString($attribs); } $opts = $this->_CalendarJSOpts($id); $opts->ifFormat = $format; $opts = json_encode($opts); // $$$ rob - we shouldnt be ini'ing the calender js in form view as its done in the date.js file. // Should ONLY be used for list filters. //if (!$this->getElement()->hidden || JRequest::getVar('view') == 'list') { /* if (JRequest::getVar('view') == 'list') { $script = array(); if (JRequest::getVar('format') !== 'raw') { $script[] = 'head.ready(function() {'; } $script[] = 'if($("'.$id.'")) { '; $script[] = 'Calendar.setup('.$opts.');'; $script[] = '}'; //end if id if (JRequest::getVar('format') !== 'raw') { $script[] = '});'; //end domready function } FabrikHelperHTML::addScriptDeclaration(implode("\n", $script)); } */ $paths = FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'media/system/images/', 'image', 'form', false); $img = FabrikHelperHTML::image('calendar.png', 'form', @$this->tmpl, array('alt' => 'calendar', 'class' => 'calendarbutton', 'id' => $id . '_cal_img')); return '<input type="text" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . $img; }
/** * Write a single comment * * @param object $params plugin params * @param object $comment comment to write * * @return string */ private function writeComment($params, $comment) { $user = JFactory::getUser(); $name = (int) $comment->annonymous == 0 ? $comment->name : JText::_('PLG_FORM_COMMENT_ANONYMOUS_SHORT'); $data = array(); $data[] = '<div class="metadata">'; $data[] = $name . ' ' . JText::_('PLG_FORM_COMMENT_WROTE_ON') . ' <small>' . JHTML::date($comment->time_date) . '</small>'; FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_form/comment/images/', 'image', 'form', false); $insrc = FabrikHelperHTML::image("star_in.png", 'form', @$this->tmpl, array(), true); if ($params->get('comment-internal-rating') == 1) { $data[] = '<div class="rating">'; $r = (int) $comment->rating; for ($i = 0; $i < $r; $i++) { $data[] = '<img src="' . $insrc . '" alt="star" />'; } $data[] = '</div>'; } if ($this->doDigg()) { $digg = $this->getDigg(); $digg->setEditable(true); $digg->commentDigg = true; $digg->commentId = $comment->id; if (JRequest::getVar('listid') == '') { JRequest::setVar('listid', $this->getListId()); } JRequest::setVar('commentId', $comment->id); $id = 'digg_' . $comment->id; $data[] = '<div id="' . $id . '" class="digg fabrik_row fabrik_row___' . $this->formModel->getId() . '">'; $data[] = $digg->render(array()); $data[] = '</div>'; } $data[] = '</div>'; $data[] = '<div class="comment" id="comment-' . $comment->id . '">'; $data[] = '<div class="comment-content">' . $comment->comment . '</div>'; $data[] = '<div class="reply">'; if (!$this->commentsLocked) { $data[] = '<a href="#" class="replybutton">' . JText::_('PLG_FORM_COMMENT_REPLY') . '</a>'; } if ($user->authorise('core.delete', 'com_fabrik')) { $data[] = '<div class="admin">'; $data[] = '<a href="#" class="del-comment">' . JText::_('PLG_FORM_COMMENT_DELETE') . '</a>'; $data[] = '</div>'; } $data[] = '</div>'; $data[] = '</div>'; if (!$this->commentsLocked) { $data[] = $this->getAddCommentForm($params, $comment->id); } return implode("\n", $data); }
/** * Search various folder locations for a template image * @since 3.0 * @param string file name * @param string type e.g. form/list/element * @param string tempalte folder name * @param string image alt text */ public function image($file, $type = 'form', $tmpl = '', $alt = '', $srcOnly = false) { $app = JFactory::getApplication(); $template = $app->getTemplate(); $paths = FabrikHelperHTML::addPath('', 'image', $type); $alt = $alt == '' ? $file : $alt; $src = ''; foreach ($paths as $path) { $path = sprintf($path, $tmpl); if (JFile::exists($path . $file)) { $src = str_replace(COM_FABRIK_BASE, COM_FABRIK_LIVESITE, $path . $file); $src = str_replace("\\", "/", $src); break; } } if ($srcOnly) { return $src; } return $src == '' ? '' : "<img src=\"{$src}\" alt=\"{$alt}\" title=\"{$alt}\" />"; }
/** * Build the HTML for the plug-in button * * @return string */ public function button_result() { if ($this->canUse()) { $p = $this->onGetFilterKey_result(); $j3 = FabrikWorker::j3(); FabrikHelperHTML::addPath('plugins/fabrik_list/' . $p . '/images/', 'image', 'list'); $name = $this->_getButtonName(); $label = $this->buttonLabel(); $imageName = $this->getImageName(); $img = FabrikHelperHTML::image($imageName, 'list', '', $label); $text = $this->buttonAction == 'dropdown' ? $label : '<span class="hidden">' . $label . '</span>'; $btnClass = $j3 && $this->buttonAction != 'dropdown' ? 'btn ' : ''; $a = '<a href="#" data-list="' . $this->context . '" class="' . $btnClass . $name . ' listplugin" title="' . $label . '">'; return $a . $img . ' ' . $text . '</a>'; } return ''; }
/** * 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) { $input = $this->app->input; $name = $this->getHTMLName($repeatCounter); $id = $this->getHTMLId($repeatCounter); $params = $this->getParams(); if ($input->get('view') == 'form' && $params->get('rating-rate-in-form', true) == 0) { return FText::_('PLG_ELEMENT_RATING_ONLY_ACCESSIBLE_IN_DETAILS_VIEW'); } $rowId = $this->getFormModel()->getRowId(); /* if (empty($rowId)) { return FText::_('PLG_ELEMENT_RATING_NO_RATING_TILL_CREATED'); } */ $css = $this->canRate($rowId) ? 'cursor:pointer;' : ''; $value = $this->getValue($data, $repeatCounter); FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/rating/images/', 'image', 'form', false); $listId = $this->getlistModel()->getTable()->id; $formId = $input->getInt('formid'); $rowId = $this->getFormModel()->getRowId(); if ($params->get('rating-mode') == 'creator-rating') { $avg = $value; } else { list($avg, $total) = $this->getRatingAverage($value, $listId, $formId, $rowId); } $imgOpts = array('icon-class' => 'small', 'style' => $css, 'data-rating' => -1); $layout = $this->getLayout('form'); $layoutData = new stdClass(); $layoutData->id = $id; $layoutData->name = $name; $layoutData->value = $value; $layoutData->clearImg = FabrikHelperHTML::image('remove.png', 'list', @$this->tmpl, $imgOpts); $layoutData->avg = $avg; $layoutData->canRate = $this->canRate($rowId); $layoutData->ratingNoneFirst = $params->get('rating-nonefirst'); $layoutData->css = $css; $layoutData->tmpl = @$this->tmpl; return $layout->render($layoutData); }
/** * Search various folder locations for an image * @param string file name * @param string type e.g. form/list/element * @param string template folder name * @return string full path name if found, original filename if not found */ public function getImagePath($file, $type = 'form', $tmpl = '') { $file = ltrim($file, DS); $paths = FabrikHelperHTML::addPath('', 'image', $type, true); $src = ''; foreach ($paths as $path) { $path = sprintf($path, $tmpl); $src = $path . $file; if (JFile::exists($src)) { return $src; } } return ''; }
public function inLineEdit() { $listModel = JModel::getInstance('List', 'FabrikFEModel'); $listid = JRequest::getInt('listid'); $rowid = JRequest::getVar('rowid'); $elementid = $this->getElement()->id; $listModel->setId($listid); $data = JArrayHelper::fromObject($listModel->getRow($rowid)); $className = JRequest::getVar('plugin'); if (!$this->canUse()) { if (JRequest::getVar('task') != 'element.save') { echo JText::_("JERROR_ALERTNOAUTHOR"); return; } $this->_editable = false; } else { $this->_editable = true; } $groupModel = $this->getGroup(); $repeatCounter = 0; $html = ''; $key = $this->getFullName(); $template = JFactory::getApplication()->getTemplate(); FabrikHelperHTML::addPath(JPATH_SITE."/administrator/templates/$template/images/", 'image', 'list'); //@TODO add acl checks here $task = JRequest::getVar('task'); $saving = ($task == 'element.save' || $task == 'save') ? true : false; $htmlid = $this->getHTMLId($repeatCounter); if ($this->canToggleValue() && ($task !== 'element.save' && $task !== 'save')) { // ok for yes/no elements activating them (double clicking in cell) // should simply toggle the stored value and return the new html to show $toggleValues = $this->getOptionValues(); $currentIndex = array_search($data[$key], $toggleValues); if ($currentIndex === false || $currentIndex == count($toggleValues)-1) { $nextIndex = 0; } else { $nextIndex = $currentIndex + 1; } $newvalue = $toggleValues[$nextIndex]; $data[$key] = $newvalue; $shortkey = array_pop(explode("___", $key)); $listModel->storeCell($rowid, $shortkey, $newvalue); $this->mode = 'readonly'; $html = $this->renderListData($data[$key], $data); $script = "\n<script type=\"text/javasript\">"; $script .= "window.fireEvent('fabrik.list.inlineedit.stopEditing');"; //makes the inlined editor stop editing the cell $script .= "</script>\n"; echo $html.$script; return; } $listModel->clearCalculations(); $listModel->doCalculations(); $doCalcs = "\nFabrik.blocks['table_".$listid."'].updateCals(".json_encode($listModel->getCalculations()).")"; if(!$saving) { // so not an element with toggle values, so load up the form widget to enable user // to select/enter a new value //wrap in fabriKElement div to ensure element js code works $html .= "<div class=\"floating-tip\" style=\"position:absolute\"> <ul class=\"fabrikElementContainer\">"; $html .= "<li class=\"fabrikElement\">"; $html .= $this->_getElement($data, $repeatCounter, $groupModel); $html .= "</li>"; if (JRequest::getBool('inlinesave') && JRequest::getBool('inlinecancel')) { $html .= "<li class=\"ajax-controls\">"; if (JRequest::getBool('inlinesave') == true) { $html .= "<a href=\"#\" class=\"inline-save\"><img src=\"".COM_FABRIK_LIVESITE."media/com_fabrik/images/action_check.png\" alt=\"".JText::_('SAVE')."\" /></a>"; } if (JRequest::getBool('inlinecancel') == true) { $html .= "<a href=\"#\" class=\"inline-cancel\"><img src=\"".COM_FABRIK_LIVESITE."media/com_fabrik/images/del.png\" alt=\"".JText::_('CANCEL')."\" /></a>"; } $html .= "</li>"; } $html .= "</ul>"; $html .= "</div>"; $onLoad = "Fabrik.inlineedit_$elementid = ".$this->elementJavascript($repeatCounter).";\n". "Fabrik.inlineedit_$elementid.select(); Fabrik.inlineedit_$elementid.focus(); Fabrik.inlineedit_$elementid.token = '".JUtility::getToken()."';\n"; $onLoad .= "window.fireEvent('fabrik.list.inlineedit.setData');\n"; $srcs = array(); $this->formJavascriptClass($srcs); FabrikHelperHTML::script($srcs, true, $onLoad); } else { $html .= $this->renderListData($data[$key], $data); $html .= "\n<script type=\"text/javasript\">"; $html .= $doCalcs; $html .= "</script>\n"; } echo $html; }
/** * Shows the data formatted for the table view with format = pdf * note pdf lib doesn't support transparent PNGs hence this func * * @param string $data Cell data * @param object $thisRow Row data * * @return string formatted value */ public function renderListData_pdf($data, $thisRow) { FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_element/yesno/images/', 'image', 'list', false); $raw = $this->getFullName() . '_raw'; $data = $thisRow->{$raw}; $j3 = FabrikWorker::j3(); if ($data == '1') { $icon = $j3 ? 'checkmark.png' : '1_8bit.png'; return FabrikHelperHTML::image($icon, 'list', @$this->tmpl, array('alt' => FText::_('JYES'))); } else { $icon = $j3 ? 'remove.png' : '0_8bit.png'; return FabrikHelperHTML::image($icon, 'list', @$this->tmpl, array('alt' => FText::_('JNO'))); } }
/** * Write a single comment * * @param object $params plugin params * @param object $comment comment to write * * @return string */ private function writeComment($params, $comment) { FabrikHelperHTML::addPath(COM_FABRIK_BASE . 'plugins/fabrik_form/comment/images/', 'image', 'form', false); $input = $this->app->input; $layoutData = new stdClass(); $layoutData->insrc = FabrikHelperHTML::image("star_in.png", 'form', @$this->tmpl, array(), true); $layoutData->name = (int) $comment->annonymous == 0 ? $comment->name : FText::_('PLG_FORM_COMMENT_ANONYMOUS_SHORT'); $layoutData->comment = $comment; $layoutData->dateFormat = $params->get('comment-date-format'); $layoutData->internalRating = $params->get('comment-internal-rating') == 1; $layoutData->canDelete = $this->user->authorise('core.delete', 'com_fabrik'); $layoutData->canAdd = !$this->commentsLocked && $this->canAddComment(); $layoutData->commentsLocked = $this->commentsLocked; $layoutData->form = $this->getAddCommentForm($comment->id); $layoutData->j3 = FabrikWorker::j3(); if ($this->doThumbs()) { $layoutData->useThumbsPlugin = true; $thumb = $this->getThumb(); $input->set('commentId', $comment->id); $layoutData->thumbs = $thumb->render(array()); } else { $layoutData->useThumbsPlugin = false; } $layout = $this->getLayout('comment'); return $layout->render($layoutData); }