/**
  * Uploads the selected images
  *
  * @return  void
  * @since   3.0
  */
 public function upload()
 {
     $result = array('error' => false);
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/upload.php';
     $uploader = new JoomUpload();
     if ($image = $uploader->upload(JRequest::getCmd('type', 'ajax'))) {
         $result['success'] = true;
         if (is_object($image)) {
             $result['id'] = $image->id;
             $result['imgtitle'] = $image->imgtitle;
             $result['thumbnailUrl'] = JoomAmbit::getInstance()->getImg('thumb_url', $image);
         }
     } else {
         if ($error = $uploader->getError()) {
             $result['error'] = $error;
         } else {
             $result['error'] = JText::_('COM_JOOMGALLERY_UPLOAD_ERROR_FILE_NOT_UPLOADED');
         }
     }
     if ($debug_output = $uploader->getDebugOutput()) {
         $result['debug_output'] = $debug_output;
     }
     $doc = JFactory::getDocument();
     $doc->setMimeEncoding('text/plain');
     echo json_encode($result);
 }
Example #2
0
 /**
  * Constructor
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('administrator');
     $this->_user = JFactory::getUser();
     $this->_doc = JFactory::getDocument();
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('admin.joomgallery.css'));
     JHtmlBehavior::framework();
     $this->_doc->addScript($this->_ambit->getScript('admin.js'));
     JoomHelper::addSubmenu();
     JHTML::addIncludePath(JPATH_COMPONENT . '/helpers/html');
     // Check for available updates
     if (!($checked = $this->_mainframe->getUserState('joom.update.checked'))) {
         $controller = JRequest::getCmd('controller');
         if ($this->_config->get('jg_checkupdate') && $controller && $controller != 'control') {
             $dated_extensions = JoomExtensions::checkUpdate();
             if (count($dated_extensions)) {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_SYSTEM_NOT_UPTODATE'), 'warning');
                 $this->_mainframe->setUserState('joom.update.checked', -1);
             } else {
                 $this->_mainframe->setUserState('joom.update.checked', 1);
             }
         }
     } else {
         if ($checked == -1) {
             $controller = JRequest::getCmd('controller');
             if ($controller && $controller != 'control') {
                 $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_SYSTEM_NOT_UPTODATE'), 'warning');
             }
         }
     }
 }
Example #3
0
 /**
  * Constructor
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('administrator');
     $this->_user = JFactory::getUser();
 }
Example #4
0
 /**
  * Constructor
  *
  * @access  protected
  * @return  void
  * @since   1.5.5
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     /*$this->_mainframe = JFactory::getApplication('site');
       $this->_user      = JFactory::getUser();*/
     $this->_db = JFactory::getDBO();
     // Uncomment following line to disable update check
     // $this->_config->set('jg_checkupdate', 0);
 }
Example #5
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.5
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->_ambit = JoomAmbit::getInstance();
     $this->_config = JoomConfig::getInstance();
     $this->_mainframe = JFactory::getApplication('site');
     $this->_user = JFactory::getUser();
     $this->_doc = JFactory::getDocument();
     JHtml::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/helpers/html');
     // If we are just displaying an image we don't need anything else
     if (JRequest::getCmd('format') == 'raw' || JRequest::getCmd('format') == 'jpg' || JRequest::getCmd('format') == 'json' || JRequest::getCmd('format') == 'feed') {
         return;
     }
     // Add the CSS file generated from backend settings
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet($this->_config->getStyleSheetName()));
     // Add the main CSS file
     $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joomgallery.css'));
     // Add the RTL CSS file if an RTL language is used
     if (JFactory::getLanguage()->isRTL()) {
         $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joomgallery_rtl.css'));
     }
     // Add individual CSS file if it exists
     if (file_exists(JPATH_ROOT . '/media/joomgallery/css/joom_local.css')) {
         $this->_doc->addStyleSheet($this->_ambit->getStyleSheet('joom_local.css'));
     }
     $pngbehaviour = "  <!-- Do not edit IE conditional style below -->" . "\n" . "  <!--[if lte IE 6]>" . "\n" . "  <style type=\"text/css\">\n" . "    .pngfile {\n" . "      behavior:url('" . JURI::root() . "media/joomgallery/js/pngbehavior.htc') !important;\n" . "    }\n" . "  </style>\n" . "  <![endif]-->" . "\n" . "  <!-- End Conditional Style -->";
     $this->_doc->addCustomTag($pngbehaviour);
     // Set documents meta data taken from menu entry definition
     $params = $this->_mainframe->getParams();
     if ($params->get('menu-meta_description')) {
         $this->_doc->setDescription($params->get('menu-meta_description'));
     }
     if ($params->get('menu-meta_keywords')) {
         $this->_doc->setMetadata('keywords', $params->get('menu-meta_keywords'));
     }
     if ($params->get('robots')) {
         $this->_doc->setMetadata('robots', $params->get('robots'));
     }
     // Page title
     $pagetitle = JoomHelper::addSitenameToPagetitle($this->_doc->getTitle());
     $this->_doc->setTitle($pagetitle);
     // Check for alternative layout only if this is not the active menu item
     $active = $this->_mainframe->getMenu()->getActive();
     if (!$active || strpos($active->link, 'view=' . $this->getName()) === false) {
         // Get the default layout from the configuration
         if ($layout = $this->_config->get('jg_alternative_layout')) {
             $this->setLayout($layout);
         }
     }
 }
