Example #1
0
function url_for2($routeName, $params = array(), $absolute = false)
{
    $params = array_merge(array('sf_route' => $routeName), is_object($params) ? array('sf_subject' => $params) : $params);
    return url_for1($params, $absolute);
}
Example #2
0
 public function executeImportSentences(dmWebRequest $request)
 {
     $catalogue = $this->getObjectOrForward404($request);
     $form = new DmCatalogueImportForm();
     sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $file = $form->getValue('file');
         $override = $form->getValue('override');
         $dataFile = $file->getTempName();
         $table = dmDb::table('DmTransUnit');
         $existQuery = $table->createQuery('t')->select('t.id, t.source, t.target, t.created_at, t.updated_at')->where('t.dm_catalogue_id = ? AND t.source = ?');
         $catalogueId = $catalogue->get('id');
         $nbAdded = 0;
         $nbUpdated = 0;
         try {
             if (!is_array($data = sfYaml::load(file_get_contents($dataFile)))) {
                 $this->getUser()->logError($this->getI18n()->__('Could not load file: %file%', array('%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             }
         } catch (Exception $e) {
             $this->getUser()->logError($this->getI18n()->__('Unable to parse file: %file%', array('%file%' => $file->getOriginalName())));
             return $this->renderPartial('dmInterface/flash');
         }
         $addedTranslations = new Doctrine_Collection($table);
         $line = 0;
         foreach ($data as $source => $target) {
             ++$line;
             if (!is_string($source) || !is_string($target)) {
                 $this->getUser()->logError($this->getI18n()->__('Error line %line%: %file%', array('%line%' => $line, '%file%' => $file->getOriginalName())));
                 return $this->renderPartial('dmInterface/flash');
             } else {
                 $existing = $existQuery->fetchOneArray(array($catalogueId, $source));
                 if (!empty($existing) && $existing['source'] === $source) {
                     if ($existing['target'] !== $target) {
                         if ($override || $existing['created_at'] === $existing['updated_at']) {
                             $table->createQuery()->update('DmTransUnit')->set('target', '?', array($target))->where('id = ?', $existing['id'])->execute();
                             ++$nbUpdated;
                         }
                     }
                 } elseif (empty($existing)) {
                     $addedTranslations->add(dmDb::create('DmTransUnit', array('dm_catalogue_id' => $catalogue->get('id'), 'source' => $source, 'target' => $target)));
                     ++$nbAdded;
                 }
             }
         }
         $addedTranslations->save();
         if ($nbAdded) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: added %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbAdded)));
         }
         if ($nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: updated %count% translation(s)', array('%catalogue%' => $catalogue->get('name'), '%count%' => $nbUpdated)));
         }
         if (!$nbAdded && !$nbUpdated) {
             $this->getUser()->logInfo($this->getI18n()->__('%catalogue%: nothing to add and update', array('%catalogue%' => $catalogue->get('name'))));
         }
         return $this->renderText(url_for1($this->getRouteArrayForAction('index')));
     }
     $action = url_for1($this->getRouteArrayForAction('importSentences', $catalogue));
     return $this->renderText($form->render('.dm_form.list.little action="' . $action . '"'));
 }
Example #3
0
<p class="flash_msg"><b><i><?php 
echo $msg;
?>
</i></b></p>
<a href="<?php 
echo url_for1($back_link);
?>
">Retour</a>
Example #4
0
                    <li class="dropdown-submenu"> 
                        <a href="#" alt="Get Notice" title="Consult the notice of scenario by language">
                            <img src="/images/boutons/apercu.png"  alt="" /> View notice </a>
                        <?php 
    $langs = $ei_project->getProjectLangs();
    if ($langs->getFirst()) {
        ?>
                            <ul class="dropdown-menu">
        <?php 
        foreach ($langs as $lang) {
            ?>

                                    <li>
                                        <a target ='_blank' href="<?php 
            echo url_for1('@show_notice?project_id=' . $ei_project->getProjectId() . '&project_ref=' . $ei_project->getRefId() . '&ei_scenario_id=' . $ei_scenario->getId() . '&profile_id=' . $ei_profile->getProfileId() . '&profile_ref=' . $ei_profile->getProfileRef() . '&id_version=' . $ei_version->getId() . '&lang=' . $lang->getLang());
            ?>
" > 
                                            <img src="/images/boutons/apercu.png" alt="View notice" title="Consult the notice of scenario"/>
                                    <?php 
            echo $lang;
            ?>
                                        </a>
                                    </li> 
        <?php 
        }
        ?>
 
                            </ul>
    <?php 
    }
Example #5
0
                                    <button class="btn btn-default" id="button_token_api_show" type="button" title="Show API Key into input box">
                                        <?php 
    echo ei_icon('ei_show', 'lg');
    ?>
                                    </button>
                                    <button class="btn btn-default" id="button_token_api_generate" type="button" title="Generate a new API Key"
                                            data-title="Confirmation"
                                            data-confirm="Are you sure you want to regenerate your access token ?">
                                        <i class="fa fa-refresh fa-lg"></i>
                                    </button>
                                </span>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <input type="hidden" value="<?php 
    echo url_for1("@api_generate_token_api");
    ?>
" name="url_to_generate_api_key" />
                <input type="hidden" value="<?php 
    echo url_for1("@api_get_token_api");
    ?>
" name="url_to_get_api_key" />
            </div>
        </div><!--/col-->

    <?php 
}
?>
</div><!--/row-->