Changeset 111

Show
Ignore:
Timestamp:
06/06/07 00:46:42 (1 year ago)
Author:
wikiplugin
Message:

Updated folio to v.6 -- many bug fixes and some additional configuration options.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • folio/folio/config.php

    r101 r111  
    11<?php 
     2// Folio Setup Options 
    23 
    3 // Folio Setup & Options 
    44global $CFG; 
     5$FOLIO_CFG->version = 0.6; 
     6$FOLIO_CFG->ajaxprefix = 'folio_control_tree_'; 
    57 
    6 // DEPRECIATED 
    7 //       THIS OPTION WAS DISABLED IN ELGG V.7 & FOLIO V.5 DUE TO COMPATABILITY PROBLEMS. 
    8 //      SETTING TO Y WILL NO LONGER WORK. 
    9 // Do you want to have a 'dropdown' menu for the 'Wiki Pages' link on the side-menu? 
    10 //      Allowable options are 'Y' and 'N' 
    11 $FOLIO_CFG->wiki_menu_dropdown = 'N'; 
    12 //  END DEPRECIATED 
    13  
    14 // Do you want to include 'Recent Changes' in the menu for a page?  Should probably be 'Y' 
    15 //      if you are not using the wiki_menu_dropdown options, otherwise, there is no easy way 
    16 //      to see the move recently updated pages. 
    17 //      Allowable options are 'Y' and 'N' 
    18 $FOLIO_CFG->wiki_menu_recentchanges = 'Y'; 
     8/////////////////////////////////////////////////////////////////////////////////////// 
     9//  WIKI OPTIONS 
     10/////////////////////////////////////////////////////////////////////////////////////// 
    1911 
    2012// Default permission level for a new page.  Can be PUBLIC, MODERATED, or PRIVATE 
    2113$FOLIO_CFG->page_defaultpermission = 'MODERATED'; 
     14 
     15/////////////////////////////////////////////////////////////////////////////////////// 
     16//  LOGGING OPTIONS 
     17/////////////////////////////////////////////////////////////////////////////////////// 
    2218 
    2319// One way of improving Apache logs is to add the user's username to each entry. 
     
    2925    apache_note('username',$_SESSION['username']);  
    3026 
    31 // Add a menu link for the Chatbox add-in 
    32 //      Allowable options are 'Y' and 'N' 
    33 $FOLIO_CFG->chatbox_installed = 'N'; 
    34  
    35 // Disable the following menu links.  
    36 // If you do not want to disable certain options, leave the array empty.  Do not comment out 
    37 //      the variable. 
    38 // Some common options are 'dashboard', 'feeds' <- subscriptions, 'folio' <- wiki page link, 'folio_feeds' <- activity 
    39 $FOLIO_CFG->disabled_menuitems = array();  
    40  
    4127// Folio has the option to keep track a historical record of user logons.  
    4228// If you want to track this data, then set this option to "Y".  If you put it  
    4329//      as 'N', then old logons will be deleted. 
    44 $FOLIO_CFG->track_logons = 'Y'; 
     30$FOLIO_CFG->track_logons = 'N'; 
     31 
     32     
     33/////////////////////////////////////////////////////////////////////////////////////// 
     34//  SIDEBAR DISPLAY OPTIONS 
     35/////////////////////////////////////////////////////////////////////////////////////// 
     36 
     37// Disable  menu links.  
     38// If you do not want to disable certain options, leave the array empty.  Do not comment out 
     39//      the variable. 
     40 
     41// TOP MENU 
     42// Some common options are 'feeds' <- subscriptions, 'folio' <- wiki page link, 'folio_feeds' <- activity 
     43$FOLIO_CFG->disabled_topmenuitems = array();  
     44 
     45// SIDE MENU 
     46// Standard options are:  (include the path) 
     47//  $CFG->dirroot . "mod/blog/lib/weblogs_user_info_menu.php"  <--- Elgg above v.8 has /mod/ instead of /units/ 
     48//  $CFG->dirroot . "mod/file/lib/files_user_info_menu.php" 
     49//  These are normally disabled, as the folio side-menu replaces their functionality.  However, if you want these, 
     50//      then remove them from the following array.  In addition, change the FOLIO_CFG->disabled_foliomenuitems variable 
     51//      to keep that from showing them. 
     52$FOLIO_CFG->disabled_sidemenuitems =  
     53    array( $CFG->dirroot . 'mod/blog/lib/weblogs_user_info_menu.php', // Elgg 8 
     54           $CFG->dirroot . 'mod/file/lib/files_user_info_menu.php', // Elgg 8 
     55                   $CFG->dirroot . 'units/weblogs/weblogs_user_info_menu.php', // Elgg 7 
     56           $CFG->dirroot . 'units/files/files_user_info_menu.php' // Elgg 7 
     57                   );  
     58                 
     59                 
     60                 
     61// If you are having troubles finding the particular include needed, set the following to true to print out the names of the included files. 
     62$FOLIO_CFG->debug_print_sidemenu_includes = false; // true 
     63 
     64// FOLIO MENU         
     65// This can be used to disable certain elements from the wiki folio sidemenu. As an example, if you decide to have 
     66//      the normal blog sidebar shown, then you will want to not show the wiki blog link. 
     67// Options ( 'weblog', 'files', 'profile', 'wiki' ) 
     68$FOLIO_CFG->disabled_foliomenuitems = array() ; //array( 'profile','weblog','files','wiki' );  
     69 
     70 
     71/////////////////////////////////////////////////////////////////////////////////////// 
     72//  FRONTPAGE DISPLAY OPTIONS 
     73/////////////////////////////////////////////////////////////////////////////////////// 
     74 
    4575 
    4676// Folio has the option to keep show a custom log-on page.  It will show 
    4777//      recent activity counts & global data.If you want to show this instead 
    4878//      of the default php value, then set this option to "Y". 
    49 $FOLIO_CFG->template_frontpage = 'Y'; 
     79$FOLIO_CFG->template_frontpage = 'N'; 
    5080 
    5181// Folio has the option to keep show a custom log-on page.  The following variable 
     
    5787<p align='center'><br/><a href='{wwwroot}activity/inbox/{username}/html/all/all/1'><img src='{wwwroot}mod/folio/image/inbox.png'   border=0/></a></p>"; 
    5888 
     89 
    5990?> 
  • folio/folio/control/commentbox.php

    r101 r111  
    1919        $item_title = folio_page_encodetitle( $item_title ); 
    2020        $item_owner_username = folio_page_encodetitle( $item_owner_username ); 
    21      
     21         
     22        // Get access level for item  
     23    $item = get_record_select('folio_page_security',"security_ident = {$item_ident}"); 
     24 
     25    if (!$item) { 
     26        trigger_error("Invalid item ident {$item_ident} passed to /mod/folio/control/commentbox.php "); die(); 
     27    } 
     28        $access = $item->accesslevel; 
     29         
     30        // Set accesslevel to public if moderated, as from a reader's perspective, that's the same thing. 
     31        if ( $access == 'MODERATED' ) { 
     32                $access = 'PUBLIC'; 
     33        } 
     34         
    2235        /* This is now passed as $item_owner_ident 
    2336            if (logged_on) { 
     
    5770function {$ajaxprefix}makeRequest(){ 
    5871    var postData = "item_ident={$item_ident}&item_type={$item_type}" + 
    59         "&item_owner_name={$item_owner_name}&item_owner_username={$item_owner_username}&access=public&url={$item_url}&item_owner_ident={$item_owner_ident}&item_title={$item_title}&body=" +  
     72        "&item_owner_name={$item_owner_name}&item_owner_username={$item_owner_username}&access={$access}&url={$item_url}&item_owner_ident={$item_owner_ident}&item_title={$item_title}&body=" +  
    6073        escape( document.{$ajaxprefix}form.{$ajaxprefix}comment.value ); 
    6174        var request = YAHOO.util.Connect.asyncRequest('POST', "{$url}", {$ajaxprefix}callback, postData); 
  • folio/folio/control/commentbox_postdata.php

    r101 r111  
    6868                'Comment by ' . $comment->creator_username . ' on ' . $comment->item_title,  
    6969                $comment->body,  
    70                 $url ) ; 
     70                $url, $comment->access ) ; 
    7171                 
    7272    // Return wrapped up. 
  • folio/folio/control/feeds.php

    r101 r111  
    134134    $date = gmdate("D M d",intval($result->created)); 
    135135    $type = str_replace( '_', ' ', $result->type ); 
     136    $iconid = user_info("icon", $result->user_ident); 
    136137 
    137138    $html .= <<< END 
     
    139140            <td width="70" valign="top"> 
    140141                <a href="{$CFG->wwwroot}{$result->user_username}"> 
    141                     <img alt="" src="{$CFG->wwwroot}_icon/user/{$result->user_ident}/h/50/w/50" border="0"/> 
     142                    <img alt="" src="{$CFG->wwwroot}_icon/user/{$iconid}/h/50/w/50" border="0"/> 
    142143                </a> 
    143144            </td> 
     
    163164 
    164165        if ( $page < $pages ) { 
    165                 $result .= "<a href='" . ($page + 1) . "'>&lt;&lt; Back</a> "; 
     166                $result .= "<a href='" . ($page + 1) . "'>&lt;&lt; Older</a> "; 
    166167        } 
    167168 
     
    169170         
    170171        if ( $page > 1 ) { 
    171                 $result .= "<a href='" . ($page - 1) . "'>Forward &gt;&gt;</a> "; 
     172                $result .= "<a href='" . ($page - 1) . "'>Newer &gt;&gt;</a> "; 
    172173        } 
    173174         
     
    231232 
    232233    // src="{$url}{$result->user_username}/icons/{$icon}/h/67/w/67"  
    233     $iconurl = $CFG->wwwroot . "_icon/user/" . $result->user_ident . '/h/50/w/50'; 
     234    $iconurl = $CFG->wwwroot . "_icon/user/" . user_info("icon",$result->user_ident) . '/h/50/w/50'; 
    234235 
    235236    /* 
  • folio/folio/control/page_edit_post.php

    r101 r111  
    6969    $security = optional_param('folio_control_page_edit_security_custom', 'PUBLIC'); 
    7070    if ( $security == 'PRIVATE' ) { 
    71         if ( folio_finduser( $username )->user_type == 'community' ) { 
     71        $u = folio_finduser( $username ); 
     72        if ( $u->user_type == 'community' ) { 
    7273            $security = 'community' . $page->user_ident; 
    7374        } else { 
     
    8081    $tags = trim($tags); 
    8182    insert_tags_from_string ($tags, 'page', $page->page_ident, $security, $page->user_ident); 
    82      
     83 
     84        // We want to delete RSS records of changes to this page by this user within the last hour UNLESS they're by an anonymous user 
     85        if ( $page->creator_ident <> -1 ) { 
     86                rss_deleteitem( 'page', $page->page_ident, $page->creator_ident, 3600 ); 
     87        } 
     88         
    8389        // Create RSS record 
    8490        rss_additem( $page->user_ident, $username, 
  • folio/folio/control/tree.php

    r101 r111  
    2121*               Get current node's other child nodes, passing the previously created (down) node  
    2222                        as an argument so that it won't be built 2x. 
    23 *       repeat until we hit this trees base node (where parentpage_ident == page_ident). 
     23*       repeat until we hit this trees base node (where parentpage_ident == page_ident).  Don't create a node for the root, as that's already in the menu by default. 
    2424* 
    2525* NOTE: Calling functions SHOULD NOT SET $previouspage_ident.   
     
    7171                if ( $page->children == 1 ) { 
    7272                        $result = folio_control_tree_getNodeChildren( $ajaxprefix, $page_ident, $previouspage_ident, $url, $result, $profile_id); 
    73                         $result .= "\n{$ajaxprefix}Node{$page_ident}.expand();\n"; 
    7473                } 
    7574                 
     
    8786                        // Add code to automatically expand. 
    8887                        $result = str_replace("%{$page_ident}root%", "root", $result);        
    89                         $result .= "\n{$ajaxprefix}Node{$page_ident}.expand();\n"; 
    9088 
    9189                } else { 
     
    175173 
    176174/** 
    177 * Public code that should be called to create a tree
     175* Public code that should be called to create a tree from an arbitrary node
    178176* 
    179177* @param $page_ident Required, the root node being shown. 
    180178* @param $page_title Required, the name of the root node being shown. 
    181179* @param $username The name of the user/community to whom this page belongs. 
     180* @param $page_id The id of the page to expand 
    182181*/ 
    183 function folio_control_tree( $page_ident, $page_title, $username ) { 
     182function folio_control_tree( $page_ident, $page_title, $username, $page_id =-1 ) { 
    184183        //      Note: Do not change the name of the root node to anything but root without also changing it in the helper functions in this file. 
    185184    global $CFG; 
    186185    global $metatags; 
    187     global $ajaxprefix; 
     186    global $FOLIO_CFG; 
     187    $address = $CFG->wwwroot . 'mod/folio/'; 
     188 
     189        // Used by the different php functions in this file to prefix all of the ajax stuff being output to the screen. 
     190        //      May eventually be used to allow for including a number of instances of this control on a single page. 
     191        $ajaxprefix = $FOLIO_CFG->ajaxprefix;  
     192         
     193    // Add CSS link. 
     194    $metatags .= "\n<link rel=\"stylesheet\" type=\"text/css\" " .  
     195        "href=\"{$address}css/treeview.css.php\" />"; 
     196     
     197    // Build javascript to load parent information. 
     198    $buildNodes = folio_control_tree_getNodes( $ajaxprefix, $page_ident ); 
     199     
     200    // BUILD JAVASCRIPT 
     201    $body = folio_tree_js( $ajaxprefix, $buildNodes, $page_id ); 
     202     
     203    // return     
     204    return $body; 
     205 
     206/* 
     207 
     208<!-- width: 40%; float: right;  --> 
     209    padding:3px;margin-left: 0.5em;"> --> 
     210<!-- <div class="infoholder" style="border: 1px solid #7F9DB9;  
     211<!-- </div> --> 
     212 
     213 
     214* In case I need the code for the 'contract all', here it is 
     215          <div id="expandcontractdiv" onload="javascript:treeInit()"> 
     216                <a href="javascript:tree.collapseAll()">Collapse all</a> 
     217          </div> 
     218*/   
     219
     220 
     221/** 
     222* Public code that should be called to create a tree from the root node. 
     223
     224* @param $userid int The userid of the user/community to whom this page belongs. 
     225*/ 
     226function folio_control_roottree( $userid, $username ) { 
     227    global $CFG; 
     228    global $metatags; 
    188229    $address = $CFG->wwwroot . 'mod/folio/'; 
    189230 
     
    197238     
    198239    // Build javascript to load parent information. 
    199     $buildNodes = folio_control_tree_getNodes( $ajaxprefix, $page_ident ); 
     240    $buildNodes = folio_control_tree_getNodeAtRoot( $ajaxprefix, $userid, $username ); 
    200241     
    201242    // BUILD JAVASCRIPT 
    202     $body = <<< END 
     243    $body = folio_tree_js( $ajaxprefix, $buildNodes ); 
     244     
     245    // return     
     246    return $body; 
     247 
     248/* 
     249 
     250<!-- width: 40%; float: right;  --> 
     251    padding:3px;margin-left: 0.5em;"> --> 
     252<!-- <div class="infoholder" style="border: 1px solid #7F9DB9;  
     253<!-- </div> --> 
     254 
     255 
     256* In case I need the code for the 'contract all', here it is 
     257          <div id="expandcontractdiv" onload="javascript:treeInit()"> 
     258                <a href="javascript:tree.collapseAll()">Collapse all</a> 
     259          </div> 
     260*/   
     261
     262 
     263/** 
     264* This function formats the title of a page in a suitable format for the treeview control 
     265*   As of Feb 2007, v.7 of Elgg forces a td.width declaration, which messes up the  yahoo treeview control 
     266*   As a fix, I do a duplicate declaration to set td.width=10px.  However, this means that the title needs to be 
     267*   forced to have the correct length.  So, I use non-breaking spaces to fill it out.  However, allowing some breaking 
     268*   spaces is a good idea, as otherwise it gets too long. So separate into chunks 
     269
     270* Note that this is re-defined in tree_getdata.php for that file's usage. 
     271* $title Incoming title 
     272**/ 
     273function folio_tree_formattitle( $title ) { 
     274    // max len 
     275    //return $title; 
     276    $len = 25; 
     277    $temp = ''; 
     278   
     279    $title = str_replace("\"", "'", trim($title) ); 
     280    $parts = explode(' ', $title); 
     281    $title = ''; 
     282 
     283    foreach ( $parts as $part ) { 
     284        if ( strlen( $temp ) == 0 ) { 
     285            // Nothing in temp variable 
     286            $temp = $part; 
     287        } elseif ( ( strlen($temp) + strlen($part) ) < $len ) { 
     288            // Can join 
     289            $temp = $temp . '~' . $part; 
     290        } else { 
     291            // Too long.  Make new temp & move old temp to return value. 
     292            $title = ltrim( $title . ' ' . $temp ); 
     293            $temp = $part; 
     294        } 
     295    } 
     296    // Move last temp to title 
     297    $title = str_replace( '~', '&nbsp;', trim( $title . ' ' . $temp ) );     
     298    return $title; 
     299
     300 
     301/** 
     302* This function contains all of the js for the tree control 
     303
     304*  It is called by a couple of the functions that create trees. 
     305* $ajaxprefix string The standard prefix for the js code namespace. 
     306* $buildNodes string The pre-built nodes to create on the page. 
     307**/ 
     308function folio_tree_js( $ajaxprefix, $buildNodes, $page_id ) { 
     309        //      Note: Do not change the name of the root node to anything but root without also changing it in the helper functions in this file. 
     310    global $CFG; 
     311    $address = $CFG->wwwroot . 'mod/folio/'; 
     312 
     313    return <<< END 
    203314 
    204315        <script type="text/javascript" src="{$address}control/yui/build/yahoo/yahoo.js" ></script> 
     
    218329       // Add Nodes 
    219330       $buildNodes 
    220                
     331 
    221332       {$ajaxprefix}tree.draw(); 
     333       {$ajaxprefix}expand( $page_id ); 
     334} 
     335 
     336// Recursively expand this node & all parents. 
     337function {$ajaxprefix}expand( nodeID ) { 
     338        var node = YAHOO.widget.TreeView.getTree( '{$ajaxprefix}treeDiv1').getNodeByProperty( 'id', nodeID ); 
     339        node.expand(); 
     340        if ( !node.isRoot() ) { 
     341            {$ajaxprefix}expand( node.parent.data.id ); 
     342        } 
    222343} 
    223344 
     
    317438    </STYLE> 
    318439    <div id='splitpanesidebar2'> 
    319     <b>Pages</b
     440    <!-- <b>Pages</b> --
    320441      <div id="{$ajaxprefix}treeDiv1"></div> 
    321442<img src="{$address}control/tree_blankimage.jpg" onload="javascript:{$ajaxprefix}treeInit()"  /> 
    322443    </div> 
    323444END; 
    324      
    325     // return     
    326     return $body; 
    327  
    328 /* 
    329  
    330 <!-- width: 40%; float: right;  --> 
    331     padding:3px;margin-left: 0.5em;"> --> 
    332 <!-- <div class="infoholder" style="border: 1px solid #7F9DB9;  
    333 <!-- </div> --> 
    334  
    335  
    336 * In case I need the code for the 'contract all', here it is 
    337           <div id="expandcontractdiv" onload="javascript:treeInit()"> 
    338                 <a href="javascript:tree.collapseAll()">Collapse all</a> 
    339           </div> 
    340 */   
    341 
    342  
    343 /** 
    344 * This function formats the title of a page in a suitable format for the treeview control 
    345 *   As of Feb 2007, v.7 of Elgg forces a td.width declaration, which messes up the  yahoo treeview control 
    346 *   As a fix, I do a duplicate declaration to set td.width=10px.  However, this means that the title needs to be 
    347 *   forced to have the correct length.  So, I use non-breaking spaces to fill it out.  However, allowing some breaking 
    348 *   spaces is a good idea, as otherwise it gets too long. So separate into chunks 
    349 
    350 * Note that this is re-defined in tree_getdata.php for that file's usage. 
    351 * $title Incoming title 
    352 **/ 
    353 function folio_tree_formattitle( $title ) { 
    354     // max len 
    355     $len = 15; 
    356     $temp = ''; 
    357    
    358     $title = str_replace("\"", "'", $title ); 
    359     $parts = explode(' ', $title); 
    360     $title = ''; 
    361  
    362     foreach ( $parts as $part ) { 
    363         if ( ( strlen($temp) + strlen($part) ) < $len ) { 
    364             // Can join 
    365             $temp = $temp . '~' . $part; 
    366         } else { 
    367             // Too long.  Make new temp & move old temp to return value. 
    368             $title = ltrim( $title . ' ' . $temp ); 
    369             $temp = $part; 
    370         } 
    371     } 
    372      
    373     // Move last temp to title 
    374     $title = str_replace( '~', '&nbsp;', trim( $title . ' ' . $temp ) ); 
    375     return $title; 
     445 
    376446} 
    377447 
  • folio/folio/control/tree_getdata.php

    r101 r111  
    4444                        "WHERE w.parentpage_ident = $page_ident AND w.newest = 1 AND w.parentpage_ident <> w.page_ident AND " .  
    4545                        folio_page_security_where( 'p', 'w', 'read', $profile_id ) . 
    46             'ORDER BY title DESC, children DESC') 
     46            'ORDER BY title ASC, children DESC') 
    4747                );       
    4848         
     
    9393function folio_tree_formattitle( $title ) { 
    9494    // max len 
    95     $len = 15; 
     95    //return $title; 
     96    $len = 25; 
    9697    $temp = ''; 
    9798   
    98     $title = str_replace("\"", "'", $title ); 
     99    $title = str_replace("\"", "'", trim($title) ); 
    99100    $parts = explode(' ', $title); 
    100101    $title = ''; 
    101102 
    102103    foreach ( $parts as $part ) { 
    103         if ( ( strlen($temp) + strlen($part) ) < $len ) { 
     104        if ( strlen( $temp ) == 0 ) { 
     105            // Nothing in temp variable 
     106            $temp = $part; 
     107        } elseif ( ( strlen($temp) + strlen($part) ) < $len ) { 
    104108            // Can join 
    105109            $temp = $temp . '~' . $part; 
     
    110114        } 
    111115    } 
    112      
    113116    // Move last temp to title 
    114     $title = str_replace( '~', '&nbsp;', trim( $title . ' ' . $temp ) ); 
     117    $title = str_replace( '~', '&nbsp;', trim( $title . ' ' . $temp ) );     
    115118    return $title; 
    116119} 
  • folio/folio/html/feeds.php

    r101 r111  
    329329 
    330330                $body = folio_feeds_controlbox( $arguments, $page ) .  
    331                         folio_control_htmlfeed( $results, $resultcount, $page, $username );  
     331                        folio_control_htmlfeed( $results, $resultcount, $page, $arguments['username'] );  
    332332 
    333333                // Transfer into template & write. 
     
    455455* Replace the variable referenced by Change to set to Value.  Makes it easier for array 
    456456*   processing. 
     457* Note that if we are being told to remove the only value in the array that we will automatically 
     458*   select the wildcard. 
    457459* 
    458460* @param $changes array - An array of arrays= ('name', 'value') to arg array. 
     
    465467        if ( is_array($arguments[$change['name']]) ) { 
    466468            if ( in_array( $change['value'], $arguments[$change['name']])  ) {  
     469                // Remove 
    467470                $arguments[$change['name']] = folio_delete_element( $arguments[$change['name']], $change['value'] ); 
     471                // Test to make sure that there is at least one option. 
     472                if ( count($arguments[$change['name']]) == 0 ) { 
     473                    array_push( $arguments[$change['name']], 'all' ); 
     474                } 
    468475            } else { 
    469476                array_push($arguments[$change['name']], $change['value']); 
  • folio/folio/html/setupdb.php

    r101 r111  
    3333 
    3434// See if a user other than news is trying to run this. 
    35 if ($USER->username <> 'news') { 
    36       error('You can only run this function if you logged on as "news"'); 
    37       die(); 
    38 
     35//if ($USER->username <> 'news') { 
     36//    error('You can only run this function if you logged on as "news"'); 
     37//    die(); 
     38//
    3939 
    4040// Start upgrading. 
  • folio/folio/html/view.php

    r101 r111  
    1717    require_once("../control/pagelist.php"); 
    1818    require_once("../control/page_view_tags.php"); 
     19    require_once("../control/commentbox.php"); 
    1920     
    2021    run("profile:init"); 
     
    2223    run("folio:init"); 
    2324     
     25    global $CFG; 
     26    global $PAGE; 
     27    global $FOLIO_CFG; 
     28 
    2429    // Retrieve passed variables (page name & user name, as well as created). 
    2530    //     These variables will be used by the menu system to build links.  See lib.php for more details. 
     
    95100                folio_page_view($page_ident,$page_title, -1, $page, $username); 
    96101 
     102            // Add the edit option 
     103            $PAGE->menu_sub[] = array( 'name' => 'folio:edit', 
     104                'html' => a_hrefg( "{$CFG->wwwroot}$username/page/" . 
     105                folio_page_encodetitle($page_title) . "/edit", 
     106                "Edit Page"));   
     107 
    97108        } else { 
    98109            // Viewing an existing page. 
     
    109120                folio_page_view_tags($page_ident) . 
    110121                folio_control_childpagelist( $username, $page, $page_owner ) . 
    111                 folio_control_commentlist( 'page', $page_ident); 
     122                folio_control_commentlist( 'page', $page_ident) . 
     123                folio_control_commentbox( $page_ident, 'page', $page_title,  
     124                    url . $comment_on_username . '/page/' . folio_page_encodetitle( $page_title ), 
     125                    $comment_on_ident, $comment_on_name, $comment_on_username); 
     126             
     127             // setup menu 
     128                // Looking at a page. 
     129                $PAGE->menu_sub[] = array( 'name' => 'folio:recentchanges', 
     130                        'html' => a_hrefg( "{$CFG->wwwroot}activity/user/$username/summary/page+page_comment/all/1", 
     131                        "Recent Changes"));   
     132                $PAGE->menu_sub[] = array( 'name' => 'folio:edit', 
     133                        'html' => a_hrefg( "{$CFG->wwwroot}$username/page/" . 
     134                        folio_page_encodetitle($page_title) . "/edit", 
     135                        "Edit Page"));   
     136                $PAGE->menu_sub[] = array( 'name' => 'folio:history', 
     137                        'html' => a_hrefg( "{$CFG->wwwroot}$username/page/" . 
     138                        folio_page_encodetitle($page_title) . "/history", 
     139                        "History"));   
     140                $PAGE->menu_sub[] = array( 'name' => 'folio:delete', 
     141                        'html' => a_hrefg( "{$CFG->wwwroot}$username/page/" . 
     142                        folio_page_encodetitle($page_title) . "/delete", 
     143                        "Delete"));   
     144                         
     145                // Setup Metatags for RSS Discovery 
     146                $metatags .= "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".url."$username/subscribe/rss/page+page_comment/\" />\n"; 
     147                 
     148 
     149 
     150//            $body .= "\n<a href=\"javascript:alert( YAHOO.widget.TreeView.getTree(  
     151  //              '{$FOLIO_CFG->ajaxprefix}treeDiv1').getNodeByProperty( 'id', '$page_ident' ) );\">Get Node</a>\n"; 
     152 
     153    //        $body .= "\n<a href=\"\">Expand</a>\n"; 
     154 
    112155        } 
    113156    } else { 
     
    131174                ) 
    132175                ); 
     176 
     177    // Add JS to exand the tree control. 
     178//    $body .= "\n<img src='{$CFG->wwwroot}mod/folio/control/tree_blankimage.jpg' onload=\"javascript:{$FOLIO_CFG->ajaxprefix}expand( '$page_ident' );\"\>\n"; 
    133179     
    134180    echo templates_page_draw(array( 
  • folio/folio/lib.php

    r101 r111  
    1111**/ 
    1212function folio_version() { 
    13     return 0.5; 
     13    global $FOLIO_CFG; 
     14    return $FOLIO_CFG->version; 
    1415} 
    1516 
     
    2627 
    2728    listen_for_event("weblog_post","publish","folio_rss_weblog_post"); 
     29    listen_for_event("weblog_post","update","folio_rss_weblog_post"); 
    2830    listen_for_event("weblog_comment","publish","folio_rss_weblog_comment"); 
    2931    listen_for_event("file","publish","folio_rss_file"); 
    30  
     32    listen_for_event("file","update","folio_rss_file"); 
     33         
    3134    // Test to see if there has been a log-on event 
    3235    $l = optional_param('username'); 
    3336    $p = optional_param('password'); 
    3437 
    35     // Test to see if a log-on event is going to occur thru cached credentials (or if they're already logged in, but 
    36     //      the session variable with the replacement template code isn't being used). 
    37     // Also test to see if a logon form has been submitted, in which case, re-test 
    38     //    against authenticate & then record the logon event. 
    39     if ( isloggedin() && !isset( $_SESSION['folio_template_frontpage'] ) ) { 
    40         // Login via cached information. 
    41         folio_record_logon(); 
    42     } else { 
    43         // Test to see if a logon-form has been submitted. 
    44         if (!empty($l) && !empty($p)) { 
    45             if ( authenticate_account($l, $p) ) { 
    46                 folio_record_logon(); 
     38    if ( $FOLIO_CFG->track_logons == 'Y' OR $FOLIO_CFG->template_frontpage == 'Y' ) { 
     39        // Test to see if a log-on event is going to occur thru cached credentials (or if they're already logged in, but 
     40        //      the session variable with the replacement template code isn't being used). 
     41        // Also test to see if a logon form has been submitted, in which case, re-test 
     42        //    against authenticate & then record the logon event. 
     43        if ( isloggedin() && !isset( $_SESSION['folio_template_frontpage'] ) ) { 
     44            // Login via cached information. 
     45            folio_record_logon(); 
     46        } else { 
     47            // Test to see if a logon-form has been submitted. 
     48            if (!empty($l) && !empty($p)) { 
     49                if ( authenticate_account($l, $p) ) { 
     50                    folio_record_logon(); 
     51                } 
    4752            } 
    4853        } 
     
    135140    if (isloggedin() & defined('context') ) { 
    136141        if ( substr(context, 0, 5) == "folio" & $username == $currentusername) { 
    137      
    138             // Show selected 
     142                // Show selected 
    139143            $PAGE->menu[] = array( 'name' => 'folio',  
    140144                'html' => '<li><a href="'.$CFG->wwwroot . $currentusername . '/page/" class="selected">Your Pages</a></li>'); 
    141      
    142         } else { 
     145                } else { 
    143146            // Show main menu unselected 
    144147            $PAGE->menu[] = array( 'name' => 'folio',  
    145148                'html' => '<li><a href="'.$CFG->wwwroot . $currentusername . '/page/">Your Pages</a></li>'); 
    146          
    147149        } 
    148150    } elseif ( isloggedin() ) { 
     
    150152        // Show link to folio. 
    151153        $PAGE->menu[] = array( 'name' => 'folio',  
    152             'html' => '<li><a href="'.$CFG->wwwroot . $currentusername . '/page/">Your Pages</a>'); 
    153          
     154            'html' => '<li><a href="'.$CFG->wwwroot . $currentusername . '/page/">Your Pages</a></li>'); 
    154155    } 
    155156 
     
    168169    } elseif ( isloggedin() ) { 
    169170        // Some pages don't have context defined. 
    170         // Show link to folio
     171        // Show link to activity
    171172        array_splice( $PAGE->menu, 0, 0, array( array( 'name' => 'folio_feeds',  
    172173            'html' => '<li><a href="'.$CFG->wwwroot . 'activity/inbox/' . $currentusername . '/html/all/all/1">Your Activity</a></li>'))); 
    173174    } 
    174175 
    175     if ( defined('context') ) { 
    176         if (substr(context, 0, 10) == 'folio_page') { 
    177             // Looking at a page. 
    178             // Look to see if we should include 'Recent Changes' as a menu option.  
    179             if ($FOLIO_CFG->wiki_menu_recentchanges == 'Y') { 
    180                 $PAGE->menu_sub[] = array( 'name' => 'folio:recentchanges', 
    181                     'html' => a_hrefg( "{$CFG->wwwroot}activity/user/$username/summary/page+page_comment/all/1", 
    182                     "Recent Changes"));   
    183             } 
    184             $PAGE->menu_sub[] = array( 'name' => 'folio:edit', 
    185                 'html' => a_hrefg( "{$CFG->wwwroot}$username/page/" . 
    186                 folio_page_encodetitle($page_title) . "/edit", 
    187                 "Edit Page"));   
    188             $PAGE->menu_sub[] = array( 'name' => 'folio:history', 
    189                 'html' => a_hrefg( "{$CFG->wwwroot}$username/page/" . 
    190                 folio_page_encodetitle($page_title) . "/history", 
    191                 "History"));   
    192             $PAGE->menu_sub[] = array( 'name' => 'folio:delete', 
    193                 'html' => a_hrefg( "{$CFG->wwwroot}$username/page/" . 
    194                 folio_page_encodetitle($page_title) . "/delete", 
    195                 "Delete"));   
    196                  
    197             // Setup Metatags for RSS Discovery 
    198             $metatags .= "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".url."$username/subscribe/rss/page+page_comment/\" />\n"; 
    199         } 
    200          
    201     }  
    202176 
    203177    // ------------------------------------------------------------- 
     
    207181    //    version used in this mod.      
    208182     
    209     // Remove the weblog & file pane. 
    210     $function['display:sidebar'] = folio_delete_element(  
    211         $function['display:sidebar'],  
    212         $CFG->dirroot . "units/weblogs/weblogs_user_info_menu.php"  
    213         ); 
    214  
    215     $function['display:sidebar'] = folio_delete_element(  
    216         $function['display:sidebar'],  
    217         $CFG->dirroot . "units/files/files_user_info_menu.php"  
    218         ); 
     183    folio_prunetopmenu(); 
     184    folio_prunesidemenu(); 
    219185 
    220186    // Insert  
     
    418384* 
    419385* @param string $input 
     386* @param array $valid Valid characterrs, defaults to standard -_() and spaces. 
    420387* @return string Clean input 
    421388**/ 
    422 function folio_clean( $input ) { 
     389function folio_clean( $input, $valid = array('(',')',' ','-','_',' ' )) { 
    423390 
    424391    $input = trim( $input ); 
    425392     
    426393    // Test for an easy clean / validation. 
    427     if ( ctype_alnum( str_replace( ' ', '', str_replace( ')', '', str_replace( '(', '', str_replace( '-', '', str_replace( '_', '', $input)) ) ) ) ) ){ 
     394                //Old Style::  str_replace( ' ', '', str_replace( ')', '', str_replace( '(', '', str_replace( '-', '', str_replace( '_', '', $input)) ) ) ) )  
     395    if ( ctype_alnum( folio_clean_replace( $input, $valid ) ) ) { 
    428396        // Validated.  Return 
    429397        return $input; 
     
    436404            $v = substr( $input, $i, 1 ); 
    437405             
    438             if ( ctype_alnum( $v ) | $v == '-' | $v == '_' | $v == '(' | $v ==')' | $v == ' ') { 
     406            if ( ctype_alnum( $v ) | in_array( $v, $valid ) ) { 
    439407                $retval .= $v; 
    440408            } 
     
    444412    } 
    445413} 
     414 
     415/** 
     416* Remove all of the valid_values in input  & return the value 
     417**/ 
     418function folio_clean_replace( $input, $remove_values ) { 
     419        foreach ( $remove_values as $value) { 
     420                $input = str_replace( $value, '', $input ); 
     421        } 
     422        return $input; 
     423} 
     424 
     425 
    446426/** 
    447427* Same as folio_clean, except suitable for array_walk 
     
    621601*    Encoded urls should not be stored in the database. 
    622602* 
    623 * Also adds in YOUTUBE links.  Should turn into an array instead of hardcoded, but this is 
     603* Automatically removes invalid characters. 
     604
     605* Creates links to other user's wikis through [[username:page titles]] 
     606
     607* Adds in YOUTUBE links.  Should turn into an array instead of hardcoded, but this is 
    624608*   just a quick fix. 
    625609* 
    626 * @todo Implement some simple checks on the [[ ]] linking.  Stuff like ]]] before [[..., title too long. 
    627610* @param string $username The username of the owner of the page. 
    628611* @param string $body The body that we're translating. 
     
    635618    while ( $i === true ) { 
    636619        $i = stripos( $body, '[[' ); 
    637         $end = stripos( $body, ']]' ); 
    638          
     620        $end = stripos( $body, ']]' );   
     621        $namespace = $username; 
     622        $nametag = ''; 
     623 
    639624        // Test find. 
    640625        if (!( $i === false | $end === false )) { 
    641626            // Translate title. 
    642             $link = substr( $body, $i+2, $end -$i -2); 
     627 
     628            $link = substr( $body, $i+2, $end -$i -2) ;  
     629            $link = folio_clean( $link, array( '(',')','-','_',':',' ') ); 
     630            // Find namespace for link.             
     631            if ( $temp = stripos( $link, ':') ) { 
     632                $namespace = substr( $link, 0, $temp ); 
     633                $link = substr( $link, $temp+1, strlen($link) - $temp ); 
     634                $nametag = $namespace  . ':'; 
     635            } 
     636 
    643637            $body = substr( $body, 0, $i ) . 
    644                 "<a href=\"{$url}{$username}/page/" . 
     638                "<a href=\"{$url}{$namespace}/page/" . 
    645639                folio_page_encodetitle($link) .  
    646                 "\">$link</a>" .  
     640                "\">{$nametag}{$link}</a>" .  
    647641                substr( $body, $end+2 ); 
    648642             
     
    792786                "or to create an online portfolio.\n\nYou can create links to new pages by simply " . 
    793787                "enclosing the page title using double bracket characters ([ and ]).  Here's an example " . 
    794                 "of a link to this [[Home Page]]."; 
     788                "of a link to this [[Home Page]].  "; 
    795789        $page->page_ident = $page_ident; 
    796790        $page->security_ident = $page_ident; 
     
    857851/** 
    858852* Publish something to an RSS feed 
     853* 
    859854*  
    860855* @param int owner_ident (int for the object owner) 
     
    897892} 
    898893 
     894 
     895/** 
     896* Deletes all RSS feed entries with the given key and type. 
     897*       Called to prevent duplicate entries for rapidly edited documents. 
     898*       If calling with the user_ident and timespan, need to use both. 
     899*  
     900* @param string Type (url-able string, etc: weblog, file, wikipage) 
     901* @param int Type_Ident  
     902* @param int User_Ident  (can be used to limit the deletion of the item to only the current user) 
     903* @param int timespan (how far back to delete) 
     904**/ 
     905function rss_deleteitem( $type, $type_ident, $user_ident = -1, $timespan = -1 ) { 
     906    global $db, $CFG; 
     907         
     908        if ( $user_ident == -1 AND $timespan == -1 ) { 
     909                delete_records('folio_rss', 'type_ident', $type_ident, 'type', $type); 
     910        } else { 
     911                $stmt = $db->Prepare("DELETE FROM {$CFG->prefix}folio_rss where type = '{$type}' AND " . 
     912                                                         "type_ident = {$type_ident} AND user_ident = {$user_ident} AND created > " . 
     913                                                         (time() - $timespan )); 
     914                $returnvalue = $db->Execute($stmt); 
     915        } 
     916} 
     917 
     918 
    899919/** 
    900920* Retrieve records from an rss feed. 
     
    10261046 
    10271047    //generate rss 
     1048        rss_deleteitem( $type, $type_ident ); 
    10281049    rss_additem( $owner_id, $owner_username, $user_id, $user_name, $user_username, $type, $type_ident, $tags, $title, $body, $link, $access); 
    10291050 
     
    10471068    $owner_id = $post->weblog; 
    10481069    $owner_username = user_info("username", $owner_id); 
     1070        $access = $post->access; 
    10491071 
    10501072    // Get user info from db. 
     
    10691091        $user_id, $user_name, $user_username,  
    10701092        'weblog_comment', $object->ident, '', 
    1071         $title, $object->body, $link ); 
    1072  
    1073 
    1074