Skip to content

Commit 8175b27

Browse files
committed
Image gallery front end ORDERING
1 parent f76db8a commit 8175b27

6 files changed

Lines changed: 138 additions & 78 deletions

File tree

admin/controller.php

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -426,54 +426,6 @@ function create_zip($files = array(),$destination = '',$overwrite = false) {
426426
function fieldsattachimagesorderajax()
427427
{
428428

429-
// Log the start
430-
// Initialise a basic logger with no options (once only).
431-
// Include the JLog class.
432-
jimport('joomla.log.log');
433-
434-
JLog::addLogger(array());
435-
436-
// Add a message.
437-
JLog::add('Logged 3', JLog::WARNING, 'fieldsattachimagesorderajax');
438-
439-
440-
// Create a new query object.
441-
$db = JFactory::getDBO();
442-
$query = $db->getQuery(true);
443-
444-
$session =& JFactory::getSession();
445-
$fieldsattachid = JRequest::getVar("fieldsid");
446-
$order = JRequest::getVar("order");
447-
//Article -------------------
448-
$articleid = $session->get('articleid');
449-
450-
// Add a message.
451-
JLog::add($articleid, JLog::WARNING, 'Article ID');
452-
JLog::add($fieldsattachid, JLog::WARNING, 'Fieldsattahc ID');
453-
JLog::add($order, JLog::WARNING, 'Order');
454-
455-
if(empty($articleid) || empty($fieldsattachid) || empty($order)){
456-
//Empty Nothing TODO
457-
}else{
458-
//SQL
459-
$tmporder = explode(",",$order);
460-
if(count($tmporder)>0)
461-
{
462-
$cont = 1;
463-
foreach($tmporder as $obj){
464-
//$query = 'UPDATE #__fieldsattach_images SET ordering='.$obj.' WHERE id='.$fieldsattachid .' AND articleid='.$articleid;
465-
$query = 'UPDATE #__fieldsattach_images SET ordering='.$cont.' WHERE id='.$obj ;
466-
467-
JLog::add($query, JLog::WARNING, "sql");
468-
$db->setQuery($query);
469-
// Add a message.
470-
$db->execute();
471-
//$db->query();
472-
$cont++;
473-
}
474-
475-
}
476-
}
477-
429+
fieldsattachHelper::fieldsattachimagesorderajax();
478430
}
479431
}

admin/extensions/fields/imagegallery/imagegallery.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ static function renderInput($articleid, $fieldsid, $value, $extras=null )
6666
$session->set('fieldsattachid',$fieldsid);
6767

6868
$sitepath = fieldsattachHelper::getabsoluteURL();
69+
70+
$app = JFactory::getApplication();
71+
$dir = '';
72+
//if ($app->isSite()) echo 'Client is site';
73+
if ($app->isAdmin()) $dir="administrator/";
74+
6975
$str_gallery = '<div id="gallery_'.$fieldsid.'" class="galleryfield">'.plgfieldsattachment_imagegallery::getGallery1($articleid, $fieldsid).'</div>';
7076
$str ='';
7177
$str .= $str_gallery;
@@ -135,9 +141,10 @@ function(){
135141
);
136142
137143
//AJAX CALL *****
138-
var url = \"".JURI::root(false)."/administrator/index.php?option=com_fieldsattach&task=fieldsattachimagesorderajax&catid=".$articleid."&fieldsid=\"+fieldsattachid+\"&order=\"+tmparray.toString();
139-
140-
var xmlhttp;
144+
145+
var url = \"".JURI::root(false).$dir."index.php?option=com_fieldsattach&task=fieldsattachimagesorderajax&catid=".$articleid."&fieldsid=\"+fieldsattachid+\"&order=\"+tmparray.toString();
146+
147+
var xmlhttp;
141148
if (window.XMLHttpRequest)
142149
{// code for IE7+, Firefox, Chrome, Opera, Safari
143150
xmlhttp=new XMLHttpRequest();
@@ -181,7 +188,7 @@ static function getHTML($articleid, $fieldsid, $category = false, $write=false)
181188
$cont = 0;
182189

183190
$sitepath = fieldsattachHelper::getabsoluteURL();
184-
$fieldtitle = fieldattach::getName( $articleid, $fieldsid , $category );
191+
$title = fieldattach::getName( $articleid, $fieldsid , $category );
185192
$published = plgfieldsattachment_imagegallery::getPublished( $fieldsid );
186193

187194
if(!empty($result) && $published){
@@ -235,7 +242,7 @@ static function getHTML($articleid, $fieldsid, $category = false, $write=false)
235242

236243

237244

238-
if(fieldattach::getShowTitle( $fieldsid )) $html = str_replace("[TITLE]", $fieldtitle, $html);
245+
if(fieldattach::getShowTitle( $fieldsid )) $html = str_replace("[TITLE]", $title, $html);
239246
else $html = str_replace("[TITLE]", "", $html);
240247

241248
$html = str_replace("[ARTICLE_ID]", $articleid, $html);
@@ -371,4 +378,4 @@ static function getLineTemplate($fieldsids)
371378

372379

373380

374-
}
381+
}

