Пример: forum_js_personal

 
+
-
edit
 

Balancer

администратор
★★★★★
js.php

code php
  1. <?php
  2.  
  3. class base_js extends base_page_db
  4. {
  5.     function can_be_empty() { return true; }
  6.  
  7.     function preShowProcess()
  8.     {
  9.         include_once("inc/js.php");
  10.         header("Content-type", "text/javascript");
  11.         return str2js($this->cacheable_body());
  12.     }
  13. }


personal.php
code php
  1. <?php
  2.  
  3. class forum_js_personal extends base_js
  4. {
  5.     private $owner;
  6.  
  7.     function __construct($id)
  8.     {
  9.         parent::__construct($id);
  10.         $this->owner = class_load('forum_user', $this->id());
  11.     }
  12.  
  13.     function cache_static() { return 7*86400; }
  14.  
  15.     function url()
  16.     {
  17.         return "http://balancer.ru/user/".$this->id()."/personal.js";
  18.     }
  19.  
  20.     function owner() { return $this->owner; }
  21. }


personal.html
code html4strict
  1. Здравствуйте, {$this->owner|get:titled_url}!
  2. <ul>
  3. <li><a href="http://balancer.ru/user/{$this->owner()|get:id}/blog/">Ваш блог</a></li>
  4. <li><a href="http://balancer.ru/user/{$this->owner()|get:id}/use-topics.html">Ваши темы</a></li>
  5. <li><a href="/actions/do-logout/">Выход</a></li>
  6. </ul>
  7.  
  8. Форум:
  9. <ul>
  10. <li><a href="http://balancer.ru/forum/punbb/search.php?action=show_24h">За сутки</a></li>
  11. <li><a href="http://balancer.ru/forum/punbb/search.php?action=show_new">Новое</a></li>
  12. </ul>

...

И, наконец, привязываем это всё к системе:

bors_map.php
code php
  1. ...
  2. '/user/(\d+)/personal\.js => forum_js_personal(1)',
  3. ...


И этого - достаточно, чтобы каждому юзеру форума в статическую
страницу вставлялся персональный кусок кода через JS.
 

в начало страницы | новое
 
Поиск
Настройки
Твиттер сайта
Статистика
Рейтинг@Mail.ru