Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
	/**
	 * 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;
		}

	}
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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;
 }
Example #6
0
	/**
	 * 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;
	}
Example #7
0
 /**
  * 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);
 }
Example #8
0
 /**
  * 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);
 }
Example #9
0
 /**
  * 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);
 }
Example #10
0
 /**
  * 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&amp;format=raw&amp;view=plugin&amp;task=pluginAjax&amp;g=element&amp;plugin=rating&amp;method=ajax_rate&amp;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 .= '&amp;row_id=' . $thisRow->__pk_val;
     $url .= '&amp;elementname=' . $this->getElement()->id;
     $url .= '&amp;userid=' . $user->get('id');
     $url .= '&amp;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}&amp;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);
 }
Example #11
0
 /**
  * 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&amp;format=raw&amp;view=plugin&amp;task=pluginAjax&amp;g=element&amp;plugin=rating&amp;method=ajax_rate&amp;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 .= '&amp;row_id=' . $oAllRowsData->__pk_val;
     $url .= '&amp;elementname=' . $this->getElement()->id;
     $url .= '&amp;userid=' . $user->get('id');
     $url .= '&amp;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}&amp;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);
 }
Example #12
0
	/**
	 * 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();
		$meta = array();
		$config = JFactory::getConfig();
		$ex = $_SERVER['SERVER_PORT'] == 80 ? 'http://' : 'https://';
		// $$$ rob no need to get other meta data as we are linking to the details which contains full meta info on what it is
		// you are liking
		$meta['og:url'] = $ex.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
		$meta['og:site_name'] = $config->getValue('sitename');
		$meta['fb:admins'] = $params->get('fblike_opengraph_applicationid');
		$str = FabrikHelperHTML::facebookGraphAPI($params->get('opengraph_applicationid'), $params->get('fblike_locale', 'en_US'), $meta);
		//in table view we like the detailed record not the table view itself
		$url = $this->getListModel()->linkHref($this, $oAllRowsData);
		return $str.$this->_render($url);
		return parent::renderListData($data, $oAllRowsData);
	}
Example #13
0
	/**
	 * 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)
	{
		$listModel = $this->getlistModel();
		$params = $this->getParams();
		$target = $params->get('link_target', '');
		$smart_link = $params->get('link_smart_link', false);
		if ($listModel->getOutPutFormat() != 'rss' && ($smart_link || $target == 'mediabox')) {
			FabrikHelperHTML::slimbox();
		}
		//$data = explode(GROUPSPLITTER, $data);
		$data = FabrikWorker::JSONtoData($data, true);
		for ($i=0; $i < count($data); $i++) {
			$data[$i] = $this->_renderListData($data[$i], $oAllRowsData);
		}
		//$data = implode(GROUPSPLITTER, $data);
		$data = json_encode($data);
		return parent::renderListData($data, $oAllRowsData);
	}
Example #14
0
	function mustValidate()
	{
		$params 		=& $this->getParams();
		if (!$this->canUse() && !$this->canView()) {
			return false;
		}
		return parent::mustValidate();
	}
Example #15
0
 /**
  * @since 3.0.4
  * get the element's cell class
  * @return	string	css classes
  */
 public function getCellClass()
 {
     $params = $this->getParams();
     $classes = parent::getCellClass();
     $format = $params->get('text_format');
     if ($format == 'decimal' || $format == 'integer') {
         $classes .= ' ' . $format;
     }
     return $classes;
 }
Example #16
0
 /**
  * @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;
 }
Example #17
0
 /**
  * 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);
 }
Example #18
0
 /**
  * load the javascript class that manages interaction with the form element
  * should only be called once
  * @return string javascript class file
  */
 function formJavascriptClass(&$srcs)
 {
     $src = "http://maps.google.com/maps/api/js?sensor=" . $this->getParams()->get('fb_gm_sensor', 'false');
     $src .= "&callback=googlemapload";
     parent::formJavascriptClass($srcs, $src);
     parent::formJavascriptClass($srcs);
 }
