/** * Add the page title and toolbar. */ protected function addToolbar() { JRequest::setVar('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); } else { $checkedOut = false; } $canDo = ImprovemycityHelper::getActions(); JToolBarHelper::title(JText::_('COM_IMPROVEMYCITY_TITLE_COMMENT'), 'item.png'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('comment.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('comment.save', 'JTOOLBAR_SAVE'); } /* if (!$checkedOut && ($canDo->get('core.create'))){ JToolBarHelper::custom('comment.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } */ // If an existing item, can save to a copy. /* if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::custom('issue.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } */ if (empty($this->item->id)) { JToolBarHelper::cancel('comment.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::cancel('comment.cancel', 'JTOOLBAR_CLOSE'); } }
function &getItem($id = null) { if (!isset($this->_item)) { if ($this->_item === null) { if (empty($id)) { $id = $this->getState('improvemycity.id'); } $db = $this->getDbo(); $query = $db->getQuery(true); $query->select('a.*'); $query->from('#__improvemycity as a'); $query->where('a.id = ' . (int) $id); // Join on user table. $query->select('u.name AS fullname'); $query->join('LEFT', '#__users AS u on u.id = a.userid'); // Join on catid table. $query->select('c.title AS catname'); $query->join('LEFT', '#__categories AS c on c.id = a.catid'); $db->setQuery((string) $query); if (!$db->query()) { JError::raiseError(500, $db->getErrorMsg()); } $this->_item = $db->loadObject(); } } if ($this->_item != null) { //also get the discussion for that record as well $model_discussions = JModel::getInstance('Discussions', 'ImprovemycityModel'); $this->_item->discussion = $model_discussions->getItems($this->_item->id); $this->_item->reported_rel = ImprovemycityHelper::getRelativeTime($this->_item->reported); $this->_item->acknowledged_rel = ImprovemycityHelper::getRelativeTime($this->_item->acknowledged); $this->_item->closed_rel = ImprovemycityHelper::getRelativeTime($this->_item->closed); } return $this->_item; }
/** * Method to display a view. * * @param boolean $cachable If true, the view output will be cached * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. * * @return JController This object to support chaining. * @since 1.5 */ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/improvemycity.php'; // Load the submenu. ImprovemycityHelper::addSubmenu(JRequest::getCmd('view', 'issues')); $view = JRequest::getCmd('view', 'issues'); JRequest::setVar('view', $view); parent::display(); return $this; }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'improvemycity.php'; $state = $this->get('State'); $canDo = ImprovemycityHelper::getActions($state->get('filter.improvemycityid')); JToolBarHelper::title(JText::_('COM_IMPROVEMYCITY_TITLE_KEYS'), 'items.png'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'key'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { //DO NOT ALLOW MORE THAN KEYS //JToolBarHelper::addNew('key.add','JTOOLBAR_NEW'); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('key.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); //JToolBarHelper::custom('keys.publish', 'publish.png', 'publish_f2.png','JTOOLBAR_PUBLISH', true); //JToolBarHelper::custom('keys.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { //If this component does not use state then show a direct delete button as we can not trash //JToolBarHelper::deleteList('', 'keys.delete','JTOOLBAR_DELETE'); } if (isset($this->items[0]->state)) { //JToolBarHelper::divider(); //JToolBarHelper::archiveList('keys.archive','JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('keys.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { //JToolBarHelper::deleteList('', 'keys.delete','JTOOLBAR_EMPTY_TRASH'); //JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { //JToolBarHelper::trash('keys.trash','JTOOLBAR_TRASH'); //JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_improvemycity'); } }
/** * Display the view */ public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->statistics = $this->get('Statistics'); $this->pagination = $this->get('Pagination'); $canDo = ImprovemycityHelper::getActions(); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display('print'); }
function getItems() { // Invoke the parent getItems method to get the main list $items = parent::getItems(); //$this->_total = count($items); //I need the discussions model to get discussions for every item... //so I get model (discussions) from within another model (issues) ... //JModel::addIncludePath(JPATH_SITE.'/components/com_improvemycity/models', 'Discussions'); //don't need this we are already inside a model ;) // Convert the params field into an object, saving original in _params $model_discussions = JModel::getInstance('Discussions', 'ImprovemycityModel'); for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; //calculate relative dates here $item->reported_rel = ImprovemycityHelper::getRelativeTime($item->reported); $item->acknowledged_rel = ImprovemycityHelper::getRelativeTime($item->acknowledged); $item->closed_rel = ImprovemycityHelper::getRelativeTime($item->closed); //TODO: Important: Get this outside for loop and set it to main query. It causes lots of queries (overhead) $item->discussion = $model_discussions->getItems($item->id); if (!isset($this->_params)) { $params = new JRegistry(); $params->loadJSON($item->params); $item->params = $params; } } return $items; }
echo JText::_('ADD_COMMENT'); ?> </a> </div> <div id="commentIndicator" class="imc-right"></div> <?php //echo JUtility::getToken(); ?> </form> <?php } else { //not logged ?> <?php $return = base64_encode(ImprovemycityHelper::generateRouteLink('index.php?option=com_improvemycity&view=issue&issue_id=' . $this->item->id)); ?> <div class="alert alert-error"> <?php echo JText::_('ONLY_LOGGED_COMMENT'); ?> <?php echo JText::_('PLEASE_LOG'); ?> <?php /* UNCOMMENT IF YOU WANT login link <?php $return = base64_encode(ImprovemycityHelper::generateRouteLink('index.php?option=com_improvemycity&view=issue&issue_id='.$this->item->id)); ?> <a class="modalwin strong-link" rel="{size: {x: 320, y: 350}}" href="index.php?option=com_users&view=login&tmpl=component&return=<?php echo $return; ?>"><span class="strong-link"><?php echo JText::_('PLEASE_LOG');?></span></a> */ ?> </div>
protected function displayError() { $link = ImprovemycityHelper::generateRouteLink('index.php?option=com_improvemycity&controller=improvemycity&task=addIssue'); $html = '<div style="text-align:center;">'; $html .= '<img src="' . JURI::root(true) . '/components/com_improvemycity/images/error.png' . '" /><br />'; $html .= '<a href="' . $link . '">' . JText::_('BACK_TO_FORM') . '</a>'; $html .= '</div>'; return $html; }
protected function setDocument() { $document = JFactory::getDocument(); if ($this->loadbootstrapcss == 1) { $document->addStyleSheet(JURI::root(true) . '/components/com_improvemycity/bootstrap/css/bootstrap.min.css'); $document->addStyleSheet(JURI::root(true) . '/components/com_improvemycity/bootstrap/css/bootstrap-responsive.min.css'); } $document->addStyleSheet(JURI::root(true) . '/components/com_improvemycity/css/mega-menu.css'); $document->addStyleSheet(JURI::root(true) . '/components/com_improvemycity/css/improvemycity.css'); //add scripts if ($this->loadjquery == 1) { $document->addScript(JURI::root(true) . '/components/com_improvemycity/js/jquery-1.7.1.min.js'); } //jquery noConflict $document->addScriptDeclaration('var jImc = jQuery.noConflict();'); if ($this->loadbootstrap == 1) { $document->addScript(JURI::root(true) . '/components/com_improvemycity/bootstrap/js/bootstrap.min.js'); } $document->addScript(JURI::root(true) . '/components/com_improvemycity/js/improvemycity.js'); //add google maps //$document->addScript("https://maps.google.com/maps/api/js?sensor=false&language=". $this->language ."®ion=". $this->region); $document->addScript("https://maps.google.com/maps/api/js?sensor=false&language=" . $this->language . "®ion=" . $this->region); $document->addScript(JURI::root(true) . '/components/com_improvemycity/js/infobox_packed.js'); $document->addScriptDeclaration('var jsonMarkers = ' . json_encode($this->getMarkersArrayFromItems()) . ';'); $LAT = $this->lat; $LON = $this->lon; //prepare custom icons accordingly (get images from improvemycity categories) $this->createCustomMarkers($this->categories); $this->customMarkers = substr($this->customMarkers, 0, -2); //remove /n and comma $googleMap = "\r\n\t\t\tvar geocoder = new google.maps.Geocoder();\r\n\t\t\tvar map;\r\n\t\t\tvar gmarkers = [];\r\n\t\t\t\r\n\t\t\tfunction zoomIn() {\r\n\t\t\t\tmap.setCenter(marker.getPosition());\r\n\t\t\t\tmap.setZoom(map.getZoom()+1);\r\n\t\t\t}\r\n\r\n\t\t\tfunction zoomOut() {\r\n\t\t\t\tmap.setCenter(marker.getPosition());\r\n\t\t\t\tmap.setZoom(map.getZoom()-1);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tvar customIcons = {\r\n\t\t\t " . $this->customMarkers . "\r\n\t\t\t};\r\n\t\t\t\r\n\t\t\t// Creating a LatLngBounds object\r\n\t\t\tvar bounds = new google.maps.LatLngBounds();\t\t\t\r\n\t\t\tvar infoWindow = null;\r\n\t\t\tvar infoBox = null;\r\n\t\t\t \t\t\r\n\r\n \t\t\r\n\t\t\tfunction initialize() {\r\n\t\t\t\tvar LAT = " . $LAT . ";\r\n\t\t\t\tvar LON = " . $LON . ";\r\n\r\n\t\t\t\tvar latLng = new google.maps.LatLng(LAT, LON);\r\n\t\t\t\tmap = new google.maps.Map(document.getElementById('mapCanvas'), {\r\n\t\t\t\t\r\n\t\t\t\tzoom: " . $this->zoom . ",\r\n\t\t\t\tcenter: latLng,\r\n\t\t\t\tpanControl: false,\r\n\t\t\t\tstreetViewControl: false,\r\n\t\t\t\tzoomControlOptions: {\r\n\t\t\t\t\tstyle: google.maps.ZoomControlStyle.SMALL\r\n\t\t\t\t},\r\n\t\t\t\tmapTypeId: google.maps.MapTypeId.ROADMAP\r\n\t\t\t\t});\r\n\r\n\t\t\t\tinfoWindow = new google.maps.InfoWindow;\r\n\t\t\t\t\r\n\t\t\t\tvar infoBoxOptions = {\r\n\t\t\t\t\tdisableAutoPan: false\r\n\t\t\t\t\t,maxWidth: 0\r\n\t\t\t\t\t,pixelOffset: new google.maps.Size(-100, 0)\r\n\t\t\t\t\t,zIndex: null\r\n\t\t\t\t\t,boxStyle: { \r\n\t\t\t\t\t background: \"url(" . JURI::base() . 'components/com_improvemycity/images/tipbox.gif' . ") -40px 0 no-repeat\"\r\n\t\t\t\t\t ,opacity: 0.75\r\n\t\t\t\t\t ,width: \"200px\"\r\n\t\t\t\t\t }\r\n\t\t\t\t\t,closeBoxMargin: \"10px 2px 2px 2px\"\r\n\t\t\t\t\t,closeBoxURL: \"https://www.google.com/intl/en_us/mapfiles/close.gif\"\r\n\t\t\t\t\t,infoBoxClearance: new google.maps.Size(1, 1)\r\n\t\t\t\t\t,isHidden: false\r\n\t\t\t\t\t,pane: \"floatPane\"\r\n\t\t\t\t\t,enableEventPropagation: false\r\n\t\t\t\t};\r\n\t\t\t\tinfoBox = new InfoBox(infoBoxOptions);\t\t\t\t\r\n\r\n\t\t\t\tfor (var i = 0; i < jsonMarkers.length; i++) {\r\n\t\t\t\t\tvar name = jsonMarkers[i].name;\r\n\t\t\t\t\tvar description = jsonMarkers[i].description;\r\n\t\t\t\t\tvar catid = jsonMarkers[i].catid;\r\n\t\t\t\t\tvar id = jsonMarkers[i].id;\r\n\t\t\t\t\t//var photos = markers[i].photos;\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t\tvar point = new google.maps.LatLng(\r\n\t\t\t\t\t\tparseFloat(jsonMarkers[i].lat),\r\n\t\t\t\t\t\tparseFloat(jsonMarkers[i].lng)\r\n\t\t\t\t\t);\r\n\r\n\r\n\t\t\t\t\tvar html = '<strong>' + name + '</strong>';\r\n\t\t\t\t\tvar icon = customIcons[catid] || {};\r\n\t\t\t\t\tvar marker = new google.maps.Marker({\r\n\t\t\t\t\t\tmap: map,\r\n\t\t\t\t\t\tposition: point,\r\n\t\t\t\t\t\ttitle: name,\r\n\t\t\t\t\t\ticon: icon.icon,\r\n\t\t\t\t\t\tshadow: icon.shadow\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\r\n\t\t\t\t\tmarker.catid = catid;\r\n\t\t\t\t\tmarker.id = id;\r\n\t\t\t\t\t//marker.photos = photos;\r\n\t\t\t\t\t\r\n\t\t\t\t\tmarker.description = description;\r\n\t\t\t\t\t\r\n\t\t\t\t\t//bindInfoWindow(marker, map, infoWindow, html);\r\n\t\t\t\t\tbindInfoBox(marker, map, infoBox, html);\r\n\t\t\t\t\t\r\n\t\t\t\t\tgmarkers.push(marker);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tresetBounds();\r\n\r\n\t\t\t\t\r\n\t\t\t\tjImc(\"#loading\").hide();\r\n\t\t\t}\r\n\r\n\t\t\tfunction bindInfoWindow(marker, map, infoWindow, html) {\r\n\t\t\t google.maps.event.addListener(marker, 'click', function() {\r\n\t\t\t\tinfoWindow.setContent(html);\r\n\t\t\t\tinfoWindow.open(map, marker);\r\n\t\t\t\tmap.panTo(marker.getPosition());\r\n\t\t\t\t//showInfo(marker);\r\n\t\t\t });\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//alternative to infoWindow is the infoBox\r\n\t\t\tfunction bindInfoBox(marker, map, infoWindow, html) {\r\n\t\t\t\tvar boxText = document.createElement(\"div\");\r\n\t\t\t\tboxText.style.cssText = \"border: 1px solid black; margin-top: 8px; background-color: yellow; padding: 5px;\";\r\n\t\t\t\tboxText.innerHTML = html;\t\t\t\r\n\t\t\r\n\t\t\t\tgoogle.maps.event.addListener(marker, 'click', function() {\r\n\t\t\t\t\twindow.location.href = '" . ImprovemycityHelper::generateRouteLink('index.php?option=com_improvemycity&view=issue&issue_id=') . "' + marker.id;\r\n\t\t\t\t});\r\n\t\t\t \r\n\t\t\t\tgoogle.maps.event.addListener(marker, 'mouseover', function() {\r\n\t\t\t\t\tinfoBox.setContent(boxText);\r\n\t\t\t\t\tinfoBox.open(map, marker);\r\n\t\t\t\t\tjImc(\"#issueid-\"+marker.id).addClass(\"imc-highlight\");\r\n\t\t\t\t});\t\t\t \r\n\t\t\t\t\r\n\t\t\t\tgoogle.maps.event.addListener(marker, 'mouseout', function() {\r\n\t\t\t\t\tinfoBox.close();\r\n\t\t\t\t\tjImc(\"#issueid-\"+marker.id).removeClass(\"imc-highlight\");\r\n\t\t\t\t});\t\t\t \r\n\t\t\t}\t\t\t\r\n\t\t\t\r\n\t\t\tfunction downloadUrl(url, callback) {\r\n\t\t\t var request = window.ActiveXObject ?\r\n\t\t\t\t new ActiveXObject('Microsoft.XMLHTTP') :\r\n\t\t\t\t new XMLHttpRequest;\r\n\r\n\t\t\t request.onreadystatechange = function() {\r\n\t\t\t\tif (request.readyState == 4) {\r\n\t\t\t\t request.onreadystatechange = doNothing;\r\n\t\t\t\t callback(request, request.status);\r\n\t\t\t\t resetBounds();\r\n\t\t\t\t}\r\n\t\t\t };\r\n\r\n\t\t\t request.open('GET', url, true);\r\n\t\t\t request.send(null);\r\n\t\t\t}\r\n\r\n\t\t\tfunction doNothing() {}\r\n\t\t\t\r\n\t\t\tfunction resetBounds() {\r\n\t\t\t\tvar a = 0;\r\n\t\t\t\tbounds = null;\r\n\t\t\t\tbounds = new google.maps.LatLngBounds();\r\n\t\t\t\tfor (var i=0; i<gmarkers.length; i++) {\r\n\t\t\t\t\tif(gmarkers[i].getVisible()){\r\n\t\t\t\t\t\ta++;\r\n\t\t\t\t\t\tbounds.extend(gmarkers[i].position);\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif(a > 0){\r\n\t\t\t\t\tmap.fitBounds(bounds);\r\n\t\t\t\t\tvar listener = google.maps.event.addListener(map, 'idle', function() { \r\n\t\t\t\t\t if (map.getZoom() > 16) map.setZoom(16); \r\n\t\t\t\t\t google.maps.event.removeListener(listener); \r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//show markers according to filtering\r\n\t\t\tfunction show(category) {\r\n\t\t\t\t// == check the checkbox ==\r\n\t\t\t\tdocument.getElementById('cat-'+category).checked = true;\r\n\t\t\t}\t\t\t\r\n\t\t\t\r\n\t\t\tfunction hide(category) {\r\n\t\t\t\t// == clear the checkbox ==\r\n\t\t\t\tdocument.getElementById('cat-'+category).checked = false;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\t//--- non recursive since IE cannot handle it (doh!!)\r\n\t\t\tfunction boxclick2(box, category) {\r\n\t\t\t\tif (box.checked) {\r\n\t\t\t\t\tshow(category);\r\n\t\t\t\t} else {\r\n\t\t\t\t\thide(category);\t\r\n\t\t\t\t}\r\n\t\t\t\tvar com = box.getAttribute('path');\r\n\t\t\t\tvar arr = new Array();\r\n\t\t\t\tarr = document.getElementsByName('cat[]');\r\n\t\t\t\tfor(var i = 0; i < arr.length; i++)\r\n\t\t\t\t{\r\n\t\t\t\t\tvar obj = document.getElementsByName('cat[]').item(i);\r\n\t\t\t\t\tvar c = obj.id.substr(4, obj.id.length);\r\n\r\n\t\t\t\t\tvar path = obj.getAttribute('path');\r\n\t\t\t\t\tif(com == path.substring(0,com.length)){\r\n\t\t\t\t\t\tif (box.checked) {\r\n\t\t\t\t\t\t\tobj.checked = true;\r\n\t\t\t\t\t\t\tshow(c);\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tobj.checked = false;\r\n\t\t\t\t\t\t\thide(c);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn false;\r\n\t\t\t}\t\t\t\r\n\t\t\t\r\n\t\t\tfunction markerclick(i) {\r\n\t\t\t\tgoogle.maps.event.trigger(gmarkers[i],'click');\r\n\t\t\t}\t\t\t\r\n\r\n\t\t\tfunction markerhover(id) {\r\n\t\t\t\tvar index;\r\n\t\t\t\tfor (var i=0; i<gmarkers.length; i++) {\t\t\t\t\r\n\t\t\t\t\tif(gmarkers[i].id == id){\r\n\t\t\t\t\t\tindex = i;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tgoogle.maps.event.trigger(gmarkers[index],'mouseover');\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tfunction markerout(id) {\r\n\t\t\t\tvar index;\r\n\t\t\t\tfor (var i=0; i<gmarkers.length; i++) {\t\t\t\t\r\n\t\t\t\t\tif(gmarkers[i].id == id){\r\n\t\t\t\t\t\tindex = i;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tgoogle.maps.event.trigger(gmarkers[index],'mouseout');\r\n\r\n\t\t\t}\t\t\t\r\n\t\t\t\r\n\t\t\t// Onload handler to fire off the app.\r\n\t\t\t//google.maps.event.addDomListener(window, 'load', initialize);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t"; $documentReady = "\r\n\t\t\r\n\t\tjImc(document).ready(function() {\r\n\t\t\t\t\t\r\n\t\t\tinitialize();\r\n\t\t\t\t\t\r\n\t\t\tjImc(\".imc-issue-item\").mouseenter(function(event)\r\n\t\t\t{\r\n\t\t\tjImc(this).addClass(\"imc-highlight\");\r\n\t\t\tmarkerhover(jImc(this).attr('id').substring(8));\r\n\t\t\t});\r\n\t\t\t\r\n\t\t\tjImc(\".imc-issue-item\").mouseleave(function(event)\r\n\t\t\t{\r\n\t\t\tjImc(this).removeClass(\"imc-highlight\");\r\n\t\t\tmarkerout(jImc(this).attr('id').substring(8));\r\n\t\t\t});\r\n\t\t\t\r\n\t\t\tjImc(document).click(function(e) {\r\n\t\t\tif( jImc('#drop-1').is('.hover')) { jImc('#drop-1').removeClass('hover');\t}\r\n\t\t\tif( jImc('#drop-2').is('.hover')) { jImc('#drop-2').removeClass('hover');\t}\r\n\t\t\tif( jImc('#drop-3').is('.hover')) { jImc('#drop-3').removeClass('hover');\t}\r\n\t\t\t});\r\n\t\t\t\t\r\n\t\t\tjImc('#btn-1').click(function(event)\r\n\t\t\t{\r\n\t\t\tif( jImc('#drop-2').is('.hover')) { jImc('#btn-2').click(); }\r\n\t\t\tif( jImc('#drop-3').is('.hover')) { jImc('#btn-3').click(); }\r\n\t\t\t\r\n\t\t\tif( jImc('#drop-1').is('.hover')) {\r\n\t\t\t\tjImc('#drop-1').removeClass('hover');\r\n\t\t\t}\r\n\t\t\telse{\r\n\t\t\t\tjImc('#drop-1').addClass('hover');\r\n\t\t\t}\r\n\t\t\tevent.stopPropagation();\r\n\t\t\t});\r\n\t\t\t\t\r\n\t\t\tjImc('#btn-2').click(function(event)\r\n\t\t\t{\r\n\t\t\tif( jImc('#drop-1').is('.hover')) { jImc('#btn-1').click(); }\r\n\t\t\tif( jImc('#drop-3').is('.hover')) { jImc('#btn-3').click(); }\r\n\t\t\t\t\r\n\t\t\tif( jImc('#drop-2').is('.hover')) {\r\n\t\t\t\tjImc('#drop-2').removeClass('hover');\r\n\t\t\t}\r\n\t\t\telse{\r\n\t\t\t\tjImc('#drop-2').addClass('hover');\r\n\t\t\t}\r\n\t\t\tevent.stopPropagation();\r\n\t\t\t});\r\n\t\t\tjImc('#btn-3').click(function(event)\r\n\t\t\t{\r\n\t\t\tif( jImc('#drop-1').is('.hover')) { jImc('#btn-1').click(); }\r\n\t\t\tif( jImc('#drop-2').is('.hover')) { jImc('#btn-2').click(); }\r\n\t\t\t\t\r\n\t\t\tif( jImc('#drop-3').is('.hover')) {\r\n\t\t\t\tjImc('#drop-3').removeClass('hover');\r\n\t\t\t}\r\n\t\t\telse{\r\n\t\t\t\tjImc('#drop-3').addClass('hover');\r\n\t\t\t}\r\n\t\t\tevent.stopPropagation();\r\n\t\t\t});\r\n\t\t\t\t\r\n\t\t\tjImc('.megadrop').click(function(event) { event.stopPropagation();\t});\r\n\t\t\t\r\n\t\t});\r\n\t\t"; $document->addScriptDeclaration($googleMap); $document->addScriptDeclaration($documentReady); }
<?php /* <h2 class="issue-title"><?php echo JText::_('NEW_ISSUE');?></h2> */ ?> <div id="imc-header"> <div id="imc-menu"> <h2 class="imc-title"><?php echo JText::_('NEW_ISSUE'); ?> </h2> <!-- bootstrap buttons --> <!-- Return to issues --> <div class="btn-group imc-right"> <a class="btn" href="<?php echo ImprovemycityHelper::generateRouteLink('index.php?option=com_improvemycity'); ?> "><i class="icon-arrow-left"></i> <?php echo JText::_('RETURN_TO_ISSUES'); ?> </a> </div> </div> </div> <div id="imc-content"> <div id="imc-main-panel"> <div id="mapCanvasNew"><?php echo JText::_('COM_IMPROVEMYCITY'); ?> </div>
private function notifyByEmail($id, $data) { // Load the parameters. $app = JFactory::getApplication(); $par = $app->getParams(); $this->mailNewIssueAdmins = $par->get('mailnewissueadmins'); $this->mailNewIssueUser = $par->get('mailnewissueuser'); //get the link to the newly created issue $issueLink = 'http://' . $_SERVER['HTTP_HOST'] . ImprovemycityHelper::generateRouteLink('index.php?option=com_improvemycity&view=issue&issue_id=' . $id); //$issueAdminLink = JURI::root() . 'administrator/' . 'index.php?option=com_improvemycity&view=issue&layout=edit&id='.$table->id; /*fixing "You are not permitted to use that link to directly access that page"*/ $issueAdminLink = JURI::root() . 'administrator/' . 'index.php?option=com_improvemycity&view=issue&task=issue.edit&id=' . $id; $user = JFactory::getUser($data['userid']); $app = JFactory::getApplication(); $mailfrom = $app->getCfg('mailfrom'); $fromname = $app->getCfg('fromname'); $sitename = $app->getCfg('sitename'); /* (A) ****--- Send notification mail to appropriate admins (as defined on category note field) */ if ($this->mailNewIssueAdmins == 1) { //get the recipient email(s) as defined in the "note" field of the selected category $issueRecipient = ''; $db = $this->getDbo(); $query = $db->getQuery(true); $query->select('a.note as note, a.title as title'); $query->from('`#__categories` AS a'); $query->where('a.id = ' . $data['catid']); $db->setQuery($query); //$result = $db->loadResult(); $row = $db->loadAssoc(); if (!empty($row)) { $issueRecipient = $row['note']; $arRecipient = explode(";", $issueRecipient); $arRecipient = array_filter($arRecipient, 'strlen'); $categoryTitle = $row['title']; } if (!empty($issueRecipient)) { //only if category note contains email(s) $subject = sprintf(JText::_('COM_IMPROVEMYCITY_MAIL_ADMINS_NEW_ISSUE_SUBJECT'), $user->name, $user->email); $body = sprintf(JText::_('COM_IMPROVEMYCITY_MAIL_ADMINS_NEW_ISSUE_BODY'), $categoryTitle, $data['title'], $data['address'], $issueLink, $issueLink, $issueAdminLink, $issueAdminLink); $mail = JFactory::getMailer(); $mail->isHTML(true); $mail->Encoding = 'base64'; foreach ($arRecipient as $recipient) { $mail->addRecipient($recipient); } $mail->setSender(array($mailfrom, $fromname)); $mail->setSubject($sitename . ': ' . $subject); $mail->setBody($body); $sent = $mail->Send(); } } /* (B) ****--- Send notification mail to the user who submitted the issue */ if ($this->mailNewIssueUser == 1) { // recipient is the user $issueRecipient = $user->email; if ($issueRecipient != '') { //check just in case... $subject = JText::_('COM_IMPROVEMYCITY_MAIL_USER_NEW_ISSUE_SUBJECT'); $body = sprintf(JText::_('COM_IMPROVEMYCITY_MAIL_USER_NEW_ISSUE_BODY'), $issueLink, $issueLink); $mail = JFactory::getMailer(); $mail->isHTML(true); $mail->Encoding = 'base64'; $mail->addRecipient($issueRecipient); $mail->setSender(array($mailfrom, $fromname)); $mail->setSubject($sitename . ': ' . $subject); $mail->setBody($body); $sent = $mail->Send(); //also inform user at the frontend for the email that is about to receive JFactory::getApplication()->enqueueMessage(JText::_('COM_IMPROVEMYCITY_NEW_ISSUE_SAVE_SUCCESS')); } } return true; }
public function comment($pk = 0, $userid = 0, $description = '') { $pk = !empty($pk) ? $pk : (int) ($id = $this->getState('improvemycity.id')); $db = $this->getDbo(); $db->setQuery('INSERT INTO #__improvemycity_comments ( improvemycityid, userid, description)' . ' VALUES ( ' . (int) $pk . ', ' . (int) $userid . ', "' . $description . '")'); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } //return the latest comment so as to be displayed with ajax in the frontend $query = $db->getQuery(true); $query->select('a.*'); $query->from('#__improvemycity_comments as a'); $query->where('a.improvemycityid = ' . (int) $pk); $query->where('a.state = 1'); // Join on user table. $query->select('u.name AS username'); $query->join('LEFT', '#__users AS u on u.id = a.userid'); $query->order('created DESC'); $db->setQuery((string) $query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } //$comments = $db->loadResult(); //return first field of first row //$comments = $db->loadAssocList(); //return all rows $comments = $db->loadAssoc(); //return first row $comments['textual_descr'] = JText::_('COMMENT_REPORTED') . ' ' . ImprovemycityHelper::getRelativeTime($comments['created']) . ' ' . JText::_('BY') . ' ' . $comments['username']; return $comments; }
<div class="alert alert-error width75"> <?php echo JText::_('COM_IMPROVEMYCITY_FILTER_REVISION'); ?> </div> <?php } ?> <?php foreach ($this->items as $item) { ?> <div class="imc-issue-item" id="issueid-<?php echo $item->id; ?> " onclick="location.href='<?php echo ImprovemycityHelper::generateRouteLink('index.php?option=com_improvemycity&view=issue&issue_id=' . $item->id); ?> ';void(0);" > <div class="imc-issue-content"> <div class="imc-issue-review"> <h2 class="imc-issue-title"> <?php echo '#' . $item->id . '. ' . $item->title; ?> <?php $status = ''; switch ($item->currentstatus) { case 1: $status = 'OPEN'; break; case 2: