Esempio n. 1
0
 public static function searchBox()
 {
     if (SEARCH_DEFAULT) {
         $onclick = sprintf('onclick="if(this.value == \'%s\')this.value = \'\';"', SEARCH_DEFAULT);
     }
     PHPWS_Core::initCoreClass('Form.php');
     $form = new PHPWS_Form('search_box');
     $form->setProtected(false);
     $form->setMethod('get');
     $form->addHidden('module', 'search');
     $form->addHidden('user', 'search');
     $form->addText('search', SEARCH_DEFAULT);
     $form->setLabel('search', dgettext('search', 'Search'));
     if (PHPWS_Settings::get('search', 'show_alternates')) {
         Search_User::addAlternates($form);
     }
     if (isset($onclick)) {
         $form->setExtra('search', $onclick);
     }
     $form->addSubmit('go', dgettext('search', 'Search'));
     $mod_list = Search_User::getModList();
     $form->addSelect('mod_title', $mod_list);
     $key = Key::getCurrent();
     if (!empty($key) && !$key->isDummy()) {
         $form->setMatch('mod_title', $key->module);
     } elseif (isset($_REQUEST['mod_title'])) {
         $form->setMatch('mod_title', $_REQUEST['mod_title']);
     }
     $template = $form->getTemplate();
     $content = PHPWS_Template::process($template, 'search', 'search_box.tpl');
     Layout::add($content, 'search', 'search_box');
 }
Esempio n. 2
0
 public static function show()
 {
     Block::showAllBlocks();
     $key = Key::getCurrent();
     if (empty($key) || $key->isDummy(true)) {
         return;
     }
     Block::showBlocks($key);
 }
Esempio n. 3
0
 public function view()
 {
     $key = \Key::getCurrent();
     if (!\Key::checkKey($key)) {
         return;
     }
     $tpl = array();
     $allSettings = $this->settings->getAll();
     foreach ($allSettings as $key => $value) {
         if ($value == 1) {
             $tpl[$key] = "";
             // dummy template
         }
     }
     $content = \PHPWS_Template::process($tpl, 'addthis', 'addThis.tpl');
     \Layout::add($content, 'addthis', 'DEFAULT');
 }
Esempio n. 4
0
 /**
  * Fills in the meta description with the current key summary.
  */
 public static function keyDescriptions()
 {
     if (!PHPWS_Settings::get('layout', 'use_key_summaries')) {
         return;
     }
     $key = Key::getCurrent();
     if (!Key::checkKey($key, false)) {
         return NULL;
     }
     if (!empty($key->summary)) {
         $GLOBALS['Layout_Description'] =& $key->summary;
     } elseif (!empty($key->title)) {
         $GLOBALS['Layout_Description'] =& $key->title;
     }
 }
Esempio n. 5
0
<?php

javascript('jquery');
Layout::plug(Layout::getPageTitle(TRUE), 'SITE_TITLE');
Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP . 'themes/bootstrap/js/bootstrap.min.js"></script>', 'bootstrap');
Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP . 'themes/bootstrap/js/modal_fix.js"></script>', 'fix');
$key = Key::getCurrent();
if (!is_null($key)) {
    Layout::plug('active', 'CONTENT_PAGE');
}
Esempio n. 6
0
 public function view($level = '1', $admin = false)
 {
     \PHPWS_Core::requireConfig('menu');
     static $current_parent = array();
     $current_link = false;
     $current_key = Key::getCurrent();
     if (!empty($current_key)) {
         if ($this->childIsCurrent($current_key)) {
             $current_parent[] = $this->id;
         }
         if (!$current_key->isDummy() && $current_key->id == $this->key_id || $current_key->url == $this->url) {
             $current_link = true;
             $current_parent[] = $this->id;
             $template['CURRENT_LINK'] = MENU_CURRENT_LINK_STYLE;
             $template['ACTIVE'] = 'active';
             // booststrap theme
         }
     }
     if (!isset($template['CURRENT_LINK']) && $this->isCurrentUrl()) {
         $current_link = true;
         $current_parent[] = $this->id;
         $template['CURRENT_LINK'] = MENU_CURRENT_LINK_STYLE;
         $template['ACTIVE'] = 'active';
         // booststrap theme
     }
     if ($this->childIsCurrentUrl()) {
         $current_parent[] = $this->id;
     }
     if ($this->_menu->_show_all || $current_link || $this->parent == 0 || in_array($this->parent, $current_parent)) {
         $link = $this->getAnchorTag($admin);
         $template['LINK'] = $link;
         $template['LINK_URL'] = $this->url;
         $template['LINK_DROPDOWN'] = 'dropdown';
         // Dummy tag to make dropdowns work
         $template['LINK_TEXT'] = $this->title;
         if (!empty($this->_children)) {
             foreach ($this->_children as $kid) {
                 $kid->_menu =& $this->_menu;
                 if ($kid_link = $kid->view($level + 1, $admin)) {
                     $sublinks[] = $kid_link;
                 }
             }
             if (!empty($sublinks)) {
                 $template['SUBLINK'] = implode("\n", $sublinks);
             }
             $template['PARENT_ID'] = sprintf('menu-parent-%s', $this->id);
         }
         $template['LEVEL'] = $level;
         $template['ID'] = $this->id;
         $tpl_file = 'menu_layout/' . $this->_menu->template . '/link.tpl';
         return PHPWS_Template::process($template, 'menu', $tpl_file);
     } else {
         return NULL;
     }
 }
Esempio n. 7
0
<?php

/**
 * @author Matthew McNaney <mcnaney at gmail dot com>
 */
if (Current_User::isLogged()) {
    $key = Key::getCurrent(true);
    if ($key) {
        $qr_func = function ($key_id, $size) {
            $qr = new QR($key_id);
            $qr->setSize($size);
            $image = $qr->get();
            return '<a download="QR-image.png" href="' . $qr->image . '">' . $qr->get() . '</a>';
        };
        $tpl_vars['small'] = $qr_func($key->id, 5);
        $tpl_vars['medium'] = $qr_func($key->id, 6);
        $tpl_vars['large'] = $qr_func($key->id, 8);
        $tpl_vars['xlarge'] = $qr_func($key->id, 12);
        $tpl = new \Template($tpl_vars);
        $tpl->setModuleTemplate('qr', 'modal.html');
        $content = $tpl->get();
        $modal = new Modal('qr-modal', $content, 'QR Codes (click to download)');
        $modal->sizeLarge();
        Layout::add($modal->get());
        MiniAdmin::add('qr', '<a data-toggle="modal" data-target="#qr-modal" class="pointer">Show QR codes</a>');
    }
}
Esempio n. 8
0
<?php

if (Current_User::allow('pagesmith', 'edit_page')) {
    $vars = array('aop' => 'pick_template', 'tpl' => 'text_only', 'pid' => 0);
    MiniAdmin::add('pagesmith', PHPWS_Text::secureLink('<i class="fa fa-file-text-o"></i> ' . dgettext('pagesmith', 'Create New Web Page'), 'pagesmith', $vars));
    $key = \Key::getCurrent();
    if (!empty($key) && !$key->isDummy() && $key->module == 'pagesmith') {
        $vars['aop'] = 'edit_page';
        $vars['id'] = $key->item_id;
        unset($vars['tpl']);
        unset($vars['pid']);
        MiniAdmin::add('pagesmith', PHPWS_Text::secureLink('<i class="fa fa-pencil-square-o"></i> ' . dgettext('pagesmith', 'Edit current page'), 'pagesmith', $vars));
    }
}
Esempio n. 9
0
 /**
  * Returns a menu and its links for display
  */
 public function view($admin = false)
 {
     $key = Key::getCurrent();
     if ($key && $key->isDummy(true)) {
         return;
     }
     $theme_tpl_dir = \PHPWS_Template::getTplDir('menu') . 'menu_layout/';
     $menu_tpl_dir = PHPWS_SOURCE_DIR . 'mod/menu/templates/menu_layout/';
     $theme_path = $theme_tpl_dir . $this->template . '/';
     $menu_path = $menu_tpl_dir . $this->template . '/';
     if (is_file($theme_path . 'menu.tpl')) {
         $file = $theme_path . 'menu.tpl';
         $path = $theme_path;
         $http = 'themes/' . Layout::getTheme() . '/templates/menu/menu_layout/' . $this->template . '/';
     } elseif (is_file($menu_path . 'menu.tpl')) {
         $file = $menu_path . 'menu.tpl';
         $path = $menu_path;
         $http = 'mod/menu/templates/menu_layout/' . $this->template . '/';
     } else {
         $this->template = 'basic';
         $this->save();
         $path = $menu_tpl_dir . 'basic/';
         $http = 'mod/menu/templates/menu_layout/basic/';
         $file = $path . '/menu.tpl';
     }
     $this->parseIni($path);
     if ($this->_style) {
         $style = $http . 'style.css';
         Layout::addToStyleList($style);
     }
     $tpl['TITLE'] = $this->getTitle();
     $tpl['LINKS'] = $this->displayLinks($admin);
     $tpl['MENU_ID'] = sprintf('menu-%s', $this->id);
     $content = PHPWS_Template::process($tpl, 'menu', $file, true);
     return $content;
 }
