includes/functions.php
changeset 242 78a94f7bb5e3
parent 241 c671f3bb8aed
child 266 917dcc6c4ceb
equal deleted inserted replaced
241:c671f3bb8aed 242:78a94f7bb5e3
  3175   
  3175   
  3176   return $score;
  3176   return $score;
  3177 }
  3177 }
  3178 
  3178 
  3179 /**
  3179 /**
       
  3180  * Registers a task that will be run every X hours. Scheduled tasks should always be scheduled at runtime - they are not stored in the DB.
       
  3181  * @param string Function name to call, or array(object, string method)
       
  3182  * @param int Interval between runs, in hours. Defaults to 24.
       
  3183  */
       
  3184 
       
  3185 function register_cron_task($func, $hour_interval = 24)
       
  3186 {
       
  3187   global $cron_tasks;
       
  3188   if ( !isset($cron_tasks[$hour_interval]) )
       
  3189     $cron_tasks[$hour_interval] = array();
       
  3190   $cron_tasks[$hour_interval][] = $func;
       
  3191 }
       
  3192 
       
  3193 /**
  3180  * Installs a language.
  3194  * Installs a language.
  3181  * @param string The ISO-639-3 identifier for the language. Maximum of 6 characters, usually 3.
  3195  * @param string The ISO-639-3 identifier for the language. Maximum of 6 characters, usually 3.
  3182  * @param string The name of the language in English (Spanish)
  3196  * @param string The name of the language in English (Spanish)
  3183  * @param string The name of the language natively (Español)
  3197  * @param string The name of the language natively (Español)
  3184  * @param string The path to the file containing the language's strings. Optional.
  3198  * @param string The path to the file containing the language's strings. Optional.
  3214   // Do we also need to install a language file?
  3228   // Do we also need to install a language file?
  3215   if ( is_string($lang_file) && file_exists($lang_file) )
  3229   if ( is_string($lang_file) && file_exists($lang_file) )
  3216   {
  3230   {
  3217     $lang = new Language($lang_id);
  3231     $lang = new Language($lang_id);
  3218     $lang->import($lang_file);
  3232     $lang->import($lang_file);
  3219     $lang->fetch(false);
       
  3220     $lang->regen_caches();
       
  3221   }
  3233   }
  3222   else if ( is_string($lang_file) && !file_exists($lang_file) )
  3234   else if ( is_string($lang_file) && !file_exists($lang_file) )
  3223   {
  3235   {
  3224     echo '<b>Notice:</b> Can\'t load language file, so the specified language wasn\'t fully installed.<br />';
  3236     echo '<b>Notice:</b> Can\'t load language file, so the specified language wasn\'t fully installed.<br />';
  3225     return false;
  3237     return false;