Example #6
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.0
  */
 public function __construct()
 {
     $this->_mainframe = JFactory::getApplication();
     $this->_db = JFactory::getDbo();
     $this->_config = JoomConfig::getInstance();
     $this->_ambit = JoomAmbit::getInstance();
     $this->logfilename = 'migration.' . $this->migration . '.php';
     require_once JPATH_COMPONENT . '/helpers/refresher.php';
     $this->refresher = new JoomRefresher(array('task' => 'migrate&migration=' . $this->migration));
     JLog::addLogger(array('text_file' => $this->logfilename, 'text_entry_format' => '{DATETIME}  {PRIORITY}  {MESSAGE}'), JLog::ALL, array('migration' . $this->migration));
     $this->newCatid = $this->_mainframe->getUserState('joom.migration.internal.new_catid', 1);
     $this->copyImages = $this->getStateFromRequest('copy_images', 'copy_images', $this->copyImages, 'boolean');
     $this->checkOwner = $this->getStateFromRequest('check_owner', 'check_owner', $this->checkOwner, 'boolean');
     $this->isCli = $this->getStateFromRequest('is_cli', 'is_cli', $this->isCli, 'boolean');
     // Connect to second database if necessary
     $db = $this->getStateFromRequest('db2', 'db', array(), 'array');
     if (JArrayHelper::getValue($db, 'enabled', false, 'boolean')) {
         $driver = JArrayHelper::getValue($db, 'db_type', 'mysqli', 'string');
         $host = JArrayHelper::getValue($db, 'db_host', 'localhost', 'string');
         $name = JArrayHelper::getValue($db, 'db_name', '', 'string');
         $user = JArrayHelper::getValue($db, 'db_user', '', 'string');
         $password = JArrayHelper::getValue($db, 'db_pass', '', 'string');
         $prefix = $this->getStateFromRequest('prefix', 'prefix', '', 'cmd');
         if (!$prefix) {
             $prefix = JArrayHelper::getValue($db, 'prefix', '', 'cmd');
             $this->setState('prefix', $prefix);
         }
         $options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $name, 'prefix' => $prefix);
         $this->_db2 = JDatabaseDriver::getInstance($options);
         $this->otherDatabase = true;
     } else {
         $this->_db2 = $this->_db;
     }
 }
