more $item data
- add $item.categories and $item.folders to object/Item.php - add $item.hastags and $item.mentions to object/Item.php - add $item.total_comments_num and $item.total_comments_text to object/Item.php (those are set for top_level item also with no comments) - move get_cats_and_terms() to include/text.php
This commit is contained in:
		
					parent
					
						
							
								eda96a82d7
							
						
					
				
			
			
				commit
				
					
						dd25c7db7e
					
				
			
		
					 3 changed files with 89 additions and 65 deletions
				
			
		| 
						 | 
				
			
			@ -1071,6 +1071,72 @@ function prepare_text($text) {
 | 
			
		|||
}}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * returns 
 | 
			
		||||
 * [
 | 
			
		||||
 *    //categories [
 | 
			
		||||
 *          {
 | 
			
		||||
 *               'name': 'category name',
 | 
			
		||||
 *              'removeurl': 'url to remove this category',
 | 
			
		||||
 *             'first': 'is the first in this array? true/false',
 | 
			
		||||
 *               'last': 'is the last in this array? true/false',
 | 
			
		||||
 *           } ,
 | 
			
		||||
 *           ....
 | 
			
		||||
 *       ],
 | 
			
		||||
 *       // folders [
 | 
			
		||||
 *               'name': 'folder name',
 | 
			
		||||
 *               'removeurl': 'url to remove this folder',
 | 
			
		||||
 *               'first': 'is the first in this array? true/false',
 | 
			
		||||
 *               'last': 'is the last in this array? true/false',
 | 
			
		||||
 *           } ,
 | 
			
		||||
 *           ....       
 | 
			
		||||
 *       ]
 | 
			
		||||
 *   ]
 | 
			
		||||
 */
 | 
			
		||||
function get_cats_and_terms($item) {
 | 
			
		||||
    $a = get_app();
 | 
			
		||||
    $categories = array();
 | 
			
		||||
    $folders = array();
 | 
			
		||||
 | 
			
		||||
    $matches = false; $first = true;
 | 
			
		||||
    $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
 | 
			
		||||
    if($cnt) {
 | 
			
		||||
        foreach($matches as $mtch) {
 | 
			
		||||
            $categories[] = array(
 | 
			
		||||
                'name' => xmlify(file_tag_decode($mtch[1])),
 | 
			
		||||
                'url' =>  "#",
 | 
			
		||||
                'removeurl' => ((local_user() == $item['uid'])?$a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""),
 | 
			
		||||
                'first' => $first,
 | 
			
		||||
                'last' => false
 | 
			
		||||
            );
 | 
			
		||||
            $first = false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (count($categories)) $categories[count($categories)-1]['last'] = true;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    $matches = false; $first = true;
 | 
			
		||||
    $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
 | 
			
		||||
    if($cnt) {
 | 
			
		||||
        foreach($matches as $mtch) {
 | 
			
		||||
            $folders[] = array(
 | 
			
		||||
                'name' => xmlify(file_tag_decode($mtch[1])),
 | 
			
		||||
                 'url' =>  "#",
 | 
			
		||||
                'removeurl' => ((local_user() == $item['uid'])?$a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])):""),
 | 
			
		||||
                'first' => $first,
 | 
			
		||||
                'last' => false
 | 
			
		||||
            );
 | 
			
		||||
            $first = false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (count($folders)) $folders[count($folders)-1]['last'] = true;
 | 
			
		||||
    
 | 
			
		||||
    return array($categories, $folders);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * return atom link elements for all of our hubs
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue