예제 #1
0
파일: Menu.php 프로젝트: Dulciane/jaws
 /**
  * Retrieves Menu Level
  *
  * @access  public
  * @param   object  $model      Jaws_Model reference
  * @param   string  $tpl_str    XHTML template content passed by reference
  * @param   int     $gid        Group ID
  * @param   int     $pid
  * @return  string  XHTML template content
  */
 function GetMenuLevel(&$model, &$tpl_str, $gid, $pid)
 {
     $menus = $model->GetLevelsMenus($pid, $gid);
     if (Jaws_Error::IsError($menus) || empty($menus)) {
         return '';
     }
     $tpl = new Jaws_Template();
     $tpl->LoadFromString($tpl_str);
     $tpl->SetBlock('parent');
     foreach ($menus as $menu) {
         $tpl->SetBlock('parent/menu');
         $tpl->SetVariable('class_name', 'menu_levels');
         $tpl->SetVariable('mg_id', 'menu_' . $menu['id']);
         $tpl->SetVariable('icon', 'gadgets/Menu/Resources/images/menu-item.png');
         $tpl->SetVariable('title', $menu['title']);
         $tpl->SetVariable('js_edit_func', "editMenu({$menu['id']})");
         $tpl->SetVariable('add_title', _t('MENU_ADD_MENU'));
         $tpl->SetVariable('add_icon', STOCK_NEW);
         $tpl->SetVariable('js_add_func', "addMenu({$gid}, {$menu['id']})");
         $tpl->SetVariable('sub_menus', $this->GetMenuLevel($model, $tpl_str, $gid, $menu['id']));
         $tpl->ParseBlock('parent/menu');
     }
     $tpl->ParseBlock('parent');
     return $tpl->Get();
 }
예제 #2
0
파일: Show.php 프로젝트: Dulciane/jaws
 /**
  * Internal recursive function to build the menu
  *
  * @access  private
  * @param   array   $items
  * @param   string  $tplString
  * @param   int     $level
  * @return  string  XHTML menu
  */
 function DisplayMenu(&$items, &$tplString, $level = 1)
 {
     $tpl = new Jaws_Template();
     $tpl->LoadFromString($tplString);
     $tpl->SetBlock('branch');
     $tpl->SetVariable('level', $level);
     if (count($items) > 0) {
         foreach ($items as $item) {
             $tpl->SetBlock('branch/menu');
             $tpl->SetVariable('level', $level);
             $tpl->SetVariable('url', $item['url']);
             $tpl->SetVariable('title', $item['title']);
             $active = '';
             if ($GLOBALS['app']->mainGadget == 'Sitemap' && jaws()->request->fetch('path', 'get') == $item['path']) {
                 $active = 'active';
             }
             $tpl->SetVariable('active', $active);
             if (count($item['childs']) > 0) {
                 $tpl->SetVariable('submenu', $this->DisplayMenu($item['childs'], $tplString, $level + 1));
             } else {
                 $tpl->SetVariable('submenu', '');
             }
             $tpl->ParseBlock('branch/menu');
         }
     }
     $tpl->ParseBlock('branch');
     return $tpl->Get();
 }