Example #7
0
 /**
  * Construct HTML List of selectable categories
  *
  * @param   int     $currentcat catid, current cat or parent
  * @param   string  $cname      Name of the HTML element
  * @param   string  $extra      Some extra code to add to the element
  * @param   int     $orig       A category to ignore (its sub-categories will be filtered out, too)
  * @param   string  $separator  A string with which the categories will be separated in the category paths
  * @param   string  $task       Null/filter
  * @param   string  $action     Action to check for each category
  * @param   mixed   $idtag      String to use as id tag for the select box
  * @return  string  The HTML output
  * @since   1.0.0
  */
 public static function categoryList($currentcat, $cname = 'catid', $extra = null, $orig = null, $separator = '- ', $task = null, $action = 'core.create', $idtag = false)
 {
     $attribs = 'class="inputbox"';
     if ($extra) {
         // Add the default class only if no class is given by caller
         if (strpos($extra, 'class=') === false && strpos($extra, 'class =') === false) {
             $attribs .= ' ' . $extra;
         } else {
             $attribs = $extra;
         }
     }
     if (JoomConfig::getInstance()->get('jg_ajaxcategoryselection')) {
         $app = JFactory::getApplication();
         if (!$idtag) {
             $idtag = $cname;
         }
         if ($currentcat == 1) {
             $name = '-';
         } else {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->select('name')->from(_JOOM_TABLE_CATEGORIES)->where('cid = ' . (int) $currentcat);
             $db->setQuery($query);
             $name = $db->loadResult();
         }
         $matches = array();
         $onchange = '';
         if (preg_match('/onchange="(.*)"/', $attribs, $matches)) {
             $onchange = $matches[1];
             $attribs = trim(str_replace($matches[0], '', $attribs));
         }
         $attribs = preg_replace('/size="(.*)"/', '', $attribs);
         JText::script('COM_JOOMGALLERY_COMMON_REQUEST_ERROR');
         JText::script('COM_JOOMGALLERY_COMMON_CATEGORIES_NO_RESULTS');
         JHtml::_('behavior.framework', true);
         $doc = JFactory::getDocument();
         if ($app->isSite()) {
             $url = JRoute::_('index.php?option=' . _JOOM_OPTION . '&task=categories.getcategories', false);
             $doc->addStyleSheet(JoomAmbit::getInstance()->getStyleSheet('joomgallery.css'));
         } else {
             $url = JRoute::_('index.php?option=' . _JOOM_OPTION . '&controller=categories&task=getcategories', false);
             $doc->addStyleSheet(JoomAmbit::getInstance()->getStyleSheet('admin.joomgallery.css'));
         }
         $doc->addScript(JoomAmbit::getInstance()->getScript('categories.js'));
         $jscript = '
     <script type="text/javascript">
       var ' . $idtag . 'search;
       window.addEvent(\'domready\', function() {
         ' . $idtag . 'search = new JoomGallerySearchCategories({
           \'inputbox\': \'jg-' . $idtag . '-input\',
           \'resultbox\': \'jg-' . $idtag . '-results\',
           \'hiddenbox\': \'' . $idtag . '\',
           \'moreresults\': \'jg-' . $idtag . '-more-results\',
           \'defaultcontent\': \'' . ($name ? addslashes($name) : JText::_('COM_JOOMGALLERY_COMMON_ALL', true)) . '\',
           \'variablename\': \'' . $idtag . 'search\',
           \'action\': \'' . ($task ? '' : $action) . '\',
           \'filter\': ' . (int) $orig . ',
           \'current\': ' . (int) $currentcat . ',
           \'onchange\': \'' . str_replace('\'', '\\\'', $onchange) . '\',
           \'url\': \'' . $url . '&format=json\'
         });
       });
     </script>';
         return $jscript . '
     <input type="hidden" name="' . $cname . '" value="' . $currentcat . '" id="' . $idtag . '" ' . $attribs . ' />
     <input type="text" name="jg-input-' . $cname . '" value="' . ($name ? addslashes($name) : JText::_('COM_JOOMGALLERY_COMMON_ALL')) . '" id="jg-' . $idtag . '-input" ' . str_replace('validate-joompositivenumeric', '', $attribs) . ' />
     <div id="jg-' . $idtag . '-results" class="jg-category-results">
       <div id="jg-' . $idtag . '-more-results" class="jg-category-more-results" onclick="' . $idtag . 'search.loadMore();return false;">
         <a href="#" onclick="return false;">
           ' . JText::_('COM_JOOMGALLERY_COMMON_CATEGORIES_MORE_RESULTS') . '</a>
       </div>
     </div>';
     }
     $user = JFactory::getUser();
     $ambit = JoomAmbit::getInstance();
     $cats = $ambit->getCategoryStructure(true);
     $options = array();
     //$filter         = ($cname == 'parent_id' && $orig != null) ? true : false;
     $origfound = false;
     $filtercatkeys = array();
     $paths = array();
     $action2 = false;
     if ($action == 'joom.upload') {
         $action2 = 'joom.upload.inown';
     }
     if ($action == 'core.create') {
         $action2 = 'joom.create.inown';
     }
     if ($action == 'core.edit') {
         $action2 = 'core.edit.own';
     }
     foreach ($cats as $key => $cat) {
         // Avoid 'ROOT' entry in drop down list in the case that no category has been created yet
         if ($cat->cid === 0) {
             continue;
         }
         // Check whether a certain category and it's sub-categories
         // have to be filtered out of the list
         if ($orig) {
             if (!$origfound) {
                 if ($cat->cid == $orig) {
                     $origfound = true;
                     $filtercatkeys[$orig] = true;
                 }
             } else {
                 if (isset($filtercatkeys[$cat->parent_id])) {
                     $filtercatkeys[$key] = true;
                 }
             }
         }
         if ($cat->parent_id > 1) {
             //$paths[$key] = $paths[$cat->parent_id].$separator.$cat->name;
             $paths[$key] = $paths[$cat->parent_id] + 1;
         } else {
             $paths[$key] = 0;
         }
         if ($task == 'filter' || $key == $currentcat || !isset($filtercatkeys[$key]) && ($user->authorise($action, _JOOM_OPTION . '.category.' . $key) || $action2 && $cat->owner == $user->get('id') && $user->authorise($action2, _JOOM_OPTION . '.category.' . $cat->cid))) {
             // Build select option for that category
             $options[$key] = new stdClass();
             $options[$key]->cid = $cat->cid;
             $options[$key]->path = str_repeat($separator, $paths[$key]) . $cat->name;
         }
     }
     if ($task == 'filter' || $currentcat == 0 || $action == 'core.create' && $user->authorise($action, _JOOM_OPTION)) {
         $rootcat = new stdClass();
         $rootcat->cid = '';
         $rootcat->path = $task == 'filter' ? JText::_('COM_JOOMGALLERY_COMMON_ALL') : '';
         array_unshift($options, $rootcat);
     }
     $count = count($options);
     if (!$count || $count == 1 && !reset($options)->cid) {
         // Return a hidden field in order to avoid JavaScript errors
         return '<input type="hidden" name="' . $cname . '"' . ($idtag ? ' id="' . $idtag . '"' : '') . ' value="" />
   <input type="text" readonly="readonly" class="readonly" value="-" />';
     }
     // Sort the array with key pathname if more than one element
     if ($count > 1) {
         //usort($options, array('JHTMLJoomSelect', 'sortCatArray'));
     }
     $output = JHTML::_('select.genericlist', $options, $cname, $attribs, 'cid', 'path', $currentcat, $idtag);
     return $output;
 }
Example #8
0
 /**
  * Creates the HTML output to display a minithumb for a category
  *
  * @param   object  $cat          Category object holding the category data
  * @param   string  $class        CSS class name for minithumb styling
  * @param   boolean $linkattribs  Link attributes for creating a link on the minithumb, if false no link will created
  * @param   boolean $showtip      Shows the thumbnail as tip on hoovering above minithumb
  * @return  string  The HTML output
  * @since   1.5.7
  */
 public static function minithumbcat($cat, $class = null, $linkattribs = null, $showtip = true)
 {
     $ambit = JoomAmbit::getInstance();
     $config = JoomConfig::getInstance();
     $html = '';
     $linked = $linkattribs ? true : false;
     if (isset($cat->thumbnail) && !empty($cat->thumbnail)) {
         $thumb = $ambit->getImg('thumb_path', $cat->thumbnail, null, $cat->cid);
         jimport('joomla.filesystem.file');
         if (JFile::exists($thumb)) {
             $isSite = JFactory::getApplication()->isSite();
             $imginfo = getimagesize($thumb);
             $url = $ambit->getImg('thumb_url', $cat->thumbnail, null, $cat->cid);
             // Clean category name
             $catname = str_replace('&nbsp;', '', $cat->name);
             $catname = trim(str_replace('&raquo;', '', $catname));
             if ($showtip) {
                 if ($isSite) {
                     $html .= '<span' . JHtml::_('joomgallery.tip', htmlspecialchars('<img src="' . $url . '" width="' . $imginfo[0] . '" height="' . $imginfo[1] . '" alt="' . $cat->name . '" />', ENT_QUOTES, 'UTF-8'), null, true, false) . '>';
                 } else {
                     $html .= '<span class="hasTooltip" title="' . htmlspecialchars('<img src="' . $url . '" width="' . $imginfo[0] . '" height="' . $imginfo[1] . '" alt="' . $catname . '" />', ENT_QUOTES, 'UTF-8') . '">';
                 }
             }
             if ($linked) {
                 if ($isSite) {
                     $html .= '<a href="' . JRoute::_('index.php?view=category&catid=' . $cat->cid) . '">';
                 } else {
                     $html .= '<a ' . $linkattribs . '">';
                 }
             }
             $html .= '<img src="' . $url . '" alt="' . htmlspecialchars($catname, ENT_QUOTES, 'UTF-8') . '"';
             if ($class !== null) {
                 $html .= ' class="' . $class . '"';
             }
             $html .= '>';
             if ($linked) {
                 $html .= '</a>';
             }
             if ($showtip) {
                 $html .= '</span>';
             }
         }
     }
     return $html;
 }
Example #9
0
    /**
     * Fetches an update zip file from JoomGallery server and extracts it
     *
     * @param   string  $url  The URL to the zip to fetch and extract
     * @return  void
     * @since   1.5.0
     */
    public static function autoUpdate($url)
    {
        $mainframe = JFactory::getApplication();
        if (!$url || !extension_loaded('curl')) {
            $mainframe->redirect('index.php?option=' . _JOOM_OPTION, JText::_('COM_JOOMGALLERY_ADMENU_MSG_ERROR_FETCHING_ZIP'), 'error');
        }
        $ambit = JoomAmbit::getInstance();
        // Create curl resource
        $ch = curl_init(strtolower($url));
        // Some settings for curl
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: JoomGallery v3'));
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // Create the zip file
        jimport('joomla.filesystem.file');
        $config = JoomConfig::getInstance();
        $output = curl_exec($ch);
        JFile::write($ambit->get('temp_path') . 'update.zip', $output);
        // Close curl resource to free up system resources
        curl_close($ch);
        // Delete files and folders from previous updates
        $folder = $ambit->get('temp_path') . 'update';
        if (JFolder::exists($folder)) {
            JFolder::delete($folder);
        }
        // Extract the zip file
        jimport('joomla.filesystem.archive');
        if (!JArchive::extract($ambit->get('temp_path') . 'update.zip', $folder)) {
            $mainframe->redirect('index.php?option=' . _JOOM_OPTION, JText::_('Error extracting the zip'), 'error');
        }
        // Copy an index.html into the created folder if there isn't already one
        if (!JFile::exists($folder . '/index.html')) {
            $src = JPATH_ROOT . '/media/joomgallery/index.html';
            $dest = $folder . '/index.html';
            JFile::copy($src, $dest);
        }
        $mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_ADMENU_REDIRECT_NOTE'), 'notice');
        // Let's redirect to do the rest
        ?>
    <form action="index.php" method="post" name="JoomUpdateForm">
      <input type="hidden" name="option" value="<?php 
        echo _JOOM_OPTION;
        ?>
" />
      <input type="hidden" name="controller" value="control" />
      <input type="hidden" name="task" value="doinstallation" />
      <?php 
        echo JHtml::_('form.token');
        ?>
    </form>
    <script type="text/javascript">
      document.JoomUpdateForm.submit();
    </script>
<?php 
    }
Example #10
0
 /**
  * Returns all categories and their sub-categories with published or no images
  *
  * @param   int     $cat          Category ID
  * @param   boolean $rootcat      True, if $cat shall also be returned as an
  *                                element of the array
  * @param   boolean $noimgcats    True if @return shall also include categories
  *                                with no images
  * @param   boolean $all          True if all categories shall be selected, defaults to true
  * @param   boolean $nohiddencats True, if sub-categories of hidden categories should be
  *                                filtered out, defaults to false
  * @return  array   An array of found categories
  * @since   1.5.5
  */
 public static function getAllSubCategories($cat, $rootcat = false, $noimgcats = false, $all = true, $nohiddencats = false)
 {
     // Initialise variables
     $cat = (int) $cat;
     $parentcats = array();
     $parentcats[$cat] = true;
     $branchfound = false;
     $allsubcats = array();
     // Get category structure from ambit
     $ambit = JoomAmbit::getInstance();
     $cats = $ambit->getCategoryStructure($all);
     $stopindex = count($cats);
     $keys = array_keys($cats);
     $startindex = array_search($cat, $keys);
     if ($startindex === false) {
         return $allsubcats;
     }
     // Find all cats which are subcategories of cat
     $hidden = array();
     for ($j = $startindex + 1; $j < $stopindex; $j++) {
         $i = $keys[$j];
         $parentcat = $cats[$i]->parent_id;
         if (isset($parentcats[$parentcat])) {
             $parentcats[$i] = true;
             $branchfound = true;
             // Don't include hidden sub-categories
             if ($nohiddencats) {
                 if ($cats[$i]->hidden) {
                     $hidden[$i] = true;
                 } else {
                     if (isset($hidden[$cats[$i]->parent_id])) {
                         $hidden[$i] = true;
                     }
                 }
             }
             if (!isset($hidden[$i])) {
                 if (!$noimgcats) {
                     // Only categories with images
                     if ($cats[$i]->piccount > 0) {
                         // Subcategory with images in array
                         $allsubcats[] = $i;
                     }
                 } else {
                     $allsubcats[] = $i;
                 }
             }
         } else {
             if ($branchfound) {
                 // Branch has been processed completely
                 break;
             }
         }
     }
     // Add rootcat
     if ($rootcat) {
         if (!$noimgcats) {
             // Includes images
             if ($cats[$cat]->piccount > 0) {
                 $allsubcats[] = $cat;
             }
         } else {
             $allsubcats[] = $cat;
         }
     }
     return $allsubcats;
 }