admin/extensions/imagegallery.zip

55 Bytes
Binary file not shown.

admin/helpers/fieldsattach.php

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,25 +1269,64 @@ function getFieldsTitle($id)
12691269
}
12701270

12711271

1272-
/**
1273-
* Get value of one field content
1272+
/**
1273+
* Save the order of imagegallery
12741274
*
12751275
* @access public
12761276
* @since 1.5
1277-
*/
1278-
/*function getfieldsvalue($fieldsid, $articleid)
1279-
{
1280-
$result ="";
1281-
$db = & JFactory::getDBO();
1282-
$query = 'SELECT a.value FROM #__fieldsattach_values as a WHERE a.fieldsid='. $fieldsid.' AND a.articleid='.$articleid ;
1283-
//echo $query;
1284-
$db->setQuery( $query );
1285-
$elid = $db->loadObject();
1286-
$return ="";
1287-
if(!empty($elid)) $return =$elid->value;
1288-
return $return ;
1289-
}*/
1277+
*/
1278+
public function fieldsattachimagesorderajax()
1279+
{
1280+
// Log the start
1281+
// Initialise a basic logger with no options (once only).
1282+
// Include the JLog class.
1283+
jimport('joomla.log.log');
1284+
1285+
JLog::addLogger(array());
1286+
1287+
// Add a message.
1288+
JLog::add('Logged 3', JLog::WARNING, 'fieldsattachimagesorderajax');
1289+
1290+
1291+
// Create a new query object.
1292+
$db = JFactory::getDBO();
1293+
$query = $db->getQuery(true);
1294+
1295+
$session = JFactory::getSession();
1296+
$fieldsattachid = JRequest::getVar("fieldsid");
1297+
$order = JRequest::getVar("order");
1298+
//Article -------------------
1299+
$articleid = $session->get('articleid');
1300+
1301+
// Add a message.
1302+
JLog::add($articleid, JLog::WARNING, 'Article ID');
1303+
JLog::add($fieldsattachid, JLog::WARNING, 'Fieldsattahc ID');
1304+
JLog::add($order, JLog::WARNING, 'Order');
1305+
1306+
if(empty($articleid) || empty($fieldsattachid) || empty($order)){
1307+
//Empty Nothing TODO
1308+
}else{
1309+
//SQL
1310+
$tmporder = explode(",",$order);
1311+
if(count($tmporder)>0)
1312+
{
1313+
$cont = 1;
1314+
foreach($tmporder as $obj){
1315+
//$query = 'UPDATE #__fieldsattach_images SET ordering='.$obj.' WHERE id='.$fieldsattachid .' AND articleid='.$articleid;
1316+
$query = 'UPDATE #__fieldsattach_images SET ordering='.$cont.' WHERE id='.$obj ;
1317+
1318+
JLog::add($query, JLog::WARNING, "sql");
1319+
$db->setQuery($query);
1320+
// Add a message.
1321+
$db->execute();
1322+
//$db->query();
1323+
$cont++;
1324+
}
1325+
1326+
}
1327+
}
12901328

1329+
}
12911330

12921331

12931332

fieldsattach.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<copyright>Copyright Info</copyright>
1313
<license>License Info</license>
1414
<!-- The version string is recorded in the components table -->
15-
<version>3.5.0.9</version>
15+
<version>3.5.1.0</version>
1616
<!-- The description is optional and defaults to the name -->
1717
<description></description>
1818