예제 #3
0
파일: Banners.php 프로젝트: Dulciane/jaws
 /**
  * Displays banners(all-time visibles and random ones)
  *
  * @access  public
  * @param   int     $gid    Group ID
  * @return  string  XHTML template content
  */
 function Banners($gid = 0)
 {
     $id = (int) $this->gadget->request->fetch('id', 'get');
     $abs_url = false;
     if (!empty($id)) {
         $gid = $id;
         header(Jaws_XSS::filter($_SERVER['SERVER_PROTOCOL']) . " 200 OK");
         $abs_url = true;
     }
     $groupModel = $this->gadget->model->load('Groups');
     $group = $groupModel->GetGroup($gid);
     if (Jaws_Error::IsError($group) || empty($group) || !$group['published']) {
         return false;
     }
     $bannerModel = $this->gadget->model->load('Banners');
     $banners = $bannerModel->GetVisibleBanners($gid, $group['limit_count']);
     if (Jaws_Error::IsError($banners) || empty($banners)) {
         return false;
     }
     $tpl = $this->gadget->template->load('Banners.html');
     switch ($group['show_type']) {
         case 1:
         case 2:
             $type_block = 'banners_type_' . $group['show_type'];
             break;
         default:
             $type_block = 'banners';
     }
     $tpl->SetBlock($type_block);
     $tpl->SetVariable('gid', $gid);
     if ($group['show_title']) {
         $tpl->SetBlock("{$type_block}/title");
         $tpl->SetVariable('title', _t('BANNER_ACTIONS_BANNERS_TITLE', $group['title']));
         $tpl->ParseBlock("{$type_block}/title");
     }
     foreach ($banners as $banner) {
         $tpl->SetBlock("{$type_block}/banner");
         $tpl_template = new Jaws_Template();
         $tpl_template->LoadFromString('<!-- BEGIN x -->' . $banner['template'] . '<!-- END x -->');
         $tpl_template->SetBlock('x');
         $tpl_template->SetVariable('title', $banner['title']);
         if (file_exists(JAWS_DATA . $this->gadget->DataDirectory . $banner['banner'])) {
             $tpl_template->SetVariable('banner', $GLOBALS['app']->getDataURL($this->gadget->DataDirectory . $banner['banner']));
         } else {
             $tpl_template->SetVariable('banner', $banner['banner']);
         }
         if (empty($banner['url'])) {
             $tpl_template->SetVariable('link', 'javascript:void(0);');
             $tpl_template->SetVariable('target', '_self');
         } else {
             $tpl_template->SetVariable('link', $this->gadget->urlMap('Click', array('id' => $banner['id']), $abs_url));
             $tpl_template->SetVariable('target', '_blank');
         }
         $tpl_template->ParseBlock('x');
         $tpl->SetVariable('template', $tpl_template->Get());
         unset($tpl_template);
         $tpl->ParseBlock("{$type_block}/banner");
         $bannerModel->ViewBanner($banner['id']);
     }
     $tpl->ParseBlock($type_block);
     return $tpl->Get();
 }
예제 #4
0
파일: Menu.php 프로젝트: juniortux/jaws
 /**
  * Displays the next level of parent menu
  *
  * @access  public
  * @param   object  $model      Jaws_Model reference
  * @param   string  $tpl_str    XHTML template content passed by reference
  * @param   int     $gid        Group ID
  * @param   int     $pid
  * @return  string  XHTML template content with sub menu items
  */
 function GetNextLevel(&$model, &$tpl_str, $gid, $pid)
 {
     $menus = $model->GetLevelsMenus($pid, $gid, true);
     if (Jaws_Error::IsError($menus) || empty($menus)) {
         return '';
     }
     $tpl = new Jaws_Template();
     $tpl->LoadFromString($tpl_str);
     $tpl->SetBlock('levels');
     $len = count($menus);
     static $level = -1;
     for ($i = 0; $i < $len; $i++) {
         // check ACL
         if ($menus[$i]['menu_type'] != 'url' && !empty($menus[$i]['key_name']) && !$GLOBALS['app']->Session->GetPermission($menus[$i]['menu_type'], $menus[$i]['acl_key_name'], $menus[$i]['acl_key_subkey'])) {
             continue;
         }
         $level++;
         $tpl->SetVariable('level', $level);
         $tpl->SetBlock('levels/menu_item');
         $tpl->SetVariable('mid', $menus[$i]['id']);
         $tpl->SetVariable('title', $menus[$i]['title']);
         $tpl->SetVariable('url', $menus[$i]['url']);
         $tpl->SetVariable('target', $menus[$i]['url_target'] == 0 ? '_self' : '_blank');
         if (!empty($menus[$i]['image'])) {
             $src = $this->gadget->urlMap('LoadImage', array('id' => $menus[$i]['id']));
             $image =& Piwi::CreateWidget('Image', $src, $menus[$i]['title']);
             $image->SetID('');
             $tpl->SetVariable('image', $image->get());
         } else {
             $tpl->SetVariable('image', '');
         }
         //menu selected?
         $selected = str_replace(BASE_SCRIPT, '', urldecode($menus[$i]['url'])) == $this->_ReqURL;
         //get sub level menus
         $subLevel = $this->GetNextLevel($model, $tpl_str, $gid, $menus[$i]['id']);
         if ($i == 0) {
             $tpl->SetBlock('levels/menu_item/first');
             $tpl->ParseBlock('levels/menu_item/first');
         }
         if ($i == $len - 1) {
             $tpl->SetBlock('levels/menu_item/last');
             $tpl->ParseBlock('levels/menu_item/last');
         }
         if ($selected) {
             $tpl->SetBlock('levels/menu_item/current');
             $tpl->ParseBlock('levels/menu_item/current');
         }
         if (!empty($subLevel)) {
             $tpl->SetBlock('levels/menu_item/super');
             $tpl->ParseBlock('levels/menu_item/super');
         }
         $tpl->SetVariable('sub_menu', $subLevel);
         $tpl->ParseBlock('levels/menu_item');
         $level--;
     }
     $tpl->ParseBlock('levels');
     return $tpl->Get();
 }