Example #11
0
 /**
  * Counts images and hits in gallery or a category and their sub-categories
  *
  * @param   int     $cat      Category ID or 0 to return images/hits of gallery
  * @param   boolean $rootcat  True to count the images/hits also in category = $cid
  * @return  array   0 = Number of images in categories->subcategories....
  *                  1 = Number of hits in categories->subcategories....
  * @since   1.5.7
  */
 public static function getNumberOfImgHits($cat = 0, $rootcat = true)
 {
     // Initialise variables
     $cat = (int) $cat;
     $imgHitsarr = array();
     $imgcount = 0;
     $hitcount = 0;
     // Get category structure from ambit
     $ambit = JoomAmbit::getInstance();
     $cats = $ambit->getCategoryStructure();
     if ($cat == 0) {
         // Count all images and hits in gallery
         foreach ($cats as $category) {
             $imgcount += $category->piccount;
             $hitcount += $category->hitcount;
         }
     } else {
         $branchfound = false;
         $parentcats = array();
         $parentcats[$cat] = true;
         $keys = array_keys($cats);
         $startindex = array_search($cat, $keys);
         $stopindex = count($cats);
         if ($rootcat && isset($cats[$cat])) {
             $imgcount += $cats[$cat]->piccount;
             $hitcount += $cats[$cat]->hitcount;
         }
         // Count all images in branch
         $hidden = array();
         for ($j = $startindex + 1; $j < $stopindex; $j++) {
             $i = $keys[$j];
             $parentcat = $cats[$i]->parent_id;
             if (isset($parentcats[$parentcat])) {
                 $parentcat = $i;
                 $parentcats[$parentcat] = true;
                 // Don't count images and hits of hidden categories
                 if ($cats[$i]->hidden) {
                     $hidden[$i] = true;
                 } else {
                     if (isset($hidden[$cats[$i]->parent_id])) {
                         $hidden[$i] = true;
                     }
                 }
                 if (!isset($hidden[$i])) {
                     $hitcount += $cats[$i]->hitcount;
                     $imgcount += $cats[$i]->piccount;
                 }
                 $branchfound = true;
             } else {
                 if ($branchfound) {
                     // Branch has been processed completely
                     break;
                 }
             }
         }
     }
     $imgHitsarr[0] = number_format($imgcount, 0, JText::_('COM_JOOMGALLERY_COMMON_DECIMAL_SEPARATOR'), JText::_('COM_JOOMGALLERY_COMMON_THOUSANDS_SEPARATOR'));
     $imgHitsarr[1] = number_format($hitcount, 0, JText::_('COM_JOOMGALLERY_COMMON_DECIMAL_SEPARATOR'), JText::_('COM_JOOMGALLERY_COMMON_THOUSANDS_SEPARATOR'));
     return $imgHitsarr;
 }
