public function display($tpl = null) { $JSNMedia = JSNFactory::getMedia(); $JSNMedia->addStyleSheet(JSN_POWERADMIN_STYLE_URI . 'styles.css'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery.cook.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery.tinyscrollbar.js'); JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-hotkeys/jquery.hotkeys.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jstree/jstree.override.js'); JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-jstorage/jquery.jstorage.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery.topzindex.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.submenu.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.mousecheck.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.functions.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.assignpages.js'); $JSNMedia->addScriptDeclaration("var baseUrl = '" . JURI::root() . "';"); //require classes JSNFactory::localimport('libraries.joomlashine.modules'); JSNFactory::localimport('libraries.joomlashine.page.assignpages'); $viewHelper = JSNAssignpages::getInstance(); $menuTypes = $viewHelper->menuTypeDropDownList(false); $this->assign('menutypes', $menuTypes); $app = JFactory::getApplication(); $moduleid = $app->getUserState('com_poweradmin.assignpages.custompage.moduleid', JRequest::getVar('moduleid', array(), 'get', 'array')); if (count($moduleid) == 1) { $menuitems = $viewHelper->renderMenu($moduleid[0]); $assignType = JSNModules::checkAssign($moduleid[0]); } else { $menuitems = $viewHelper->renderMenu(0); $assignType = 3; } $this->assign('menuitems', $menuitems); $this->assign('assignType', $assignType); return parent::display(); }
/** * Display the view */ public function display($tpl = null) { $JSNMedia = JSNFactory::getMedia(); $JSNMedia->addStyleSheet(JSN_POWERADMIN_STYLE_URI . 'styles.css'); JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-hotkeys/jquery.hotkeys.js'); JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-jstorage/jquery.jstorage.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery.topzindex.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.submenu.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.mousecheck.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.functions.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JS_URI . 'jquery.tinyscrollbar.js'); JSNHtmlAsset::addScript(JSN_POWERADMIN_LIB_JSNJS_URI . 'jsn.assignpages.js'); JSNHtmlAsset::addScript(JSN_FRAMEWORK_ASSETS . '/3rd-party/jquery-jstree/jquery.jstree.js'); $JSNMedia->addScriptDeclaration("var baseUrl = '" . JURI::root() . "';"); //require helper JSNFactory::localimport('libraries.joomlashine.page.assignpages'); $viewHelper = JSNAssignpages::getInstance(); $menuTypes = $viewHelper->menuTypeDropDownList(false); $this->assign('menutypes', $menuTypes); $moduleid = JRequest::getVar('id', 0); $menuitems = $viewHelper->renderMenu($moduleid); $this->assign('menuitems', $menuitems); JSNFactory::localimport('libraries.joomlashine.modules'); $assignType = JSNModules::checkAssign($moduleid); $this->assign('assignType', $assignType); $this->form = $this->get('Form'); $this->item = $this->get('Item'); $this->state = $this->get('State'); $language = JFactory::getLanguage(); $language->load('com_modules'); parent::display($tpl); }
/** * get all modules in position * @position: String - position of template * @attributes: String - Attributes will be set for modules in position * @return: String of modules in position after rendered */ public function renderModules($position, $Itemid, $attributes = array(), $showmode, $published = '') { $modules = JSNModules::getModules($position, $Itemid, $published); $modulesHTML = array(); $count = count($modules); if ($count) { foreach ($modules as $module) { $modulesHTML[] = PoweradminFrontHelper::renderModule($module, $attributes, $showmode); } } return implode(PHP_EOL, $modulesHTML); }
/** * This function to set an module to unpublish * * @return: Change value in table of database */ function unassign() { JSNFactory::localimport('libraries.joomlashine.modules'); $moduleid = JRequest::getVar('moduleid', array(), 'post', 'array'); $pages = JRequest::getVar('assignpages', array(), 'post', 'array'); $unpublish_area = JRequest::getVar('unpublish_area', ''); $count = count($moduleid); if ($count == 0) { JText::printf('MSG_AJAX_ERROR', JText::_('MSG_AJAX_MOVE_ERROR')); jexit(); } $model = $this->getModel('assignpages'); switch ($unpublish_area) { case 'all': for ($i = 0; $i < $count; $i++) { $model->removeAll($moduleid[$i]); } if ($count == 1) { JText::printf('MSG_AJAX_ASSIGNMENT_MODULE', '"' . JSNModules::getNameOfModule($moduleid) . '"', 'unassigned', 'from', 'All Pages'); } else { JText::printf('MSG_AJAX_MULTIPLE', $count, ' unassigned to all pages. '); } break; default: case 'one': for ($i = 0; $i < $count; $i++) { $model->unassignPages($moduleid[$i], $pages); } if ($count == 1) { JText::printf('MSG_AJAX_ASSIGNMENT_MODULE', '"' . JSNModules::getNameOfModule($moduleid[0]) . '"', 'unassigned', 'from', $model->getPageName($pages[0])); } else { JText::printf('MSG_AJAX_MULTIPLE', $count, ' unassigned to this page. '); } break; } jexit(); }
/** * Check in */ public function checkin() { $moduleid = JRequest::getVar('moduleid', array(), 'post', 'array'); $count = count($moduleid); for ($i = 0; $i < $count; $i++) { JSNModules::checkin($moduleid[$i]); } jexit(); }
/** * Move an module to new position * * @param: $moduleid is id of module in the database * @param: $position is position of template * @return: None return value just change the param of module */ public static function moveModule($moduleid, $position, $order) { $instances = JSNModules::getInstance(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('position'); $query->from('#__modules'); $query->where("id = " . $db->Quote($moduleid)); $db->setQuery($query); $from_position = $db->loadResult(); // save your drag & drop $query->clear(); $query->update("#__modules"); $query->set("position = " . $db->Quote($position)); $query->where("id = " . $db->Quote($moduleid)); $db->setQuery($query); if (!$db->query()) { JText::printf('MSG_AJAX_ERROR', $db->getErrorMsg()); return false; } //save your sort on position foreach ($order as $key => $ordering) { $query->clear(); $query->update("#__modules"); $query->set("ordering=" . $db->quote($key)); $query->where("id=" . $db->quote($ordering)); $db->setQuery($query); $db->query(); } return true; }
/** * * Render all rawmode */ public function renderAll() { foreach ($this->getParam('positions') as $position) { $position = (string) $position->name; $this->renderPosition($position); } $modulesNotDefaultPosition = JSNModules::getModulesNotDefaultPosition($this->getParam('Itemid')); $this->_htmlpositions['notdefault'] = $this->renderModulesNotDefaultPosition($modulesNotDefaultPosition); $this->_jspositions['notdefault'] = $this->toJSPosition('notdefault', $modulesNotDefaultPosition); $this->renderComponent(); }
/** * * Unassign all pages selected * @param Number $moduleid * @param Array $pages */ public function unassignPages($moduleid, $pages) { JSNFactory::localimport('libraries.joomlashine.modules'); $db = JFactory::getDbo(); $query = $db->getQuery(true); $assignmentType = JSNModules::checkAssign($moduleid); if ($assignmentType == 0) { for ($i = 0; $i < count($pages); $i++) { $query->clear(); $query->insert("#__modules_menu"); $query->values($moduleid . ',-' . $pages[$i]); $db->setQuery($query); $db->query(); } } else { if ($assignmentType === 1) { $this->removeAll($moduleid); $allItems = $this->getAllPages(); for ($i = 0; $i < count($allItems); $i++) { if (!in_array($allItems[$i]->id, $pages)) { $query->clear(); $query->insert("#__modules_menu"); $query->values($moduleid . ',' . $allItems[$i]->id); $db->setQuery($query); $db->query(); } } } else { if ($assignmentType === 2) { for ($i = 0; $i < count($pages); $i++) { $query->clear(); $query->insert("#__modules_menu"); $query->values($moduleid . ',-' . $pages[$i]); $db->setQuery($query); $db->query(); } } else { if ($assignmentType === 3) { for ($i = 0; $i < count($pages); $i++) { $query->clear(); $query->delete(); $query->from("#__modules_menu"); $query->where("menuid=" . $db->quote($pages[$i]) . ' AND moduleid = ' . $db->quote($moduleid)); $db->setQuery($query); $db->query(); } } } } } }
/** * * Check module is assigned * * @param Number $itemid * @param Number $moduleid */ public function getCheckboxAttributes($itemid, $moduleid) { $attrs = array('name' => 'assignpages[]', 'value' => $itemid); JSNFactory::localimport('libraries.joomlashine.modules'); $assignmentType = JSNModules::getItemAssignmentType($moduleid, $itemid); if ($assignmentType == 'selected' || $assignmentType == 'all' || $assignmentType == 'except') { $attrs += array('checked' => "checked"); } return $attrs; }