phpBB3 Website Integration Framework | Whizby Basic

Need some coding help with a MOD or tweak you are working on? - Ask here.
Forum rules
Ask for support specifically regarding coding help with phpBB3.
Not for generic usability questions or support.

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby Kane » 31 Dec 2009, 04:20

mtotheikle wrote:I think if you remove
Code: Select all
$template->set_custom_template(SITE_ROOT . SITE_TEMPLATE_PATH, SITE_TEMPLATE_NAME);


from common.php it will use the default phpBB3 users style path.


Not by just removing that line alone, I already tried that in the beginning, but just to be sure I just set up a fresh copy and got the same result

Code: Select all
General Error
template->_tpl_load_file(): File /index_body.html does not exist or is empty


Besides that, isn't that what tells framework to use its own template files? That part is needed, what we need to do is find a way to make it only use /theme and /imageset from the forum style and nothing else. Ultimately the problem is that $user->theme['template_path'] or $user->theme['theme_path'] isn't working.

With framework:
var_dump($user->theme['theme_path']); = NULL

Inside phpBB3:
var_dump($user->theme['theme_path']); = string(21) "prosilver-black-3.0.6"

So what do I need to add to what file to make it recognize that variable outside the phpbb directory?
I already died once. Let's hope it doesn't happen again.
User avatar
Kane    
Cadet II
Cadet II
 
Posts: 25
Joined: 27 Dec 2009, 21:15
Location: Texas
Favorite Team: Silver
Gender: Male
phpBB Knowledge: 5




phpBB Academy at StarTrekGuide
Support STG
Using PayPal Donate

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby mtotheikle » 31 Dec 2009, 16:52

Okay found the problem, in common.php

Find:
Code: Select all
$user      = new site_user();


Replace with:
Code: Select all
$user      = new user();
"You have a lifetime to learn technique. But I can teach you what is more important than technique: How to see. Learn that and all you have to do afterwards is press the shutter." - Garry Winogrand

I have turned into a Military Sergeant and Highway of Life and Handyman are my newest privates under my command. Don't be scared anyone, this is all for your good!

Image
User avatar
mtotheikle    
Supporter
Supporter
 
Posts: 1054
Joined: 10 Oct 2007, 22:43
Location: Washington
Favorite Team: Seahawks
Gender: Male
phpBB Knowledge: 10

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby Kane » 31 Dec 2009, 20:20

mtotheikle wrote:Okay found the problem, in common.php

Find:
Code: Select all
$user      = new site_user();


Replace with:
Code: Select all
$user      = new user();


That works, except for one problem....

That pulls the template files too. We need for it to use the template files that we make for the framework that are outside the phpBB directory, the folder /templates.

So we are really close just have to make it use our custom template files instead.
I already died once. Let's hope it doesn't happen again.
User avatar
Kane    
Cadet II
Cadet II
 
Posts: 25
Joined: 27 Dec 2009, 21:15
Location: Texas
Favorite Team: Silver
Gender: Male
phpBB Knowledge: 5

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby Kane » 31 Dec 2009, 22:13

Instead of doing it that way and having no control for the framework, I copy/pasted the entire user setup function from includes/session.php and am tinkering with it trying to get it not to bother with the /template folder at all. Any pointers?

The new site_user.php is this;

Code: Select all
<?php
/**
*
* @author David Lewis (Highway of Life) http://startrekguide.com
*
* @package Website
* @version $Id: site_user.php 70 2009-01-21 04:16:06Z Highway of Life $
* @copyright (c) 2009 StarTrekGuide
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_SITE'))
{
   exit;
}

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

/**
* @package user
*/
class site_user extends user
{
   /**
   * Setup basic user-specific items (style, language, ...)
   */
   function setup($lang_set = false, $style = false)
   {
      global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;

      if ($this->data['user_id'] != ANONYMOUS)
      {
         $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);

         $this->date_format = $this->data['user_dateformat'];
         $this->timezone = $this->data['user_timezone'] * 3600;
         $this->dst = $this->data['user_dst'] * 3600;
      }
      else
      {
         $this->lang_name = basename($config['default_lang']);
         $this->date_format = $config['default_dateformat'];
         $this->timezone = $config['board_timezone'] * 3600;
         $this->dst = $config['board_dst'] * 3600;
      }

      // We include common language file here to not load it every time a custom language file is included
      $lang = &$this->lang;

      // Do not suppress error if in DEBUG_EXTRA mode
      $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx");

      if ($include_result === false)
      {
         die('Language file ' . $this->lang_path . $this->lang_name . "/common.$phpEx" . " couldn't be opened.");
      }

      $this->add_lang($lang_set);
      unset($lang_set);

      if (!empty($_GET['style']) && $auth->acl_get('a_styles') && !defined('ADMIN_START'))
      {
         global $SID, $_EXTRA_URL;

         $style = request_var('style', 0);
         $SID .= '&amp;style=' . $style;
         $_EXTRA_URL = array('style=' . $style);
      }
      else
      {
         // Set up style
         $style = ($style) ? $style : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']);
      }

      $sql = 'SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
         FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i
         WHERE s.style_id = $style
            AND t.template_id = s.template_id
            AND c.theme_id = s.theme_id
            AND i.imageset_id = s.imageset_id";
      $result = $db->sql_query($sql, 3600);
      $this->theme = $db->sql_fetchrow($result);
      $db->sql_freeresult($result);

      // User has wrong style
      if (!$this->theme && $style == $this->data['user_style'])
      {
         $style = $this->data['user_style'] = $config['default_style'];

         $sql = 'UPDATE ' . USERS_TABLE . "
            SET user_style = $style
            WHERE user_id = {$this->data['user_id']}";
         $db->sql_query($sql);

         $sql = 'SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
            FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i
            WHERE s.style_id = $style
               AND t.template_id = s.template_id
               AND c.theme_id = s.theme_id
               AND i.imageset_id = s.imageset_id";
         $result = $db->sql_query($sql, 3600);
         $this->theme = $db->sql_fetchrow($result);
         $db->sql_freeresult($result);
      }

      if (!$this->theme)
      {
         trigger_error('Could not get style data', E_USER_ERROR);
      }

      // Now parse the cfg file and cache it
      $parsed_items = $cache->obtain_cfg_items($this->theme);

      // We are only interested in the theme configuration for now
      $parsed_items = $parsed_items['theme'];

      $check_for = array(
         'parse_css_file'   => (int) 0,
         'pagination_sep'   => (string) ', '
      );