Example #12
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.5.5
  */
 public function JoomInterface()
 {
     // Load JoomGallery defines
     require_once JPATH_ADMINISTRATOR . '/components/com_joomgallery/includes/defines.php';
     // Register some classes
     JLoader::register('JoomConfig', JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/helpers/config.php');
     JLoader::register('JoomHelper', JPATH_ROOT . '/components/' . _JOOM_OPTION . '/helpers/helper.php');
     JLoader::register('JoomAmbit', JPATH_ROOT . '/components/' . _JOOM_OPTION . '/helpers/ambit.php');
     // Add include path for JoomGallery tables
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/tables');
     // Add include path for JoomGallery HTML functions
     JHtml::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . _JOOM_OPTION . '/helpers/html');
     $this->_mainframe = JFactory::getApplication();
     $this->_db = JFactory::getDBO();
     $this->_ambit = JoomAmbit::getInstance();
     $this->_jg_config = JoomConfig::getInstance();
     $this->_user = JFactory::getUser();
     // Include language for display
     $language = JFactory::getLanguage();
     $language->load(_JOOM_OPTION);
     // Load JoomGallery plugins
     JPluginHelper::importPlugin('joomgallery');
     // Set some default values for options given in global JG config (may be overridden)
     $this->_config['showhits'] = $this->_jg_config->get('jg_showhits');
     $this->_config['showdownloads'] = $this->_jg_config->get('jg_showdownloads');
     $this->_config['showpicasnew'] = $this->_jg_config->get('jg_showpicasnew');
     $this->_config['showtitle'] = $this->_jg_config->get('jg_showtitle');
     $this->_config['showauthor'] = $this->_jg_config->get('jg_showauthor');
     $this->_config['showrate'] = $this->_jg_config->get('jg_showcatrate');
     $this->_config['shownumcomments'] = $this->_jg_config->get('jg_showcatcom');
     $this->_config['showdescription'] = $this->_jg_config->get('jg_showcatdescription');
     $this->_config['openimage'] = $this->_jg_config->get('jg_detailpic_open');
     // Further defaults (not given by JG config)
     // - Category path links to category
     $this->_config['showcatlink'] = 1;
     // - Comma-separated list of categories to filter from (empty: all categories, default)
     $this->_config['categoryfilter'] = '';
     // - Display last comment (see Module JoomImages) not implemented yet!
     $this->_config['showlastcomment'] = 0;
     // - Make use of hidden images and images in hidden categories
     $this->_config['showhidden'] = 0;
     // Store the config for being able to reset it later on (if useful)
     $this->storeConfig();
 }