Example #19
0
 /**
  * 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);
 }
Example #20
0
 /**
  * @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);
 }
Example #21
0
	/**
	 * 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->format($data);
		return parent::renderListData($data, $oAllRowsData);
	}
Example #22
0
 /**
  * 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)
 {
     $data = FabrikWorker::JSONtoData($data, true);
     JArrayHelper::toInteger($data);
     $db = FabrikWorker::getDbo(true);
     $query = $db->getQuery(true);
     if (!empty($data)) {
         $query->select('title')->from('#__usergroups')->where('id IN (' . implode(',', $data) . ')');
         $db->setQuery($query);
         $data = $db->loadColumn();
     }
     $data = json_encode($data);
     return parent::renderListData($data, $thisRow);
 }
Example #23
0
 /**
  * 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 = JHTML::_('date', $data, JText::_($params->get('timestamp_format', 'DATE_FORMAT_LC2')));
     return parent::renderListData($data, $oAllRowsData);
 }
Example #24
0
 /**
  * get the value
  *
  * @param array $data
  * @param int $repeatCounter
  * @param array options
  * @return unknown
  */
 function getValue($data, $repeatCounter = 0, $opts = array())
 {
     //cludge for 2 scenarios
     if (array_key_exists('rowid', $data)) {
         //when validating the data on form submission
         $key = 'rowid';
     } else {
         //when rendering the element to the form
         $key = '__pk_val';
     }
     if (empty($data) || !array_key_exists($key, $data) || array_key_exists($key, $data) && empty($data[$key])) {
         // $$$rob - if no search form data submitted for the search element then the default
         // selection was being applied instead
         if (array_key_exists('use_default', $opts) && $opts['use_default'] == false) {
             $value = '';
         } else {
             $value = $this->getDefaultValue($data);
         }
         return $value;
     }
     $res = parent::getValue($data, $repeatCounter, $opts);
     return $res;
 }
Example #25
0
 /**
  * Manupulates posted form data for insertion into database
  *
  * @param   mixed  $val   this elements posted form data
  * @param   array  $data  posted form data
  *
  * @return  mixed
  */
 public function storeDatabaseFormat($val, $data)
 {
     $val = parent::storeDatabaseFormat($val, $data);
     return $val;
 }