      foreach ($check_for as $key => $default_value)
      {
         $this->theme[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value;
         settype($this->theme[$key], gettype($default_value));

         if (is_string($default_value))
         {
            $this->theme[$key] = htmlspecialchars($this->theme[$key]);
         }
      }

      // If the style author specified the theme needs to be cached
      // (because of the used paths and variables) than make sure it is the case.
      // For example, if the theme uses language-specific images it needs to be stored in db.
      if (!$this->theme['theme_storedb'] && $this->theme['parse_css_file'])
      {
         $this->theme['theme_storedb'] = 1;

         $stylesheet = file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/stylesheet.css");
         // Match CSS imports
         $matches = array();
         preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches);

         if (sizeof($matches))
         {
            $content = '';
            foreach ($matches[0] as $idx => $match)
            {
               if ($content = @file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/" . $matches[1][$idx]))
               {
                  $content = trim($content);
               }
               else
               {
                  $content = '';
               }
               $stylesheet = str_replace($match, $content, $stylesheet);
            }
            unset($content);
         }

         $stylesheet = str_replace('./', 'styles/' . $this->theme['theme_path'] . '/theme/', $stylesheet);

         $sql_ary = array(
            'theme_data'   => $stylesheet,
            'theme_mtime'   => time(),
            'theme_storedb'   => 1
         );

         $sql = 'UPDATE ' . STYLES_THEME_TABLE . '
            SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
            WHERE theme_id = ' . $this->theme['theme_id'];
         $db->sql_query($sql);

         unset($sql_ary);
      }

      $template->set_template();

      $this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang'];

      // Same query in style.php
      $sql = 'SELECT *
         FROM ' . STYLES_IMAGESET_DATA_TABLE . '
         WHERE imageset_id = ' . $this->theme['imageset_id'] . "
         AND image_filename <> ''
         AND image_lang IN ('" . $db->sql_escape($this->img_lang) . "', '')";
      $result = $db->sql_query($sql, 3600);

      $localised_images = false;
      while ($row = $db->sql_fetchrow($result))
      {
         if ($row['image_lang'])
         {
            $localised_images = true;
         }

         $row['image_filename'] = rawurlencode($row['image_filename']);
         $this->img_array[$row['image_name']] = $row;
      }
      $db->sql_freeresult($result);

      // there were no localised images, try to refresh the localised imageset for the user's language
      if (!$localised_images)
      {
         // Attention: this code ignores the image definition list from acp_styles and just takes everything
         // that the config file contains
         $sql_ary = array();

         $db->sql_transaction('begin');

         $sql = 'DELETE FROM ' . STYLES_IMAGESET_DATA_TABLE . '
            WHERE imageset_id = ' . $this->theme['imageset_id'] . '
               AND image_lang = \'' . $db->sql_escape($this->img_lang) . '\'';
         $result = $db->sql_query($sql);

         if (@file_exists("{$phpbb_root_path}styles/{$this->theme['imageset_path']}/imageset/{$this->img_lang}/imageset.cfg"))
         {
            $cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$this->theme['imageset_path']}/imageset/{$this->img_lang}/imageset.cfg");
            foreach ($cfg_data_imageset_data as $image_name => $value)
            {
               if (strpos($value, '*') !== false)
               {
                  if (substr($value, -1, 1) === '*')
                  {
                     list($image_filename, $image_height) = explode('*', $value);
                     $image_width = 0;
                  }
                  else
                  {
                     list($image_filename, $image_height, $image_width) = explode('*', $value);
                  }
               }
               else
               {
                  $image_filename = $value;
                  $image_height = $image_width = 0;
               }

               if (strpos($image_name, 'img_') === 0 && $image_filename)
               {
                  $image_name = substr($image_name, 4);
                  $sql_ary[] = array(
                     'image_name'      => (string) $image_name,
                     'image_filename'   => (string) $image_filename,
                     'image_height'      => (int) $image_height,
                     'image_width'      => (int) $image_width,
                     'imageset_id'      => (int) $this->theme['imageset_id'],
                     'image_lang'      => (string) $this->img_lang,
                  );
               }
            }
         }

         if (sizeof($sql_ary))
         {
            $db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
            $db->sql_transaction('commit');
            $cache->destroy('sql', STYLES_IMAGESET_DATA_TABLE);

            add_log('admin', 'LOG_IMAGESET_LANG_REFRESHED', $this->theme['imageset_name'], $this->img_lang);
         }
         else
         {
            $db->sql_transaction('commit');
            add_log('admin', 'LOG_IMAGESET_LANG_MISSING', $this->theme['imageset_name'], $this->img_lang);
         }
      }

      // Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes...
      // After calling it we continue script execution...
      phpbb_user_session_handler();

      // If this function got called from the error handler we are finished here.
      if (defined('IN_ERROR_HANDLER'))
      {
         return;
      }

      // Disable board if the install/ directory is still present
      // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally
      if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install'))
      {
         // Adjust the message slightly according to the permissions
         if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))
         {
            $message = 'REMOVE_INSTALL';
         }
         else
         {
            $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
         }
         trigger_error($message);
      }

      // Is board disabled and user not an admin or moderator?
      if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
      {
         if ($this->data['is_bot'])
         {
            header('HTTP/1.1 503 Service Unavailable');
         }

         $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
         trigger_error($message);
      }

      // Is load exceeded?
      if ($config['limit_load'] && $this->load !== false)
      {
         if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN'))
         {
            // Set board disabled to true to let the admins/mods get the proper notification
            $config['board_disable'] = '1';

            if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
            {
               if ($this->data['is_bot'])
               {
                  header('HTTP/1.1 503 Service Unavailable');
               }
               trigger_error('BOARD_UNAVAILABLE');
            }
         }
      }

      if (isset($this->data['session_viewonline']))
      {
         // Make sure the user is able to hide his session
         if (!$this->data['session_viewonline'])
         {
            // Reset online status if not allowed to hide the session...
            if (!$auth->acl_get('u_hideonline'))
            {
               $sql = 'UPDATE ' . SESSIONS_TABLE . '
                  SET session_viewonline = 1
                  WHERE session_user_id = ' . $this->data['user_id'];
               $db->sql_query($sql);
               $this->data['session_viewonline'] = 1;
            }
         }
         else if (!$this->data['user_allow_viewonline'])
         {
            // the user wants to hide and is allowed to  -> cloaking device on.
            if ($auth->acl_get('u_hideonline'))
            {
               $sql = 'UPDATE ' . SESSIONS_TABLE . '
                  SET session_viewonline = 0
                  WHERE session_user_id = ' . $this->data['user_id'];
               $db->sql_query($sql);
               $this->data['session_viewonline'] = 0;
            }
         }
      }


      // Does the user need to change their password? If so, redirect to the
      // ucp profile reg_details page ... of course do not redirect if we're already in the ucp
      if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && !empty($this->data['is_registered']) && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400))
      {
         if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != "ucp.$phpEx")
         {
            redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&amp;mode=reg_details'));
         }
      }

      return;
   }
}

?>
I already died once. Let's hope it doesn't happen again.
User avatar
Kane    
Cadet II
Cadet II
 
Posts: 25
Joined: 27 Dec 2009, 21:15
Location: Texas
Favorite Team: Silver
Gender: Male
phpBB Knowledge: 5

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby Kane » 01 Jan 2010, 02:52

Eureka! I did it! :grin:

Included the entire user setup function for styles from session.php and changed the set custom template there instead of common.php

Edited the links for theme and stylesheet in website_class along with adding some more globals

Now I have it pulling template files from the framework, the ones we edit for the "website" and the rest of the information is pulled from the boards current theme.

I don't have a domain yet or anyway to host a live demo to show you but I screen shot the progress so far. As you can see it's using our index_body.html and the rest from the black prosilver style I made to base dark styles off of.

http://i46.tinypic.com/2u6ogup.jpg

Now I can finally start developing the different CaseMods (What I decided to name it :blush: )(Still very much welcoming other name ideas).
I already died once. Let's hope it doesn't happen again.
User avatar
Kane    
Cadet II
Cadet II
 
Posts: 25
Joined: 27 Dec 2009, 21:15
Location: Texas
Favorite Team: Silver
Gender: Male
phpBB Knowledge: 5

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby gades » 05 Jan 2010, 08:00

Kane wrote:Eureka! I did it!


I am a web and database developper (oriented more towards Model/View/Controller than templates), trying to help out some friends with their phpBB3 forum dealing with old cars...

Of course they want a site besides the forum, where various docs and other goodies would be available to logged in members, and of course with the forum theme. So this framework seems to perfectly fit the bill...
I have a domain, and subdomains, an online server to experiment with.

So I wonder, Kane, if that would be Ok, would you share your code and I could maybe debug, experiment, help out if I can (although my knowledge of the phpBB core is nill) ?

Gades
gades    
Crewman
Crewman
 
