Esempio n. 1
0
function multilingual_get_langs()
{
    $langs = intl_get_langs();
    // remove default language
    unset($langs[intl_default_lang()]);
    return $langs;
}
Esempio n. 2
0
 function onSubmit($vals)
 {
     if (intl_lang() == intl_default_lang()) {
         $ps1 = new PropertySet('sitegallery', 'album_title');
         $ps2 = new PropertySet('sitegallery', 'album_description');
         $ps3 = new PropertySet('sitegallery', 'album_date');
     } else {
         $ps1 = new PropertySet('sitegallery', 'album_title_' . intl_lang());
         $ps2 = new PropertySet('sitegallery', 'album_description_' . intl_lang());
         $ps3 = new PropertySet('sitegallery', 'album_date');
     }
     $ps1->set($vals['album'], $vals['title']);
     $ps2->set($vals['album'], $vals['description']);
     $ps3->set($vals['album'], $vals['date']);
     if (appconf('page_alias')) {
         header('Location: ' . site_prefix() . '/index/' . appconf('page_alias'));
         exit;
     }
     header('Location: ' . site_prefix() . '/index/sitegallery-app');
     exit;
 }
Esempio n. 3
0
 function MultilingualTranslateForm()
 {
     parent::MailForm();
     $this->autosave = true;
     global $page, $cgi, $intl;
     $intl->language = $cgi->_lang;
     $intl->charset = $intl->languages[$intl->language]['charset'];
     $this->extra = 'id="multilingual-translate-form"';
     $w =& $this->addWidget('template', '_header');
     $this->lang = multilingual_filter_lang($cgi->_lang);
     $this->reflang = multilingual_filter_lang(intl_default_lang());
     $w->template = '<tr><th colspan="2" width="50%">{intl Language}: {lang}</th><th width="50%">{intl Reference}: {reflang}</th></tr>';
     // get copy from repository
     loader_import('cms.Versioning.Rex');
     $rex = new Rex($cgi->_collection);
     $doc = $rex->getCurrent($cgi->_key);
     $widgets = $rex->getStruct();
     if (!$widgets) {
         $widgets = array();
     }
     // edit widgets go here
     $this->widgets = array_merge($this->widgets, $widgets);
     foreach ($this->widgets as $k => $v) {
         if (in_array($k, array($rex->key, 'sitellite_status', 'sitellite_access', 'sitellite_startdate', 'sitellite_expirydate', 'sitellite_owner', 'sitellite_team'))) {
             unset($this->widgets[$k]);
             continue;
         }
         if ($v->name != '_header' && !in_array($v->type, array('text', 'textarea', 'xeditor'))) {
             unset($this->widgets[$k]);
             continue;
         }
         if (strtolower(get_class($this->widgets[$k])) == 'mf_widget_xeditor') {
             $this->extra = 'onsubmit="xed_copy_value (this, \'' . $k . '\')"';
         }
         if (isset($doc->{$k})) {
             $this->widgets[$k]->reference = $doc->{$k};
         }
     }
     $w =& $this->addWidget('hidden', '_key');
     $w =& $this->addWidget('hidden', '_collection');
     $w =& $this->addWidget('hidden', '_lang');
     $w =& $this->addWidget('status', '_status');
     $w->alt = intl_get('Translation Status');
     $w->setValue('draft');
     $w->reference = '';
     // submit buttons
     $w =& $this->addWidget('msubmit', 'submit_button');
     $w->reference = '';
     $b =& $w->getButton();
     $b->setValues(intl_get('Save'));
     $b =& $w->addButton('submit_button', intl_get('Cancel'));
     $b->extra = 'onclick="return cms_cancel (this.form)"';
     $this->error_mode = 'all';
     if ($rex->info['Collection']['singular']) {
         page_title(intl_get('Translating') . ' ' . $rex->info['Collection']['singular'] . ': ' . $doc->{$rex->key});
     } else {
         page_title(intl_get('Translating Item') . ': ' . $doc->{$rex->key});
     }
     $tr = new Translation($cgi->_collection, $cgi->_lang);
     $curr = $tr->get($cgi->_key);
     if ($curr) {
         foreach ($curr->data as $k => $v) {
             if (isset($this->widgets[$k])) {
                 $this->widgets[$k]->setDefault($v);
             }
         }
         $this->widgets['_status']->setDefault($curr->sitellite_status);
     }
 }
Esempio n. 4
0
 /**
  * Takes the string provided (which is usually the global $REQUEST_URI,
  * and returns a version of it without illegal characters so it can be used as a
  * file name to store a cached page.
  * 
  * @access	public
  * @param	string	$file
  * @return	string
  * 
  */
 function serialize($file = '')
 {
     if (intl_lang() != intl_default_lang()) {
         $file .= '_' . intl_lang();
     }
     return preg_replace("/[\\/\\\\?&%#~:]/", '', $file);
 }