Esempio n. 10
0
 public static function showBlock()
 {
     PHPWS_Core::initModClass('layout', 'Layout.php');
     if (PHPWS_Settings::get('whatsnew', 'homeonly')) {
         $key = Key::getCurrent();
         if (!empty($key) && $key->isHomeKey()) {
             Layout::add(Whatsnew::whatsnewBlock(), 'whatsnew', 'whatsnew_sidebox');
         }
     } else {
         Layout::add(Whatsnew::whatsnewBlock(), 'whatsnew', 'whatsnew_sidebox');
     }
 }
Esempio n. 11
0
 /**
  * Determines the current menu to be shown based on the current key.
  * This is for category view only.
  * @return int
  */
 private static function getCurrentActiveMenu()
 {
     $key = \Key::getCurrent(true);
     if (empty($key) || $key->isDummy(true)) {
         return -1;
     } elseif ($key->isHomeKey()) {
         return 0;
     }
     $db = \Database::newDB();
     $t = $db->addTable('menu_links');
     $t->addFieldConditional('key_id', $key->id);
     $t->addField('menu_id');
     $db->setLimit(1);
     $row = $db->selectOneRow();
     if ($row) {
         return $row['menu_id'];
     }
     // menu link not found, now check menu assoc
     $db2 = \Database::newDB();
     $t2 = $db2->addTable('menus');
     $t2->addFieldConditional('assoc_key', $key->id);
     $t2->addField('id');
     $db2->setLimit(1);
     $row2 = $db2->selectOneRow();
     if ($row2) {
         return $row2['id'];
     } else {
         return 0;
     }
 }
Esempio n. 12
0
 public static function miniAdmin()
 {
     $key = Key::getCurrent();
     if (empty($key) || $key->isDummy() || isset($key->_error)) {
         $on_page = FALSE;
     } else {
         $on_page = TRUE;
     }
     if ($on_page) {
         $search = new Search($key);
         if ($search->keywords) {
             foreach ($search->keywords as $keyword) {
                 $vars['key_id'] = $key->id;
                 $link['WORD'] = $vars['kw'] = $keyword;
                 $vars['command'] = 'remove_searchword';
                 $link['DROP_LINK'] = PHPWS_Text::secureLink(dgettext('search', 'Drop'), 'search', $vars);
                 $tpl['current-words'][] = $link;
             }
         }
         $tpl['CURRENT_TITLE'] = dgettext('search', 'Current keywords');
     }
     if (isset($_SESSION['Search_Add_Words'])) {
         foreach ($_SESSION['Search_Add_Words'] as $keyword) {
             $link = $vars = NULL;
             $link['WORD'] = $vars['kw'] = $keyword;
             $vars['command'] = 'drop_keyword';
             $link['DROP_LINK'] = PHPWS_Text::secureLink(dgettext('search', 'Drop'), 'search', $vars);
             if ($on_page) {
                 if (!in_array($keyword, $search->keywords)) {
                     $vars['key_id'] = $key->id;
                     $vars['command'] = 'add_keyword';
                     $link['ADD_LINK'] = PHPWS_Text::secureLink(dgettext('search', 'Add'), 'search', $vars);
                 }
             }
             $tpl['add-words'][] = $link;
         }
         $tpl['BANK_TITLE'] = dgettext('search', 'Clipped words');
     }
     $tpl['TITLE'] = dgettext('search', 'Search Admin');
     $tpl['CLOSE_LINK'] = PHPWS_Text::secureLink(dgettext('search', 'Close'), 'search', array('module' => 'search', 'command' => 'close_admin'));
     $content = PHPWS_Template::process($tpl, 'search', 'mini_menu.tpl');
     Layout::add($content, 'search', 'admin_box');
 }
Esempio n. 13
0
 public static function permissionMenu()
 {
     $key = Key::getCurrent();
     if (empty($key) || $key->isDummy() || empty($key->edit_permission)) {
         return;
     }
     if (Current_User::isUnrestricted($key->module) && Current_User::allow($key->module, $key->edit_permission)) {
         if (!javascriptEnabled()) {
             $tpl = User_Form::permissionMenu($key);
             $content = PHPWS_Template::process($tpl, 'users', 'forms/permission_menu.tpl');
             Layout::add($content, 'users', 'permissions');
         } else {
             $links[] = Current_User::popupPermission($key->id, sprintf(dgettext('users', 'Set permissions'), $key->title));
             MiniAdmin::add('users', $links);
         }
     }
 }