Posts: 1
Joined: 05 Jan 2010, 07:49
Gender: Male
phpBB Knowledge: 1

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby Highway of Life » 05 Jan 2010, 14:45

You guys might want to look at the Whizby Development: http://whizby.assembla.com - Whizby CMS is basically the next advanced version of the WIF (Website Integration Framework), the WIF is meant almost strictly for programmers, but the Whizby CMS is designed for everybody. We are very close to the first beta with the CMS, so it might be worth doing a git clone and trying it out on your localhost. If you are interested in becoming a tester of the project, set yourself to "watcher" status on Assembla, or send us an e-mail (address listed on the Assembla project space).
If you would like to share patches, or contribute in other ways, that would be welcomed, please let us know how you would like to contribute.
Watch out! I might do a code wheelie!

User avatar
Highway of Life    
STG Jedi Master
STG Jedi Master
 
Posts: 10458
Joined: 08 May 2006, 05:23
Location: Beware of Programmers carrying screwdrivers
Gender: Male
phpBB Knowledge: 10

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby Kane » 06 Jan 2010, 09:19

Just wanted to let you know that in your default package, if a user is guest/not logged in the framework will output a blank white page
I already died once. Let's hope it doesn't happen again.
User avatar
Kane    
Cadet II
Cadet II
 
Posts: 25
Joined: 27 Dec 2009, 21:15
Location: Texas
Favorite Team: Silver
Gender: Male
phpBB Knowledge: 5

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby renathy » 10 Jan 2010, 15:15

Hi! I am using your framwork and I've a problem to check if a user is logged in.
For a month I've worked with PHPBB3 acp to add my own modules, now I need to create site to use them...

The problem is as follows -

I've installed your framwork.
I've change overall_header.html, overall_footer.html, site_body.html.
Overall_header.html should contains
1) a box with - login form or user profile (depanding on whether user is logged in or not).
2) navigation - also depands on whether user is logged in
...

I've already created box for login form or user profile (it shows login form if user is logged in, otherwise - profile info). This actually doesn't work, because I've not created login check in my index.php (and this is the probolem).

I've not changed anything in index.php yet - it is still the same.

Now,
1) I want to check if user is loged in to fill up my "overal_header.html" file correctly (i need template value S_USER_LOGGED_IN which is set in website_class to be correct).
2) - I need to show index.php also if user is not logged in, but with body = intro.html
3) - if user is logged in I need to change body to xxx.html (depending on GET variable).

I cannot figure out how to do this.
I've found in phpbb3 tutorial function login_box, however, if user is not logged in, it simply generates new page with login form. This is not what I need - I do not need to generate any new pages, I need to have the same index.php page... (otherwise, steps "2" and "3" couldn't be done)

So I need some function $loged_or_not = login(); No idea how to create id. Should I somehow look at login_box function more carefully and change it a little bit?
I hope you've understand my problem.

Please, give me some clues... I'm stuck.
Maybe I have to think another way?

Renathy
renathy
Crewman
Crewman
 
Posts: 3
Joined: 14 Dec 2009, 07:31
Gender: Female

Re: phpBB3 Website Integration Framework | Whizby Basic

Postby DHMH » 16 Jan 2010, 10:42

Thank you Highway of Life for that great framework :thumbsup: !!!!

@renathy:
That's a simple thing:
Insert that code into your index.php and change it a bit:
Spoiler:
Code: Select all
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if ($user->data['user_id'] == ANONYMOUS)
{
   $template->set_filenames(array(
   'body'   => 'not_logged_in.html',
));
}
else
{
// user is logged in
$template->set_filenames(array(
   'body'   => 'logged_in.html',
));
}
DHMH
Crewman
Crewman
 
Posts: 2
Joined: 08 Sep 2009, 06:53
Gender: Male
phpBB Knowledge: 8

PreviousNext

Return to phpBB3 Coding Assistance

Who is online

Users browsing this forum: Googlebot and 14 guests