/**
  * Function used to get available templates
  */
 function get_templates($visible = false)
 {
     $dir = STYLES_DIR;
     //Scaning Dir
     $dirs = scandir($dir);
     foreach ($dirs as $tpl) {
         if (substr($tpl, 0, 1) != '.') {
             $tpl_dirs[] = $tpl;
         }
     }
     //Now Checking for template template.xml
     $tpls = array();
     foreach ($tpl_dirs as $tpl_dir) {
         if ($visible == true) {
             $hidden = get_hidden_templates();
             if ($hidden) {
                 if (in_array($tpl_dir, $hidden)) {
                     continue;
                 }
             }
         }
         $tpl_details = CBTemplate::get_template_details($tpl_dir);
         if ($tpl_details && $tpl_details['name'] != '') {
             $tpls[$tpl_details['name']] = $tpl_details;
         }
     }
     return $tpls;
 }
/**
 * 
 * @author Fawaz Tahir <*****@*****.**>
 * @global object $cbtpl
 * @param type $dir
 */
function show_the_template($dir)
{
    global $cbtpl;
    $details = $cbtpl->get_template_details($dir);
    if ($details) {
        $hidden = get_hidden_templates();
        if ($hidden) {
            $tpl_index = array_search($details['dir'], $hidden);
            if ($hidden[$tpl_index]) {
                unset($hidden[$tpl_index]);
                config('hidden_templates', json_encode($hidden));
                e(lang($details['name'] . " is now visible to user."), "m");
            }
        }
        return;
    } else {
        e(lang('This template is not Clipbucket compatible or template does not exist'));
    }
}