Esempio n. 5
0
    $res = array($res);
}
if (session_admin()) {
    echo '<div class="scm-sidebar-top">';
    echo loader_box('cms/buttons/add', array('collection' => 'sitellite_sidebar', 'return' => site_current(), 'extra' => '&position=' . $position));
    echo '</div>';
}
if (!$res) {
    return;
}
if (intl_lang() != intl_default_lang()) {
    loader_import('multilingual.Translation');
    $tr = new Translation('sitellite_sidebar', intl_lang());
}
foreach ($res as $key => $row) {
    if (intl_lang() != intl_default_lang()) {
        if (session_admin()) {
            $translated = $tr->get($row->id);
        } else {
            $translated = $tr->get($row->id, true);
        }
        if ($translated) {
            foreach ($translated->data as $k => $v) {
                $row->{$k} = $v;
            }
        }
    }
    if (count($res) == 1) {
        $up = false;
        $down = false;
        $upkey = '';
Esempio n. 6
0
<?php

$default = intl_lang();
if (!$default) {
    $default = intl_default_lang();
}
$langs = intl_get_langs();
echo template_simple('intl_select.spt', array('default' => $default, 'langs' => $langs));
Esempio n. 7
0
 /**
  * Returns a single object with the specified $id.
  *
  * @access public
  * @param mixed
  * @return object
  */
 function &get($id)
 {
     if ($this->usePermissions) {
         if (session_admin()) {
             $and = ' and ' . session_allowed_sql();
         } else {
             $and = ' and ' . session_approved_sql();
         }
     } else {
         $and = '';
     }
     $res = db_fetch('SELECT * FROM ' . $this->table . ' WHERE ' . $this->pkey . ' = ?' . $and . $this->_end(), $id);
     if (!$res) {
         $this->error = db_error();
         return false;
     }
     if ($this->multilingual && intl_lang() != intl_default_lang()) {
         loader_import('multilingual.Translation');
         $tr = new Translation($this->table, intl_lang());
         if (session_admin()) {
             $translated = $tr->get($res->{$this->pkey});
         } else {
             $translated = $tr->get($res->{$this->pkey}, true);
         }
         if ($translated) {
             foreach ($translated->data as $key => $value) {
                 $res->{$key} = $value;
             }
         }
     }
     return $res;
 }
Esempio n. 8
0
 /**
  * Builds the item tree from the database table specified.
  * 
  * @access	public
  * @return	boolean
  * 
  */
 function getTree()
 {
     if (!session_valid() && $this->cache > 0) {
         if (intl_lang() != intl_default_lang()) {
             $this->cacheLocation .= '_' . intl_lang();
         }
         if (@file_exists($this->cacheLocation) && filemtime($this->cacheLocation) > time() - $this->cache) {
             $this->loadConfig($this->cacheLocation);
             return true;
         }
     }
     $table = $this->table;
     $idcol = $this->idcolumn;
     $showcol = $this->showcolumn;
     $refcol = $this->refcolumn;
     $listcol = $this->listcolumn;
     $hidevalue = $this->hideValue;
     if (!empty($listcol)) {
         //			$list = "where $listcol != '$hidevalue' and $listcol is not null";
         $listcolumn = ', ' . $listcol;
     } else {
         $list = '';
         $listcolumn = '';
     }
     if (!empty($this->sectioncolumn)) {
         $sectioncolumn = ', ' . $this->sectioncolumn;
     } else {
         $sectioncolumn = '';
     }
     if (!empty($this->templatecolumn)) {
         $templatecolumn = ', ' . $this->templatecolumn;
     } else {
         $templatecolumn = '';
     }
     if ($this->sitelliteAllowed) {
         global $session;
         if (!empty($list)) {
             $allowed = 'and ' . $session->allowedSql();
         } else {
             $allowed = 'where ' . $session->allowedSql();
         }
     } else {
         $allowed = '';
     }
     if ($this->sortcolumn) {
         $sort = ', ' . $this->sortcolumn;
         if ($this->sortorder) {
             $sort .= ' ' . $this->sortorder;
         }
     } else {
         $sort = '';
     }
     $tree = db_fetch("select {$idcol}, {$showcol}, {$refcol} {$listcolumn} {$sectioncolumn} {$templatecolumn} from {$table} {$list} {$allowed} group by {$refcol} {$sort}, {$showcol} asc");
     if (!$tree) {
         $this->error = db_error();
         return false;
     } elseif (is_object($tree)) {
         $tree = array($tree);
     }
     $this->initTree($tree);
     if (intl_lang() != intl_default_lang()) {
         loader_import('multilingual.Translation');
         $tr = new Translation($table, intl_lang());
         $titles = $tr->getTitles();
         foreach ($titles as $key => $title) {
             $this->{'items_' . $key}->title = $title;
         }
     }
     if (!session_valid() && $this->cache > 0) {
         if (@is_writeable($this->cacheLocation) || !@file_exists($this->cacheLocation) && @is_writeable(dirname($this->cacheLocation))) {
             $fp = fopen($this->cacheLocation, 'w');
             if ($fp) {
                 fwrite($fp, $this->makeConfig($tree));
                 fclose($fp);
             }
         }
     }
     return true;
 }