Пример #1
0
 public function Base_Render_After($Sender, $Args)
 {
     $Locale = Gdn::Locale();
     if (!is_a($Locale, 'DeveloperLocale')) {
         return;
     }
     $Path = $this->LocalePath . '/tmp_' . RandomString(10);
     if (!file_exists(dirname($Path))) {
         mkdir(dirname($Path), 0777, TRUE);
     } elseif (file_exists($Path)) {
         // Load the existing definitions.
         $Locale->Load($Path);
     }
     // Save the current definitions.
     $fp = fopen($Path, 'wb');
     fwrite($fp, $this->GetFileHeader());
     LocaleModel::WriteDefinitions($fp, $Locale->AllDefinitions());
     fclose($fp);
     // Copy the file over the existing one.
     $FinalPath = $this->LocalePath . '/captured.php';
     rename($Path, $FinalPath);
 }
 /**
  * Save the captured definitions.
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function Base_Render_After($Sender, $Args)
 {
     $Locale = Gdn::Locale();
     if (!is_a($Locale, 'DeveloperLocale')) {
         return;
     }
     $Path = $this->LocalePath . '/tmp_' . RandomString(10);
     if (!file_exists(dirname($Path))) {
         mkdir(dirname($Path), 0777, TRUE);
     } elseif (file_exists($Path)) {
         // Load the existing definitions.
         $Locale->Load($Path);
     }
     // Load the core definitions.
     if (file_exists($this->LocalePath . '/captured_site_core.php')) {
         $Definition = array();
         include $this->LocalePath . '/captured_site_core.php';
         $Core = $Definition;
     } else {
         $Core = array();
     }
     // Load the admin definitions.
     if (file_exists($this->LocalePath . '/captured_dash_core.php')) {
         $Definition = array();
         include $this->LocalePath . '/captured_dash_core.php';
         $Admin = $Definition;
     } else {
         $Admin = array();
     }
     // Load the ignore file.
     $Definition = array();
     include dirname(__FILE__) . '/ignore.php';
     $Ignore = $Definition;
     $Definition = array();
     $CapturedDefinitions = $Locale->CapturedDefinitions();
     //      decho ($CapturedDefinitions);
     //      die();
     foreach ($CapturedDefinitions as $Prefix => $Definition) {
         $FinalPath = $this->LocalePath . "/captured_{$Prefix}.php";
         // Load the definitions that have already been captured.
         if (file_exists($FinalPath)) {
             include $FinalPath;
         }
         $Definition = array_diff_key($Definition, $Ignore);
         // Strip core definitions from the file.
         if ($Prefix != 'site_core') {
             $Definition = array_diff_key($Definition, $Core);
             if ($Prefix != 'dash_core') {
                 $Definition = array_diff_key($Definition, $Admin);
             }
         }
         // Save the current definitions.
         $fp = fopen($Path, 'wb');
         fwrite($fp, $this->GetFileHeader());
         LocaleModel::WriteDefinitions($fp, $Definition);
         fclose($fp);
         // Copy the file over the existing one.
         $Result = rename($Path, $FinalPath);
     }
 }