Well … alternate solution … not sure yet where I am going to put it or how it’s going to work. Dependent on the structure of app_name (dependent on naming convention). Could get a lot more fancy with this.
My naming convention is:
module_apptype_db_table_action_more
Example:
app_form_sec_users_add (becomes “Manage Users Add”)
app_form_sec_users_edit (becomes “Manage Users Edit”)
app_grid_sec_users (becomes “List Users”)
app_control_sec_users_force_password (becomes “Process Users force password”)
I am also using Friendly URL - but only for those applications displayed outside the menu system (still on the fence about it - although I have found that friendly url is working better in the latest version than it has in the past (thanks guys!) Where I am using a friendly URL (which has no app_type) I’m just using the friendly url as the description too.
//Parse app_name to create the value of sec_apps.description
sc_select(rs, “SELECT app_name FROM sec_apps”);
//Array1 = Applications in sec_apps
$arr_apps_db = array();
while(!$rs->EOF)
{
$arr_apps_db[] = $rs->fields[0];
$rs->MoveNext();
}
$rs->Close();
//print_r($arr_apps_db); //this shows the values in array format
//process that array
foreach($arr_apps_db as $k => $app_name) {
//echo “$app_name <br>” ; // this shows a list of appnames
//array2 - words in app_name
$word_count = str_word_count($app_name); //how many words are in app_name
//echo str_word_count($app_name); //number - how many words are in the app_name
$word = (str_word_count($app_name, 1)) ; //returns the words in app_name
//print_r(str_word_count($app_name, 1)); //this shows the appname further into words in an array
//Try to get app_type
if ($word_count >= '2') {
$app_type = $word[1] ;
switch ($app_type) {
case 'form':
$action = 'Manage' ;
break;
case 'grid':
$action = 'List' ;
break;
case 'calendar':
$action = 'Schedule' ;
break;
case 'control':
$action = 'Process' ;
break;
case 'pdfreport':
$action = 'Report' ;
break;
case 'blank':
$action = 'Compute' ;
break;
case 'search':
$action = 'Filter' ;
break;
case 'dashboard':
$action = 'Dashboard' ;
break;
default: //others
$action = $app_type ;
break;
} //end case
} else {
$app_type = '' ;
$desc = $word[0] ;
} //end app_type
//Create Description
switch ($word_count) {
case '3' :
$desc = $action . ' ' . $word[2] ;
break;
case '4' :
$desc = $action . ' ' . $word[3] ;
break;
case '5' :
$desc = $action . ' ' . $word[3] . ' ' . $word[4] ;
break;
default: //others
$desc = $word[0] ; ;
break;
} // end switch of word count
//Update the description field in sec_apps
$sql="UPDATE sec_apps SET description = '$desc' WHERE app_name = '$app_name' " ;
sc_exec_sql($sql) ;
}