WackoWiki: Вам запрещён доступDev/PatchesHacks/Category ...

Home Page | Изменения | Новые Комменты | Пользователи | Каталог | Регистрация | Вход:  Пароль:  

Action: Category

from WikkaWiki: http://wikkawiki.org/.
it works in WackoWiki in my site: http://www.openstory.ru


{{category}}


/actions/category.php

<?php
if ($cattag $_REQUEST["wakka"])
{
    
$str ="";
    if (!isset(
$col)) $col=1;
    if (!isset(
$compact)) $compact=0;
    if (!isset(
$page)) $page=$this->getPageTag(); 
    if (
$page=="/"$page="CategoryCategory"

//    $page= preg_replace( "/(\w+)\s(\w+)/", "$1$2",$page);
    
if (isset($class)) {
        
$class="class=\"$class\"";
    } else {
        
$class="";
    }
    if (!
$page) {$page=$cattag;}

    if (
$this->CheckMySQLVersion(4,0,1))
    {
            
$results $this->FullCategoryTextSearch($page); 
    }
    else
    {
            
$results $this->FullTextSearch($page); 
    }

    if (
$results)
    {
        if (!
$compact$str .= ' pages belong to ' $page ': <br /><br /><table '.$class.' width="100%"><tr>';
        else 
$str .= '<div '.$class.'><ul>';
        
        
$count 0
        
$pagecount 0;
        
$list = array();
        
        foreach (
$results as $i => $cpage) if($cpage['tag'] != $page) { array_push($list,$cpage['tag']);}
        
sort($list);
        while (list(
$key$val) = each($list)) {
            if (
$count == $col & !$compact)  { $str .= "</tr><tr>"$count=0; }
            if (!
$compact$str .= '<td>'.$this->Format('[['.$val.']]').'</td>';
            else 
$str .= '<li>'.$this->Format('[['.$val.' '.preg_replace"/Category/""",$val).']]').'</li>';
            
$count++;
            
$pagecount++;
        }
        
$str 'The following '.$pagecount.$str;
        if (!
$compact)  $str .= '</tr></table>'; else $str .= '</ul></div>';
    }
    else 
$str .= 'Sorry, no items found for ' $page .'.';
    print(
$str);
}
?>


include this to classes/wacko.php

<?php
     
function CheckMySQLVersion($major$minor$subminor)
    {
        
$result = @mysql_query('SELECT VERSION() AS version');
        if (
$result != FALSE && @mysql_num_rows($result) > 0)
        {
            
$row   mysql_fetch_array($result);
            
$match explode('.'$row['version']);
        }
        else
        {
            
$result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
            if (
$result != FALSE && @mysql_num_rows($result) > 0) {
                
$row   mysql_fetch_row($result);
                
$match explode('.'$row[1]);
            } else {
                return 
0;
            }
        }

        
$mysql_major $match[0];
        
$mysql_minor $match[1];
        
$mysql_subminor $match[2][0].$match[2][1];

        if (
$mysql_major $major) {
            return 
1;
        } else {
            if ((
$mysql_major == $major) && ($mysql_minor >= $minor) && ($mysql_subminor >= $subminor)) {
                return 
1;
            } else {
                return 
0;
            }
        }
    }

 function 
ExistsPage($page)
    {
        
$count 0;
        
$query =     "SELECT COUNT(tag)
                    FROM "
.$this->config['table_prefix']."pages
                    WHERE tag='"
.mysql_real_escape_string($page)."'";
        if (
$r $this->Query($query))
        {
            
$count mysql_result($r,0);
            
mysql_free_result($r);
        }
        return (
$count 0) ? TRUE FALSE;
    }
    function 
getCatMembers($category)
    {
        if (
$this->CheckMySQLVersion(4,0,1))
        {
            return 
$this->FullCategoryTextSearch($category);
        }
        else
        {
            return 
$this->FullTextSearch($category);        # @@@ could be more efficient by returning only 'tag'
        
}
    } 

        function 
FullCategoryTextSearch($phrase) { return $this->LoadAll("select * from ".$this->config["table_prefix"]."pages where latest = 'Y' and match(body) against('".mysql_real_escape_string($phrase)."' IN BOOLEAN MODE)"); }
?>

How to

to use it you mast create page CategoryCaregory – it will be Main Category – Index of Categories and include there {{category}}
All next categories must be named like CategorySomeName and have action {{category}} and link to ((CategoryCategory List of all Categories)).
If you want to insert you page to some Category, you mast put there link CategoryName_of_Category


To correct working, create all CategoryPages in first level and make link to category like /CategoryName_of_Category

To Do


Страницы, ссылающиеся на данную: Dev/PatchesHacks
WackoIdeas/Категории


 
Файлов нет. [Показать файлы/форму]
Комментариев нет. [Показать комментарии/форму]
Donate
Время работы: 1.886 s
Использовано памяти: 2.839 Mb