protected function getInput() { $helper = new BtApbHelper(); if ($helper->checkPhocaComponent()) { $db = JFactory::getDBO(); //build the list of categories $query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parentid' . ' FROM #__phocagallery_categories AS a' . ' WHERE a.published = 1' . ' ORDER BY a.ordering'; $db->setQuery($query); $phocagallerys = $db->loadObjectList(); // TODO - check for other views than category edit $view = JRequest::getVar('view'); $catId = -1; if ($view == 'phocagalleryc') { $id = $this->form->getValue('id'); // id of current category if ((int) $id > 0) { $catId = $id; } } $tree = array(); $text = ''; if (method_exists('PhocaGalleryRenderAdmin', 'CategoryTreeOption')) { $tree = PhocaGalleryRenderAdmin::CategoryTreeOption($phocagallerys, $tree, 0, $text, $catId); } else { if (method_exists('PhocaGalleryCategory', 'CategoryTreeOption')) { $tree = PhocaGalleryCategory::CategoryTreeOption($phocagallerys, $tree, 0, $text, $catId); } else { $class = $this->element['class'] ? (string) $this->element['class'] : ''; return "<div class='{$class}'>" . JText::_('MOD_BTBGSLIDESHOW_PHOCA_ALERT') . "</div>"; } } array_unshift($tree, JHTML::_('select.option', '', '- ' . JText::_('PHOCA_ALL_CATEGORIES') . ' -', 'value', 'text')); // Initialize JavaScript field attributes. $class = $this->element['class'] ? (string) $this->element['class'] : ''; $attr = ''; $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; $attr .= ' class="inputbox ' . $class . '"'; $document = JFactory::getDocument(); $document->addCustomTag('<script type="text/javascript"> function changeCatid() { var catid = document.getElementById(\'jform_catid\').value; var href = document.getElementById(\'pgselectytb\').href; href = href.substring(0, href.lastIndexOf("&")); href += \'&catid=\' + catid; document.getElementById(\'pgselectytb\').href = href; } </script>'); return JHTML::_('select.genericlist', $tree, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); } else { $class = $this->element['class'] ? (string) $this->element['class'] : ''; return "<span class='{$class} source_phocagallery_not_found'>" . JText::_('PHOCA_ALERT') . "</span>"; } }
/** * Get images from Phoca Gallery Component */ function getImagesFromPhoca(&$photos) { if (!is_array($photos)) { $photos = array(); } require_once JPATH_ROOT . '/modules/mod_bt_apb/helpers/helper.php'; $helper = new BtApbHelper(); if (!$helper->checkPhocaComponent()) { $this->result["message"] = JText::_('COM_PHOCA_NOT_EXIST'); } else { $rs = $helper->getPhocaPhotos(JRequest::getString('phoca_catid')); if (count($rs) > 0) { foreach ($rs as $photo) { $file = JURI::root() . "images/phocagallery/" . $photo->filename; $fileInfo = pathinfo($file); $hashedName = md5($this->moduleID . '-' . 'phoca-' . $photo->cat_name . '-' . $fileInfo['filename']); if ($file && !JFile::exists($this->saveDir . "/tmp/manager/{$hashedName}.{$fileInfo["extension"]}") && !in_array($hashedName . '.' . $fileInfo["extension"], $this->items)) { $objFile = new stdClass(); $objFile->file = str_replace('http://', '', $file); $objFile->title = $photo->title; $objFile->source = 'phoca-' . $photo->cat_name; $photos[] = $objFile; } } } } }