예제 #1
0
 private function _scanOverride()
 {
     // scan overrides ini files
     $reftag = $this->getState('translations.reference');
     $filter_client = $this->getState('filter.client');
     $filter_tag = $this->getState('filter.tag') ? "^({$reftag}|" . $this->getState('filter.tag') . ")\$" : '.';
     $filter_storage = $this->getState('filter.storage');
     $filter_type = $this->getState('filter.type');
     $filter_origin = $this->getState('filter.origin') ? $this->getState('filter.origin') : '.';
     $filter_search = $this->getState('filter.search') ? $this->getState('filter.search') : '.';
     if ((empty($filter_client) || $filter_client != 'installation') && (empty($filter_storage) || $filter_storage == 'global') && (empty($filter_type) || $filter_type == 'override') && preg_match("/{$filter_origin}/", '_override') && preg_match("/{$filter_search}/i", 'override')) {
         if (empty($filter_client)) {
             $clients = array('site', 'administrator');
         } else {
             $clients = array($filter_client);
         }
         foreach ($clients as $client) {
             $tags = JFolder::folders(constant('LOCALISEPATH_' . strtoupper($client)) . '/language', $filter_tag, false, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'pdf_fonts', 'overrides'));
             foreach ($tags as $tag) {
                 $path = constant('LOCALISEPATH_' . strtoupper($client)) . "/language/overrides/{$tag}.override.ini";
                 $translation = new JObject(array('type' => 'override', 'tag' => $tag, 'client' => $client, 'storage' => 'global', 'filename' => 'override', 'name' => JText::_('COM_LOCALISE_LABEL_TRANSLATIONS_OVERRIDE'), 'refpath' => $path, 'path' => $path, 'state' => 'inlanguage', 'writable' => LocaliseHelper::isWritable($path), 'origin' => '_override'));
                 $this->translations["{$client}|{$tag}|override"] = $translation;
             }
         }
     }
 }
예제 #2
0
 /**
  * Method to get the package.
  *
  * @return JObject the package
  */
 public function getItem()
 {
     $id = $this->getState('package.id');
     $package = new JObject();
     $package->checked_out = 0;
     $package->standalone = true;
     $package->manifest = null;
     $package->title = null;
     $package->description = null;
     if (!empty($id)) {
         // If the package exists get it
         $table = $this->getTable();
         if (is_array($id)) {
             $id = $id[0];
         }
         $table->load($id);
         $package->setProperties($table->getProperties());
         // Get the manifest
         $xml = simplexml_load_file($table->path);
         if ($xml) {
             $manifest = (string) $xml->manifest;
             $client = (string) $xml->manifest->attributes()->client;
             LocaliseHelper::loadLanguage($manifest, $client);
             // Set up basic information
             $name = basename($table->path);
             $name = substr($name, 0, strlen($name) - 4);
             $package->id = $id;
             $package->name = $name;
             $package->manifest = $manifest;
             $package->client = $client;
             $package->standalone = substr($manifest, 0, 4) == 'fil_';
             $package->core = (string) $xml->attributes()->core == 'true';
             $package->icon = (string) $xml->icon;
             $package->title = (string) $xml->title;
             $package->description = (string) $xml->description;
             $package->license = (string) $xml->license;
             $package->copyright = (string) $xml->copyright;
             $package->author = (string) $xml->author;
             $package->writable = LocaliseHelper::isWritable($package->path);
             $user = JFactory::getUser($table->checked_out);
             $package->setProperties($table->getProperties());
             if ($package->checked_out == JFactory::getUser()->id) {
                 $package->checked_out = 0;
             }
             $package->editor = JText::sprintf('COM_LOCALISE_TEXT_PACKAGE_EDITOR', $user->name, $user->username);
             // Get the translations
             $package->translations = array();
             $package->administrator = array();
             if ($xml->administrator) {
                 foreach ($xml->administrator->children() as $file) {
                     $data = (string) $file;
                     if ($data) {
                         $package->translations[] = "administrator_{$data}";
                     } else {
                         $package->translations[] = "administrator_joomla";
                     }
                     $package->administrator[] = $data;
                 }
             }
             $package->site = array();
             if ($xml->site) {
                 foreach ($xml->site->children() as $file) {
                     $data = (string) $file;
                     if ($data) {
                         $package->translations[] = "site_{$data}";
                     } else {
                         $package->translations[] = "site_joomla";
                     }
                     $package->site[] = $data;
                 }
             }
             $package->installation = array();
             if ($xml->installation) {
                 foreach ($xml->installation->children() as $file) {
                     $data = (string) $file->data();
                     if ($data) {
                         $package->translations[] = "installation_{$data}";
                     } else {
                         $package->translations[] = "installation_joomla";
                     }
                     $package->installation[] = $data;
                 }
             }
         } else {
             $package = null;
             $this->setError(JText::sprintf('COM_LOCALISE_ERROR_PACKAGE_FILEEDIT'), $table->path);
         }
     }
     return $package;
 }
예제 #3
0
 /**
  * Method to get the language.
  */
 public function getItem()
 {
     $id = $this->getState('language.id');
     $client = $this->getState('language.client');
     $tag = $this->getState('language.tag');
     $language = new JObject();
     $language->id = $id;
     $language->client = $client;
     $language->tag = $tag;
     $language->checked_out = 0;
     if (!empty($id)) {
         $table = $this->getTable();
         $table->load($id);
         $user = JFactory::getUser($table->checked_out);
         $language->setProperties($table->getProperties());
         if ($language->checked_out == JFactory::getUser()->id) {
             $language->checked_out = 0;
         }
         $language->editor = JText::sprintf('COM_LOCALISE_TEXT_LANGUAGE_EDITOR', $user->name, $user->username);
         $language->writable = LocaliseHelper::isWritable($language->path);
         if (JFile::exists($language->path)) {
             $xml = simplexml_load_file($language->path);
             if ($xml) {
                 foreach ($xml->children() as $node) {
                     if ($node->name() == 'metadata') {
                         // metadata nodes
                         foreach ($node->children() as $subnode) {
                             $property = $subnode->name();
                             $language->{$property} = $subnode;
                         }
                     } else {
                         // main nodes
                         $property = $node->name();
                         if ($property == 'copyright') {
                             if (isset($language->joomlacopyright)) {
                                 $language->copyright[] = $node;
                             } else {
                                 $language->copyright = array();
                                 $language->joomlacopyright = $node;
                             }
                         } else {
                             $language->{$property} = $node;
                         }
                     }
                 }
                 $language->copyright = implode('<br/>', $language->copyright);
             } else {
                 $this->setError(JText::sprintf('COM_LOCALISE_ERROR_LANGUAGE_FILEEDIT', $language->path));
             }
         }
     }
     return $language;
 }