site/controller.php

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
jimport('joomla.application.component.controller');
1717
//jimport('components.com_search.controller');
18-
JLoader::register('SearchController', 'components/com_search/controller.php');
18+
JLoader::register('SearchController', 'helper/com_search/controller.php');
1919

20+
JLoader::register('fieldsattachHelper', JPATH_ADMINISTRATOR.'/components/com_fieldsattach/helpers/fieldsattach.php');
2021

2122

2223
/**
@@ -45,6 +46,9 @@ public function display($cachable = false, $urlparams = false)
4546

4647
//echo "VIEW:".JRequest::getVar("view");
4748
$vName = JRequest::getVar("view");
49+
$task = JRequest::getVar('task', 'default');
50+
51+
4852
// echo "<br>vNAEMMME: ".$vName;
4953
if($vName == "images" || $vName == "imagesList" || $vName == "fieldsattachimage" || $vName == "fieldsattachimages" || $vName == "fieldsattachimagesajax"){
5054

@@ -112,8 +116,17 @@ public function display($cachable = false, $urlparams = false)
112116
// Set the layout
113117
$view->setLayout($vLayout);
114118

119+
115120
// Display the view
116-
$view->display();
121+
122+
if($task == "fieldsattachimagesorderajax")
123+
{
124+
// Add a message.
125+
$this->fieldsattachimagesorderajax();
126+
}else{
127+
$view->display();
128+
}
129+
117130

118131
//return $this;
119132

@@ -122,8 +135,8 @@ public function display($cachable = false, $urlparams = false)
122135
return parent::display($cachable, $urlparams);
123136
}
124137
}
125-
/*DELETE IMAGE GALLERY*/
126-
public function delete()
138+
/*DELETE IMAGE GALLERY*/
139+
public function delete()
127140
{
128141
$model = $this->getModel( "fieldsattachimage" );
129142
$model->delete();
@@ -253,9 +266,9 @@ function advancedsearch()
253266
$uri = JURI::getInstance();
254267
$uri->setQuery($post);
255268
$uri->setVar('option', 'com_fieldsattach');
256-
$uri->setVar('view', 'advancedsearch');
257-
$uri->setVar('advancedsearchcategories', $advancedsearchcategories);
258-
$uri->setVar('fields', $fields);
269+
$uri->setVar('view', 'advancedsearch');
270+
$uri->setVar('advancedsearchcategories', $advancedsearchcategories);
271+
$uri->setVar('fields', $fields);
259272

260273

261274

@@ -265,4 +278,53 @@ function advancedsearch()
265278

266279
}
267280

281+
/* Reorder Galery type */
282+
function fieldsattachimagesorderajax()
283+
{
284+
285+
286+
287+
fieldsattachHelper::fieldsattachimagesorderajax();
288+
289+
// Log the start
290+
// Initialise a basic logger with no options (once only).
291+
// Include the JLog class.
292+
/*jimport('joomla.log.log');
293+
294+
JLog::addLogger(array());
295+
296+
297+
// Create a new query object.
298+
$db = JFactory::getDBO();
299+
$query = $db->getQuery(true);
300+
301+
$session = JFactory::getSession();
302+
$fieldsattachid = JRequest::getVar("fieldsid");
303+
$order = JRequest::getVar("order");
304+
//Article -------------------
305+
$articleid = $session->get('articleid');
306+
307+
if(empty($articleid) || empty($fieldsattachid) || empty($order)){
308+
//Empty Nothing TODO
309+
}else{
310+
//SQL
311+
$tmporder = explode(",",$order);
312+
if(count($tmporder)>0)
313+
{
314+
$cont = 1;
315+
foreach($tmporder as $obj){
316+
$query = 'UPDATE #__fieldsattach_images SET ordering='.$cont.' WHERE id='.$obj ;
317+
318+
$db->setQuery($query);
319+
// Add a message.
320+
$db->execute();
321+
//$db->query();
322+
$cont++;
323+
}
324+
325+
}
326+
}*/
327+
328+
}
329+
268330
}

0 commit comments

Comments
 (0)