function display($tpl = null) { JHTML::_('behavior.mootools'); JHTML::_('behavior.keepalive'); $app =& JFactory::getApplication(); $document =& JFactory::getDocument(); $id = (int) JRequest::getVar('id'); $force_fixed_size = JRequest::getVar('fixed', 0); $name = JRequest::getVar('name'); $galleries = RokGallery_Model_GalleryTable::getAll(); $current_gallery = false; if (null != $id) { $current_gallery = RokGallery_Model_GalleryTable::getSingle($id); } if (null != $name) { $default_name = $name . rc__('ROKGALLERY_GALLERY_CREATE_DEFAULT_EXTENSION'); } $this->assign('default_name', $default_name); $this->assign('current_gallery_id', $id); $this->assign('force_fixed_size', $force_fixed_size); $this->assignRef('galleries', $galleries); $this->assignRef('current_gallery', $current_gallery); $this->assign('context', 'com_rokgallery.gallerymanager'); $this->setLayout('default'); parent::display($tpl); }
/** */ public function process() { try { /** @var $properties RokGallery_Job_Property_ImportFile[] */ $properties = $this->_job->getProperties(); $total_files = count($properties['files']); foreach ($properties['files'] as $key => &$file) { // keep bumping the time as log as a file doesnt take 30 seconds or more /** @var RokGallery_Job_Property_ImportFile $file */ if (!$this->_checkState($properties, rc__('ROKGALLERY_CREATE_UPDATE'))) { return; } if ($file->isCompleted()) { continue; } RokGallery_Doctrine::getConnection()->beginTransaction(); $gallery = RokGallery_Model_GalleryTable::getSingle($properties['galleryId']); if ($gallery === false) { throw new RokGallery_Job_Exception(rc__('ROKGALLERY_NOT_A_VALID_GALLERY')); } $full_file = RokGallery_Model_FileTable::getSingle($file->getId()); if ($full_file === false) { $file->setStatus(rc__('ROKGALLERY_UNABLE_TO_FIND_FILE')); $file->setError(true); RokGallery_Doctrine::getConnection()->commit(); continue; } if ($gallery && $full_file) { $full_file->updateSlicesForGallery($gallery); } $file->setCompleted(); $percent = (int) (($key + 1) / $total_files * 100); $this->_job->setProperties($properties); $this->_job->save(rc__('ROKGALLERY_UPDATED_GALLERY_SLICE_FOR_FILE_N', $full_file->title), $percent); RokGallery_Doctrine::getConnection()->commit(); } $this->_job->Complete(rc__('ROKGALLERY_GALLERY_UPDATE_COMPLETE')); if (RokGallery_Config::getOption(RokGallery_Config::OPTION_AUTO_CLEAR_SUCCESSFUL_JOBS, false)) { sleep(5); $this->_job->Delete(); } return; } catch (Exception $e) { RokGallery_Doctrine::getConnection()->rollback(); $this->_job->Error($e->getMessage()); return; } }
protected function getInput() { global $mainframe; //$db =& JFactory::getDBO(); $doc =& JFactory::getDocument(); $fieldName = $this->name; //$article =& JTable::getInstance('content'); //if ($value) { // $article->load($value); //} else { // $article->title = JText::_('Select a Gallery'); //} $js = "\r\n\t\tvar RokGalleryPopup = RokGalleryID = null;\r\n\t\tvar RokGalleryFixed = 0;\r\n\t\twindow.addEvent('domready', function(){\r\n\t\t\tvar mooVersion = MooTools.version;\r\n\t\t\tif (RokGalleryPopup) return;\r\n\t\t\t\r\n\t\t\tRokGalleryPopup = document.id('gallery-popup');\r\n\t\t\tRokGalleryID = document.id('" . $this->id . "_id');\r\n\t\t\tvar titles = ['#title' , 'input[name=name]', '#jform_title', '#jform_title'],\r\n\t\t\t\ttitle = '',\r\n\t\t\t\thref = RokGalleryPopup.get('href');\r\n\t\t\t\r\n\t\t\ttitles.each(function(selector){\r\n\t\t\t\tvar element = document.getElement(selector); if (element) title = element;\r\n\t\t\t});\r\n\t\t\t\r\n\t\t\tRokGalleryPopup.addEvent('mouseover', function(){\r\n\t\t\t\tRokGalleryUpdateTitle(title, href);\r\n\t\t\t});\r\n\t\t\t\r\n\t\t});\r\n\t\t\r\n\t\tfunction RokGalleryUpdateTitle(title, href){\r\n\t\t\ttitle = title.get('value') || '';\r\n\t\t\tvar args = '&id=' + RokGalleryID.get('value') + '&name=' + title + '&fixed=' + RokGalleryFixed + '&nocache=' + (Date.now());\r\n\t\t\t\r\n\t\t\tRokGalleryPopup.set('href', href + args);\r\n\t\t};"; $css = ".sbox-content-iframe#sbox-content {overflow: hidden !important;}"; if (!self::$js_loaded) { $doc->addScriptDeclaration($js); $doc->addStyleDeclaration($css); self::$js_loaded = true; } $link = 'index.php?option=com_rokgallery&view=gallerymanager&tmpl=component'; JHTML::_('behavior.modal', 'a.modal'); $gallery_name = ''; $value = $this->value; if (!empty($value)) { $gallery = RokGallery_Model_GalleryTable::getSingle((int) $this->value); if ($gallery === false) { $value = null; } else { $gallery_name = $gallery->name; } } $html = "\n" . '<div style="float: left;"><input style="background: #ffffff;" type="text" id="' . $this->id . '_name" value="' . htmlspecialchars($gallery_name, ENT_QUOTES, 'UTF-8') . '" disabled="disabled" /></div>'; // $html .= "\n <input class=\"inputbox modal-button\" type=\"button\" value=\"".JText::_('Select')."\" />"; $html .= '<div class="button2-left"><div class="blank"><a id="gallery-popup" class="modal" title="' . JText::_('Select a Gallery') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 420, y: 555}}">' . JText::_('Select') . '</a></div></div>' . "\n"; $html .= "\n" . '<input type="hidden" id="' . $this->id . '_id" name="' . $fieldName . '" value="' . $value . '" />'; return $html; }
/** * @param \RokGallery_Model_File $file * @param array $tags */ public static function removeTagsFromFile(RokGallery_Model_File &$file, array $tags = array()) { try { $query = Doctrine_Query::create()->delete('RokGallery_Model_FileTags ft')->where('ft.file_id = ?', $file->id)->andWhereIn('ft.tag', $tags); $query->execute(); foreach ($tags as $tag) { $galleries = RokGallery_Model_GalleryTable::getByTag($tag); foreach ($galleries as $gallery) { $slices = $file->getSlicesForGallery($gallery->id); if (is_array($slices)) { foreach ($slices as &$slice) { if (RokGallery_Config::getOption(RokGallery_Config::OPTION_GALLERY_REMOVE_SLICES, false)) { $file->unlink('Slices', array($slice->id)); $slice->delete(); } else { $slice->gallery_id = null; $slice->save(); } } } } } $file->save(); } catch (Exception $e) { throw $e; } }
} if (!defined('ROKGALLERYMODULE_ROOT')) { define('ROKGALLERYMODULE_ROOT', dirname(__FILE__)); } $include_file = @realpath(ROKGALLERYMODULE_ROOT . '/include.php'); $included_files = get_included_files(); if (defined('ROKGALLERY_ERROR_MISSING_LIBS')) { return; } if (!in_array($include_file, $included_files) && ($loaderrors = (require_once $include_file)) !== 'JOOMLA_ROKGALLERYMODULE_LIB_LOADED') { JError::raiseWarning(100, 'RokGallery Module: ' . implode('<br /> - ', $loaderrors)); return; } JHTML::_('behavior.mootools'); $doc =& JFactory::getDocument(); $gallery = RokGallery_Model_GalleryTable::getSingle($params->get('gallery_id', 0)); if ($gallery == false) { rc_e('ROKGALLERY_NO_GALLERY_DEFINED', $module->title, $module->id); return; } $passed_params = new stdClass(); $passed_params->link = $params->get('link', 0); $passed_params->title = $params->get('title', false); $passed_params->caption = $params->get('caption', 0); $passed_params->arrows = $params->get('arrows', 'onhover'); $passed_params->navigation = $params->get('navigation', 'none'); $passed_params->image_width = str_replace('px', '', $gallery->width); $passed_params->image_height = str_replace('px', '', $gallery->height); $passed_params->thumb_width = str_replace('px', '', $gallery->thumb_xsize); $passed_params->thumb_height = str_replace('px', '', $gallery->thumb_ysize); $passed_params->columns = $params->get('columns', 2);
function display($tpl = null) { JHTML::_('behavior.mootools'); $session = JFactory::getSession(); $session_namespace = 'com_rokgallery.site'; $app =& JFactory::getApplication(); $menu = $app->getMenu(); $activemenu = $menu->getActive(); if (empty($activemenu)) { $activemenu = $menu->getDefault(); $menu->setActive($activemenu->id); } /** @var $params JParameter */ $params =& $activemenu->params; foreach ($params->toArray() as $param_name => $param_value) { $this->assign($param_name, $param_value); } $document =& JFactory::getDocument(); $uri = JRequest::getURI(); // Get session variables $style = JRequest::getWord('style', $params->get('default_style')); $sort_direction = JRequest::getVar('sort_direction', $session->get('sort_direction', $params->get('default_sort_direction'), $session_namespace)); if ($params->get('show_sorts')) { $sort_by = JRequest::getVar('sort_by', $session->get('sort_by', $params->get('default_sort_by'), $session_namespace)); } else { $sort_by = JRequest::getVar('sort_by', $params->get('default_sort_by')); } if ($params->get('show_available_layouts', true)) { $layout = JRequest::getVar('layout', $session->get('layout', $this->getLayout(), $session_namespace)); } else { $layout = JRequest::getVar('layout', $this->getLayout()); } if ($layout == 'default') { $layout = $params->get('default_layout'); } $items_per_row = (int) $params->get($layout . '-items_per_row', 2); $items_per_page = (int) $params->get($layout . '-items_per_row', 2) * (int) $params->get($layout . '-rows_per_page', 2); $gallery_id = $params->get('gallery_id'); $current_page = JRequest::getInt('page', 1); $menu_item = JRequest::getInt('Itemid'); // Set session passed vars $session->set('gallery_id', $gallery_id, $session_namespace); $session->set('sort_by', $sort_by, $session_namespace); $session->set('sort_direction', $sort_direction, $session_namespace); $session->set('layout', $layout, $session_namespace); $session->set('last_page', $current_page, $session_namespace); $session->set('items_per_page', $items_per_page, $session_namespace); $base_page_url = RokCommon_URL::setParams('index.php', array('option' => 'com_rokgallery', 'view' => 'gallery')); $base_ajax_url = RokCommon_URL::setParams('index.php', array('option' => 'com_rokgallery', 'task' => 'ajax', 'format' => 'raw')); $model = new RokGallery_Site_GalleryModel($gallery_id, $sort_by, $sort_direction); $gallery = RokGallery_Model_GalleryTable::getSingle($gallery_id); if ($gallery == false) { return JError::raiseError(500, 'Gallery with ID "' . $params->get('gallery_id') . '" not found'); } $slices = $model->getPagedSlices($current_page, $items_per_page); $pager = $model->getPager(); if ($pager->getLastPage() < $current_page) { $current_page = $pager->getLastPage(); } $next_page = false; $prev_page = false; $pages = false; if ($pager->haveToPaginate()) { $ranger = $pager->getRange('Sliding', array('chunk' => $params->get('pages_in_shown_range'))); $pages = array(); foreach ($ranger->rangeAroundPage() as $page) { $page_class = new stdClass(); $page_class->page_num = $page; $page_class->active = $current_page == $page; if (!$page_class->active) { $page_class->link = JRoute::_(RokCommon_URL::updateParams($base_page_url, array('page' => $page))); } else { $page_class->link = '#'; } $pages[] = $page_class; if ($page == $pager->getNextPage() && $pager->getNextPage() != $current_page) { $next_page = $page_class; } if ($page == $pager->getPreviousPage() && $pager->getPreviousPage() != $current_page) { $prev_page = $page_class; } } } $images = array(); $passed_slices = array(); foreach ($slices as &$slice) { $images[] = $this->getPresentationImage($slice, $params, $base_page_url, $sort_by, $sort_direction); $passed_slices[$slice->id] = $slice; } $this->assignRef('images', $images); $this->assignRef('slices', $passed_slices); $layout_names = array('grid-3col' => rc__('ROKGALLERY_GRID_3COL'), 'grid-4col' => rc__('ROKGALLERY_GRID_4COL'), 'list-2col' => rc__('ROKGALLERY_LIST_2COL')); $layouts = $this->getList('layout', $layout, $current_page, $layout_names, $menu_item, $base_page_url); $this->assignRef('layouts', $layouts); $style_names = array('light' => rc__('ROKGALLERY_LIGHT'), 'dark' => rc__('ROKGALLERY_DARK')); $styles = $this->getList('style', $style, $current_page, $style_names, $menu_item, $base_page_url); $this->assignRef('styles', $styles); $sort_by_names = array('gallery_ordering' => rc__('ROKGALLERY_SORT_GALLERY_ORDERING'), 'file_created_at' => rc__('ROKGALLERY_SORT_CREATED'), 'slice_updated_at' => rc__('ROKGALLERY_SORT_UPDATED'), 'slice_title' => rc__('ROKGALLERY_SORT_TITLE'), 'loves' => rc__('ROKGALLERY_SORT_LOVES'), 'views' => rc__('ROKGALLERY_SORT_VIEWS')); $sort_bys = $this->getList('sort_by', $sort_by, $current_page, $sort_by_names, $menu_item, $base_page_url); $this->assignRef('sort_bys', $sort_bys); $sort_dir_names = array('ASC' => 'ascending', 'DESC' => 'descending'); $sort_directions = $this->getList('sort_direction', $sort_direction, $current_page, $sort_dir_names, $menu_item, $base_page_url); $this->assignRef('sort_directions', $sort_directions); $total_items = $pager->getNumResults(); $item_number = $pager->getFirstIndice(); $layout_context = 'com_rokgallery.gallery.' . $layout; $style_context = $layout_context . '.' . $style; // Assignments to JS namespaces $this->assign('base_ajax_url', $base_ajax_url); $this->assign('available_layouts', $params->get('available_layouts', array())); $this->assign('available_sorts', $params->get('available_sorts', array())); $sort_dir = false; foreach ($sort_bys as $sort_by_item) { if ($sort_by_item->active) { $sort_dir = new stdClass(); $sort_dir->field = $sort_by_item->name; $other_sort = $sort_direction == 'ASC' ? 'DESC' : 'ASC'; $sort_dir->link = $sort_directions[$other_sort]->link; $sort_dir->class = $other_sort == 'ASC' ? 'ascending' : 'descending'; break; } } // Joomla params $this->assign('show_page_heading', $params->get('show_page_heading', 1)); $this->assign('page_heading', $this->escape($params->get('page_heading'))); // Assignments to page passed vars $this->assign('pages', $pages); $this->assign('next_page', $next_page); $this->assign('prev_page', $prev_page); $this->assign('items_per_row', $items_per_row); $this->assign('total_items', $total_items); $this->assign('items_per_page', $items_per_page); $this->assign('item_number', $item_number); $this->assign('context', $layout_context); $this->assign('style_context', $style_context); $this->assign('current_page', $current_page); $this->assign('thumb_width', $gallery->thumb_xsize); $this->assign('thumb_height', $gallery->thumb_ysize); $this->assign('sort_by', $sort_by); $this->assign('sort_direction', $sort_direction); $this->assign('sort_dir', $sort_dir); $this->assign('style', $style); $this->assign('layout', $layout); // populate basic page render vars $this->assign('show_created_at', $params->get('gallery_show_created_at', true)); $this->assign('show_tags', $params->get('gallery_show_tags', false)); $this->assign('show_tags_count', $params->get('gallery_show_tags_count', false)); $this->assign('show_caption', $params->get('gallery_show_caption', false)); $this->assign('show_title', $params->get('gallery_show_title', false)); $this->assign('show_loves', $params->get('gallery_show_loves', false)); $this->assign('show_views', $params->get('gallery_show_views', false)); $this->assign('show_available_layouts', $params->get('show_available_layouts', true)); $this->setLayout('default'); parent::display($tpl); }
/** * Save the order of images in a gallery * $params object should be a json like * <code> * { * "id" : 1, * "order": [1, 2, 10, 3, 8] * } * </code> * @param $params */ public function order($params) { $result = new RokCommon_Ajax_Result(); $tx = RokGallery_Doctrine::getConnection()->transaction; $tx->setIsolation('REPEATABLE READ'); try { $tx->beginTransaction(); $gallery = RokGallery_Model_GalleryTable::getSingle($params->id); if ($gallery === false) { throw new RokCommon_Ajax_Exception('No gallery with id ' . $params->id); } $gallery->setSliceOrder($params->order); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } return $result; }
function display($tpl = null) { JHTML::_('behavior.mootools'); JHTML::_('behavior.keepalive'); $option = JRequest::getCmd('option'); $document =& JFactory::getDocument(); $session =& JFactory::getSession(); $model = new RokGallery_Admin_MainPage(); $current_page = 1; $items_per_page = RokGallery_Config::getOption(RokGallery_Config::OPTION_ADMIN_ITEMS_PER_PAGE, 6); $items_per_row = RokGallery_Config::getOption(RokGallery_Config::OPTION_ADMIN_ITEMS_PER_ROW, 3); $files = $model->getFiles($current_page, $items_per_page * 2); $pager = $model->getPager($current_page, $items_per_page * 2); $next_page = $current_page == 1 ? 3 : $current_page + 1; $next_page = $current_page == $pager->getLastPage() ? false : $next_page; $more_pages = $next_page == false ? "false" : "true"; $application = JURI::root(true) . '/administrator/components/' . $option . '/assets/application/'; $images = JURI::root(true) . '/administrator/components/' . $option . '/assets/images/'; $url = JURI::root(true) . '/administrator/index.php?option=com_rokgallery&task=ajax&format=raw'; // debug: &XDEBUG_SESSION_START=default $document->addScriptDeclaration('var RokGallerySettings = { application: "' . $application . '", images: "' . $images . '", next_page: "' . $next_page . '", last_page: "' . $pager->getLastPage() . '", more_pages: ' . $more_pages . ', items_per_page: "' . $items_per_page . '", total_items: ' . $pager->getNumResults() . ', url: "' . $url . '", token: "' . JUtility::getToken() . '", session: { name: "' . $session->getName() . '", id: "' . $session->getId() . '" }, order: ["order-created_at", "order-desc"] };'); $document->addStyleSheet('components/' . $option . '/assets/styles/master.css'); if (RokCommon_Browser::getShortName() == 'ie8') { $document->addStyleSheet('components/' . $option . '/assets/styles/internet-explorer-8.css'); } $document->addScript('components/' . $option . '/assets/application/Common.js'); $document->addScript('components/' . $option . '/assets/application/RokGallery.js'); $document->addScript('components/' . $option . '/assets/application/RokGallery.Filters.js'); $document->addScript('components/' . $option . '/assets/application/RokGallery.Blocks.js'); $document->addScript('components/' . $option . '/assets/application/RokGallery.FileSettings.js'); $document->addScript('components/' . $option . '/assets/application/RokGallery.Edit.js'); $document->addScript('components/' . $option . '/assets/application/MainPage.js'); $document->addScript('components/' . $option . '/assets/application/Tags.js'); $document->addScript('components/' . $option . '/assets/application/Tags.Slice.js'); $document->addScript('components/' . $option . '/assets/application/Tags.Ajax.js'); $document->addScript('components/' . $option . '/assets/application/Scrollbar.js'); $document->addScript('components/' . $option . '/assets/application/Popup.js'); $document->addScript('components/' . $option . '/assets/application/Progress.js'); $document->addScript('components/' . $option . '/assets/application/Job.js'); $document->addScript('components/' . $option . '/assets/application/JobsManager.js'); $document->addScript('components/' . $option . '/assets/application/MassTags.js'); $document->addScript('components/' . $option . '/assets/application/GalleriesManager.js'); $document->addScript('components/' . $option . '/assets/application/Swiff.Uploader.js'); $document->addScript('components/' . $option . '/assets/application/Uploader.js'); $document->addScript('components/' . $option . '/assets/application/Rubberband.js'); $document->addScript('components/' . $option . '/assets/application/Marquee.js'); $document->addScript('components/' . $option . '/assets/application/Marquee.Crop.js'); $galleries = RokGallery_Model_GalleryTable::getAll(); if ($galleries === false) { $galleries = array(); } $this->assign('total_items_in_filter', $pager->getNumResults()); $this->assign('items_to_be_rendered', $pager->getResultsInPage()); $this->assign('next_page', $next_page); $this->assign('items_per_page', $items_per_page); $this->assign('items_per_row', $items_per_row); $this->assign('currently_shown_items', $pager->getLastIndice()); $this->assign('totalFilesCount', $pager->getNumResults()); $this->assignRef('files', $files); $this->assignRef('galleries', $galleries); parent::display($tpl); }