示例#1
0
 /**
  * Returns the HTML for a category select box form field.
  *
  * @access  protected
  * @return  object    The category select box form field.
  * @since   2.0
  */
 function getInput()
 {
     require_once JPATH_ROOT . '/modules/mod_bt_apb/helpers/helper.php';
     $helper = new BtApbHelper();
     if ($helper->checkJGalleryComponent()) {
         require_once JPATH_ADMINISTRATOR . '/components/com_joomgallery/includes/defines.php';
         JLoader::register('JoomExtensions', JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/helpers/extensions.php');
         JLoader::register('JoomHelper', JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/helper.php');
         JLoader::register('JoomConfig', JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/config.php');
         JLoader::register('JoomAmbit', JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/ambit.php');
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/tables');
         JHTML::addIncludePath(JPATH_BASE . '/components/' . _JOOM_OPTION . '/helpers/html');
         $class = $this->element['class'] ? (string) $this->element['class'] : '';
         if ($this->element['required'] && $this->element['required'] == true && strpos($class, 'required') === false) {
             if (!empty($class)) {
                 $class .= ' ';
             }
             $class .= 'required';
         }
         if ($this->element['validate'] && (string) $this->element['validate'] == 'joompositivenumeric') {
             $doc =& JFactory::getDocument();
             // Add a validation script for form validation
             $js_validate = "\n            window.addEvent('domready', function() {\n              document.formvalidator.setHandler('joompositivenumeric', function(value) {\n                regex=/^[1-9]+[0-9]*\$/;\n                return regex.test(value);\n              })\n            });";
             $doc->addScriptDeclaration($js_validate);
             // Element class needs attribute validate-...
             if (!empty($class)) {
                 $class .= ' ';
             }
             $class .= 'validate-' . (string) $this->element['validate'];
             // Add some style to make the slect box red bordered when invalid
             $css = '
         select.invalid {
           border: 1px solid red;
         }';
             $doc->addStyleDeclaration($css);
         }
         $attr = '';
         $attr .= !empty($class) ? ' class="' . $class . '"' : '';
         $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
         $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
         $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
         $action = $this->element['action'] ? (string) $this->element['action'] : 'core.create';
         $exclude = $this->element['exclude'] ? (int) $this->element['exclude'] : null;
         $task = $this->element['task'] ? (int) $this->element['task'] : null;
         $html = JHTML::_('joomselect.categorylist', $this->value, $this->name, $attr, $exclude, '- ', $task, $action, $this->id);
         return $html;
     } else {
         $class = $this->element['class'] ? (string) $this->element['class'] : '';
         return "<span class='{$class} source_jgallery_not_found'>" . JText::_('MOD_BTBGSLIDESHOW_JOOMGALLERY_ALERT') . "</span>";
     }
 }
示例#2
0
文件: ajax.php 项目: Tommar/vino
 /**
  * Get images from JoomGallery Component
  */
 function getImagesFromJoomGallery(&$photos)
 {
     if (!is_array($photos)) {
         $photos = array();
     }
     require_once JPATH_ROOT . '/modules/mod_bt_apb/helpers/helper.php';
     $helper = new BtApbHelper();
     if (!$helper->checkJGalleryComponent()) {
         $this->result["success"] = false;
         $this->result["message"] = JText::_('COM_JOOMGALLERY_NOT_EXIST');
     } else {
         $rs = $helper->getJoomGalleryPhotos(JRequest::getString('jgallery_catid'));
         if (count($rs) > 0) {
             foreach ($rs as $photo) {
                 $file = JURI::root() . "images/joomgallery/originals/" . $photo->cat_name . '/' . $photo->filename;
                 $fileInfo = pathinfo($file);
                 $hashedName = md5($this->moduleID . '-' . 'jgallery-' . $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 = 'jgallery-' . $photo->cat_name;
                     $photos[] = $objFile;
                 }
             }
         }
     }
 }