Пример #1
0
 public function display($content = null, $title = null, $message = null)
 {
     $itemname = $this->getItemname();
     $currentTab = $this->getCurrentTab();
     $tabs = $this->getTabs();
     $panel = $this->getPanel();
     $module = $this->getModule();
     if (empty($content)) {
         $content = $this->getContent();
     } else {
         $settpl['TITLE'] =& $title;
         $settpl['MESSAGE'] =& $message;
         $settpl['CONTENT'] =& $content;
         $content = PHPWS_Template::process($settpl, 'controlpanel', 'default.tpl');
     }
     if (!isset($module)) {
         $module = 'controlpanel';
     }
     if (!isset($panel)) {
         $panel = CP_DEFAULT_PANEL;
     }
     if (!is_file(PHPWS_Template::getTemplateDirectory($module) . $panel)) {
         $module = 'controlpanel';
         $panel = CP_DEFAULT_PANEL;
     }
     foreach ($tabs as $id => $tab) {
         if ($this->_secure) {
             $tab->enableSecure();
         } else {
             $tab->disableSecure();
         }
         $tpl['TITLE'] = $tab->getLink();
         if ($id == $currentTab) {
             $tpl['STATUS'] = 'class="active"';
             $tpl['ACTIVE'] = ' ';
         } else {
             $tpl['STATUS'] = 'class="inactive"';
             $tpl['INACTIVE'] = ' ';
         }
         $template['tabs'][] = $tpl;
     }
     $template['CONTENT'] = $content;
     return PHPWS_Template::process($template, $module, $panel);
 }
Пример #2
0
 /**
  * Lists the template files in a directory.
  * Can be called statically.
  */
 public function listTemplates($module, $directory = NULL)
 {
     $tpl_dir = PHPWS_Template::getTemplateDirectory($module, $directory);
     if (!($result = scandir($tpl_dir))) {
         return NULL;
     }
     foreach ($result as $file) {
         if (!preg_match('/(^\\.)|(~$)/iU', $file) && preg_match('/\\.tpl$/i', $file)) {
             $file_list[$file] = $file;
         }
     }
     return $file_list;
 }
Пример #3
0
 public function getTemplateList()
 {
     $included_result = PHPWS_File::listDirectories(PHPWS_Template::getTemplateDirectory('menu') . 'menu_layout/');
     $theme_result = PHPWS_File::listDirectories(PHPWS_SOURCE_DIR . Layout::getThemeDir() . 'templates/menu/menu_layout/');
     if (PHPWS_Error::logIfError($included_result) || PHPWS_Error::logIfError($theme_result)) {
         return null;
     }
     if ($theme_result) {
         $result = array_unique(array_merge($included_result, $theme_result));
     } else {
         $result = $included_result;
     }
     $result = array_combine($result, $result);
     if (empty($result)) {
         return null;
     }
     foreach ($result as $dir) {
         $directories[$dir] = $dir;
     }
     return $directories;
 }
Пример #4
0
 public static function pageTplDir()
 {
     return PHPWS_Template::getTemplateDirectory('pagesmith') . 'page_templates/';
 }