예제 #5
0
 /**
  * Builds the visits report
  *
  * @access  public
  * @param   array   $visit_counters  Types of reports
  * @return  string  XHTML content
  */
 function GetVisitorsFormat($visit_counters)
 {
     $tpl = $this->gadget->template->load('VisitCounter.html');
     $tpl->SetBlock("VisiCounter");
     $tpl->SetVariable('title', _t('VISITCOUNTER_VISITORS'));
     $model = $this->gadget->model->load('Visitors');
     $viewMode = strtolower($this->gadget->registry->fetch('mode'));
     $theme = $GLOBALS['app']->GetTheme();
     if (is_dir($theme['path'] . 'VisitCounter/Resources/images/')) {
         $counter_image = $theme['url'] . 'VisitCounter/Resources/images/';
     } else {
         $counter_image = $GLOBALS['app']->getSiteURL('/gadgets/VisitCounter/Resources/images/', true);
     }
     $online_count = $model->GetOnlineVisitors();
     $today_count = $model->GetTodayVisitors();
     $yesterday_count = $model->GetYesterdayVisitors();
     $total_count = $model->GetTotalVisitors();
     $date = Jaws_Date::getInstance();
     $startdate = $date->Format($model->GetStartDate());
     if (in_array('online', $visit_counters)) {
         $tpl->SetBlock("VisiCounter/classic");
         $tpl->SetVariable('label', _t('VISITCOUNTER_ONLINE_VISITORS'));
         $tpl->SetVariable('value', $viewMode == 'text' ? $this->gadget->ParseText($online_count) : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $online_count));
         $tpl->ParseBlock("VisiCounter/classic");
     }
     if (in_array('today', $visit_counters)) {
         $tpl->SetBlock("VisiCounter/classic");
         $tpl->SetVariable('label', _t('VISITCOUNTER_TODAY_VISITORS'));
         $tpl->SetVariable('value', $viewMode == 'text' ? $this->gadget->ParseText($today_count) : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $today_count));
         $tpl->ParseBlock("VisiCounter/classic");
     }
     if (in_array('yesterday', $visit_counters)) {
         $tpl->SetBlock("VisiCounter/classic");
         $tpl->SetVariable('label', _t('VISITCOUNTER_YESTERDAY_VISITORS'));
         $tpl->SetVariable('value', $viewMode == 'text' ? $this->gadget->ParseText($yesterday_count, 'VisitCounter') : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $yesterday_count));
         $tpl->ParseBlock("VisiCounter/classic");
     }
     if (in_array('total', $visit_counters)) {
         $tpl->SetBlock("VisiCounter/classic");
         $tpl->SetVariable('label', _t('VISITCOUNTER_TOTAL_VISITORS'));
         $tpl->SetVariable('value', $viewMode == 'text' ? $this->gadget->ParseText($total_count, 'VisitCounter') : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $total_count));
         $tpl->ParseBlock("VisiCounter/classic");
     }
     if (in_array('custom', $visit_counters)) {
         $custom = stripslashes($this->gadget->registry->fetch('custom_text'));
         if (trim($custom) == '') {
             $res = "{$total_count} - {$startdate}";
         } else {
             $tp = new Jaws_Template();
             $tp->LoadFromString("<!-- BEGIN x -->{$custom}<!-- END x -->");
             $tp->SetBlock('x');
             $tp->SetVariable('online', $viewMode == 'text' ? $this->gadget->ParseText($online_count) : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $online_count));
             $tp->SetVariable('today', $viewMode == 'text' ? $this->gadget->ParseText($today_count) : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $today_count));
             $tp->SetVariable('yesterday', $viewMode == 'text' ? $this->gadget->ParseText($yesterday_count) : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $yesterday_count));
             $tp->SetVariable('total', $viewMode == 'text' ? $this->gadget->ParseText($total_count) : preg_replace('/([0-9])/', '<img src="' . $counter_image . '$1.png" alt="$1" />', $total_count));
             $tp->SetVariable('date', $this->gadget->ParseText($startdate));
             $tp->ParseBlock('x');
             $res = $tp->Get();
             $tp = null;
         }
         $tpl->SetBlock('VisiCounter/custom');
         $tpl->SetVariable('custom_text', $res);
         $tpl->ParseBlock('VisiCounter/custom');
     }
     $tpl->ParseBlock("VisiCounter");
     return $tpl->Get();
 }