Example #26
0
 /**
  * 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 = FabrikWorker::JSONtoData($data, true);
     $params = $this->getParams();
     $pathset = false;
     foreach ($data as $d) {
         if (strstr($d, '/')) {
             $pathset = true;
             break;
         }
     }
     if ($data === '' || empty($data) || !$pathset) {
         //no data so default to image (or simple image name stored).
         $iPath = $params->get('imagepath');
         if (!strstr($iPath, '/')) {
             //single file specified so find it in tmpl folder
             $data = (array) FabrikHelperHTML::image($iPath, 'list', @$this->tmpl, array(), true);
         } else {
             $data = (array) $iPath;
         }
     }
     $selectImage_root_folder = $params->get('selectImage_root_folder', '');
     // $$$ hugh - tidy up a bit so we don't have so many ///'s in the URL's
     $selectImage_root_folder = ltrim($selectImage_root_folder, '/');
     $selectImage_root_folder = rtrim($selectImage_root_folder, '/');
     $showImage = $params->get('show_image_in_table', 0);
     $linkURL = $params->get('link_url', '');
     if (empty($data) || $data[0] == '') {
         //$data[] = $params->get('imagefile');
         $data[] = $params->get('imagepath');
     }
     for ($i = 0; $i < count($data); $i++) {
         if ($showImage) {
             // $$$ rob 30/06/2011 - say if we import via csv a url to the image check that and use that rather than the relative path
             $src = substr($data[$i], 0, 4) == 'http' ? $data[$i] : COM_FABRIK_LIVESITE . $selectImage_root_folder . '/' . $data[$i];
             $data[$i] = '<img src="' . $src . '" alt="' . $data[$i] . '" />';
         }
         if ($linkURL) {
             $data[$i] = '<a href="' . $linkURL . '" target="_blank">' . $data[$i] . '</a>';
         }
     }
     $data = json_encode($data);
     return parent::renderListData($data, $oAllRowsData);
 }
Example #27
0
 /**
  * Cache method to populate auto-complete 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())
 {
     $listModel = $elementModel->getListModel();
     $table = $listModel->getTable();
     $db = $listModel->getDb();
     $name = $elementModel->getFullName(false, false);
     $query = $db->getQuery(true);
     $params = $elementModel->getParams();
     $format = $params->get('date_table_format');
     $elementModel->strftimeTFormatToMySQL($format);
     $search = $db->quote('%' . addslashes($search) . '%');
     $query->select('DISTINCT(' . $name . ') AS value, ' . $name . ' AS text')->from($table->db_table_name)->where($name . ' LIKE ' . $search . ' OR DATE_FORMAT(' . $name . ', "' . $format . '" ) LIKE ' . $search);
     $db->setQuery($query);
     $tmp = $db->loadObjectList();
     $ddData = array();
     foreach ($tmp as &$t) {
         $elementModel->toLabel($t->text);
         if (!array_key_exists($t->text, $ddData)) {
             $ddData[$t->text] = $t;
         }
     }
     $ddData = array_values($ddData);
     echo json_encode($ddData);
 }
Example #28
0
 /**
  * Get a query for our media query
  *
  * @param   object  &$listModel  list
  * @param   string  $label       label
  *
  * @return string
  */
 protected function getMedianQuery(&$listModel, $label = "'calc'")
 {
     $db = $listModel->getDb();
     $fields = $listModel->getDBFields($this->getTableName(), 'Field');
     $name = $this->getElement()->name;
     $field = JArrayHelper::getValue($fields, $name, false);
     if ($field !== false && $field->Type == 'time') {
         $name = $this->getFullName(false, false, false);
         $table = $listModel->getTable();
         $joinSQL = $listModel->_buildQueryJoin();
         $whereSQL = $listModel->_buildQueryWhere();
         return "SELECT SEC_TO_TIME(TIME_TO_SEC({$name})) AS value, {$label} AS label FROM " . $db->quoteName($table->db_table_name) . " {$joinSQL} {$whereSQL}";
     } else {
         return parent::getMedianQuery($listModel, $label);
     }
 }
Example #29
0
 /**
  * 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();
     $tz_offset = $params->get('gmt_or_local', '0') == '0';
     $data = JHTML::_('date', $data, JText::_($params->get('timestamp_format', 'DATE_FORMAT_LC2')), $tz_offset);
     return parent::renderListData($data, $thisRow);
 }
Example #30
0
 /**
  * this builds an array containing the filters value and condition
  * If no date time option, then we change the filter into a ranged filter to search
  * the whole day for records.
  * @param string initial $value
  * @param string intial $condition
  * @param string eval - how the value should be handled
  * @return array (value condition) values should be in mySQL format
  */
 function getFilterValue($value, $condition, $eval)
 {
     $params =& $this->getParams();
     $store_as_local = (int) $params->get('date_store_as_local', 0);
     if (!$params->get('date_showtime', 0) || $store_as_local) {
         $this->_resetToGMT = false;
     }
     $exactTime = $this->formatContainsTime($params->get('date_table_format'));
     $filterType =& $this->getElement()->filter_type;
     switch ($filterType) {
         case 'field':
         case 'dropdown':
             $mysql = $this->tableDateToMySQL($value);
             if ($mysql !== false) {
                 $value = $mysql;
             }
             if (!$params->get('date_showtime', 0) || $exactTime == false) {
                 //$$$ rob turn into a ranged filter to search the entire day
                 $value = (array) $value;
                 $condition = 'BETWEEN';
                 $value[1] = date("Y-m-d H:i:s", strtotime($this->addDays($value[0], 1)) - 1);
             }
             break;
         case 'ranged':
             $value = (array) $value;
             foreach ($value as &$v) {
                 $mysql = $this->tableDateToMySQL($v);
                 if ($mysql !== false) {
                     $v = $mysql;
                 }
             }
             break;
     }
     $this->_resetToGMT = true;
     return parent::getFilterValue($value, $condition, $eval);
 }