Ejemplo n.º 1
0
 public function contains(Option $opt)
 {
     foreach ($this->options as $o) {
         if ($o->getIconSelectAttributeOptionID() == $opt->getIconSelectAttributeOptionID()) {
             return true;
         }
     }
     return false;
 }
 public function submit()
 {
     $extractor = Core::make('multilingual/extractor');
     if ($this->post('action') == 'reload') {
         if (Core::make('token')->validate()) {
             // First, we look in all the site sources for PHP code with GetText
             $baseTranslations = $extractor->extractTranslatableSiteStrings();
             //Attach new translation files
             $icontranslations = \Concrete\Package\IconSelector\Attribute\IconSelector\Option::exportTranslations();
             $baseTranslations->mergeWith($icontranslations);
             // $translations contains all of our site translations.
             $list = Section::getList();
             $defaultSourceLocale = Config::get('concrete.multilingual.default_source_locale');
             foreach ($list as $section) {
                 /* @var $section \Concrete\Core\Multilingual\Page\Section\Section */
                 if ($section->getLocale() != $defaultSourceLocale) {
                     $localeTranslations = clone $baseTranslations;
                     /* @var $localeTranslations \Gettext\Translations */
                     $localeTranslations->setLanguage($section->getLocale());
                     $localeTranslations->setPluralForms($section->getNumberOfPluralForms(), $section->getPluralsRule());
                     // now we load the translations that currently exist for each section
                     $extractor->mergeTranslationsWithSectionFile($section, $localeTranslations);
                     $extractor->mergeTranslationsWithCore($section, $localeTranslations);
                     $extractor->mergeTranslationsWithPackages($section, $localeTranslations);
                     $extractor->saveSectionTranslationsToFile($section, $localeTranslations);
                     // now that we've updated the translation file, we take all the translations and
                     // we insert them into the database so we can update our counts, and give the users
                     // a web interface
                     $extractor->saveSectionTranslationsToDatabase($section, $localeTranslations);
                 }
             }
             $this->redirect('/dashboard/system/multilingual/translate_interface', 'reloaded');
         } else {
             $this->error->add(Core::make('token')->getErrorMessage());
         }
     }
     if ($this->post('action') == 'export') {
         if (Core::make('token')->validate()) {
             $defaultSourceLocale = Config::get('concrete.multilingual.default_source_locale');
             $list = Section::getList();
             foreach ($list as $section) {
                 if ($section->getLocale() != $defaultSourceLocale) {
                     $translations = $section->getSectionInterfaceTranslations();
                     $extractor->mergeTranslationsWithSectionFile($section, $translations);
                     $extractor->saveSectionTranslationsToFile($section, $translations);
                 }
             }
             \Localization::clearCache();
             $this->redirect('/dashboard/system/multilingual/translate_interface', 'exported');
         } else {
             $this->error->add(Core::make('token')->getErrorMessage());
         }
     }
     $this->view();
 }
Ejemplo n.º 3
0
 public function filterByAttribute(AttributedItemList $list, $value, $comparison = '=')
 {
     if ($value instanceof Option) {
         $option = $value;
     } else {
         $option = Option::getByValue($value);
     }
     if (is_object($option)) {
         $column = 'ak_' . $this->attributeKey->getAttributeKeyHandle();
         $qb = $list->getQueryObject();
         $qb->andWhere($qb->expr()->like($column, ':iconOptionValue'));
         $qb->setParameter('iconOptionValue', "%\n" . $option->getIconSelectAttributeOptionValue() . "\n%");
     }
 }
Ejemplo n.º 4
0
 public function saveOrCreate($ak)
 {
     if ($this->tempID != false || $this->oid == 0) {
         return Option::add($ak, $this->optValue, $this->optIcon);
     } else {
         $db = Loader::db();
         $th = Loader::helper('text');
         $db->Execute('update atIconSelectorOptions set optValue = ? where oid = ?', array($th->sanitize($this->optValue), $this->oid));
         return Option::getByID($this->oid);
     }
 }