/** * Layout controls bar * */ function LayoutBar($theme_name, $theme_locality, $user = 0, $index_layout = false) { $tpl = $this->gadget->template->load('LayoutControls.html'); $tpl->SetBlock('controls'); $tpl->SetVariable('base_script', BASE_SCRIPT); $tpl->SetVariable('cp-title', _t('GLOBAL_CONTROLPANEL')); $tpl->SetVariable('cp-title-separator', _t('GLOBAL_CONTROLPANEL_TITLE_SEPARATOR')); if ($this->gadget->GetPermission('default_admin', '', false, 'ControlPanel')) { $tpl->SetVariable('admin_script', 'admin.php'); } else { $tpl->SetVariable('admin_script', 'javascript:void();'); } $tpl->SetVariable('title-name', _t('LAYOUT_TITLE')); $tpl->SetVariable('icon-gadget', 'gadgets/Layout/Resources/images/logo.png'); $tpl->SetVariable('title-gadget', 'Layout'); $tpl->SetVariable('layout-url', $this->gadget->urlMap('Layout', array())); // dashboards $tpl->SetVariable('lbl_dashboard', _t('LAYOUT_DASHBOARD')); $dashboards =& Piwi::CreateWidget('Combo', 'user'); $dashboards->setID('user'); if ($this->gadget->GetPermission('ManageLayout')) { $dashboards->AddOption(_t('LAYOUT_DASHBOARD_GLOBAL'), 0); } if ($GLOBALS['app']->Session->GetPermission('Users', 'ManageDashboard')) { $dashboards->AddOption(_t('LAYOUT_DASHBOARD_USER'), (int) $GLOBALS['app']->Session->GetAttribute('user')); } $dashboards->SetDefault($user); $dashboards->AddEvent(ON_CHANGE, "layoutControlsSubmit(this);"); $tpl->SetVariable('dashboards_combo', $dashboards->Get()); // themes $tpl->SetVariable('lbl_theme', _t('LAYOUT_THEME')); $themeCombo =& Piwi::CreateWidget('ComboGroup', 'theme'); $themeCombo->setID('theme'); $themeCombo->addGroup(0, _t('LAYOUT_THEME_LOCAL')); $themeCombo->addGroup(1, _t('LAYOUT_THEME_REMOTE')); $themes = Jaws_Utils::GetThemesInfo(); foreach ($themes[0] as $theme => $tInfo) { $themeCombo->AddOption(0, $tInfo['name'], "{$theme},0"); } foreach ($themes[1] as $theme => $tInfo) { $themeCombo->AddOption(1, $tInfo['name'], "{$theme},1"); } $themeCombo->SetDefault("{$theme_name},{$theme_locality}"); $themeCombo->AddEvent(ON_CHANGE, "layoutControlsSubmit(this);"); $themeCombo->SetEnabled($this->gadget->GetPermission('ManageThemes')); $tpl->SetVariable('theme_combo', $themeCombo->Get()); // layouts $tpl->SetVariable('lbl_layout', _t('LAYOUT_LAYOUT')); $layouts =& Piwi::CreateWidget('Combo', 'index_layout'); $layouts->setID('index_layout'); $layouts->AddOption(_t('LAYOUT_LAYOUT_DEFAULT'), 0); if (isset($themes[$theme_locality][$theme_name]) && $themes[$theme_locality][$theme_name]['index']) { $layouts->AddOption(_t('LAYOUT_LAYOUT_INDEX'), 1); } $layouts->SetDefault((int) $index_layout); $layouts->AddEvent(ON_CHANGE, "layoutControlsSubmit(this);"); $tpl->SetVariable('layouts_combo', $layouts->Get()); $add =& Piwi::CreateWidget('Button', 'add', _t('LAYOUT_NEW'), STOCK_ADD); $url = $GLOBALS['app']->getSiteURL('/') . BASE_SCRIPT . '?gadget=Layout&action=AddLayoutElement&user='******'" . $url . "', '" . _t('LAYOUT_NEW') . "');"); $tpl->SetVariable('add_gadget', $add->Get()); $docurl = $this->gadget->GetDoc(); if (!empty($docurl) && !is_null($docurl)) { $tpl->SetBlock('controls/documentation'); $tpl->SetVariable('src', 'images/stock/help-browser.png'); $tpl->SetVariable('alt', _t('GLOBAL_HELP')); $tpl->SetVariable('url', $docurl); $tpl->ParseBlock('controls/documentation'); } $tpl->ParseBlock('controls'); return $tpl->Get(); }
/** * Delete the theme * * @access public * @param string $theme * @returns boolean */ function DeleteTheme($theme) { $this->gadget->CheckPermission('DeleteTheme'); @(list($theme, $locality) = explode(',', $theme)); $tInfo = Jaws_Utils::GetThemesInfo($locality, $theme); if (!empty($tInfo) && $locality == 0) { // get default theme $defaultTheme = unserialize($GLOBALS['app']->Registry->fetch('theme', 'Settings')); // Check is default theme? if ($defaultTheme['locality'] != 0 || $theme != $defaultTheme['name']) { return Jaws_Utils::delete(JAWS_THEMES . $theme); } } return false; }
/** * Layout controls bar * */ function LayoutBar($theme_name, $theme_locality, $layout = 'Layout') { $tpl = $this->gadget->template->load('LayoutControls.html'); $tpl->SetBlock('controls'); $tpl->SetVariable('base_script', BASE_SCRIPT); $tpl->SetVariable('layout_layout_url', $this->gadget->urlMap('Layout', array('layout' => '~layout~'))); $tpl->SetVariable('layout_theme_url', $this->gadget->urlMap('Layout', array('theme' => '~theme~'))); $tpl->SetVariable('cp-title', _t('GLOBAL_CONTROLPANEL')); $tpl->SetVariable('cp-title-separator', _t('GLOBAL_CONTROLPANEL_TITLE_SEPARATOR')); if ($this->gadget->GetPermission('default_admin', '', false, 'ControlPanel')) { $tpl->SetVariable('admin_script', 'admin.php'); } else { $tpl->SetVariable('admin_script', 'javascript:void();'); } $tpl->SetVariable('title-name', _t('LAYOUT_TITLE')); $tpl->SetVariable('icon-gadget', 'gadgets/Layout/Resources/images/logo.png'); $tpl->SetVariable('title-gadget', 'Layout'); $tpl->SetVariable('layout-url', $this->gadget->urlMap('Layout', array())); // themes $tpl->SetVariable('lbl_theme', _t('LAYOUT_THEME')); $themeCombo =& Piwi::CreateWidget('ComboGroup', 'theme'); $themeCombo->setID('theme'); $themeCombo->addGroup(0, _t('LAYOUT_THEME_LOCAL')); $themeCombo->addGroup(1, _t('LAYOUT_THEME_REMOTE')); $themes = Jaws_Utils::GetThemesInfo(); foreach ($themes[0] as $theme => $tInfo) { $themeCombo->AddOption(0, $tInfo['name'], "{$theme},0"); } foreach ($themes[1] as $theme => $tInfo) { $themeCombo->AddOption(1, $tInfo['name'], "{$theme},1"); } $themeCombo->SetDefault("{$theme_name},{$theme_locality}"); $themeCombo->AddEvent(ON_CHANGE, "layoutControlsSubmit(this);"); $themeCombo->SetEnabled($this->gadget->GetPermission('ManageThemes')); $tpl->SetVariable('theme_combo', $themeCombo->Get()); // layouts $tpl->SetVariable('lbl_layout', _t('LAYOUT_LAYOUT')); $layouts =& Piwi::CreateWidget('Combo', 'layout'); $layouts->setID('layout'); if (isset($themes[$theme_locality][$theme_name])) { $theme_layouts = array_flip(array_map('basename', glob(($theme_locality ? JAWS_BASE_THEMES : JAWS_THEMES) . $theme_name . '/*.html'))); // default layout $layouts->AddOption(_t('LAYOUT_LAYOUT_DEFAULT'), 'Layout'); // index layout if (isset($theme_layouts['Index.html'])) { $layouts->AddOption(_t('LAYOUT_LAYOUT_INDEX'), 'Index'); } // dashboard layout available if user has permission for use it if ($GLOBALS['app']->Session->GetPermission('Users', 'ManageDashboard') && isset($theme_layouts['Index.Dashboard.html'])) { $layouts->AddOption(_t('LAYOUT_DASHBOARD'), 'Index.Dashboard'); } // unset pre-added layouts unset($theme_layouts['Layout.html'], $theme_layouts['Index.html'], $theme_layouts['Index.Dashboard.html']); // loop for add other layouts foreach ($theme_layouts as $theme_layout => $temp) { $theme_layout = basename($theme_layout, '.html'); $layouts->AddOption($theme_layout, $theme_layout); } } $layouts->SetDefault($layout); $layouts->AddEvent(ON_CHANGE, "layoutControlsSubmit(this);"); $tpl->SetVariable('layouts_combo', $layouts->Get()); $add =& Piwi::CreateWidget('Button', 'add', _t('LAYOUT_NEW'), STOCK_ADD); $url = $GLOBALS['app']->getSiteURL('/') . BASE_SCRIPT . '?gadget=Layout&action=AddLayoutElement&layout=' . $layout; $add->AddEvent(ON_CLICK, "addGadget('" . $url . "', '" . _t('LAYOUT_NEW') . "');"); $tpl->SetVariable('add_gadget', $add->Get()); $docurl = $this->gadget->GetDoc(); if (!empty($docurl) && !is_null($docurl)) { $tpl->SetBlock('controls/documentation'); $tpl->SetVariable('src', 'images/stock/help-browser.png'); $tpl->SetVariable('alt', _t('GLOBAL_HELP')); $tpl->SetVariable('url', $docurl); $tpl->ParseBlock('controls/documentation'); } $tpl->ParseBlock('controls'); return $tpl->Get(); }