Example #13
0
if ($displayData->params->get('show_btm_modules')) {
    ?>
  <div class="jg-modules-btm">
<?php 
    foreach ($displayData->modules['btm'] as $module) {
        ?>
    <div class="jg-module-btm">
      <?php 
        echo $module->rendered;
        ?>
    </div>
<?php 
    }
    ?>
  </div>
<?php 
}
if ($displayData->params->get('show_credits')) {
    ?>
  <div class="jg-powered-by text-center">
    <a href="http://www.joomgallery.net" target="_blank">
      <img src="<?php 
    echo JoomAmbit::getInstance()->getIcon('powered_by.gif');
    ?>
" alt="Powered by JoomGallery" />
    </a>
  </div>
<?php 
}
?>
</div>
Example #14
0
    /**
     * Make a redirect
     *
     * @param   int     $remaining  Number of remaining steps
     * @param   string  $task       The task which will be called after the redirect
     * @param   string  $msg        An optional message which will be enqueued (this is currently disabled)
     * @param   string  $type       Type of the message (one of 'message', 'notice', 'error')
     * @param   string  $controller The controller which will be called after the redirect
     * @return  void
     * @since   1.5.5
     */
    public function refresh($remaining = null, $task = null, $msg = null, $type = null, $controller = null)
    {
        if ($remaining) {
            $this->_remaining = $remaining;
        }
        if ($this->_msg && is_null($task)) {
            $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_COMMON_REDIRECT'));
        }
        if (!$task) {
            $task = $this->_task;
        }
        if (!$controller) {
            $controller = $this->_controller;
        }
        if ($msg) {
            $this->_mainframe->enqueueMessage($msg, $type);
        }
        if (!$this->_msg || $msg) {
            // Persist messages if they exist
            $messages = $this->_mainframe->getMessageQueue();
            if (count($messages)) {
                $session = JFactory::getSession();
                $session->set('application.queue', $messages);
            }
        }
        $url = 'index.php?option=' . _JOOM_OPTION . '&controller=' . $controller . '&task=' . $task;
        $onclick = 'document.location.href=\'' . $url . '\';';
        $buffer = '';
        if ($buffer = ob_get_contents()) {
            ob_end_clean();
        }
        echo '<?xml version="1.0" encoding="utf-8"?' . '>';
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <!--<link rel="stylesheet" href="<?php 
        echo JoomAmbit::getInstance()->getStyleSheet('admin.joomgallery.css');
        ?>
" type="text/css" />
    <link href="templates/<?php 
        echo $this->_mainframe->getTemplate();
        ?>
/css/template.css" rel="stylesheet" type="text/css" />-->
    <link href="<?php 
        echo JUri::root();
        ?>
media/jui/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="<?php 
        echo JUri::root();
        ?>
media/jui/css/bootstrap-extended.css" rel="stylesheet" type="text/css" />
    <?php 
        if (JFactory::getLanguage()->isRTL()) {
            ?>
    <link href="<?php 
            echo JUri::root();
            ?>
media/jui/css/bootstrap-rtl.css" rel="stylesheet" type="text/css" />
    <?php 
        }
        ?>
    <style type="text/css">
      body{
        margin-top:30px;
      }
<?php 
        if ($this->_showprogress) {
            ?>
      .bar{
        width:<?php 
            echo floor(($this->_total - $this->_remaining) / $this->_total * 100);
            ?>
% !important;
      }
<?php 
        }
        ?>
    </style>
    <title><?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_REFRESHER_IN_PROGRESS');
        ?>
</title>
  </head>
  <body>
    <div class="row-fluid">
      <div class="offset2 span8 well">
        <div class="alert alert-info">
          <?php 
        echo JText::_('COM_JOOMGALLERY_COMMON_REFRESHER_PLEASE_WAIT');
        if ($this->_name) {
            ?>
          <br />
          <?php 
            echo JText::sprintf('COM_JOOMGALLERY_COMMON_REFRESHER_CURRENT_TASK', '<span style="color:green;">' . $this->_name . '</span>');
        }
        ?>
        </div>
        <p class="center"><img src="<?php 
        echo JUri::root();
        ?>
media/system/images/modal/spinner.gif" alt="Spinner" width="16" height="16" /></p>
<?php 
        if ($this->_showprogress) {
            ?>
        <div class="progress progress-striped active" title="<?php 
            echo JText::sprintf('COM_JOOMGALLERY_COMMON_REFRESHER_PROGRESSBAR', $this->_maxtime);
            ?>
">
          <div class="bar"></div>
        </div>
        <div class="small muted center"><?php 
            echo JText::sprintf('COM_JOOMGALLERY_COMMON_REFRESHER_PROGRESSBAR', $this->_maxtime);
            ?>
</div>
<?php 
        }
        if ($this->_msg) {
            $doc = JFactory::getDocument();
            $renderer = $doc->loadRenderer('message');
            echo $renderer->render('');
        }
        ?>
      </div>
    </div>
    <div><?php 
        echo $buffer;
        ?>
</div>
    <script type="text/javascript"><?php 
        echo $onclick;
        ?>
</script>
  </body>
</html><?php 
        $this->_mainframe->close();
    }
Example #15
0
 /**
  * Constructor
  *
  * @return  void
  * @since   1.0.0
  */
 public function __construct()
 {
     $this->_mainframe = JFactory::getApplication();
     $this->_config = JoomConfig::getInstance();
     $this->_ambit = JoomAmbit::getInstance();
     $this->_user = JFactory::getUser();
     $this->_db = JFactory::getDBO();
     $this->debug = $this->_mainframe->getUserStateFromRequest('joom.upload.debug', 'debug', false, 'post', 'bool');
     $this->_debugoutput = $this->_mainframe->getUserStateFromRequest('joom.upload.debugoutput', 'debugoutput', '', 'post', 'string');
     $this->catid = $this->_mainframe->getUserStateFromRequest('joom.upload.catid', 'catid', 0, 'int');
     $this->imgtitle = $this->_mainframe->getUserStateFromRequest('joom.upload.title', 'imgtitle', '', 'string');
     $this->counter = $this->getImageNumber();
     $this->_site = $this->_mainframe->isSite();
     // TODO Parameter in JoomGallery configuration neccessary ?
     // Create folder for image chunks
     $this->chunksFolder = $this->_mainframe->getCfg('tmp_path') . '/joomgallerychunks';
     if (!JFolder::exists($this->chunksFolder)) {
         JFolder::create($this->chunksFolder);
         JoomFile::copyIndexHtml($this->chunksFolder);
     }
 }