Пример #5
0
    private function menuList()
    {
        \Layout::addStyle('menu', 'admin.css');
        javascript('jquery');
        javascript('jquery_ui');
        //commenting out for now. problem clearing select dropdown
        //javascript('select2');
        $template = new \Template();
        $template->setModuleTemplate('menu', 'admin/administrate.html');
        $first_menu_pin_all = 0;
        $first_menu_template = null;
        $db = new PHPWS_DB('menus');
        $db->addOrder('queue');
        $result = $db->getObjects('Menu_Item');
        $first_menu = null;
        if (!empty($result)) {
            foreach ($result as $menu) {
                $menu->_show_all = true;
                if (empty($first_menu)) {
                    $first_menu = $menu;
                    $active = 'active';
                } else {
                    $active = null;
                }
                $tpl['menus'][] = array('title' => $menu->title, 'id' => $menu->id, 'active' => $active);
            }
            $first_menu_template = $first_menu->template;
            // for display, use the admin template
            $first_menu->template = 'admin';
            $tpl['first_menu'] = $first_menu->view(true);
            $first_menu_pin_all = $first_menu->pin_all;
            $first_menu_id = $first_menu->id;
        } else {
            $first_menu_id = 0;
            $tpl['first_menu'] = null;
        }
        $vars['delete'] = t('Delete');
        $vars['confirm_delete'] = t('Confirm deletion');
        $vars['first_menu_id'] = $first_menu_id;
        $vars['authkey'] = \Current_User::getAuthKey();
        $vars['blank_title'] = t('Title must not be blank');
        $vars['title_error'] = t('Make sure you have filled in the required inputs.');
        $vars['url_error'] = t('Please enter a url or choose a PageSmith page.');
        $vars['delete_menu_message'] = t('Are you sure you want to delete this menu and links?');
        $vars['edit'] = t('Edit');
        $vars['title_error'] = t('Please enter a menu title');
        if (PHPWS_Settings::get('menu', 'display_type')) {
            $vars['pin_all'] = null;
            $vars['pin_some'] = null;
        } else {
            $vars['pin_all'] = t('Shown on all pages');
            $vars['pin_some'] = t('Shown on some pages');
        }
        $jvar = json_encode($vars);
        $script = <<<EOF
<script type="text/javascript">var translate = {$jvar}; var fmp={$first_menu_pin_all};</script>
EOF;
        \Layout::addJSHeader($script);
        \Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP . 'mod/menu/javascript/administrate/script.js"></script>');
        $main_menu_templates = PHPWS_File::listDirectories(PHPWS_Template::getTemplateDirectory('menu') . 'menu_layout/');
        $theme_menu_templates = PHPWS_File::listDirectories(PHPWS_Template::getTplDir('menu') . 'menu_layout/');
        $menu_tpls[] = '<optgroup label="' . t('Menu module templates') . '">';
        foreach ($main_menu_templates as $menu_tpl) {
            if ($first_menu_template == $menu_tpl) {
                $selected = ' selected="selected"';
            } else {
                $selected = null;
            }
            $menu_tpls[] = "<option value='{$menu_tpl}'{$selected}>{$menu_tpl}</option>";
        }
        $menu_tpls[] = '</optgroup>';
        if (!empty($theme_menu_templates)) {
            $menu_tpls[] = '<optgroup label="' . t('Theme templates') . '">';
            foreach ($theme_menu_templates as $menu_tpl) {
                if ($first_menu_template == $menu_tpl) {
                    $selected = ' selected="selected"';
                } else {
                    $selected = null;
                }
                $menu_tpls[] = "<option value='{$menu_tpl}'{$selected}>{$menu_tpl}</option>";
            }
            $menu_tpls[] = '</optgroup>';
        }
        $tpl['templates'] = implode('', $menu_tpls);
        $tpl['display_type'] = \PHPWS_Settings::get('menu', 'display_type');
        if (isset($first_menu) && $first_menu->pin_all) {
            $tpl['pin_all'] = $vars['pin_all'];
            $tpl['pin_button_class'] = 'btn-primary';
        } else {
            $tpl['pin_all'] = $vars['pin_some'];
            $tpl['pin_button_class'] = 'btn-default';
        }
        if (\Current_User::isDeity()) {
            $tpl['reset_menu_link'] = PHPWS_Text::linkAddress('menu', array('command' => 'reset_menu'), true);
        } else {
            $tpl['reset_menu_link'] = '#';
        }
        $tpl['link_limit'] = \PHPWS_Settings::get('menu', 'max_link_characters');
        if (\PHPWS_Core::moduleExists('carousel')) {
            $tpl['carousel'] = $this->carouselSlidesForm();
        } else {
            $tpl['carousel'] = null;
        }
        $template->addVariables($tpl);
        return $template->get();
    }