Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

compile_search_actions()

Parameters

ColumnTypeDefaultDescription
$top_actions

Location

include/search_functions.php lines 551 to 771

Definition

 
function compile_search_actions($top_actions)
    {
    
$options = array();
    
$o=0;

    global 
$baseurl,$baseurl_short$lang$k$search$restypes$order_by$archive$sort$daylimit$home_dash$url,
           
$allow_smart_collections$resources_count$show_searchitemsdiskusage$offset$allow_save_search,
           
$collection$usercollection$internal_share_access$show_edit_all_link;

    if(!isset(
$internal_share_access)){$internal_share_access=false;}
    

    
// globals that could also be passed as a reference
    
global $starsearch;
    
$urlparams = array(
        
"search"        =>  $search,
        
"collection"    =>  $collection,
        
"restypes"      =>  $restypes,
        
"starsearch"    =>  $starsearch,
        
"order_by"      =>  $order_by,
        
"archive"       =>  $archive,
        
"sort"          =>  $sort,
        
"daylimit"      =>  $daylimit,
        
"offset"        =>  $offset,
        
"k"             =>  $k
        
);

    
$omit_edit_all false;

    
#This is to stop duplicate "Edit all resources" caused on a collection search
    
if(isset($search) && substr($search011) == '!collection' && ($k == '' || $internal_share_access))
        { 
        
$omit_edit_all true;
        }
                   
    if(!
checkperm('b') && ($k == '' || $internal_share_access)) 
        {
        if(
$top_actions && $allow_save_search && $usercollection != $collection)
            {
            
$options[$o]['value']='save_search_to_collection';
            
$options[$o]['label']=$lang['savethissearchtocollection'];
            
$data_attribute['url'] = generateURL($baseurl_short "pages/collections.php"$urlparams, array("addsearch" => $search));
            
$options[$o]['data_attr']=$data_attribute;
            
$options[$o]['category']  = ACTIONGROUP_COLLECTION;
            
$options[$o]['order_by']  = 70;
            
$o++;
            }

        
#Home_dash is on, AND NOT Anonymous use, AND (Dash tile user (NOT with a managed dash) || Dash Tile Admin)
        
if($top_actions && $home_dash && checkPermission_dashcreate())
            {
            
$option_name 'save_search_to_dash';
            
$extraparams = array();
            
$extraparams["create"] = "true";
            
$extraparams["tltype"] = "srch";
            
$extraparams["freetext"] = "true";
            
            
$data_attribute = array(
                
'url'  => generateURL($baseurl_short "pages/dash_tile.php"$urlparams$extraparams),
                
'link' => str_replace($baseurl,'',$url)
            );

            if(
substr($search011) == '!collection')
                {
                
$option_name 'save_collection_to_dash';
                
$extraparams["promoted_resource"] = "true";
                
$extraparams["all_users"] = "1";
                
$extraparams["link"] = $baseurl_short "pages/search.php?search=!collection" $collection;
                
$data_attribute['url'] = generateURL($baseurl_short "pages/dash_tile.php"$urlparams$extraparams);
                }

            
$options[$o]['value'] = $option_name;
            
$options[$o]['label'] = $lang['savethissearchtodash'];
            
$options[$o]['data_attr'] = $data_attribute;
            
$options[$o]['category']  = ACTIONGROUP_SHARE;
            
$options[$o]['order_by']  = 170;
            
$o++;
            }
            
        
// Save search as Smart Collections
        
if($top_actions && $allow_smart_collections && substr($search011) != '!collection')
            {
            
$extra_tag_attributes sprintf('
                    data-url="%spages/collections.php?addsmartcollection=%s&restypes=%s&archive=%s&starsearch=%s"
                '
,
                
$baseurl_short,
                
urlencode($search),
                
urlencode($restypes),
                
urlencode($archive),
                
urlencode($starsearch)
            );

            
$options[$o]['value']='save_search_smart_collection';
            
$options[$o]['label']=$lang['savesearchassmartcollection'];
            
$options[$o]['data_attr']=array();
            
$options[$o]['extra_tag_attributes']=$extra_tag_attributes;
            
$options[$o]['category']  = ACTIONGROUP_COLLECTION;
            
$options[$o]['order_by']  = 170;
            
$o++;
            }

        
/*// Wasn't able to see this working even in the old code
        // so I left it here for reference. Just uncomment it and it should work
        global $smartsearch;
        if($allow_smart_collections && substr($search, 0, 11) == '!collection' && (is_array($smartsearch[0]) && !empty($smartsearch[0])))
            {
            $smartsearch = $smartsearch[0];

            $extra_tag_attributes = sprintf('
                    data-url="%spages/search.php?search=%s&restypes=%s&archive=%s&starsearch=%s&daylimit=%s"
                ',
                $baseurl_short,
                urlencode($smartsearch['search']),
                urlencode($smartsearch['restypes']),
                urlencode($smartsearch['archive']),
                urlencode($smartsearch['starsearch']),
                urlencode($daylimit)
            );

            $options[$o]['value']='do_saved_search';
            $options[$o]['label']=$lang['dosavedsearch'];
            $options[$o]['data_attr']=array();
            $options[$o]['extra_tag_attributes']=$extra_tag_attributes;
            $o++;
            }*/

        
if($resources_count != 0)
            {
                
$extra_tag_attributes sprintf('
                        data-url="%spages/collections.php?addsearch=%s&restypes=%s&order_by=%s&sort=%s&archive=%s&mode=resources&daylimit=%s&starsearch=%s"
                    '
,
                    
$baseurl_short,
                    
urlencode($search),
                    
urlencode($restypes),
                    
urlencode($order_by),
                    
urlencode($sort),
                    
urlencode($archive),
                    
urlencode($daylimit),
                     
urlencode($starsearch)
                );

                
$options[$o]['value']='save_search_items_to_collection';
                
$options[$o]['label']=$lang['savesearchitemstocollection'];
                
$options[$o]['data_attr']=array();
                
$options[$o]['extra_tag_attributes']=$extra_tag_attributes;
                
$options[$o]['category']  = ACTIONGROUP_COLLECTION;
                
$options[$o]['order_by']  = 170;
                
$o++;
                

            if(
!= $resources_count && $show_searchitemsdiskusage
                {
                
$extra_tag_attributes sprintf('
                        data-url="%spages/search_disk_usage.php?search=%s&restypes=%s&offset=%s&order_by=%s&sort=%s&archive=%s&daylimit=%s&k=%s"
                    '
,
                    
$baseurl_short,
                    
urlencode($search),
                    
urlencode($restypes),
                    
urlencode($offset),
                    
urlencode($order_by),
                    
urlencode($sort),
                    
urlencode($archive),
                    
urlencode($daylimit),
                    
urlencode($k)
                );

                
$options[$o]['value']='search_items_disk_usage';
                
$options[$o]['label']=$lang['searchitemsdiskusage'];
                
$options[$o]['data_attr']=array();
                
$options[$o]['extra_tag_attributes']=$extra_tag_attributes;
                
$options[$o]['category']  = ACTIONGROUP_ADVANCED;
                
$options[$o]['order_by']  = 300;
                
$o++;
                }
            }
        }

    
// If all resources are editable, display an edit all link
    
if($top_actions && $show_edit_all_link && !$omit_edit_all)
        {
        
$editable_resources do_search($search,$restypes,'resourceid',$archive,-1,'',false,0,false,false,$daylimit,false,falsetruetrue);

        if (
is_array($editable_resources) && $resources_count == count($editable_resources))
            {
            
$data_attribute['url'] = generateURL($baseurl_short "pages/edit.php",$urlparams,array("editsearchresults" => "true"));
            
$options[$o]['value']='editsearchresults';
            
$options[$o]['label']=$lang['edit_all_resources'];
            
$options[$o]['data_attr']=$data_attribute;
            
$options[$o]['category'] = ACTIONGROUP_EDIT;
            
$options[$o]['order_by']  = 130;
            
$o++;
            }
        }
        
    if(
$top_actions && ($k == '' || $internal_share_access))
        {
        
$options[$o]['value']            = 'csv_export_results_metadata';
        
$options[$o]['label']            = $lang['csvExportResultsMetadata'];
        
$options[$o]['data_attr']['url'] = sprintf('%spages/csv_export_results_metadata.php?search=%s&restypes=%s&order_by=%s&archive=%s&sort=%s&starsearch=%s',
            
$baseurl_short,
            
urlencode($search),
            
urlencode($restypes),
            
urlencode($order_by),
            
urlencode($archive),
            
urlencode($sort),
            
urlencode($starsearch)
        );
        
$options[$o]['category'] = ACTIONGROUP_ADVANCED;
        
$options[$o]['order_by']  = 290;
        
$o++;
        }

    
// Add extra search actions or modify existing options through plugins
    
$modified_options hook('render_search_actions_add_option','',array($options$urlparams));
    if(
$top_actions && !empty($modified_options))
        {
        
$options=$modified_options;
        }

    return 
$options;
    }

This article was last updated 26th November 2020 04:05 Europe/London time based on the source file dated 19th November 2020 14:20 Europe/London time.