/** * class constructor * */ function __construct($action) { $this->_mainframe =& JFactory::getApplication('administrator'); $this->_db =& JFactory::getDBO(); $this->_config = Joom_GetConfig(); $this->logfilename = 'migration.log.txt'; //Check the maximum execution time of the script //set secure setting of the real execution time $max_execution_time = @ini_get('max_execution_time'); //try to set the max execution time to 60s if lower than //if not succesful the return value will be the old time, so use this if ($max_execution_time < 60) { @ini_set('max_execution_time', '60'); $max_execution_time = @ini_get('max_execution_time'); } $this->max_execution_time = $max_execution_time; $this->maxtime = (int) $this->max_execution_time * 0.8; $this->starttime = time(); switch ($action) { case 'start': $this->Joom_Migrate_Start(); $this->Joom_Migrate_FirstStep(); break; case 'continue': $this->Joom_Migrate_OpenLogfile('a'); $this->Joom_Migrate_WriteLogfile('*****************************'); $this->Joom_Migrate_Continue(); break; default: //check $this->Joom_Migrate_Check(); break; } }
function Joom_ShowMenu_HTML() { $database =& JFactory::getDBO(); $document =& JFactory::getDocument(); $config = Joom_GetConfig(); jimport('joomla.html.pane'); $document->addStyleDeclaration(' .joom_cpanel img { padding:21px 0px !important; }'); $database->setQuery("SELECT id\n FROM #__components\n WHERE link = 'option=" . _JOOM_OPTION . "' AND parent=''"); $id = $database->loadResult(); $database->setQuery("SELECT *\n FROM #__components\n WHERE parent='" . $id . "' ORDER BY id ASC"); $rows = $database->loadObjectList(); ?> <table border="0" cellpadding="10" style="margin-right:auto; margin-left:auto;" class="adminform"> <tbody> <tr> <td width="55%" valign="top"> <div id="cpanel" class="joom_cpanel"> <?php foreach ($rows as $row) { Joom_QuickIconButton($row->admin_menu_link, $row->admin_menu_img, $row->name); } ?> </div> </td> <td width="45%" valign="top"> <?php $modules =& JModuleHelper::getModules('joom_cpanel'); // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. $pane =& JPane::getInstance('sliders', array('allowAllClose' => true)); echo $pane->startPane("content-pane"); if ($config->jg_checkupdate) { Joom_ShowDatedExtensions($pane); } foreach ($modules as $module) { echo $pane->startPanel($module->title, 'cpanel-panel-' . $module->name); echo JModuleHelper::renderModule($module); echo $pane->endPanel(); } echo $pane->endPane(); if ($config->jg_checkupdate) { if (!count(Joom_CheckUpdate())) { ?> <div style=" weight:100%; text-align:center; color:#008000; font-weight:bold;"> <?php echo JText::_('JGA_SYSTEM_UPTODATE'); ?> </div> <?php } } ?> </td> </tr> </tbody> </table> <?php }
/** * returns the currently installed version of JoomGallery * * @return string Version */ function Joom_GetGalleryVersion() { static $version; if (!isset($version)) { $config = Joom_GetConfig(); // do not read RSS file if update check is disabled if ($config->jg_checkupdate) { $extensions = Joom_GetInstalledExtensions(); if (isset($extensions['JoomGallery']['installed_version'])) { $version = $extensions['JoomGallery']['installed_version']; } else { $version = 'not found'; } } else { $xml_file = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joomgallery' . DS . 'joomgallery.xml'; if (file_exists($xml_file)) { $xml =& JFactory::getXMLParser('simple'); $xml->loadFile($xml_file); // TODO: error handling, maybe there's no 'version' tag? $version_tag = $xml->document->getElementByPath('version'); $version = $version_tag->data(); } } } return $version; }
/** * recreates thumbnails of the selected images * if original image is existent, detail image will be recreated, too. */ function Joom_Recreate() { jimport('joomla.filesystem.file'); $mainframe =& JFactory::getApplication('administrator'); $database =& JFactory::getDBO(); $config = Joom_GetConfig(); $cids = $mainframe->getUserStateFromRequest('joom.recreate.ids', 'id', array(), 'array'); $thumb_count = $mainframe->getUserState('joom.recreate.thumbcount'); $img_count = $mainframe->getUserState('joom.recreate.imgcount'); $row = new mosjoomgallery($database); // before first loop check for selected images if (is_null($thumb_count) and !count($cids)) { return array(false, JText::_('JGA_NO_IMAGES_SELECTED')); } //Check the maximum execution time of the script //set secure setting of the real execution time $max_execution_time = @ini_get('max_execution_time'); //try to set the max execution time to 60s if lower than //if not succesful the return value will be the old time, so use this if ($max_execution_time < 60) { #@ini_set('max_execution_time','60'); $max_execution_time = @ini_get('max_execution_time'); } $maxtime = (int) $max_execution_time * 0.8; $starttime = time(); $debugoutput = ''; //loop through selected images foreach ($cids as $key => $cid) { $row->load($cid); //catpath for category $catpath = Joom_GetCatPath($row->catid); $orig = JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $row->imgfilename; $img = JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $row->imgfilename; $thumb = JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $row->imgthumbname; //check if there is an original image if (JFile::exists($orig)) { $orig_existent = true; } else { //if not, use detail image to create thumbnail $orig_existent = false; if (JFile::exists($img)) { $orig = $img; } else { JError::raiseWarning(100, JText::sprintf('JGA_IMG_NOT_EXISTENT', $img)); $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.count', null); return false; } } //TODO: move image into a trash instead of deleting immediately for possible rollback JFile::delete($thumb); $return = Joom_ResizeImage($debugoutput, $orig, $thumb, $config->jg_useforresizedirection, $config->jg_thumbwidth, $config->jg_thumbheight, $config->jg_thumbcreation, $config->jg_thumbquality); if (!$return) { JError::raiseWarning(100, JText::sprintf('JGA_COULD_NOT_CREATE_THUMB', $thumb)); $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.thumbcount', null); $mainframe->setUserState('joom.recreate.imgcount', null); return false; } $mainframe->enqueueMessage(JText::sprintf('JGA_SUCCESSFULLY_CREATED_THUMB', $row->id, $row->imgtitle)); $thumb_count++; if ($orig_existent) { //TODO: move image into a trash instead of deleting immediately for possible rollback JFile::delete($img); $return = Joom_ResizeImage($debugoutput, $orig, $img, false, $config->jg_maxwidth, false, $config->jg_thumbcreation, $config->jg_picturequality, true); if (!$return) { JError::raiseWarning(100, JText::sprintf('JGA_COULD_NOT_CREATE_IMG', $img)); $this->_mainframe->setUserState('joom.recreate.cids', array()); $this->_mainframe->setUserState('joom.recreate.thumbcount', null); $this->_mainframe->setUserState('joom.recreate.imgcount', null); return false; } } $mainframe->enqueueMessage(JText::sprintf('JGA_SUCCESSFULLY_CREATED_IMG', $row->id, $row->imgtitle)); $img_count++; unset($cids[$key]); //check remaining time $timeleft = -(time() - $starttime - $maxtime); if ($timeleft <= 0 and count($cids)) { $mainframe->setUserState('joom.recreate.cids', $cids); $mainframe->setUserState('joom.recreate.thumbcount', $thumb_count); $mainframe->setUserState('joom.recreate.imgcount', $img_count); $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&task=recreate', JText::_('JGA_REDIRECT')); } } $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.thumbcount', null); $mainframe->setUserState('joom.recreate.imgcount', null); return array($thumb_count, $img_count); }