Example #1
0
 public function summary($field, $data, $object)
 {
     $languages = languages();
     $fieldname = strval($field['name']);
     if (isset($languages[$data->{$fieldname}])) {
         return $languages[$data->{$fieldname}];
     }
     return '';
 }
Example #2
0
function l($input, $lang = false)
{
    if (!is_array($input)) {
        return l(array_combine(array_slice(array_keys(languages()), 0, func_num_args()), func_get_args()));
    }
    if (!$lang) {
        $lang = language();
    }
    return isset($input[$lang]) ? $input[$lang] : current($input);
}
Example #3
0
 public function get_slugs($field, $data, $object)
 {
     if (isset($data->id)) {
         $slugs = array();
         $object_language = language();
         $parent_id = 0;
         foreach ($object->children() as $sibling) {
             if ($sibling->getName() == 'slug') {
                 $source = false;
                 foreach ($object->children() as $child) {
                     if (strval($child['name']) == strval($sibling['source'])) {
                         $source = $child;
                     }
                 }
                 if ($source) {
                     $name = isset($sibling['name']) ? strval($sibling['name']) : 'slug';
                     if (isset($source['translatable']) && $source['translatable']) {
                         foreach (languages() as $code => $lang) {
                             $fieldname = $name . '_' . $code;
                             $slugs[$code] = $data->{$fieldname};
                         }
                     } else {
                         $slugs[] = $data->{$name};
                     }
                 }
             } else {
                 if ($sibling->getName() == 'language') {
                     $language = strval($sibling['name']);
                     $object_language = $data->{$language};
                 } else {
                     if ($sibling->getName() == 'recursive' && isset($data->parent_id) && $data->parent_id) {
                         $parent_id = $data->parent_id;
                     }
                 }
             }
         }
         foreach ($slugs as $language => $slug) {
             if (!is_string($language)) {
                 $slugs[$object_language] = $slug;
                 unset($slugs[$language]);
             }
         }
         if ($parent_id) {
             $parent_slugs = self::get_slugs($field, where('id = %d', $parent_id)->get_row($object['stack']), $object);
             foreach ($parent_slugs as $key => $parent_slug) {
                 if (isset($slugs[$key])) {
                     $slugs[$key] = $parent_slug . '/' . $slugs[$key];
                 }
             }
         }
         return $slugs;
     } else {
         return array();
     }
 }
Example #4
0
/**
 * Loads a language based on input data
 * @param string $language language to grab.
 * @return string
 */
function language($language)
{
    if (in_array($language, languages())) {
        // Include language
        include 'include/languages/' . $language . '.php';
    } else {
        // Include language
        include 'include/languages/en.php';
    }
    // Return language
    return $lang;
}
Example #5
0
/**
 * Loads a language based on input data
 * @param string $language language to grab.
 * @return string
 */
function language($language)
{
    if (in_array($language, languages())) {
        // Include language
        include BASEPATH . 'languages/' . $language . EXT;
    } else {
        // Include language
        include BASEPATH . 'languages/en' . EXT;
    }
    // Return language
    return $lang;
}
Example #6
0
function pCell($item, $var, $format, $size = "", $nohelp = "")
{
    $var = stripslashes($var);
    $out = tda(gTxt($item), ' style="text-align:right;vertical-align:middle"');
    switch ($format) {
        case "radio":
            $in = yesnoradio($item, $var);
            break;
        case "input":
            $in = text_input($item, $var, $size);
            break;
        case "timeoffset":
            $in = timeoffset_select($item, $var);
            break;
        case 'commentmode':
            $in = commentmode($item, $var);
            break;
        case 'cases':
            $in = cases($item, $var);
            break;
        case 'dateformats':
            $in = dateformats($item, $var);
            break;
        case 'weeks':
            $in = weeks($item, $var);
            break;
        case 'logging':
            $in = logging($item, $var);
            break;
        case 'languages':
            $in = languages($item, $var);
            break;
        case 'text':
            $in = text($item, $var);
            break;
        case 'urlmodes':
            $in = urlmodes($item, $var);
    }
    $out .= td($in);
    $out .= $nohelp != 1 ? tda(popHelp($item), ' style="vertical-align:middle"') : td();
    return tr($out);
}
        <meta property="og:image:type" content="image/png">
        <meta property="og:image:width" content="1200">
        <meta property="og:image:height" content="1200">
<?php 
}
?>
        <meta property="og:url" content="<?php 
echo base_url();
?>
">
        <link rel="canonical" href="<?php 
echo base_url();
?>
">
<?php 
foreach (languages() as $lang) {
    if ($lang['folder'] != current_lang('folder')) {
        ?>
        <link rel="alternate" hreflang="<?php 
        echo $lang['code'];
        ?>
" href="<?php 
        echo site_url('process/lang/' . $lang['code'] . '?redirect=' . urlencode(current_url()));
        ?>
">
<?php 
    }
    /* endif */
}
/* endforeach */
?>
Example #8
0
 public function edited($field, $data, $object)
 {
     $fieldname = strval($field['name']);
     $newtags = explode(',', $_POST[$fieldname]);
     if (isset($field['translatable'])) {
         $translated = array();
         foreach (languages() as $lang => $langname) {
             if (isset($_POST[$fieldname . '_' . $lang])) {
                 $translated[$lang] = explode(',', $_POST[$fieldname . '_' . $lang]);
             }
         }
     }
     if (isset($data->id)) {
         foreach ($data->{$fieldname} as $tag) {
             $index = array_search($tag->tag, $newtags);
             if ($index !== false) {
                 if (isset($field['translatable'])) {
                     $to_update = array();
                     foreach (languages() as $lang => $langname) {
                         if ($lang != language()) {
                             $fieldn = 'tag_' . $lang;
                             if ($tag->{$fieldn} != trim($translated[$lang][$index])) {
                                 $to_update[$fieldn] = trim($translated[$lang][$index]);
                                 $to_update['slug_' . $lang] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($to_update[$fieldn]))))));
                             }
                             unset($translated[$lang][$index]);
                         }
                     }
                     if (count($to_update)) {
                         where('id = %d', $tag->id)->update($object['stack'] . '>' . $field['name'], $to_update);
                     }
                 }
                 unset($newtags[$index]);
             } else {
                 where(strval($object['name']) . ' = %d AND ' . strval($field['name']) . '_id = %d', $data->id, $tag->id)->delete($object['stack'] . '>' . $field['name'] . '>relation');
                 if (where(strval($field['name']) . '_id = %d', $tag->id)->get($object['stack'] . '>' . $field['name'] . '>relation')->count() == 0) {
                     where('id = %d', $tag->id)->delete($object['stack'] . '>' . $field['name']);
                 }
             }
         }
     }
     foreach ($newtags as $index => $tag) {
         $existing = where('tag = %s', $tag)->get_row($object['stack'] . '>' . $fieldname);
         if ($existing) {
             $tag_id = $existing->id;
             if (isset($field['translatable'])) {
                 $to_update = array();
                 foreach (languages() as $lang => $langname) {
                     if ($lang != language()) {
                         $fieldn = 'tag_' . $lang;
                         if ($existing->{$fieldn} != trim($translated[$lang][$index])) {
                             $to_update[$fieldn] = trim($translated[$lang][$index]);
                             $to_update['slug_' . $lang] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($to_update[$fieldn]))))));
                         }
                         unset($translated[$lang][$index]);
                     }
                 }
                 if (count($to_update)) {
                     where('id = %d', $existing->id)->update($object['stack'] . '>' . $field['name'], $to_update);
                 }
             }
         } else {
             $to_insert = array('tag' => $tag, 'slug' => strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($tag)))))));
             if (isset($field['translatable'])) {
                 foreach (languages() as $lang => $langname) {
                     if ($lang != language()) {
                         $to_insert['tag_' . $lang] = trim($translated[$lang][$index]);
                         $to_insert['slug_' . $lang] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($to_insert['tag_' . $lang]))))));
                     }
                 }
             }
             $tag_id = insert($object['stack'] . '>' . $fieldname, $to_insert);
         }
         insert($object['stack'] . '>' . $fieldname . '>relation', array($fieldname . '_id' => $tag_id, strval($object['name']) => $data->id));
     }
 }
Example #9
0
    function print_row($field, $shownfields, $row, $object, $show_edit = true, $level = 0, $currentslug = '', $parenturl = '', $delete_limits = array())
    {
        if ($level == 0) {
            echo '<tbody data-id="' . $row->id . '">';
        }
        $user = FW4_User::get_user();
        $typemanager = FW4_Type_Manager::get_instance();
        ?>
		<tr<?php 
        echo $level > 0 ? ' data-root="' . $GLOBALS['root_id'] . '"' : '';
        ?>
 data-id="<?php 
        echo $row->id;
        ?>
" onclick="window.location='<?php 
        echo $parenturl . ($level > 0 ? $GLOBALS['recursive_name'] : $field['name']);
        ?>
/<?php 
        echo $row->id;
        ?>
/';">
			<?php 
        if (isset($field['sortable']) && $field['sortable']) {
            ?>
				<td valign="middle">
					<?php 
            if ($level == 0) {
                ?>
						<img class="sort-handle" src="<?php 
                echo url(ADMINRESOURCES . 'images/sort.png');
                ?>
" width="10" height="11"/><input type="hidden" name="sort-<?php 
                echo $row->id;
                ?>
" value="<?php 
                echo $row->_sort_order;
                ?>
" />
					<?php 
            }
            ?>
				</td>
			<?php 
        }
        $i = 0;
        foreach ($shownfields as $name => $subfield) {
            ?>
				<td<?php 
            if ($subfield->getName() == "price") {
                ?>
 align="right"<?php 
            }
            ?>
><div class="overflow">
					<?php 
            if ($i++ == 0 && $level > 0) {
                echo '&nbsp;&nbsp;';
                for ($s = 0; $s < $level - 1; $s++) {
                    echo '&nbsp;&nbsp;&nbsp;&nbsp;';
                }
                echo '<span style="opacity:0.5">&#9492;</span> ';
            }
            if ($subfield->getName() == "bool") {
                if ($row->{$name} == 1) {
                    ?>
							<img src="<?php 
                    echo url(ADMINRESOURCES . 'images/tick.png');
                    ?>
" class="bool" width="16" height="16"/>
						<?php 
                } else {
                    ?>
							<img src="<?php 
                    echo url(ADMINRESOURCES . 'images/cross.png');
                    ?>
" class="bool" width="16" height="16"/> 
						<?php 
                }
            } else {
                if ($subfield->getName() == "date") {
                    if ($row->{$name}) {
                        echo date('j/m/Y', $row->{$name});
                    }
                } else {
                    if ($subfield->getName() == "float") {
                        if ($row->{$name}) {
                            echo rtrim(rtrim(number_format($row->{$name}, 2, ',', '.'), '0'), ',');
                        }
                    } else {
                        if ($subfield->getName() == "timedate") {
                            if ($row->{$name}) {
                                if (date('H:i', $row->{$name}) == '00:00') {
                                    echo date('j/m/Y', $row->{$name});
                                } else {
                                    echo date('j/m/Y H:i', $row->{$name});
                                }
                            }
                        } else {
                            if ($subfield->getName() == "text") {
                                if (isset($row->{$name})) {
                                    if ($subfield['summary'] == 'bool') {
                                        if (trim($row->{$name})) {
                                            ?>
									<img src="<?php 
                                            echo url(ADMINRESOURCES . 'images/tick.png');
                                            ?>
" class="bool" width="16" height="16"/>
								<?php 
                                        } else {
                                            ?>
									<img src="<?php 
                                            echo url(ADMINRESOURCES . 'images/cross.png');
                                            ?>
" class="bool" width="16" height="16"/> 
								<?php 
                                        }
                                    } else {
                                        echo excerpt($row->{$name}, 50);
                                    }
                                }
                            } else {
                                if ($subfield->getName() == "slug") {
                                    foreach ($field->children() as $child) {
                                        $childname = strval($child['name']);
                                        if (is_numeric($row->{$childname}) && isset($subfield['format_' . $child['name'] . '_' . $row->{$childname}])) {
                                            if (!$name) {
                                                $name = 'slug';
                                            }
                                            $i = 0;
                                            foreach (languages() as $key => $lang) {
                                                $childlang = $name . '_' . $key;
                                                if ($i++ != 0) {
                                                    echo ' &bull; ';
                                                }
                                                $link = url((count(languages()) > 1 ? $key . '/' : '') . str_replace('$slug', $row->{$childlang}, $subfield['format_' . $child['name'] . '_' . $row->{$childname}]), false);
                                                if (count(languages()) > 1) {
                                                    echo '<a href="' . $link . '">' . strtoupper($key) . '</a>';
                                                } else {
                                                    echo '<a href="' . $link . '">' . $link . '</a>';
                                                }
                                            }
                                            $currentslug = str_replace('$slug', $row->{$name}, $subfield['format_' . $child['name'] . '_' . $row->{$childname}]) . '/';
                                        }
                                    }
                                } else {
                                    if ($type = $typemanager->get_type(strval($subfield->getName()))) {
                                        echo $type->summary($subfield, $row, $object);
                                    } else {
                                        echo htmlentities_all($row->{$name});
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ?>
				</div></td>
			<?php 
        }
        ?>
			<?php 
        $deletable = true;
        ?>
			<?php 
        foreach ($delete_limits as $delete_limit_key => $delete_limit_value) {
            if (!isset($row->{$delete_limit_key}) || $row->{$delete_limit_key} != $delete_limit_value) {
                $deletable = false;
            }
        }
        ?>
			<td align="right">
				<?php 
        if ($deletable && !isset($field['delete_disabled'])) {
            ?>
					<div style="white-space:nowrap;">
						<?php 
            if ($field['name'] != 'user' || $row->id != $user->id) {
                ?>
							<a class="delete" href="<?php 
                echo $parenturl . ($level > 0 ? $GLOBALS['recursive_name'] : $field['name']);
                ?>
/<?php 
                echo $row->id;
                ?>
/delete/" onclick="event.stopPropagation();return confirm('<?php 
                echo l(array('nl' => 'Bent u zeker dat u dit item wilt verwijderen?', 'fr' => '&Ecirc;tes-vous s&ucirc;r de vouloir supprimer cet &eacute;l&eacute;ment?', 'en' => 'Are you sure you want to remove this item?'));
                ?>
');"><img alt="<?php 
                echo l(array('nl' => 'Verwijderen', 'fr' => 'Supprimer', 'en' => 'Delete'));
                ?>
" title="<?php 
                echo l(array('nl' => 'Verwijderen', 'fr' => 'Supprimer', 'en' => 'Delete'));
                ?>
" src="<?php 
                echo url(ADMINRESOURCES . 'images/del.png');
                ?>
" width="22" height="23"></a>
						<?php 
            }
            ?>
					</div>
				<?php 
        }
        ?>
			</td>
		</tr>
		<?php 
        if (isset($GLOBALS['recursive_name']) && $GLOBALS['recursive_name']) {
            if ($level == 0) {
                $GLOBALS['root_id'] = $row->id;
            }
            foreach ($row->{$GLOBALS}['recursive_name'] as $subrow) {
                print_row($field, $shownfields, $subrow, $object, $show_edit, $level + 1, $currentslug, $parenturl . ($level == 0 ? $field['name'] : $GLOBALS['recursive_name']) . '/' . $row->id . '/');
            }
        }
        if ($level == 0) {
            echo '</tbody>';
        }
    }
Example #10
0
 function account($redirect = '')
 {
     // check user is logged in, if not send them away from this controller
     if (!$this->session->userdata('session_user')) {
         redirect('/users/login/' . $this->core->encode($this->uri->uri_string()));
     }
     // required
     $this->core->required = array('email' => array('label' => 'Email', 'rules' => 'valid_email|unique[users.email]|required|trim'), 'firstName' => array('label' => 'First Name', 'rules' => 'required|trim|ucfirst'), 'lastName' => array('label' => 'Last Name', 'rules' => 'required|trim|ucfirst'), 'address1' => array('label' => 'Address1', 'rules' => 'trim|ucfirst'), 'address2' => array('label' => 'Address2', 'rules' => 'trim|ucfirst'), 'address3' => array('label' => 'Address3', 'rules' => 'trim|ucfirst'), 'city' => array('label' => 'City / State', 'rules' => 'trim|ucfirst'), 'displayName' => array('label' => 'Display Name', 'rules' => 'unique[users.displayName]|max_length[15]|min_length[3]|alpha_dash|trim'));
     // set object ID
     $objectID = array('userID' => $this->session->userdata('userID'));
     // get values
     $data = $this->core->get_values('users', $objectID);
     if (count($_POST)) {
         // set default error message
         $error = '';
         // upload image
         if (@$_FILES['image']['name'] != '') {
             // set upload config
             $img_upload_path = site_url() . 'static/uploads/avatars';
             $this->uploads->allowedTypes = 'gif|jpg|png';
             $this->uploads->uploadsPath .= '/avatars';
             $this->uploads->maxSize = '100000';
             $this->uploads->maxWidth = '2000';
             $this->uploads->maxHeight = '2000';
             // upload avatar
             if ($imageData = $this->uploads->upload_image(FALSE)) {
                 $this->core->set['avatar'] = $imageData['file_name'];
             }
             // set error
             $error = $this->uploads->errors ? 'Problem with your image: ' . $this->uploads->errors : '';
         }
         // upload logo
         if (@$_FILES['logo']['name'] != '') {
             // set upload config
             $this->uploads->allowedTypes = 'gif|jpg|png';
             $this->uploads->uploadsPath .= '/avatars';
             $this->uploads->maxSize = '100000';
             $this->uploads->maxWidth = '2000';
             $this->uploads->maxHeight = '2000';
             // upload logo
             if ($imageData = $this->uploads->upload_image(FALSE, NULL, 'logo')) {
                 $this->core->set['companyLogo'] = $imageData['file_name'];
             }
             // set error
             $error = $this->uploads->errors ? 'Problem with your logo: ' . $this->uploads->errors : '';
         }
         // get image errors if there are any
         if ($error) {
             $this->form_validation->set_error($error);
         } else {
             // security check
             if ($this->input->post('username')) {
                 $this->core->set['username'] = $data['username'];
             }
             if ($this->input->post('subscribed')) {
                 $this->core->set['subscribed'] = $data['subscribed'];
             }
             if ($this->input->post('siteID')) {
                 $this->core->set['siteID'] = $this->siteID;
             }
             if ($this->input->post('userID')) {
                 $this->core->set['userID'] = $data['userID'];
             }
             if ($this->input->post('resellerID')) {
                 $this->core->set['resellerID'] = $data['resellerID'];
             }
             if ($this->input->post('kudos')) {
                 $this->core->set['kudos'] = $data['kudos'];
             }
             if ($this->input->post('posts')) {
                 $this->core->set['posts'] = $data['posts'];
             }
             // update
             if ($this->core->update('users', $objectID)) {
                 // get updated row
                 $row = $this->core->viewall('users', $objectID, NULL, 1);
                 // remove the password field
                 unset($row['users'][0]['password']);
                 // set session data
                 $this->session->set_userdata($row['users'][0]);
                 // update image data in session
                 if (isset($imageData)) {
                     $this->session->set_userdata('avatar', $imageData['file_name']);
                 }
                 // set success message
                 $this->session->set_flashdata('success', 'Your details have been updated.');
                 // redirect
                 if ($redirect) {
                     redirect('/users/' . $redirect);
                 } else {
                     redirect('/users/account');
                 }
             }
         }
     }
     // set title
     $output['page:title'] = $this->site->config['siteName'] . ' - Account';
     // load errors
     $output['errors'] = validation_errors() ? validation_errors() : FALSE;
     // if reverted show a message
     if ($message = $this->session->flashdata('success')) {
         $output['message'] = $message;
     }
     // populate template
     $output['user:avatar'] = anchor('/users/profile/' . $data['userID'], display_image($this->users->get_avatar($data['avatar']), 'User Avatar', 150, 'class="bordered"', base_url() . $this->config->item('staticPath') . '/images/noavatar.gif'));
     $output['user:logo'] = anchor('/users/profile/' . $data['userID'], display_image($this->users->get_avatar($data['companyLogo']), 'Company Logo', 150, 'class="bordered"'));
     $output['form:email'] = set_value('email', $data['email']);
     $output['form:displayName'] = set_value('displayName', $data['displayName']);
     $output['form:firstName'] = set_value('firstName', $data['firstName']);
     $output['form:lastName'] = set_value('lastName', $data['lastName']);
     $output['form:bio'] = set_value('bio', $data['bio']);
     $output['form:website'] = set_value('website', $data['website']);
     $output['form:signature'] = set_value('signature', $data['signature']);
     $output['form:companyName'] = set_value('companyName', $data['companyName']);
     $output['form:companyEmail'] = set_value('companyEmail', $data['companyEmail']);
     $output['form:companyWebsite'] = set_value('companyWebsite', $data['companyWebsite']);
     $output['form:companyDescription'] = set_value('companyDescription', $data['companyDescription']);
     $output['form:address1'] = set_value('address1', $data['address1']);
     $output['form:address2'] = set_value('address2', $data['address2']);
     $output['form:address3'] = set_value('address3', $data['address3']);
     $output['form:city'] = set_value('city', $data['city']);
     $output['form:postcode'] = set_value('postcode', $data['postcode']);
     $output['form:phone'] = set_value('phone', $data['phone']);
     $output['select:country'] = @display_countries('country', set_value('country', $data['country']), 'id="country" class="formelement"');
     $values = array('V' => 'Everyone can see my profile', 'H' => 'Hide my profile and feed');
     $output['select:privacy'] = @form_dropdown('privacy', $values, set_value('privacy', $data['privacy']), 'id="privacy" class="formelement"');
     $values = array(0 => 'No', 1 => 'Yes');
     $output['select:notifications'] = @form_dropdown('notifications', $values, set_value('notifications', $data['notifications']), 'id="notifications" class="formelement"');
     $output['select:currency'] = @form_dropdown('currency', currencies(), set_value('currency', $data['currency']), 'id="currency" class="formelement"');
     $output['select:language'] = @form_dropdown('language', languages(), set_value('language', $data['language']), 'id="language" class="formelement"');
     // display with cms layer
     $this->pages->view('community_account', $output, 'community');
 }
Example #11
0
 public static function reload_site()
 {
     $db = FW4_Db::get_instance();
     $site = false;
     if (!$site) {
         try {
             if (count(languages()) > 1) {
                 $query = from('site')->where('url LIKE %s', $_SERVER['HTTP_HOST'] . '%');
                 $language_codes = array_keys(languages());
                 if ($countries = Config::countries()) {
                     $language_codes = array_keys($countries);
                 }
                 foreach ($language_codes as $code) {
                     $query->or_where('`url_' . $code . '` LIKE %s', $_SERVER['HTTP_HOST'] . '%');
                 }
                 $site = $query->get_row();
             } else {
                 $site = from('site')->where('url LIKE %s', $_SERVER['HTTP_HOST'] . '%')->get_row();
             }
         } catch (PDOException $exception) {
             FW4_Structure::check_structure('', true);
         }
         if (!$site) {
             if (!($site = get_row('site'))) {
                 $name = str_ireplace('www.', '', $_SERVER['HTTP_HOST']);
                 $name = ucfirst(substr($name, 0, strpos($name, '.')));
                 $url = $_SERVER['HTTP_HOST'];
                 if (stristr(getcwd(), 'httpdocs')) {
                     $url .= substr(getcwd(), stripos(getcwd(), 'httpdocs') + strlen('httpdocs'));
                 }
                 insert('site', array("url" => $url, "name" => $name));
                 FW4_Structure::check_structure();
                 $site = where('url LIKE %s', $_SERVER['HTTP_HOST'])->get_row('site');
             } else {
                 $domain_handled = false;
                 // Process minisites
                 $types = FW4_Type_Manager::get_instance()->get_types();
                 foreach ($types as $typename => $type) {
                     if (method_exists($type, 'handle_domain')) {
                         if (!$site->structure_xml_expanded) {
                             FW4_Structure::check_structure("", true);
                             return self::reload_site();
                         }
                         $structure = new SimpleXMLElement($site->structure_xml_expanded);
                         $fields = $structure->xpath('//*[@type_name="' . $typename . '"]');
                         if (count($fields)) {
                             $prev = self::$current;
                             self::$current = $site;
                             if (call_user_func_array(array($type, 'handle_domain'), array($_SERVER['HTTP_HOST'], $fields))) {
                                 $domain_handled = true;
                                 break;
                             }
                             self::$current = $prev;
                         }
                     }
                 }
                 // Process subdomains
                 foreach (Config::subdomains() as $subdomain => $handler) {
                     //if () Router::set_content_prefix($handler);
                 }
                 if (!$domain_handled && $site->live) {
                     redirect((Config::https() ? 'https' : 'http') . '://' . $site->url . $_SERVER['REQUEST_URI']);
                 }
             }
         }
     }
     if (!$site->live && false === stristr($_SERVER['HTTP_HOST'], '.fw4.') && false === stristr($_SERVER['HTTP_HOST'], 'local')) {
         $db->query("UPDATE site SET live = 1 WHERE id = " . $site->id);
         if (stristr($site->url, '.fw4.be')) {
             where('id = %d', $site->id)->update('site', array('url' => $_SERVER['HTTP_HOST']));
         }
     }
     self::$current = $site;
     return $site;
 }
Example #12
0
    ?>
				</dt>
				<dd><input type="text" name="site_name" value="<?php 
    echo switchs($_POST['site_name'], $config['site_name']);
    ?>
" class="border" style="width: 40%" /></dd>
			</dl>

			<dl class="input">
				<dt>
					<?php 
    echo lang('site_language');
    ?>
				</dt>
				<dd><?php 
    languages(true);
    ?>
</dd>
			</dl>

			<dl class="input">
				<dt>
					<?php 
    echo lang('site_theme');
    ?>
				</dt>
				<dd><?php 
    themes(true);
    ?>
</dd>
			</dl>
Example #13
0
function list_languages($message = '')
{
    global $prefs, $locale, $txpcfg, $textarray;
    require_once txpath . '/lib/IXRClass.php';
    // Select and save active language
    if (!$message && ps('step') == 'list_languages' && ps('language')) {
        $locale = doSlash(getlocale(ps('language')));
        safe_update("txp_prefs", "val='" . doSlash(ps('language')) . "'", "name='language'");
        safe_update("txp_prefs", "val='" . $locale . "'", "name='locale'");
        $textarray = load_lang(doSlash(ps('language')));
        $locale = setlocale(LC_ALL, $locale);
        $message = gTxt('preferences_saved');
    }
    $active_lang = safe_field('val', 'txp_prefs', "name='language'");
    $lang_form = tda(form(gTxt('active_language') . '&nbsp;&nbsp;' . languages('language', $active_lang) . '&nbsp;&nbsp;' . fInput('submit', 'Submit', gTxt('save_button'), '') . eInput('prefs') . sInput('list_languages'), 'display:inline;'), ' style="text-align:center" colspan="3"');
    $client = new IXR_Client(RPC_SERVER);
    #$client->debug = true;
    $available_lang = array();
    $rpc_connect = false;
    $show_files = false;
    # Get items from RPC
    @set_time_limit(90);
    if (gps('force') != 'file' && $client->query('tups.listLanguages', $prefs['blog_uid'])) {
        $rpc_connect = true;
        $response = $client->getResponse();
        foreach ($response as $language) {
            $available_lang[$language['language']]['rpc_lastmod'] = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year);
        }
    } elseif (gps('force') != 'file') {
        $msg = gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->";
    }
    # Get items from Filesystem
    $files = get_lang_files();
    if (gps('force') == 'file' || !$rpc_connect) {
        $show_files = true;
    }
    if ($show_files && is_array($files) && !empty($files)) {
        foreach ($files as $file) {
            if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) {
                $name = str_replace('.txt', '', $file);
                $firstline = fgets($fp, 4069);
                fclose($fp);
                if (strpos($firstline, '#@version') !== false) {
                    @(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1)))));
                } else {
                    $fversion = $ftime = NULL;
                }
                $available_lang[$name]['file_note'] = isset($fversion) ? $fversion : 0;
                $available_lang[$name]['file_lastmod'] = isset($ftime) ? $ftime : 0;
            }
        }
    }
    # Get installed items from the database
    # I'm affraid we need a value here for the language itself, not for each one of the rows
    $rows = safe_rows('lang, UNIX_TIMESTAMP(MAX(lastmod)) as lastmod', 'txp_lang', "1 GROUP BY lang ORDER BY lastmod DESC");
    foreach ($rows as $language) {
        $available_lang[$language['lang']]['db_lastmod'] = $language['lastmod'];
    }
    $list = '';
    # Show the language table
    foreach ($available_lang as $langname => $langdat) {
        $file_updated = isset($langdat['db_lastmod']) && @$langdat['file_lastmod'] > $langdat['db_lastmod'];
        $rpc_updated = @$langdat['rpc_lastmod'] > @$langdat['db_lastmod'];
        $rpc_install = tda(strong(eLink('prefs', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']))) . br . safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']), isset($langdat['db_lastmod']) ? ' style="color:red;text-align:center;background-color:#FFFFCC;"' : ' style="color:#667;vertical-align:middle;text-align:center"');
        $list .= tr(tda(gTxt($langname) . tag(isset($langdat['db_lastmod']) ? br . '&nbsp;' . safe_strftime('%d %b %Y %X', $langdat['db_lastmod']) : '', 'span', ' style="color:#aaa;font-style:italic"'), isset($langdat['db_lastmod']) && $rpc_updated ? ' nowrap="nowrap" style="color:red;background-color:#FFFFCC;"' : ' nowrap="nowrap" style="vertical-align:middle"') . n . ($rpc_updated ? $rpc_install : tda(isset($langdat['rpc_lastmod']) ? gTxt('updated') : '-', ' style="vertical-align:middle;text-align:center"')) . n . ($show_files ? tda(tag(isset($langdat['file_lastmod']) ? eLink('prefs', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file') . br . '&nbsp;' . safe_strftime($prefs['archive_dateformat'], $langdat['file_lastmod']) : ' &nbsp; ', 'span', $file_updated ? ' style="color:#667;"' : ' style="color:#aaa;font-style:italic"'), ' class="langfile" style="text-align:center;vertical-align:middle"') . n : '')) . n . n;
    }
    // Output Table + Content
    pagetop(gTxt('update_languages'), $message);
    if (isset($msg) && $msg) {
        echo tag($msg, 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
    }
    echo startTable('list'), tr(tdcs(hed(gTxt('manage_languages'), 1), 3)), tr(tdcs(sLink('prefs', 'prefs_list', gTxt('site_prefs'), 'navlink') . sp . sLink('prefs', 'advanced_prefs', gTxt('advanced_preferences'), 'navlink') . sp . sLink('prefs', 'list_languages', gTxt('manage_languages'), 'navlink-active'), '3')), tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')), tr($lang_form), tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')), tr(tda(gTxt('language')) . tda(gTxt('from_server')) . ($show_files ? tda(gTxt('from_file')) : ''), ' style="font-weight:bold"');
    echo $list;
    if (!$show_files) {
        $linktext = gTxt('from_file') . ' (' . gTxt('experts_only') . ')';
        echo tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')) . tr(tda(strong(eLink('prefs', 'list_languages', 'force', 'file', $linktext)), ' colspan="3" style="text-align:center"'));
    } elseif (gps('force') == 'file') {
        echo tr(tda('&nbsp;', ' colspan="3" style="font-size:0.25em"')) . tr(tda(sLink('prefs', 'list_languages', strong(gTxt('from_server'))), ' colspan="3" style="text-align:center"'));
    }
    echo endTable();
    $install_langfile = gTxt('install_langfile', array('{url}' => strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>')));
    if ($install_langfile == 'install_langfile') {
        $install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.';
    }
    echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
}
Example #14
0
 public function insert($objectname, $data)
 {
     if (!$this->structure) {
         $this->structure = FW4_Structure::get_object_structure($this->objectname_prefix . $objectname);
     }
     if ($this->structure) {
         $language_field = false;
         $language = language();
         $is_recursive = false;
         // Translate data
         foreach ($this->structure->children() as $child) {
             if (in_array($child->getName(), array('string', 'text')) && isset($child['translatable']) && $child['translatable'] && $child['translatable'] != 'false') {
                 if (isset($data[strval($child['name'])])) {
                     $data[strval($child['name']) . '_' . language()] = $data[strval($child['name'])];
                     unset($data[strval($child['name'])]);
                 }
             } else {
                 if ($child->getName() == 'slug') {
                     // Setup slugs
                     if (!isset($child['name'])) {
                         $child['name'] = 'slug';
                     }
                     if (!isset($data[strval($child['name'])])) {
                         $slugdata = array();
                         if (!isset($child['format']) && isset($child['source'])) {
                             $child['format'] = '[' . $child['source'] . ']';
                         }
                         preg_match_all('/\\[([a-z0-9\\_]+)\\]/is', strval($child['format']), $matches, PREG_SET_ORDER);
                         $name = strval($child['name']);
                         $translatable = $invalid = false;
                         $slug_fields = array();
                         foreach ($matches as $match) {
                             $source = false;
                             foreach ($this->structure->children() as $subchild) {
                                 if (strval($subchild['name']) == $match[1]) {
                                     $source = $subchild;
                                 }
                             }
                             if ($source) {
                                 $slug_fields[strval($source['name'])] = $source;
                                 if (isset($source['translatable']) && $source['translatable']) {
                                     $translatable = true;
                                 }
                             } else {
                                 $slug_fields[$match[1]] = false;
                             }
                         }
                         if ($translatable) {
                             foreach (languages() as $code => $lang) {
                                 $slugdata[$name . '_' . $code] = strval($child['format']);
                             }
                         } else {
                             $slugdata[$name] = strval($child['format']);
                         }
                         foreach ($slug_fields as $slug_name => $slug_field) {
                             if ($translatable) {
                                 foreach (languages() as $code => $lang) {
                                     $slugnamecode = $slug_name . '_' . $code;
                                     $namecode = $name . '_' . $code;
                                     if (isset($data[$slugnamecode])) {
                                         $slugdata[$name . '_' . $code] = str_ireplace('[' . $slug_name . ']', $data[$slugnamecode], $slugdata[$namecode]);
                                     }
                                 }
                             } else {
                                 if (isset($data[$slug_name])) {
                                     $slugdata[$name] = str_ireplace('[' . $slug_name . ']', $data[$slug_name], $slugdata[$name]);
                                 } else {
                                     unset($slugdata[$name]);
                                     $invalid = true;
                                 }
                             }
                         }
                         if ($invalid) {
                             continue;
                         }
                         if ($translatable) {
                             foreach (languages() as $code => $lang) {
                                 $namecode = $name . '_' . $code;
                                 $slugdata[$namecode] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', remove_accents($slugdata[$name . '_' . $code])))));
                                 if (!isset($data[$namecode])) {
                                     $data[$namecode] = $slugdata[$namecode];
                                 }
                             }
                             unset($data[$name]);
                         } else {
                             $slugdata[$name] = strtolower(preg_replace('/\\s+/is', '-', trim(preg_replace('/[^a-z0-9\\s]/is', '', str_replace('-', ' ', remove_accents($slugdata[$name]))))));
                             if (!isset($data[$name])) {
                                 $data[$name] = $slugdata[$name];
                             }
                         }
                     }
                 } else {
                     if ($child->getName() == 'language') {
                         $language_field = $child;
                         $language = 0;
                     } else {
                         if ($child->getName() == 'recursive') {
                             if (isset($data['parent_id']) && $data['parent_id']) {
                                 $is_recursive = true;
                             }
                         }
                     }
                 }
             }
         }
         // Give pages a default parent
         if (!$is_recursive && $this->structure['parent_name'] && $this->structure['parent_type'] == 'page' && $this->structure['name'] != '_versions' && !isset($data[$this->structure['parent_name'] . '_id']) && !(isset($this->structure['child']) && $this->structure['child'] == 'false')) {
             $data[$this->structure['parent_name'] . '_id'] = 1;
         }
     }
     $sql_lines = array();
     foreach ($data as $field => $value) {
         if (is_null($value)) {
             continue;
         }
         if (is_object($value)) {
             continue;
         }
         if (is_float($value)) {
             $value = number_format($value, 2, '.', '');
         }
         if (is_bool($value)) {
             $value = $value ? 1 : 0;
         }
         $sql_lines[] = '`' . $field . '` = ' . $this->db->quote($value);
     }
     if ($this->structure) {
         $sql = 'INSERT INTO `' . $this->structure['path'] . '`';
     } else {
         $sql = 'INSERT INTO `' . $objectname . '`';
     }
     if (count($sql_lines)) {
         $sql .= ' SET ' . implode(',', $sql_lines);
     } else {
         $sql .= ' (`id`) VALUES (NULL);';
     }
     $this->db->query($sql);
     $newid = $this->db->lastInsertId();
     if ($this->structure) {
         $data['id'] = $newid;
         // Save a version
         if (isset($this->structure['archived']) && $this->save_version && $this->structure['name'] != '_versions' && count(array_filter($data)) > 1) {
             $versiondata = $data;
             $version_id = insert($this->structure['stack'] . '>_versions', $versiondata);
         }
         // Add record to search index if needed
         $types = FW4_Type_Manager::get_instance();
         $search_index = array();
         foreach ($this->structure->children() as $type => $field) {
             if (isset($field['searchable'])) {
                 if (isset($field['type_name']) && ($type_obj = $types->get_type(strval($field['type_name'])))) {
                     if (method_exists($type_obj, 'get_insert_search_index')) {
                         $fieldname = strval($field['searchable']);
                         if (isset($field['translatable'])) {
                             foreach (languages() as $key => $lang) {
                                 if (!isset($search_index[$key])) {
                                     $search_index[$key] = array();
                                 }
                                 $search_index[$key][$fieldname] = $type_obj->get_insert_search_index($field, $data, $this->structure, $lang);
                             }
                         } else {
                             if (!isset($search_index[$language])) {
                                 $search_index[$language] = array();
                             }
                             $search_index[$language][$fieldname] = $type_obj->get_insert_search_index($field, $data, $this->structure, $language);
                         }
                     }
                 } else {
                     $fieldname = strval($field['searchable']);
                     if (isset($field['translatable'])) {
                         foreach (languages() as $key => $lang) {
                             if (!isset($search_index[$key])) {
                                 $search_index[$key] = array();
                             }
                             if (isset($data[strval($field['name']) . '_' . $key])) {
                                 $search_index[$key][$fieldname] = strip_tags(preg_replace('/\\<br(\\s*)?\\/?\\>/i', "\n", $data[strval($field['name']) . '_' . $key]));
                             }
                         }
                     } else {
                         if (!isset($search_index[language()])) {
                             $search_index[language()] = array();
                         }
                         if (isset($data[strval($field['name'])])) {
                             $search_index[language()][$fieldname] = strip_tags(preg_replace('/\\<br(\\s*)?\\/?\\>/i', "\n", $data[strval($field['name'])]));
                         }
                     }
                 }
             }
         }
         foreach ($search_index as $language => &$searchdata) {
             if (count($searchdata) && $this->structure['name'] != '_versions') {
                 $searchdata['object_id'] = $newid;
                 $searchdata['object_name'] = strval($this->structure['stack']);
                 $searchdata['_language'] = $language;
                 if (isset($this->structure['archived']) && $this->save_version && $this->structure['name'] != '_versions') {
                     $searchdata['_version_id'] = $version_id;
                 }
                 insert('_search_index', $searchdata);
             }
         }
     }
     return $newid;
 }
Example #15
0
 private static function print_field($field, $data, $structure)
 {
     if (in_array($field->getName(), array('div', 'span', 'img'))) {
         echo '<div class="usernote">' . strval($field->asXML()) . '</div>';
         return false;
     }
     $user = FW4_User::get_user();
     if (isset($field['require']) && $user->id !== 0) {
         $require_fields = explode('.', $field['require']);
         $require_field = $user;
         foreach ($require_fields as $current_field) {
             if (isset($require_field[$current_field]) && $require_field[$current_field]) {
                 $require_field = $require_field[$current_field];
             } else {
                 $require_field = false;
                 break;
             }
         }
         if (!$require_field && !isset($structure['is_version'])) {
             return false;
         }
     }
     if (isset($field['hide_on_recursive']) && self::$recursive_levels > 0) {
         return false;
     }
     $types = FW4_Type_Manager::get_instance();
     $fieldname = strval($field['name']);
     switch ($field->getName()) {
         case 'object':
             if (isset($data->id) && !isset($structure['is_version'])) {
                 $objectquery = where((isset($structure['orig_name']) ? $structure['orig_name'] : $structure['name']) . '_id = %d', $data->id);
                 foreach ($field->children() as $type => $subfield) {
                     if ($type == 'object') {
                         $objectquery->including(strval($subfield['name']));
                     }
                     if ($type == 'summary' && isset($subfield['needs'])) {
                         foreach (explode(',', strval($subfield['needs'])) as $needs) {
                             $objectquery->including(trim($needs));
                         }
                     }
                     if ($type == 'recursive') {
                         $objectquery->where('parent_id IS NULL');
                     }
                 }
                 $objectamount = $objectquery->get($structure['stack'] . '>' . $field['name'])->rowCount();
                 $objectdata = $objectquery->limit(50)->get($structure['stack'] . '>' . $field['name']);
                 $field['stack'] = $structure['stack'] . '>' . $field['name'];
                 self::print_object_list($field, $objectdata, $objectamount, $data->id);
             }
             return false;
         case 'recursive':
             if (isset($structure['editing_disabled'])) {
                 return false;
             }
             if (isset($field['levels']) && $field['levels'] <= self::$recursive_levels) {
                 return false;
             }
             if (isset($data->id)) {
                 $recursive_structure = clone $structure;
                 if (isset($field['title'])) {
                     $recursive_structure['title'] = $field['title'];
                 }
                 if (isset($field['label'])) {
                     $recursive_structure['label'] = $field['label'];
                 }
                 if (isset($field['name'])) {
                     $recursive_structure['orig_name'] = $recursive_structure['name'];
                     $recursive_structure['name'] = $field['name'];
                 }
                 $objectquery = where('parent_id = %d', $data->id)->limit(50);
                 $objectdata = $objectquery->get($structure['stack']);
                 $objectamount = $objectquery->count_rows($structure['stack']);
                 self::print_object_list($recursive_structure, $objectdata, $objectamount, $data->id, true, true, true);
             }
             return false;
         case 'list':
             if (isset($field['datasource'])) {
                 if (function_exists('datasource_' . $field['datasource'])) {
                     $listdata = call_user_func('datasource_' . $field['datasource'], false);
                     if (is_array($listdata)) {
                         echo View_Loader::get_instance()->load("data_list", array('data' => $listdata, 'export' => isset($field['exportable']), 'datasource' => isset($field['datasource']) ? strval($field['datasource']) : false, 'object' => isset($field['object']) ? strval($field['object']) : false));
                     }
                 }
             }
             if (isset($data->id)) {
                 $object = FW4_Structure::get_object_structure(strval($field['object']));
                 if (!$object) {
                     return false;
                 }
                 foreach ($field->attributes() as $key => $val) {
                     $object->addAttribute($key, $val);
                 }
                 $query = new Query();
                 if (isset($field['order_field'])) {
                     $query->order_by(strval($field['order_field']));
                 }
                 if (isset($field['where'])) {
                     foreach (explode(',', strval($field['where'])) as $item) {
                         $item = explode(':', $item);
                         $query->where($item[0] . ' = %s', $item[1]);
                     }
                 }
                 $allow_edit = true;
                 if (isset($field['allow_edit']) && ($field['allow_edit'] == 'false' || !$field['allow_edit'])) {
                     $allow_edit = false;
                 }
                 $rows = $query->load_children(true)->get(strval($field['object']));
                 self::print_object_list($object, $rows, count($rows), $data->id, true, $allow_edit);
             }
             return false;
         case 'string':
         case 'email':
             if (isset($field['readonly']) && isset($data->id) || isset($structure['editing_disabled'])) {
                 echo '<div class="input"><label for="' . $field['name'] . '" class="for-input">' . $field['label'] . '</label><div class="value">' . (isset($data->{$fieldname}) && $data->{$fieldname} ? self::placeholder_decode($data->{$fieldname}, $field) : '-') . '</div></div>';
             } else {
                 if (isset($field['translatable']) && $field['translatable']) {
                     echo '<div class="' . (FW4_Admin::$in_fieldset ? 'field' : 'input') . '"><label' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> ';
                     foreach (languages() as $key => $lang) {
                         $fieldlang = $fieldname . '_' . $key;
                         echo '<div class="language"><input type="text" class="' . (count(languages()) > 1 ? 'with_lang_label lowmargin' : '') . (isset($field['required']) && $field['required'] ? ' required' : '') . '' . (isset($field['wide']) ? ' wide' : '') . '" name="' . $field['name'] . '_' . $key . '" value="' . htmlentities_all(isset($data->{$fieldlang}) ? $data->{$fieldlang} : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 150) . '"' . (isset($field['visible_condition']) ? ' data-visible-condition="' . $field['visible_condition'] . '"' : '') . ' />' . (count(languages()) > 1 ? '<span class="lang_label">' . strtoupper($key) . '</span>' : '') . '</div>';
                     }
                     echo '<br/></div>';
                 } else {
                     echo '<div class="' . (FW4_Admin::$in_fieldset ? 'field' : 'input') . '"><label for="' . $field['name'] . '" class="for-input">' . $field['label'] . '</label> <input class="' . (isset($field['required']) && $field['required'] ? 'required' : '') . '' . (isset($field['wide']) ? ' wide' : '') . '" type="text" id="input-' . $field['name'] . '" name="' . $field['name'] . '" value="' . htmlspecialchars(isset($data->{$fieldname}) ? $data->{$fieldname} : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 150) . '"' . (isset($field['visible_condition']) ? ' data-visible-condition="' . $field['visible_condition'] . '"' : '') . ' /></div>';
                 }
             }
             return true;
         case 'number':
             if (isset($field['readonly']) && $field['readonly'] || isset($structure['editing_disabled'])) {
                 if (isset($data->id)) {
                     echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <div class="value">' . (isset($data->{$fieldname}) ? $data->{$fieldname} : '') . '</div></div>';
                 }
             } else {
                 echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <input class="number' . (isset($field['required']) && $field['required'] ? ' required' : '') . '" type="text" name="' . $field['name'] . '" value="' . (isset($data->{$fieldname}) ? $data->{$fieldname} : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 20) . '" /></div>';
             }
             return true;
         case 'float':
             if (isset($field['readonly']) && $field['readonly'] || isset($structure['editing_disabled'])) {
                 if (isset($data->id)) {
                     echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <div class="value">' . (isset($data->{$fieldname}) ? trim(trim(number_format($data->{$fieldname}, 2, ',', '.'), '0'), ',') : '') . '</div></div>';
                 }
             } else {
                 echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <input class="float' . (isset($field['required']) && $field['required'] ? ' required' : '') . '" type="text" name="' . $field['name'] . '" value="' . (isset($data->{$fieldname}) ? trim(trim(number_format($data->{$fieldname}, 2, ',', '.'), '0'), ',') : '') . '" maxlength="' . (isset($field['length']) ? $field['length'] : 20) . '" /></div>';
             }
             return true;
         case 'password':
             if (isset($field['readonly']) && isset($data->id) || isset($structure['editing_disabled'])) {
                 return false;
             } else {
                 echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <input type="password"' . (isset($field['required']) && $field['required'] && !isset($data->id) ? ' class="required"' : '') . ' name="' . $field['name'] . '" maxlength="' . (isset($field['length']) ? $field['length'] : 150) . '" /></div>';
             }
             return true;
         case 'bool':
             if (self::$in_fieldset) {
                 echo '<div class="field">';
             } else {
                 echo '<fieldset>';
             }
             if (isset($field['readonly']) && isset($data->id) || isset($structure['editing_disabled'])) {
                 echo $field['label'] . ': <strong>' . (isset($data->{$fieldname}) && $data->{$fieldname} == 1 || !$data->id && isset($field['default']) ? l(array('nl' => 'Ja', 'fr' => 'Oui', 'en' => 'Yes')) : l(array('nl' => 'Nee', 'fr' => 'Non', 'en' => 'No'))) . '</strong>';
             } else {
                 echo '<input id="input-' . $field['name'] . '"' . (isset($field['enabled_condition']) ? ' data-enabled-condition="' . $field['enabled_condition'] . '"' : '') . '' . (isset($field['visible_condition']) ? ' data-visible-condition="' . $field['visible_condition'] . '"' : '') . ' type="checkbox" name="' . $field['name'] . '" value="1" ' . (isset($data->{$fieldname}) && $data->{$fieldname} == 1 || (!isset($data->id) || !$data->id) && isset($field['default']) ? 'checked="checked"' : '') . ' /><label for="input-' . $field['name'] . '">' . $field['label'] . '</label>';
             }
             if (self::$in_fieldset) {
                 echo '</div>';
             } else {
                 echo '</fieldset>';
             }
             return true;
         case 'date':
             if (isset($field['default_today']) && $field['default_today'] && !isset($data->id)) {
                 $data->{$fieldname} = time();
             } else {
                 if (!isset($data->{$fieldname})) {
                     $data->{$fieldname} = '';
                 }
             }
             echo '<div class="' . (FW4_Admin::$in_fieldset ? 'field' : 'input') . '"><label class="for-input">' . $field['label'] . '</label>';
             if (isset($field['readonly']) && $field['readonly'] || isset($structure['editing_disabled'])) {
                 echo '<div class="value">' . (isset($data->{$fieldname}) && is_numeric($data->{$fieldname}) && $data->{$fieldname} ? date('d/m/Y', $data->{$fieldname}) : ($data->{$fieldname} ? $data->{$fieldname} : 'Nooit')) . '</div>';
             } else {
                 echo '<input type="text" name="' . $field['name'] . '" style="width:100px" class="date' . (isset($field['required']) && $field['required'] ? ' required' : '') . '" size="20" id="input-' . $field['name'] . '" value="' . (isset($data->{$fieldname}) && is_numeric($data->{$fieldname}) ? date('d/m/Y', $data->{$fieldname}) : $data->{$fieldname}) . '"' . (isset($field['visible_condition']) ? ' data-visible-condition="' . $field['visible_condition'] . '"' : '') . '' . (isset($field['limit']) ? ' data-limit="' . $field['limit'] . '"' : '') . '/>';
             }
             echo '</div>';
             return true;
         case 'timedate':
             $date = new DateTime(null, new DateTimeZone('Etc/GMT+2'));
             if (isset($field['default_today']) && $field['default_today'] && !isset($data->{$fieldname})) {
                 $data->{$fieldname} = $date->getTimestamp();
             } else {
                 if (!isset($data->{$fieldname})) {
                     $data->{$fieldname} = '';
                 }
             }
             if (isset($data->{$fieldname}) && is_numeric($data->{$fieldname}) && $data->{$fieldname} > 0) {
                 if (strftime('%H:%M', $data->{$fieldname}) == '00:00') {
                     $value = strftime('%d/%m/%Y', $data->{$fieldname});
                 } else {
                     $value = strftime('%d/%m/%Y %H:%M', $data->{$fieldname});
                 }
             } else {
                 $value = '';
             }
             echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label>';
             if (isset($field['readonly']) && $field['readonly'] || isset($structure['editing_disabled'])) {
                 echo '<div class="value">' . ($value ? $value : 'Nooit') . '</div>';
             } else {
                 echo '<input type="text" name="' . $field['name'] . '" style="width:150px" class="timedate' . (isset($field['required']) && $field['required'] ? ' required' : '') . '" size="20" value="' . $value . '" data-limit="' . (isset($field['limit']) ? $field['limit'] . '"' : '') . '/>';
             }
             echo '</div>';
             return true;
         case 'text':
             $placeholdernames = array();
             $placeholderlabels = array();
             $placeholdericons = array();
             foreach ($field->xpath('//placeholder') as $child) {
                 $placeholdernames[] = strval($child['name']);
                 $placeholderlabels[] = isset($child['label']) ? $child['label'] : ucfirst($child['name']);
                 $placeholdericons[] = isset($child['icon']) ? $child['icon'] : url(ADMINRESOURCES . 'images/icon-placeholder.png');
             }
             if (isset($field['readonly']) && $field['readonly'] || isset($structure['editing_disabled'])) {
                 echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label><div class="value">' . (isset($data->{$fieldname}) && $data->{$fieldname} ? self::placeholder_decode($data->{$fieldname}, $field) : '-') . '</div></div>';
             } else {
                 if (isset($field['translatable']) && $field['translatable']) {
                     echo '<div class="input langswitch"><label' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label><div class="translate-container">';
                     if (count(languages()) > 1) {
                         echo '<select class="langswitch">';
                         foreach (languages() as $key => $lang) {
                             echo '<option value="' . $key . '">' . $lang . '</option> ';
                         }
                         echo '</select>';
                     }
                     foreach (languages() as $key => $lang) {
                         $fieldlang = $fieldname . '_' . $key;
                         echo '<div class="translatable editor lang_' . $key . ($key == language() ? '' : ' hidden') . '"><textarea class="' . (isset($field['required']) && $field['required'] ? ' required' : '') . (isset($field['controls']) && $field['controls'] ? ' ' . $field['controls'] : '') . (isset($field['size']) && $field['size'] ? ' ' . $field['size'] : '') . '" name="' . $field['name'] . '_' . $key . '" rows="5"' . (isset($field['toolbar']) && $field['toolbar'] ? ' data-controls="' . $field['toolbar'] . '"' : '');
                         if (count($placeholdernames)) {
                             echo ' data-placeholder-names="' . e(implode(',', $placeholdernames)) . '"';
                         }
                         if (count($placeholderlabels)) {
                             echo ' data-placeholder-labels="' . e(implode(',', $placeholderlabels)) . '"';
                         }
                         if (count($placeholdericons)) {
                             echo ' data-placeholder-icons="' . e(implode(',', $placeholdericons)) . '"';
                         }
                         echo '>' . (isset($data->{$fieldlang}) ? self::placeholder_decode($data->{$fieldlang}, $field) : '') . '</textarea></div>';
                     }
                     echo '<div class="textarea-loader"></div></div></div>';
                 } else {
                     echo '<div class="input"><label for="' . $field['name'] . '"' . (isset($field['invalid']) && $field['invalid'] ? ' class="invalid"' : '') . '>' . $field['label'] . '</label> <textarea name="' . $field['name'] . '" rows="5" class="' . (isset($field['required']) && $field['required'] ? ' required' : '') . (isset($field['controls']) && $field['controls'] ? ' ' . $field['controls'] : '') . (isset($field['size']) && $field['size'] ? ' ' . $field['size'] : '') . '"' . (isset($field['toolbar']) && $field['toolbar'] ? ' data-controls="' . $field['toolbar'] . '"' : '');
                     if (count($placeholdernames)) {
                         echo ' data-placeholder-names="' . e(implode(',', $placeholdernames)) . '"';
                     }
                     if (count($placeholderlabels)) {
                         echo ' data-placeholder-labels="' . e(implode(',', $placeholderlabels)) . '"';
                     }
                     if (count($placeholdericons)) {
                         echo ' data-placeholder-icons="' . e(implode(',', $placeholdericons)) . '"';
                     }
                     echo '>' . (isset($data->{$fieldname}) ? self::placeholder_decode($data->{$fieldname}, $field) : '') . '</textarea><div class="textarea-loader"></div></div>';
                 }
             }
             return true;
         case 'fieldset':
             $iseditable = false;
             self::$in_fieldset = true;
             echo '<fieldset>';
             foreach ($field->children() as $type => $subfield) {
                 $user = FW4_User::get_user();
                 if (isset($field['hidden'])) {
                     continue;
                 }
                 if (isset($subfield['superadmin_only']) && $user['id'] != 0) {
                     continue;
                 }
                 if (self::print_field($subfield, $data, $structure)) {
                     $iseditable = true;
                 } else {
                     if ($type_obj = $types->get_type($type)) {
                         $type_obj->print_field($subfield, $data, $field);
                         if ($type != 'header') {
                             $iseditable = true;
                         }
                     }
                 }
             }
             echo '</fieldset>';
             self::$in_fieldset = false;
             return $iseditable;
     }
     return false;
 }
Example #16
0
 private static function rebuild_search_index_for_object($structure)
 {
     $searchable_objects = array();
     $search_index = array();
     $languages = languages();
     $types = FW4_Type_Manager::get_instance();
     $language_field = false;
     $language = language();
     foreach ($structure->xpath('string[@type_name="language"]') as $possible_language_field) {
         $language_field = $possible_language_field;
         $language = 0;
     }
     foreach ($structure->children() as $type => $field) {
         if ($type == 'page' || $type == 'object' || $type == 'site') {
             $searchable_objects = array_merge($searchable_objects, self::rebuild_search_index_for_object($field));
         } else {
             if (isset($field['searchable']) && isset($field['type_name']) && ($type_obj = $types->get_type(strval($field['type_name'])))) {
                 if (method_exists($type_obj, 'get_search_index')) {
                     $fieldname = strval($field['searchable']);
                     if (isset($field['translatable'])) {
                         foreach ($languages as $key => $lang) {
                             if (!isset($search_index[$key])) {
                                 $search_index[$key] = array();
                             }
                             $search_index[$key][$fieldname] = array('type' => $type_obj, 'field' => $field);
                         }
                     } else {
                         if (!isset($search_index[$language])) {
                             $search_index[$language] = array();
                         }
                         $search_index[$language][$fieldname] = array('type' => $type_obj, 'field' => $field);
                     }
                 }
             } else {
                 if (isset($field['searchable'])) {
                     $fieldname = strval($field['searchable']);
                     if (isset($field['translatable'])) {
                         foreach ($languages as $key => $lang) {
                             if (!isset($search_index[$key])) {
                                 $search_index[$key] = array();
                             }
                             $search_index[$key][$fieldname] = strval($field['name']) . '_' . $key;
                         }
                     } else {
                         if (!isset($search_index[$language])) {
                             $search_index[$language] = array();
                         }
                         $search_index[$language][$fieldname] = strval($field['name']);
                     }
                 }
             }
         }
     }
     if (count($search_index)) {
         $page = 1;
         do {
             $results = limit(50)->page($page++)->get(strval($structure['stack']));
             foreach ($results as $result) {
                 foreach ($search_index as $language => $searchfields) {
                     if ($language === 0) {
                         $language_field_name = strval($language_field['name']);
                         $language = $result->{$language_field_name};
                         where('object_id = %d', $result->id)->where('_language != %s', $language)->where('object_name = %s', strval($structure['stack']))->delete('_search_index');
                     }
                     $data = array();
                     foreach ($searchfields as $searchfieldname => $searchfield) {
                         if (is_array($searchfield)) {
                             $data[$searchfieldname] = $searchfield['type']->get_search_index($searchfield['field'], $result, $structure, $language);
                         } else {
                             if (isset($result->{$searchfield})) {
                                 $data[$searchfieldname] = $result->{$searchfield};
                             }
                         }
                     }
                     if (count($data)) {
                         $existing = where('object_id = %d', $result->id)->where('_language = %s', $language)->where('object_name = %s', strval($structure['stack']))->get_row('_search_index');
                         if ($existing) {
                             where('id = %d', $existing->id)->update('_search_index', $data);
                             where('id != %d', $existing->id)->where('object_id = %d', $result->id)->where('_language = %s', $language)->where('object_name = %s', strval($structure['stack']))->delete('_search_index');
                         } else {
                             $data['object_id'] = $result->id;
                             $data['object_name'] = strval($structure['stack']);
                             $data['_language'] = $language;
                             insert('_search_index', $data);
                         }
                     }
                 }
             }
         } while (count($results) == 50);
         $searchable_objects[] = strval($structure['stack']);
     }
     return $searchable_objects;
 }
Example #17
0
     savethemes($xDefault_Theme, $xoverwrite_theme);
     break;
 case "users":
     users();
     break;
 case "saveusers":
     saveusers($xanonymous, $xanonpost, $xoverwrite_theme, $xminpass, $xbroadcast_msg, $xmy_headlines, $xuser_news);
     break;
 case "comments":
     comments();
     break;
 case "savecomments":
     savecomments($xanonpost, $xmoderate, $xcommentlimit, $xpollcomm, $xarticlecomm, $xCensorMode, $xCensorReplace);
     break;
 case "languages":
     languages();
     break;
 case "savelanguages":
     savelanguages($xlanguage, $xlocale, $xmultilingual, $xuseflags, $xbackend_language);
     break;
 case "footer":
     footer();
     break;
 case "savefooter":
     savefooter($xfoot1, $xfoot2, $xfoot3);
     break;
 case "backend":
     backend();
     break;
 case "savebackend":
     savebackend($xbackend_title, $xbackend_language, $xsite_logo, $xultramode);
Example #18
0
                                            <div class="hrd-box">
                                                <div class="col-md-6 hrd-rsn">
                                                    <span class="sprite check-rblue pull-left"></span>
                                                    <span class="hrd-rsn-text">
                                                        <span class="bold">We speak;</span>
                                                        <br>
                                                        <?php 
echo $hotel_info->name;
?>
's staff speak:

                                                        <?php 
if (isset($settings['spoken_languages'])) {
    foreach ($settings['spoken_languages'] as $lang) {
        $langs = languages();
        echo $langs[$lang]['name'] . ',';
    }
}
?>
                                                        <br>
                                                    </span>
                                                </div>
                                                <div class="col-md-6 hrd-rsn">
                                                    <span class="sprite check-rblue pull-left"></span>
                                                    <span class="hrd-rsn-text">
                                                        <span class="bold">The staff speak English</span><br>
                                                        Hotel Sultania's staff speak: Arabic, English, Russian and Spanish<br>
                                                    </span>
                                                </div>
                                                <div class="col-md-6 hrd-rsn">
Example #19
0
 /**
  * Imports available properties from and communicates import progress with Skarabee's servers
  */
 public function import()
 {
     $client = self::get_client();
     $types = array('LOT' => 2, 'MODEL' => 4, 'PROJECT' => 3, 'TRANSACTION' => 1);
     $categories = array('Dwelling' => 1, 'Flat' => 2, 'Land' => 3, 'ServiceFlat' => 4, 'Room' => 5, 'Parking' => 6, 'Other' => 7, 'Catering' => 8, 'Office' => 9, 'Industry' => 10, 'Shop' => 11, 'ProfessionalOther' => 12, 'ProfessionalLand' => 13);
     $subcategories = array('Dwelling' => array('nl' => 'Huis', 'fr' => 'Maison', 'en' => 'House', 'de' => 'Haus'), 'Flat' => array('nl' => 'Appartement', 'fr' => 'Appartement', 'en' => 'Apartment', 'de' => 'Appartement'), 'Land' => array('nl' => 'Grond', 'fr' => 'Terrain', 'en' => 'Land', 'de' => 'Boden'), 'ServiceFlat' => array('nl' => 'Serviceflat', 'fr' => 'Service flat', 'en' => 'Service flat', 'de' => 'Serviceflat'), 'Room' => array('nl' => 'Kamer', 'fr' => 'Chambre', 'en' => 'Room', 'de' => 'Zimmer'), 'Parking' => array('nl' => 'Parking', 'fr' => 'Parking', 'en' => 'Parking', 'de' => 'Parkplatz'), 'Other' => array('nl' => 'Andere', 'fr' => 'Autre', 'en' => 'Other', 'de' => 'Andere'), 'Catering' => array('nl' => 'Horeca', 'fr' => 'Horeca', 'en' => 'Catering', 'de' => 'Gaststättengewerbe'), 'Industry' => array('nl' => 'Bedrijfsterrein', 'fr' => 'Surface industriel', 'en' => 'Industrial property', 'de' => 'Betriebsterrain'), 'Office' => array('nl' => 'Kantoor', 'fr' => 'Bureau', 'en' => 'Office', 'de' => 'Büro'), 'Shop' => array('nl' => 'Winkel', 'fr' => 'Magasin', 'en' => 'Shop', 'de' => 'Laden'), 'ProfessionalOther' => array('nl' => 'Professioneel pand', 'fr' => 'Bien professionel', 'en' => 'Professional property', 'de' => 'Professionelle Immobilien'), 'ProfessionalLand' => array('nl' => 'Grond', 'fr' => 'Terrain', 'en' => 'Land', 'de' => 'Boden'), 'ArchitectDwelling' => array('nl' => 'Architectenwoning', 'fr' => 'Maison architecte', 'en' => 'Architect house', 'de' => 'Architektenwohnung'), 'Bastide' => array('nl' => 'Bastide', 'fr' => 'Bastide', 'en' => 'Bastide', 'de' => 'Bastide'), 'Bungalow' => array('nl' => 'Bungalow', 'fr' => 'Plain-pied', 'en' => 'Bungalow', 'de' => 'Bungalow'), 'CanalHouse' => array('nl' => 'Grachtenpand', 'fr' => 'Canal maison', 'en' => 'Canal house', 'de' => 'Grachtenhaus'), 'Castle' => array('nl' => 'Kasteel', 'fr' => 'Château', 'en' => 'Castle', 'de' => 'Schloss'), 'Chalet' => array('nl' => 'Chalet', 'fr' => 'Chalet', 'en' => 'Chalet', 'de' => 'Chalet'), 'CityDwelling' => array('nl' => 'Stadswoning', 'fr' => 'Maison de ville', 'en' => 'City house', 'de' => 'Stadtswohnung'), 'CourtyardHouse' => array('nl' => 'Hofjeswoning', 'fr' => 'Maison avec cour', 'en' => 'Courtyard house', 'de' => 'Hofhaus'), 'Cottage' => array('nl' => 'Landhuis', 'fr' => 'Maison de campagne', 'en' => 'Cottage', 'de' => 'Landhaus'), 'Domain' => array('nl' => 'Landgoed', 'fr' => 'Domaine', 'en' => 'Domain', 'de' => 'Domäne'), 'DriveInHouse' => array('nl' => 'Drive-inwoning', 'fr' => 'Bel-étage', 'en' => 'Drive-in house', 'de' => 'Drive-in-Haus'), 'DykeHouse' => array('nl' => 'Dijkwoning', 'fr' => 'Maison sur digue', 'en' => 'Dyke house', 'de' => 'Dyke Haus'), 'ExclusiveVilla' => array('nl' => 'Exclusieve villa', 'fr' => 'Villa exclusive', 'en' => 'Exclusive villa', 'de' => 'exklusive villa'), 'Farm' => array('nl' => 'Boerderij', 'fr' => 'Ferme', 'en' => 'Farm', 'de' => 'Bauernhof'), 'Farmhouse' => array('nl' => 'Fermette', 'fr' => 'Fermette', 'en' => 'Farmhouse', 'de' => 'Fermette'), 'FishermanDwelling' => array('nl' => 'Vissershuis', 'fr' => 'Maison de pêcheur', 'en' => 'Fisherman house', 'de' => 'Fischershaus'), 'GroundfloorBasementHouse' => array('nl' => 'Bel-étage', 'fr' => 'Bel-étage', 'en' => 'Bel-étage', 'de' => 'Bel-étage'), 'HotelDwelling' => array('nl' => 'Stadspaleis', 'fr' => 'Hôtel particulier', 'en' => 'Townhouse', 'de' => 'Reihenhaus'), 'LordHouse' => array('nl' => 'Herenhuis', 'fr' => 'Maison de maître', 'en' => 'Manor', 'de' => 'Herrschafliches Haus'), 'Mansion' => array('nl' => 'Landhuis', 'fr' => 'Manoir', 'en' => 'Mansion', 'de' => 'Landhaus'), 'Mas' => array('nl' => 'Herenboerderij', 'fr' => 'Mas', 'en' => 'Farmhouse', 'de' => 'Bauernhaus'), 'PatioBungalow' => array('nl' => 'Patiowoning', 'fr' => 'Maison patio', 'en' => 'Patio house', 'de' => 'Patio Haus'), 'PileDwelling' => array('nl' => 'Paalwoning', 'fr' => 'Maison palafittique', 'en' => 'Stilt house', 'de' => 'Stelzenhaus'), 'Presbytery' => array('nl' => 'Pastorie', 'fr' => 'Presbytère', 'en' => 'Presbytery', 'de' => 'Pfarrhaus'), 'SemiBungalow' => array('nl' => 'Semi-bungalow', 'fr' => 'Semi-bungalow', 'en' => 'Semi-bungalow', 'de' => 'Halbbungalow'), 'SingleFamilyDwelling' => array('nl' => 'Eengezinswoning', 'fr' => 'Maison unifamiliale', 'en' => 'Single family house', 'de' => 'Einfamilienhaus'), 'SmallDwelling' => array('nl' => 'Maisonnette', 'fr' => 'Maisonnette', 'en' => 'Small house', 'de' => 'kleines haus'), 'SplitLevelHouse' => array('nl' => 'Split-level woning', 'fr' => 'Maison à paliers multiples', 'en' => 'Split-level house', 'de' => 'Split-Level-Haus'), 'StandingDwelling' => array('nl' => 'Prestigewoning', 'fr' => 'Propriété de prestige', 'en' => 'Luxury house', 'de' => 'Luxus-Haus'), 'TownDwelling' => array('nl' => 'Dorpshuis', 'fr' => 'Maison de village', 'en' => 'Townhouse', 'de' => 'Reihenhaus'), 'Villa' => array('nl' => 'Villa', 'fr' => 'Villa', 'en' => 'Villa', 'de' => 'Villa'), 'WaterDwelling' => array('nl' => 'Waterwoning', 'fr' => 'Maison flottante', 'en' => 'Water dwelling', 'de' => 'Wasser-Wohnung'), 'BasementFlat' => array('nl' => 'Kelder appartement', 'fr' => 'Souterrain', 'en' => 'Basement flat', 'de' => 'Souterrainwohnung'), 'Duplex' => array('nl' => 'Duplex', 'fr' => 'Duplex', 'en' => 'Duplex', 'de' => 'Duplex'), 'GroundfloorFlat' => array('nl' => 'Gelijkvloers appartement', 'fr' => 'Rez de chaussée', 'en' => 'Ground floor flat', 'de' => 'Erdgeschoss-Wohnung'), 'GroundfloorBasementFlat' => array('nl' => 'Bel-étage flat', 'fr' => 'Appartement bel-étage', 'en' => 'Ground floor flat', 'de' => 'Erdgeschoss-Wohnung'), 'IndependentRoom' => array('nl' => 'Aparte kamer', 'fr' => 'Chambre de bonne', 'en' => 'Separate room', 'de' => 'Separates Zimmer'), 'Loft' => array('nl' => 'Loft', 'fr' => 'Loft', 'en' => 'Loft', 'de' => 'Loft'), 'Maisonette' => array('nl' => 'Maisonnette', 'fr' => 'Maisonnette', 'en' => 'Maisonnette', 'de' => 'Maisonnette'), 'Penthouse' => array('nl' => 'Penthouse', 'fr' => 'Penthouse', 'en' => 'Penthouse', 'de' => 'Penthouse'), 'RoofAppartement' => array('nl' => 'Dakappartement', 'fr' => 'Mansarde', 'en' => 'Roof apartment', 'de' => 'Dach Appartement'), 'Studio' => array('nl' => 'Studio', 'fr' => 'Studio', 'en' => 'Studio', 'de' => 'Studio'), 'Triplex' => array('nl' => 'Triplex', 'fr' => 'Triplex', 'en' => 'Triplex', 'de' => 'Triplex'), 'UpstairsDwelling' => array('nl' => 'Bovenwoning', 'fr' => 'Habitation à l\'étage', 'en' => 'Upstairs home', 'de' => 'Upstairs Hause'), 'StudentRoom' => array('nl' => 'Studentenkamer', 'fr' => 'Chambre d\'étudiant', 'en' => 'Student room', 'de' => 'Studentenzimmer'), 'Carport' => array('nl' => 'Carport', 'fr' => 'Carport', 'en' => 'Carport', 'de' => 'Carport'), 'Garage' => array('nl' => 'Garage', 'fr' => 'Garage', 'en' => 'Garage', 'de' => 'Garage'), 'GarageBox' => array('nl' => 'Garagebox', 'fr' => 'Garage box', 'en' => 'Garage box', 'de' => 'Garage box'), 'ParkingCellar' => array('nl' => 'Parkeerkelder', 'fr' => 'Parking sous-sol', 'en' => 'Parking cellar', 'de' => 'Parkkeller'), 'ParkingLot' => array('nl' => 'Parkeerterrein', 'fr' => 'Terrain de parking', 'en' => 'Parking lot', 'de' => 'Parkterrain'), 'ParkingPlace' => array('nl' => 'Parkeerplaats', 'fr' => 'Parking', 'en' => 'Parking spot', 'de' => 'Parkplatz'), 'Barn' => array('nl' => 'Schuur', 'fr' => 'Grange', 'en' => 'Barn', 'de' => 'Scheune'), 'Caravan' => array('nl' => 'Caravan', 'fr' => 'Caravane', 'en' => 'Caravan', 'de' => 'Karawane'), 'Forest' => array('nl' => 'Bos', 'fr' => 'Forêt', 'en' => 'Forest', 'de' => 'Wald'), 'HolidayHouse' => array('nl' => 'Vakantiewoning', 'fr' => 'Gîte', 'en' => 'Holiday house', 'de' => 'Ferienwohnung'), 'HouseBoat' => array('nl' => 'Woonboot', 'fr' => 'Péniche', 'en' => 'Houseboat', 'de' => 'Wohnbot'), 'PastureLand' => array('nl' => 'Weide', 'fr' => 'Pâturage', 'en' => 'Pasture', 'de' => 'Wiese'), 'Pavillion' => array('nl' => 'Clubhuis', 'fr' => 'Pavillion', 'en' => 'Pavillion', 'de' => 'Clubhaus'), 'RecreationGround' => array('nl' => 'Recreatiegrond', 'fr' => 'Parcelle de récréation', 'en' => 'Recreational land', 'de' => 'Freizeit-Land'), 'WatermillHouse' => array('nl' => 'Watermolen', 'fr' => 'Moulin à eau', 'en' => 'Watermill', 'de' => 'Wassermühle'), 'WindmillHouse' => array('nl' => 'Windmomen', 'fr' => 'Moulin à vent', 'en' => 'Windmill', 'de' => 'Windmühle'), 'Bar' => array('nl' => 'Bar', 'fr' => 'Bar', 'en' => 'Bar', 'de' => 'Bar'), 'Cafe' => array('nl' => 'Café', 'fr' => 'Café', 'en' => 'Café', 'de' => 'Wirtschaft'), 'Disco' => array('nl' => 'Discotheek', 'fr' => 'Discothèque', 'en' => 'Disco', 'de' => 'Diskothek'), 'Hotel' => array('nl' => 'Hotel', 'fr' => 'Hôtel', 'en' => 'Hotel', 'de' => 'Hotel'), 'MotorwayRestaurant' => array('nl' => 'Wegrestaurant', 'fr' => 'Relais routier', 'en' => 'Roadside diner', 'de' => 'Raststätte'), 'PartyHall' => array('nl' => 'Feestzaal', 'fr' => 'Salle communalle', 'en' => 'Banquet hall', 'de' => 'Festzentrum'), 'Restaurant' => array('nl' => 'Restaurant', 'fr' => 'Restaurant', 'en' => 'Restaurant', 'de' => 'Restaurant'), 'TeaRoom' => array('nl' => 'Eetcafé', 'fr' => 'Tea-room', 'en' => 'Tearoom', 'de' => 'Esswirtschaft'), 'Services' => array('nl' => 'Servicekantoor', 'fr' => 'Bureau de service', 'en' => 'Service office', 'de' => 'Service Büro'), 'Hangar' => array('nl' => 'Hangar', 'fr' => 'Hangar', 'en' => 'Hangar', 'de' => 'Hangar'), 'Warehouse' => array('nl' => 'Opslagruimte', 'fr' => 'Entrepôt', 'en' => 'Warehouse', 'de' => 'Lagerraum'), 'Workshop' => array('nl' => 'Atelier', 'fr' => 'Atelier', 'en' => 'Atelier', 'de' => 'Atelier'), 'Boutique' => array('nl' => 'Boetiek', 'fr' => 'Boutique', 'en' => 'Boutique', 'de' => 'Boutique'), 'Showroom' => array('nl' => 'Showroom', 'fr' => 'Showroom', 'en' => 'Showroom', 'de' => 'Showroom'), 'Practice' => array('nl' => 'Praktijk', 'fr' => 'Cabinet', 'en' => 'Practice', 'de' => 'Praxis'), 'Agricultural' => array('nl' => 'Landbouwgrond', 'fr' => 'Terrain agricole', 'en' => 'Farmland', 'de' => 'Ackerland'), 'ArableLand' => array('nl' => 'Akker', 'fr' => 'Champ', 'en' => 'Field', 'de' => 'Acker'), 'Orchard' => array('nl' => 'Boomgaard', 'fr' => 'Verger', 'en' => 'Orchard', 'de' => 'Obstgarten'), 'Shop' => array('nl' => 'Winkel', 'fr' => 'Magasin', 'en' => 'Shop', 'de' => 'Laden'), 'Vineyard' => array('nl' => 'Wijngaard', 'fr' => 'Vignoble', 'en' => 'Vineyard', 'de' => 'Weingarten'));
     $subcategory_ids = array_flip(array_merge(array(''), array_keys($subcategories)));
     $styles = array('Dwelling_Corner' => array('nl' => 'Hoekwoning', 'fr' => 'Maison de coin', 'en' => 'Corner house', 'de' => 'Eckwohnung'), 'Dwelling_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Individuelle', 'en' => 'Detached', 'de' => 'Alleinstehend'), 'Dwelling_Linked' => array('nl' => 'Rijhuis', 'fr' => 'Maison de ville', 'en' => 'Linked', 'de' => 'Reihenhaus'), 'Dwelling_Quadrant' => array('nl' => 'Kwadrantwoning', 'fr' => 'Maison quadrant', 'en' => 'Quadrant house', 'de' => 'Quadrant Haus'), 'Dwelling_SemiDetached' => array('nl' => 'Half-open bebouwing', 'fr' => 'Trois façades', 'en' => 'Semi-detached', 'de' => 'Quadrant Haus'), 'Dwelling_Terraced' => array('nl' => 'Rijwoning', 'fr' => 'Deux façades', 'en' => 'Terraced', 'de' => 'Rijwoning'), 'Flat_Corridor' => array('nl' => 'Corridorflat', 'fr' => 'Corridor plat', 'en' => 'Corridor flat', 'de' => 'Corridor Wohnung'), 'Flat_Gallery' => array('nl' => 'Galerij', 'fr' => 'Galerie', 'en' => 'Gallery', 'de' => 'Galerie'), 'Flat_Highrise' => array('nl' => 'Hoogbouw', 'fr' => 'Grande hauteur', 'en' => 'Highrise', 'de' => 'Hochbau'), 'Flat_Porch' => array('nl' => 'Portiekflat', 'fr' => 'Porche', 'en' => 'Porch', 'de' => 'Trobogen Appartement'), 'Flat_Condominium' => array('nl' => 'Condominium', 'fr' => 'Copropriété', 'en' => 'Condo', 'de' => 'Condominium'), 'Flat_Villa' => array('nl' => 'Villa-appartement', 'fr' => 'Dans une villa', 'en' => 'In a villa', 'de' => 'Villa-Appartement'), 'Flat_Townhouse' => array('nl' => 'In stadswoning', 'fr' => 'Dans une maison de village', 'en' => 'In a townhouse', 'de' => 'In stadtwohung'), 'Flat_Haussmann' => array('fr' => 'Haussmannien', 'en' => 'Haussmannian', 'de' => 'Haussmann'), 'Land_Corner' => array('nl' => 'Hoekpand', 'fr' => 'Sur un angle', 'en' => 'At a corner', 'de' => 'Eckwohnung'), 'Land_Detached' => array('nl' => 'Open bebouwing', 'fr' => 'Quatre façades', 'en' => 'Detached construction', 'de' => 'Offene Bebauung'), 'Land_Linked' => array('nl' => 'Gesloten bebouwing', 'fr' => 'Deux façades', 'en' => 'Linked construction', 'de' => 'Verlinkte Bau'), 'Land_SemiDetached' => array('nl' => 'Half-open bebouwing', 'fr' => 'Trois façades', 'en' => 'Semi-detached construction', 'de' => 'Quadrant Haus'), 'Land_Terraced' => array('nl' => 'Gesloten bebouwing', 'fr' => 'Deux façades', 'en' => 'Terraced construction', 'de' => 'Reihen Bau'), 'ServiceFlat_Corridor' => array('nl' => 'Corridorflat', 'fr' => 'Corridor plat', 'en' => 'Corridor flat', 'de' => 'Corridor Wohnung'), 'ServiceFlat_Gallery' => array('nl' => 'Galerij', 'fr' => 'Galerie', 'en' => 'Gallery', 'de' => 'Galerie'), 'ServiceFlat_Porch' => array('nl' => 'Portiekflat', 'fr' => 'Porche', 'en' => 'Porch', 'de' => 'Trobogen Appartement'), 'ServiceFlat_Condominium' => array('nl' => 'Condominium', 'fr' => 'Copropriété', 'en' => 'Condo', 'de' => 'Condominium'), 'ServiceFlat_Villa' => array('nl' => 'Villa-appartement', 'fr' => 'Dans une villa', 'en' => 'In a villa', 'de' => 'Villa-Appartement'), 'ServiceFlat_Townhouse' => array('nl' => 'In stadswoning', 'fr' => 'Dans une maison de village', 'en' => 'In a townhouse', 'de' => 'In stadtwohung'), 'ServiceFlat_Haussmann' => array('fr' => 'Haussmannien', 'en' => 'Haussmannian', 'de' => 'Haussmann'), 'Room_InComplex' => array('nl' => 'In complex', 'fr' => 'Dans un complexe', 'en' => 'In a complex', 'de' => 'In einem komplexen'), 'Room_InDwelling' => array('nl' => 'In een huis', 'fr' => 'Dans un maison', 'en' => 'In a house', 'de' => 'In einem Haus'), 'Room_InFlat' => array('nl' => 'In appartement', 'fr' => 'Dans une appartement', 'en' => 'In an apartment', 'de' => ''), 'Room_Townhouse' => array('nl' => 'In stadswoning', 'fr' => 'Dans une maison de village', 'en' => 'In a townhoue', 'de' => 'Ist in einer Wohnung'), 'Parking_Annex' => array('nl' => 'Aangebouwd', 'fr' => 'Attaché', 'en' => 'Attached', 'de' => 'Befestigt'), 'Parking_Inbuilt' => array('nl' => 'Inpandig', 'fr' => 'Intégré', 'en' => 'Inbuilt', 'de' => 'Integriert'), 'Parking_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Détaché', 'en' => 'Detached', 'de' => 'Freistehend'), 'Other_Corner' => array('nl' => 'Hoekpand', 'fr' => 'Sur un angle', 'en' => 'Corner property', 'de' => 'Eckwohnung'), 'Other_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Détaché', 'en' => 'Detached', 'de' => 'Alleinstehend'), 'Other_Linked' => array('nl' => 'Geschakeld', 'fr' => 'Deux façades', 'en' => 'Linked', 'de' => 'Verlinkte Bau'), 'Other_Quadrant' => array('nl' => 'Kwadrantpand', 'fr' => 'Bien quadrant', 'en' => 'Quadrant property', 'de' => 'Kwadrantpand'), 'Other_SemiDetached' => array('nl' => 'Half-open bebouwing', 'fr' => 'Trois façades', 'en' => 'Semi-detached', 'de' => 'Quadrant Haus'), 'Other_Terraced' => array('nl' => 'Gesloten bebouwing', 'fr' => 'Deux façades', 'en' => 'Terraced', 'de' => 'Verlinkte Bau'), 'Catering_Corner' => array('nl' => 'Op hoek', 'fr' => 'Sur un angle', 'en' => 'At a corner', 'de' => 'An der Ecke'), 'Catering_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Individuelle', 'en' => 'Detached', 'de' => 'Alleinstehend'), 'Catering_Linked' => array('nl' => 'Schakel', 'fr' => 'Deux façades', 'en' => 'Linked', 'de' => 'Link'), 'Catering_Quadrant' => array('nl' => 'Kwadrant', 'fr' => 'Quadrant', 'en' => 'Quadrant', 'de' => 'Quadrant'), 'Catering_SemiDetached' => array('nl' => 'Half-open bebouwing', 'fr' => 'Trois façades', 'en' => 'Semi-detached', 'de' => 'Quadrant Haus'), 'Catering_Terraced' => array('nl' => 'Gesloten bebouwing', 'fr' => 'Deux façades', 'en' => 'Terraced', 'de' => 'Verlinkte Bau'), 'Catering_InShoppingCenter' => array('nl' => 'Shopping center', 'fr' => 'Centre commercial', 'en' => 'Shopping center', 'de' => 'Shopping Zentrum'), 'Office_InOfficeBuilding' => array('nl' => 'Kantoorgebouw', 'fr' => 'Immeuble de bureaux', 'en' => 'Office building', 'de' => 'Geschäftsgebäude'), 'Office_InShoppingCenter' => array('nl' => 'Shopping center', 'fr' => 'Centre commercial', 'en' => 'Shopping center', 'de' => 'Shopping Zentrum'), 'Industry_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Individuelle', 'en' => 'Detached', 'de' => 'Alleinstehend'), 'Shop_Corner' => array('nl' => 'Op hoek', 'fr' => 'Sur un angle', 'en' => 'At a corner', 'de' => 'An der Ecke'), 'Shop_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Individuelle', 'en' => 'Detached', 'de' => 'Alleinstehend'), 'Shop_Linked' => array('nl' => 'Schakel', 'fr' => 'Deux façades', 'en' => 'Linked', 'de' => 'Link'), 'Shop_Quadrant' => array('nl' => 'Kwadrant', 'fr' => 'Quadrant', 'en' => 'Quadrant', 'de' => 'Quadrant'), 'Shop_SemiDetached' => array('nl' => 'Half-open bebouwing', 'fr' => 'Trois façades', 'en' => 'Semi-detached', 'de' => 'Quadrant Haus'), 'Shop_Terraced' => array('nl' => 'Gesloten bebouwing', 'fr' => 'Deux façades', 'en' => 'Terraced', 'de' => 'Verlinkte Bau'), 'Shop_InShoppingCenter' => array('nl' => 'Shopping center', 'fr' => 'Centre commercial', 'en' => 'Shopping center', 'de' => 'Shopping Zentrum'), 'ProfessionalOther_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Individuelle', 'en' => 'Detached', 'de' => 'Alleinstehend'), 'ProfessionalLand_Corner' => array('nl' => 'Op hoek', 'fr' => 'Sur un angle', 'en' => 'At a corner', 'de' => 'An der Ecke'), 'ProfessionalLand_Detached' => array('nl' => 'Vrijstaand', 'fr' => 'Individuelle', 'en' => 'Detached', 'de' => 'Alleinstehend'), 'ProfessionalLand_Linked' => array('nl' => 'Schakel', 'fr' => 'Deux façades', 'en' => 'Linked', 'de' => 'Link'), 'ProfessionalLand_Quadrant' => array('nl' => 'Kwadrant', 'fr' => 'Quadrant', 'en' => 'Quadrant', 'de' => 'Quadrant'), 'ProfessionalLand_SemiDetached' => array('nl' => 'Half-open bebouwing', 'fr' => 'Trois façades', 'en' => 'Semi-detached', 'de' => 'Quadrant Haus'), 'ProfessionalLand_Terraced' => array('nl' => 'Gesloten bebouwing', 'fr' => 'Deux façades', 'en' => 'Terraced', 'de' => 'Verlinkte Bau'), 'ProfessionalLand_InShoppingCenter' => array('nl' => 'Shopping center', 'fr' => 'Centre commercial', 'en' => 'Shopping center', 'de' => 'Shopping Zentrum'));
     $purposes = array('FOR_RENT' => 2, 'FOR_RENT_ORDER_ENDED' => 2, 'FOR_SALE' => 1, 'FOR_SALE_ORDER_ENDED' => 1, 'IN_MANAGEMENT' => 3, 'OPTION_FOR_RENT' => 2, 'OPTION_FOR_SALE' => 1, 'PRICING' => 3, 'PROSPECT_FOR_RENT' => 2, 'PROSPECT_FOR_SALE' => 1, 'RENTED' => 2, 'SOLD' => 1);
     $purpose_statuses = array('FOR_RENT' => 1, 'FOR_RENT_ORDER_ENDED' => 1, 'FOR_SALE' => 1, 'FOR_SALE_ORDER_ENDED' => 1, 'IN_MANAGEMENT' => 5, 'OPTION_FOR_RENT' => 3, 'OPTION_FOR_SALE' => 3, 'PRICING' => 5, 'PROSPECT_FOR_RENT' => 4, 'PROSPECT_FOR_SALE' => 4, 'RENTED' => 2, 'SOLD' => 2);
     $rent_types = array('CIVAL' => 1, 'COMMERCIAL' => 2, 'HABITATION' => 3, 'MAINRESIDENCE' => 4, 'PROFESSIONAL' => 5);
     $rent_times = array('LIFETIME' => 6, 'NINE_YEARS' => 5, 'ONE_YEAR' => 1, 'RENOVATION' => 7, 'SIX_YEARS' => 4, 'THREE_YEARS' => 3, 'TWO_YEARS' => 2);
     $payment_periods = array('MONTHLY' => 1, 'TRIMESTRIAL' => 2);
     $payment_types = array('AT_END_OF_PERIOD' => 1, 'IN_ADVANCE' => 2);
     $availabilities = array('BY_DATE' => 4, 'BY_DEED' => 2, 'IMMEDIATELY' => 1, 'IN_CONSULTATION' => 3);
     $price_types = array('M2_PER_MONTH' => 5, 'M2_PER_YEAR' => 6, 'PER_M2' => 4, 'PRICE_PER_MONTH' => 2, 'PRICE_PER_YEAR' => 3, 'TOTAL' => 1);
     $price_indications = array('ASKING_PRICE' => 1, 'BUY_PRICE' => 2, 'NEGOTIABLE' => 3, 'ON_REQUEST' => 4);
     $shop_locations = array('OTHER' => 4, 'SHOPPING_CENTRE' => 1, 'SHOPPING_GALLERY' => 2, 'SHOPPING_STREET' => 3);
     $states = array('LUXURY_FINISH' => 6, 'NORMAL' => 1, 'READY_FOR_ENTRY' => 5, 'TO_BE_DEMOLISHED' => 2, 'TO_REFURBISH' => 3, 'TO_RENOVATE' => 4);
     $garden_qualities = array('CONSTRUCTED' => 4, 'MAINTAINED' => 2, 'NEGLECTED' => 3, 'NICELY_CONSTRUCTED' => 5, 'NORMAL' => 1, 'TO_CONSTRUCT' => 6);
     $roof_types = array('COMPOSITE_ROOF' => 1, 'CROSS_GABLE_ROOF' => 2, 'DOME_ROOF' => 3, 'FLAT_CONCRETE_ROOF' => 4, 'FLAT_FELT_ROOF' => 5, 'FLAT_ROOF' => 6, 'FLAT_WOODEN_ROOF' => 7, 'LEAN_TO_ROOF' => 8, 'MANSARD_ROOF' => 9, 'PITCHED_ROOF' => 10, 'SHIELD_ROOF' => 11, 'TENT_ROOF' => 12);
     $evaluations = array('BAD' => 1, 'GOOD' => 3, 'MEDIOCRE' => 2, 'VERY_GOOD' => 4);
     $roof_covers = array('CONCRETE' => 1, 'IN_TERRACE' => 2, 'INDUSTRIAL_TILES' => 3, 'OTHER' => 4, 'SHEETING' => 5, 'SLATE' => 6, 'STUBBLE' => 7, 'TILES' => 8, 'TILES_TERRA_COTTA' => 9, 'ZINC' => 10);
     $window_types = array('ALUMINIUM' => 1, 'PVC' => 2, 'WOOD' => 3, 'OTHER' => 4);
     $glazing_types = array('DOUBLE' => 1, 'PARTLY_DOUBLE' => 2, 'SINGLE' => 3, 'BAY' => 4, 'OTHER' => 5);
     $heating_types = array('COLLECTIVE_HEATING' => 1, 'INDIVIDUAL' => 2, 'COLLECTIVE' => 1);
     $heating_sources = array('AIRCO' => 1, 'BOILER_OWN' => 2, 'BOILER_RENT' => 3, 'CENTRAL_FACILITIES' => 4, 'CENTRALLY_HEATED' => 4, 'COALS' => 5, 'COMBI_BOILER' => 6, 'CONDENSING_BOILER' => 7, 'DISTRICT_HEATING' => 8, 'ELECTRICAL_BOILER_OWN' => 9, 'ELECTRICAL_BOILER_RENT' => 10, 'ELECTRICITY' => 11, 'FIRE_PLACE' => 12, 'FIRE_PLACE_POSSIBLE' => 13, 'FLOOR_HEATING_FULLY' => 14, 'FLOOR_HEATING_PARTIAL' => 15, 'GAS_FIREPLACE' => 16, 'GAS_STOVE' => 17, 'GEOTHERMAL' => 18, 'GEYSER_OWN' => 19, 'GEYSER_RENT' => 20, 'HEATING_OIL' => 21, 'HEATING_PUMP' => 22, 'HOT_AIR_HEATING' => 23, 'HP_BOILER' => 24, 'NATURAL_GAS' => 25, 'NONE' => 29, 'OTHER' => 28, 'PARENT_HEARTH' => 12, 'SOLAR_COLLECTORS' => 26, 'WINDMILL' => 27);
     $water_heating_sources = array('ELECTRICITY' => 1, 'GAS' => 2, 'GASOIL' => 3, 'SOLAR_COLLECTORS' => 4);
     $plumbing_types = array('BOILER_OWN' => 1, 'BOILER_RENT' => 2, 'CENTRAL_FACILITIES' => 3, 'CENTRALLY_HEATED' => 3, 'ELECTRICAL_BOILER_OWN' => 4, 'ELECTRICAL_BOILER_RENT' => 5, 'ELECTRICITY' => 6, 'GEYSER_OWN' => 7, 'GEYSER_RENT' => 8, 'HEATING_OIL' => 9, 'NATURAL_GAS' => 10, 'NONE' => 14, 'OTHER' => 13, 'SOLAR_COLLECTORS' => 12, 'SOLAR_BOILER' => 11);
     $common_walls = array('ONE_WALL' => 1, 'TWO_WALLS' => 2, 'THREE_WALLS' => 3);
     $orientations = array('EAST' => 1, 'NORTH' => 7, 'NORTH_EAST' => 8, 'NORTH_WEST' => 6, 'SOUTH' => 3, 'SOUTH_EAST' => 2, 'SOUTH_WEST' => 4, 'WEST' => 5);
     $maintenance = array('BAD' => 1, 'EXCELLENT' => 4, 'GOOD' => 3, 'MEDIOCRE' => 2, 'MODERATE' => 2);
     $construction_types = array('BREEZE_BLOCK' => 1, 'BRICK' => 2, 'CONCRETE' => 3, 'GRINDING' => 4, 'HONE_OF_SIZE' => 5, 'OTHER' => 10, 'PREFAB_FRAME' => 6, 'STONE' => 7, 'TRADITIONAL_FRAME' => 8, 'WOOD' => 9, 'WOOD_FRAME' => 10);
     $frontage_types = array('BRICK' => 1, 'COATING' => 2, 'COB' => 3, 'GRINDING' => 4, 'HALF_TIMBERING' => 5, 'HONE_OF_SIZE' => 6, 'WOOD' => 7);
     $living_types = array('GARDEN_ROOM' => 5, 'L_ROOM' => 1, 'SERRE' => 6, 'SUN_ROOM' => 7, 'T_ROOM' => 2, 'U_ROOM' => 3, 'Z_ROOM' => 4);
     $garage_types = array('BASEMENT' => 1, 'CARPORT' => 2, 'ELEVATOR_ACCESS' => 3, 'GARAGE_POSSIBLE' => 4, 'GARAGEBOX' => 5, 'GROUND_FLOOR' => 6, 'INBUILT' => 7, 'INSIDE' => 8, 'OUTSIDE' => 9, 'PARKING_CELLAR' => 1, 'PARKING_PLACE' => 10, 'SOUTTERAIN' => 11, 'STONE_DETACHED' => 12, 'STONE_OUTBUILDED' => 15, 'WOOD_DETACHED' => 13, 'WOOD_OUTBUILDED' => 14);
     $profession_room_types = array('ATTACHED' => 1, 'DETACHED' => 2, 'INBUILT' => 3, 'POSSIBLE' => 4);
     $office_types = array('ATTACHED' => 1, 'DETACHED' => 2, 'INBUILT' => 3, 'POSSIBLE' => 4);
     $storage_types = array('BOX' => 1, 'DETACHED_STONE' => 2, 'DETACHED_WOOD' => 3, 'INSIDE' => 4, 'MOUNTED_STONE' => 5, 'MOUNTED_WOOD' => 6, 'PATIO_BUNGALOW' => 7, 'SEMI_BUNGALOW' => 8);
     $kitchen_types = array('AMERICAN_KITCHEN' => 1, 'BUILD_WITH_APPLIANCES' => 2, 'CLOSED_KITCHEN' => 3, 'KITCHENETTE' => 4, 'LARGE_KITCHEN' => 5, 'OPEN_KITCHEN' => 6, 'SEMI_OPEN_KITCHEN' => 7);
     $cellar_types = array('BASEMENT' => 1, 'CRAWL_SPACE' => 2, 'FULL_GROUND' => 3);
     $isolation_types = array('FLOOR_ISOLATION' => 1, 'FULLY_ISOLATED' => 2, 'GREEN_CONSTRUCTION' => 3, 'NO_CAVITY' => 4, 'NO_ISOLATION' => 5, 'ROOF_ISOLATION' => 6, 'WALL_ISOLATION' => 7);
     $easements = array('PASSAGE' => 1, 'PRESENT' => 6, 'RIGHT_OF_EXIT' => 2, 'RIGHT_OF_WAY' => 3, 'ROAD_PLANNING' => 5, 'SIGHT' => 4);
     $environmental_planning_types = array('APPLIED_FOR' => 2, 'BEING_PROCESSED' => 3, 'OK' => 1);
     $land_use_designations = array('Ag' => 1, 'Bg' => 2, 'Gdr' => 3, 'Gvr' => 4, 'Iab' => 5, 'Igb' => 6, 'Lwag' => 7, 'Ng' => 8, 'Nr' => 9, 'OTHER' => 10, 'Pg' => 11, 'Wche' => 12, 'Wg' => 13, 'Wglk' => 14, 'Wp' => 15, 'Wug' => 16);
     $picture_types = array('EXTERIEUR' => 1, 'GARDEN' => 2, 'INTERIEUR' => 3, 'MAP_DOWNSTAIRS' => 4, 'MAP_OVERALL' => 5, 'MAP_UPSTAIRS' => 6);
     $floor_types = array('LEVEL_ATTIC' => 1, 'LEVEL_BASEMENT' => 2, 'LEVEL_FLOOR' => 3, 'LEVEL_GROUNDFLOOR_FLAT' => 4, 'LEVEL_VLIERING' => 5);
     $certificate_fields = array('AS_BUILT' => 'as_built_certificate_date', 'DIAGNOSTICS_ELECTRICITY' => 'diagnostics_certificate_date', 'ELECTRICITY_CERTIFICATE' => 'electricity_certificate_date', 'ENERGY_CONSUMPTION' => 'energy_consumption_certificate_date', 'ENERGY_PERFORMANCE' => 'energy_performance_certificate_date', 'GAS' => 'gas_certificate_date', 'GAZ' => 'gas_certificate_date', 'GROUNDPOLUTION' => 'polution_certificate_date', 'HOUSE_ADAPTED_TO_DISABLED_HALLMARK' => 'accessibility_certificate_date', 'LEAD' => 'lead_certificate_date', 'NATURAL_RISK' => 'nature_risk_certificate_date', 'NATURE_RISK' => 'nature_risk_certificate_date', 'OIL_TANK' => 'oil_tank_certificate_date', 'PLANNING_CERT' => 'planning_certificate_date', 'PRIVATE_AREA' => 'private_area_certificate_date', 'SMOKE_DETECTION' => 'smoke_detection_certificate_date', 'SOIL_CERT' => 'soil_certificate_date');
     $publication_summaries = $client->GetPublicationSummaries();
     if (isset($publication_summaries->GetPublicationSummariesResult->PublicationSummaries->PublicationSummary)) {
         $present_properties = array();
         $feedbacks = array();
         foreach ($publication_summaries->GetPublicationSummariesResult->PublicationSummaries->PublicationSummary as $summary) {
             $publication = $client->GetPublication(array('PublicationId' => $summary->ID));
             if (isset($publication->GetPublicationResult->Publication)) {
                 $publication = $publication->GetPublicationResult->Publication;
                 $flashes = array();
                 if (isset($publication->Property->AllFlashes->Flash)) {
                     if (!is_array($publication->Property->AllFlashes->Flash)) {
                         $publication->Property->AllFlashes->Flash = array($publication->Property->AllFlashes->Flash);
                     }
                     foreach ($publication->Property->AllFlashes->Flash as $flash) {
                         if (!isset($flashes[substr($flash->ID, -1)])) {
                             $flashes[substr($flash->ID, -1)] = array();
                         }
                         $flashes[substr($flash->ID, -1)][strtolower(substr($flash->LanguageID, -2))] = $flash;
                     }
                 }
                 // Process photos
                 $photos = array();
                 if (isset($publication->Pictures->Picture)) {
                     if (!is_array($publication->Pictures->Picture)) {
                         $publication->Pictures->Picture = array($publication->Pictures->Picture);
                     }
                     foreach ($publication->Pictures->Picture as $picture) {
                         $photos[$picture->Index] = array('orig_filename' => $picture->Name, 'description' => $picture->Description, 'url' => $picture->URL, 'type' => isset($picture_types[$picture->PictureType]) ? $picture_types[$picture->PictureType] : null);
                     }
                 }
                 // Process documents
                 $documents = array();
                 if (isset($publication->Documents->Document)) {
                     if (!is_array($publication->Documents->Document)) {
                         $publication->Documents->Document = array($publication->Documents->Document);
                     }
                     foreach ($publication->Documents->Document as $document) {
                         $documents[] = array('filename' => $document->OriginalName, 'name' => $document->Description, 'url' => $document->URL, 'filetype' => $document->FileType == 'UNDEFINED' ? null : strtolower($document->FileType));
                     }
                 }
                 // Process open house
                 $openhouse = array();
                 if (isset($publication->Property->OpenHouse->FromToDates->FromToDate)) {
                     if (!is_array($publication->Property->OpenHouse->FromToDates->FromToDate)) {
                         $publication->Property->OpenHouse->FromToDates->FromToDate = array($publication->Property->OpenHouse->FromToDates->FromToDate);
                     }
                     foreach ($publication->Property->OpenHouse->FromToDates->FromToDate as $fromtodate) {
                         $from = date_parse_from_format('Y-m-d H:i:s', $fromtodate->From);
                         $to = date_parse_from_format('Y-m-d H:i:s', $fromtodate->To);
                         $openhouse[] = array('comment' => isset($publication->Property->OpenHouse->Comment) ? $publication->Property->OpenHouse->Comment : null, 'from' => mktime($from['hour'], $from['minute'], $from['second'], $from['month'], $from['day'], $from['year']), 'to' => mktime($to['hour'], $to['minute'], $to['second'], $to['month'], $to['day'], $to['year']));
                     }
                 }
                 // Process floors
                 $floors = array();
                 if (isset($publication->Property->Floors->Floor)) {
                     if (!is_array($publication->Property->Floors->Floor)) {
                         $publication->Property->Floors->Floor = array($publication->Property->Floors->Floor);
                     }
                     foreach ($publication->Property->Floors->Floor as $floor) {
                         $newfloor = array('level' => $floor->Level, 'description' => trim($floor->Description), 'rooms' => $floor->NumOfRooms < 0 ? null : $floor->NumOfRooms, 'bedrooms' => $floor->NumOfBedRooms < 0 ? null : $floor->NumOfBedRooms, 'type' => isset($floor_types[$floor->Type]) ? $floor_types[$floor->Type] : null, 'alleyway' => $floor->Alleyway == 'UNDEFINED' ? null : $floor->Alleyway == 'TRUE', 'attic_stair' => $floor->AtticFixStair == 'UNDEFINED' ? null : $floor->AtticFixStair == 'TRUE', 'attic_room_possible' => $floor->AtticRoomPossible == 'UNDEFINED' ? null : $floor->AtticRoomPossible == 'TRUE', 'balcony' => $floor->Balcony == 'UNDEFINED' ? null : $floor->Balcony == 'TRUE', 'dormer' => $floor->Dormer == 'UNDEFINED' ? null : $floor->Dormer == 'TRUE', 'hall' => $floor->Hall == 'UNDEFINED' ? null : $floor->Hall == 'TRUE', 'machine_room' => $floor->MachineRoom == 'UNDEFINED' ? null : $floor->MachineRoom == 'TRUE', 'provision_room' => $floor->ProvisionRoom == 'UNDEFINED' ? null : $floor->ProvisionRoom == 'TRUE', 'roof_terrace' => $floor->RoofTerrace == 'UNDEFINED' ? null : $floor->RoofTerrace == 'TRUE', 'shower' => $floor->Shower == 'UNDEFINED' ? null : $floor->Shower == 'TRUE', 'stair_in_living' => $floor->StairInLivingRoom == 'UNDEFINED' ? null : $floor->StairInLivingRoom == 'TRUE', 'storage' => $floor->Storage == 'UNDEFINED' ? null : $floor->Storage == 'TRUE', 'toilet' => $floor->Toilet == 'UNDEFINED' ? null : $floor->Toilet == 'TRUE', 'utility_room' => $floor->UtilityRoom == 'UNDEFINED' ? null : $floor->UtilityRoom == 'TRUE', 'vestibule' => $floor->Vestibule == 'UNDEFINED' ? null : $floor->Vestibule == 'TRUE', 'kitchen_renewed_year' => $floor->KitchenRenewed <= 0 ? null : $floor->KitchenRenewed, 'kitchen_surface' => $floor->KitchenSurface <= 0 ? null : $floor->KitchenSurface, 'kitchen_equipped' => null, 'living_surface' => $floor->LivingRoomSurface <= 0 ? null : $floor->LivingRoomSurface, 'living_type' => null, 'bathroom1_length' => $floor->Bathroom1Length <= 0 ? null : $floor->Bathroom1Length, 'bathroom1_width' => $floor->Bathroom1Width <= 0 ? null : $floor->Bathroom1Width, 'bathroom1_bath' => false, 'bathroom1_short_bath' => false, 'bathroom1_shower' => false, 'bathroom1_toilet' => false, 'bathroom2_length' => $floor->Bathroom2Length <= 0 ? null : $floor->Bathroom2Length, 'bathroom2_width' => $floor->Bathroom2Width <= 0 ? null : $floor->Bathroom2Width, 'bathroom2_bath' => false, 'bathroom2_short_bath' => false, 'bathroom2_shower' => false, 'bathroom2_toilet' => false);
                         if (isset($floor->KitchenTypes->KitchenType)) {
                             if (!is_array($floor->KitchenTypes->KitchenType)) {
                                 $floor->KitchenTypes->KitchenType = array($floor->KitchenTypes->KitchenType);
                             }
                             foreach ($floor->KitchenTypes->KitchenType as $type) {
                                 if ($type != 'UNDEFINED') {
                                     $newfloor['kitchen_equipped'] = $type == 'BUILD_WITH_APPLIANCES';
                                     break;
                                 }
                             }
                         }
                         if (isset($floor->LivingRoomTypes->LivingRoomType)) {
                             if (!is_array($floor->LivingRoomTypes->LivingRoomType)) {
                                 $floor->LivingRoomTypes->LivingRoomType = array($floor->LivingRoomTypes->LivingRoomType);
                             }
                             foreach ($floor->LivingRoomTypes->LivingRoomType as $type) {
                                 if (isset($living_types[$type])) {
                                     $newfloor['living_type'] = $living_types[$type];
                                     break;
                                 }
                             }
                         }
                         for ($i = 1; $i <= 2; $i++) {
                             $types_field = 'Bathroom' . $i . 'Types';
                             if (isset($floor->{$types_field}->BathRoomType)) {
                                 if (!is_array($floor->{$types_field}->BathRoomType)) {
                                     $floor->{$types_field}->BathRoomType = array($floor->{$types_field}->BathRoomType);
                                 }
                                 foreach ($floor->{$types_field}->BathRoomType as $type) {
                                     if ($type == 'BATHROOM_BATH') {
                                         $newfloor['bathroom' . $i . '_bath'] = true;
                                     } else {
                                         if ($type == 'BATHROOM_HIPBATH') {
                                             $newfloor['bathroom' . $i . '_short_bath'] = true;
                                         } else {
                                             if ($type == 'BATHROOM_SHOWER') {
                                                 $newfloor['bathroom' . $i . '_shower'] = true;
                                             } else {
                                                 if ($type == 'BATHROOM_TOILET') {
                                                     $newfloor['bathroom' . $i . '_toilet'] = true;
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         $floors[$floor->Level] = $newfloor;
                     }
                 }
                 // Process features
                 $features = array();
                 if (isset($publication->Property->MarketingTypes->MarketingType)) {
                     if (!is_array($publication->Property->MarketingTypes->MarketingType)) {
                         $publication->Property->MarketingTypes->MarketingType = array($publication->Property->MarketingTypes->MarketingType);
                     }
                     foreach ($publication->Property->MarketingTypes->MarketingType as $marketing_type) {
                         if (!is_array($marketing_type->Descriptions->Description)) {
                             $marketing_type->Descriptions->Description = array($marketing_type->Descriptions->Description);
                         }
                         foreach ($marketing_type->Descriptions->Description as $marketing_type_description) {
                             if ($marketing_type_description->_ == $marketing_type->Code) {
                                 continue;
                             }
                             $language = strtolower(substr($marketing_type_description->LanguageId, -2));
                             if (!isset($features[$language])) {
                                 $features[$language] = array();
                             }
                             $features[$language][] = capitalize($marketing_type_description->_, false);
                         }
                     }
                 }
                 if (isset($publication->Property->Dimensions->RentableSurface->_)) {
                     $publication->Property->Dimensions->RentableSurface = $publication->Property->Dimensions->RentableSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->CantineSurface->_)) {
                     $publication->Property->Dimensions->CantineSurface = $publication->Property->Dimensions->CantineSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->CateringSurface->_)) {
                     $publication->Property->Dimensions->CateringSurface = $publication->Property->Dimensions->CateringSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->IndustrySurface->_)) {
                     $publication->Property->Dimensions->IndustrySurface = $publication->Property->Dimensions->IndustrySurface->_;
                 }
                 if (isset($publication->Property->Dimensions->IndustryOfficeSurface->_)) {
                     $publication->Property->Dimensions->IndustryOfficeSurface = $publication->Property->Dimensions->IndustryOfficeSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->IndustryLandSurface->_)) {
                     $publication->Property->Dimensions->IndustryLandSurface = $publication->Property->Dimensions->IndustryLandSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->IndustryHallSurface->_)) {
                     $publication->Property->Dimensions->IndustryHallSurface = $publication->Property->Dimensions->IndustryHallSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->OfficeSurface->_)) {
                     $publication->Property->Dimensions->OfficeSurface = $publication->Property->Dimensions->OfficeSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->ProductionHallSurface->_)) {
                     $publication->Property->Dimensions->ProductionHallSurface = $publication->Property->Dimensions->ProductionHallSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->SalesRoomSurface->_)) {
                     $publication->Property->Dimensions->SalesRoomSurface = $publication->Property->Dimensions->SalesRoomSurface->_;
                 }
                 if (isset($publication->Property->Dimensions->ShopSurface->_)) {
                     $publication->Property->Dimensions->ShopSurface = $publication->Property->Dimensions->ShopSurface->_;
                 }
                 $data = array('software_id' => $publication->Property->ID, 'publication_id' => $summary->ID, 'create_date' => strtotime($publication->Property->Created), 'update_date' => strtotime($publication->Property->Modified), 'purpose' => isset($purposes[$publication->Property->Status]) ? $purposes[$publication->Property->Status] : 3, 'purpose_status' => isset($purpose_statuses[$publication->Property->Status]) ? $purpose_statuses[$publication->Property->Status] : 1, 'rent_type' => isset($rent_types[$publication->Property->RentType]) ? $rent_types[$publication->Property->RentType] : null, 'rent_time' => isset($rent_times[$publication->Property->RentTime]) ? $rent_times[$publication->Property->RentTime] : null, 'rent_temporary' => intval($publication->Property->TemporaryRent) < 0 ? null : $publication->Property->TemporaryRent == '1', 'payment_period' => isset($payment_periods[$publication->Property->PaymentPeriod]) ? $payment_periods[$publication->Property->PaymentPeriod] : null, 'payment_type' => isset($payment_types[$publication->Property->Payment]) ? $payment_types[$publication->Property->Payment] : null, 'to_take_over' => intval($publication->Property->TakeOver) < 0 ? null : $publication->Property->TakeOver == '1', 'investment' => intval($publication->Property->IsYieldProperty) < 0 ? null : $publication->Property->IsYieldProperty == '1', 'exclusive' => $publication->Property->IsExclusive == '1', 'availability' => isset($availabilities[$publication->Property->Acception]) ? $availabilities[$publication->Property->Acception] : null, 'availability_date' => null, 'selected_flash' => intval(preg_replace('/\\D/', '', $publication->Info->FlashID)), 'show_address' => !$publication->Info->HideAddress, 'show_number' => !$publication->Info->HideHouseNumber, 'reference' => $publication->Property->Reference, 'address_name' => $publication->Property->Address->Residence, 'address' => trim($publication->Property->Address->Street . ' ' . $publication->Property->Address->HouseNumber . $publication->Property->Address->HouseNumberExtension . ' ' . $publication->Property->Address->MailBox), 'postal' => $publication->Property->Address->City->ZipCode, 'city' => ucfirst($publication->Property->Address->City->_), 'country' => strtolower($publication->Property->Address->CountryID), 'nearby_public_transport' => $publication->Property->NearbyPublicTransport == 'UNDEFINED' ? null : $publication->Property->NearbyPublicTransport == 'TRUE', 'nearby_shops' => $publication->Property->NearbyShops == 'UNDEFINED' ? null : $publication->Property->NearbyShops == 'TRUE', 'nearby_school' => $publication->Property->NearbySchool == 'UNDEFINED' ? null : $publication->Property->NearbySchool == 'TRUE', 'nearby_highway' => $publication->Property->NearbyHighway == 'UNDEFINED' ? null : $publication->Property->NearbyHighway == 'TRUE', 'shop_location' => isset($shop_locations[$publication->Property->ShopLocation]) ? $shop_locations[$publication->Property->ShopLocation] : null, 'construction_year' => $publication->Property->ConstructionYear < 0 ? null : $publication->Property->ConstructionYear, 'renovation_year' => $publication->Property->RenovationYear < 0 ? null : $publication->Property->RenovationYear, 'newly_constructed' => $publication->Property->NewEstate == 'UNDEFINED' ? null : $publication->Property->NewEstate == 'TRUE', 'under_construction' => $publication->Property->UnderConstruction == 'UNDEFINED' ? null : $publication->Property->UnderConstruction == 'TRUE', 'in_production' => $publication->Property->IsInProduction == 'UNDEFINED' ? null : $publication->Property->IsInProduction == 'TRUE', 'state' => isset($states[$publication->Property->GeneralState]) ? $states[$publication->Property->GeneralState] : null, 'floors' => $publication->Property->NumberOfFloors < 0 ? null : $publication->Property->NumberOfFloors, 'youtube_code' => null);
                 if (isset($publication->Property->Address->Position->Y)) {
                     $data['coord_lat'] = floatval(str_replace(',', '.', $publication->Property->Address->Position->Y));
                 }
                 if (isset($publication->Property->Address->Position->X)) {
                     $data['coord_lon'] = floatval(str_replace(',', '.', $publication->Property->Address->Position->X));
                 }
                 if (isset($publication->Property->VideoUrl) && preg_match('/(?:http:|https:|)\\/\\/(?:player.|www.)?(?:youtu(?:be\\.com|\\.be|be\\.googleapis\\.com))\\/(?:video\\/|embed\\/|watch\\?v=|v\\/)?([A-Za-z0-9._%-]*)(\\&\\S+)?/is', $publication->Property->VideoUrl, $match)) {
                     $data['youtube_code'] = $match[1];
                 }
                 if (preg_match('/^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})$/s', $publication->Property->Dates->AvailableFromText, $match)) {
                     $data['availability_date'] = mktime(0, 0, 0, $match[2], $match[3], $match[1]);
                 }
                 foreach (array_keys(languages()) as $language) {
                     for ($i = 1; $i <= 5; $i++) {
                         if (isset($flashes[$i][$language])) {
                             $flash = $flashes[$i][$language];
                             $data['flash' . $i . '_title_' . $language] = $flash->Title;
                             $data['flash' . $i . '_content_' . $language] = $flash->Text;
                         }
                     }
                 }
                 $is_project = isset($types[$publication->Property->PropertyType]) && $types[$publication->Property->PropertyType] == 3;
                 $stack = $is_project ? 'skarabee>project' : 'skarabee>property';
                 if ($is_project) {
                     if (isset($publication->Property->Project->Name)) {
                         $data['name'] = ucfirst($publication->Property->Project->Name);
                         $data['slug'] = slug_format($data['name']);
                     }
                     $data = array_merge($data, array('construction_start_date' => null, 'construction_end_date' => null, 'acceptance_date' => null, 'construction_start_comment' => isset($publication->Property->Project->StartBuildingComment) && $publication->Property->Project->StartBuildingComment ? $publication->Property->Project->StartBuildingComment : null, 'construction_end_comment' => isset($publication->Property->Project->StopBuildingComment) && $publication->Property->Project->StopBuildingComment ? $publication->Property->Project->StopBuildingComment : null, 'acceptance_comment' => isset($publication->Property->Project->AcceptanceComment) && $publication->Property->Project->AcceptanceComment ? $publication->Property->Project->AcceptanceComment : null, 'consumer_info' => isset($publication->Property->Project->ConsumerInfo) && $publication->Property->Project->ConsumerInfo ? $publication->Property->Project->ConsumerInfo : null, 'contractor' => isset($publication->Property->Project->BuildingCompany) && $publication->Property->Project->BuildingCompany ? $publication->Property->Project->BuildingCompany : null));
                     if (isset($publication->Property->Project->StartBuilding) && preg_match('/^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})$/s', $publication->Property->Project->StartBuilding, $match)) {
                         $data['construction_start_date'] = mktime(0, 0, 0, $match[2], $match[3], $match[1]);
                     }
                     if (isset($publication->Property->Project->StopBuilding) && preg_match('/^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})$/s', $publication->Property->Project->StopBuilding, $match)) {
                         $data['construction_end_date'] = mktime(0, 0, 0, $match[2], $match[3], $match[1]);
                     }
                     if (isset($publication->Property->Project->Acceptance) && preg_match('/^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})$/s', $publication->Property->Project->Acceptance, $match)) {
                         $data['acceptance_date'] = mktime(0, 0, 0, $match[2], $match[3], $match[1]);
                     }
                 } else {
                     $data = array_merge($data, array('project_id' => null, 'type' => isset($types[$publication->Property->PropertyType]) ? $types[$publication->Property->PropertyType] : 1, 'category' => isset($categories[$publication->Property->Typo->Sort]) ? $categories[$publication->Property->Typo->Sort] : 1, 'service_charges_included' => $publication->Property->ServiceCharges == 'UNDEFINED' ? null : $publication->Property->ServiceCharges == 'COSTS_INCLUSIVE', 'show_price' => !$publication->Info->HidePrice, 'price' => floatval($publication->Property->Price), 'price_type' => isset($price_types[$publication->Property->PriceType]) ? $price_types[$publication->Property->PriceType] : 1, 'price_indication' => isset($price_types[$publication->Property->PriceIndication]) ? $price_types[$publication->Property->PriceIndication] : null, 'vat_included' => !($publication->Property->IsVATInclusive == 'FALSE' || $publication->Property->IsVATExclusive == 'TRUE'), 'charges' => floatval($publication->Property->ChargesAndProvisions) >= 0 ? floatval($publication->Property->ChargesAndProvisions) : null, 'communal_expenses' => floatval($publication->Property->CommunalExpenses) >= 0 ? floatval($publication->Property->CommunalExpenses) : null, 'heating_water_costs' => floatval($publication->Property->HeatingWaterCosts) >= 0 ? floatval($publication->Property->HeatingWaterCosts) : null, 'heating_costs' => floatval($publication->Property->HeatingCosts) >= 0 ? floatval($publication->Property->HeatingCosts) : null, 'garage_costs' => floatval($publication->Property->CostsGarage) >= 0 ? floatval($publication->Property->CostsGarage) : null, 'surface' => $publication->Property->Area < 0 ? null : $publication->Property->Area, 'surface_terrain' => $publication->Property->LandArea < 0 ? null : $publication->Property->LandArea, 'surface_livable' => floatval($publication->Property->SurfaceLivable) < 0 ? null : floatval($publication->Property->SurfaceLivable), 'surface_buildable' => isset($publication->Property->Dimensions->ConstructionSurface->_) && floatval($publication->Property->Dimensions->ConstructionSurface->_) >= 0 ? floatval($publication->Property->Dimensions->ConstructionSurface->_) : null, 'surface_terrace' => isset($publication->Property->SurfaceTerrace) && floatval($publication->Property->SurfaceTerrace) >= 0 ? floatval($publication->Property->SurfaceTerrace) : null, 'surface_garden' => isset($publication->Property->SurfaceGarden) && floatval($publication->Property->SurfaceGarden) >= 0 ? floatval($publication->Property->SurfaceGarden) : null, 'surface_balcony' => isset($publication->Property->Dimensions->BalconySurface->_) && floatval($publication->Property->Dimensions->BalconySurface->_) >= 0 ? floatval($publication->Property->Dimensions->BalconySurface->_) : null, 'terrain_width' => floatval($publication->Property->Width) < 0 ? null : floatval($publication->Property->Width), 'terrain_depth' => floatval($publication->Property->Depth) < 0 ? null : floatval($publication->Property->Depth), 'terrain_width_front' => floatval($publication->Property->FrontWidth) < 0 ? null : floatval($publication->Property->FrontWidth), 'floor_number' => is_numeric($publication->Property->FloorLevelNL) ? intval($publication->Property->FloorLevelNL) : null, 'parkings' => $publication->Property->NumberOfParkingPlaces < 0 ? null : $publication->Property->NumberOfParkingPlaces, 'has_parking' => $publication->Property->NumberOfParkingPlaces < 0 && $publication->Property->HasParkingPlace == 'UNDEFINED' ? null : $publication->Property->NumberOfParkingPlaces > 0 || $publication->Property->HasParkingPlace == 'TRUE', 'has_garden' => $publication->Property->SurfaceGarden < 1 && $publication->Property->HasBackYard == 'UNDEFINED' ? null : $publication->Property->SurfaceGarden > 0 || $publication->Property->HasBackYard == 'TRUE', 'has_balcony' => $publication->Property->HasBalcony == 'UNDEFINED' ? null : $publication->Property->HasBalcony == 'TRUE', 'garden_width' => floatval($publication->Property->BackYardWidth) < 0 ? null : floatval($publication->Property->BackYardWidth), 'garden_depth' => floatval($publication->Property->BackYardDepth) < 0 ? null : floatval($publication->Property->BackYardDepth), 'garden_quality' => isset($garden_qualities[$publication->Property->GardenQuality]) ? $garden_qualities[$publication->Property->GardenQuality] : null, 'roof_type' => isset($roof_types[$publication->Property->RoofType]) ? $roof_types[$publication->Property->RoofType] : null, 'roof_evaluation' => isset($evaluations[$publication->Property->RoofEvaluation]) ? $evaluations[$publication->Property->RoofEvaluation] : null, 'roof_comment' => $publication->Property->RoofComment, 'roof_cover' => isset($roof_covers[$publication->Property->RoofCoverType]) ? $roof_covers[$publication->Property->RoofCoverType] : null, 'roof_cover_evaluation' => isset($evaluations[$publication->Property->RoofCoverEvaluation]) ? $evaluations[$publication->Property->RoofCoverEvaluation] : null, 'roof_cover_comment' => isset($publication->Property->RoofCoverComment) ? $publication->Property->RoofCoverComment : '', 'window_type' => isset($window_types[$publication->Property->WindowType]) ? $window_types[$publication->Property->WindowType] : null, 'window_evaluation' => isset($evaluations[$publication->Property->WindowEvaluation]) ? $evaluations[$publication->Property->WindowEvaluation] : null, 'window_comment' => $publication->Property->WindowComment, 'glazing_evaluation' => isset($evaluations[$publication->Property->GlazingEvaluation]) ? $evaluations[$publication->Property->GlazingEvaluation] : null, 'glazing_comment' => $publication->Property->GlazingComment, 'electricity_evaluation' => isset($evaluations[$publication->Property->ElectricityEvaluation]) ? $evaluations[$publication->Property->ElectricityEvaluation] : null, 'electricity_comment' => $publication->Property->ElectricityComment, 'plumbing_evaluation' => isset($evaluations[$publication->Property->PlumbingEvaluation]) ? $evaluations[$publication->Property->PlumbingEvaluation] : null, 'plumbing_comment' => $publication->Property->PlumbingComment, 'sanitary_evaluation' => isset($evaluations[$publication->Property->SanitaryEvaluation]) ? $evaluations[$publication->Property->SanitaryEvaluation] : null, 'sanitary_comment' => $publication->Property->SanitaryComment, 'modification_allowed' => $publication->Property->Modification == 'UNDEFINED' ? null : $publication->Property->Modification == 'ALLOWED', 'common_walls' => isset($common_walls[$publication->Property->CommonWalls]) ? $common_walls[$publication->Property->CommonWalls] : null, 'orientation' => isset($orientations[$publication->Property->Orientation]) ? $orientations[$publication->Property->Orientation] : null, 'maintenance_inside' => isset($maintenance[$publication->Property->MaintenanceInside]) ? $maintenance[$publication->Property->MaintenanceInside] : null, 'maintenance_outside' => isset($maintenance[$publication->Property->MaintenanceOutside]) ? $maintenance[$publication->Property->MaintenanceOutside] : null, 'construction_type' => isset($construction_types[$publication->Property->ConstructionType]) ? $construction_types[$publication->Property->ConstructionType] : null, 'construction_evaluation' => isset($evaluations[$publication->Property->ConstructionEvaluation]) ? $evaluations[$publication->Property->ConstructionEvaluation] : null, 'frontage_type' => isset($frontage_types[$publication->Property->FrontageType]) ? $frontage_types[$publication->Property->FrontageType] : null, 'frontage_evaluation' => isset($evaluations[$publication->Property->FrontageEvaluation]) ? $evaluations[$publication->Property->FrontageEvaluation] : null, 'rooms' => $publication->Property->NumberOfRooms < 0 ? null : $publication->Property->NumberOfRooms, 'bedrooms' => $publication->Property->NumberOfBedrooms < 0 ? null : $publication->Property->NumberOfBedrooms, 'bathrooms' => $publication->Property->NumberOfBathrooms < 0 ? null : $publication->Property->NumberOfBathrooms, 'offices' => $publication->Property->NumberOfOffices < 0 ? null : $publication->Property->NumberOfOffices, 'garages' => $publication->Property->NumberOfGarages < 0 ? null : $publication->Property->NumberOfGarages, 'garage_size' => $publication->Property->NumberOfPlacesInGarage < 0 ? null : $publication->Property->NumberOfPlacesInGarage, 'toilets' => $publication->Property->NumberOfToilets < 0 ? null : $publication->Property->NumberOfToilets, 'has_garage' => $publication->Property->NumberOfGarages < 0 && $publication->Property->HasGarage == 'UNDEFINED' ? null : $publication->Property->NumberOfGarages > 0 || $publication->Property->HasGarage == 'TRUE', 'has_terrace' => $publication->Property->SurfaceTerrace < 1 && $publication->Property->HasTerrace == 'UNDEFINED' ? null : $publication->Property->SurfaceTerrace > 0 || $publication->Property->HasTerrace == 'TRUE', 'has_cellar' => $publication->Property->SurfaceBasement < 1 && $publication->Property->HasCellar == 'UNDEFINED' ? null : $publication->Property->SurfaceBasement > 0 || $publication->Property->HasCellar == 'TRUE', 'has_attic' => $publication->Property->SurfaceAttick < 1 && $publication->Property->HasAttick == 'UNDEFINED' ? null : $publication->Property->SurfaceAttick > 0 || $publication->Property->HasAttick == 'TRUE', 'has_showroom' => $publication->Property->SurfaceShowroom < 1 && $publication->Property->HasShowroom == 'UNDEFINED' ? null : $publication->Property->SurfaceShowroom > 0 || $publication->Property->HasShowroom == 'TRUE', 'has_office' => $publication->Property->HasOffice == 'UNDEFINED' ? null : $publication->Property->HasOffice == 'TRUE', 'has_greenhouse' => $publication->Property->HasGreenHouse == 'UNDEFINED' ? null : $publication->Property->HasGreenHouse == 'TRUE', 'has_profession_room' => $publication->Property->SurfaceProfessionRoom < 1 && $publication->Property->HasProfessionRoom == 'UNDEFINED' ? null : $publication->Property->SurfaceProfessionRoom > 0 || $publication->Property->HasProfessionRoom == 'TRUE', 'has_living' => $publication->Property->SurfaceLiving < 1 && $publication->Property->HasLivingRoom == 'UNDEFINED' ? null : $publication->Property->SurfaceLiving > 0 || $publication->Property->HasLivingRoom == 'TRUE', 'has_kitchen' => $publication->Property->SurfaceKitchen < 1 && $publication->Property->HasKitchen == 'UNDEFINED' ? null : $publication->Property->SurfaceKitchen > 0 || $publication->Property->HasKitchen == 'TRUE', 'has_utility_room' => $publication->Property->SurfaceUtilityRoom < 1 && $publication->Property->HasUtilityRoom == 'UNDEFINED' ? null : $publication->Property->SurfaceUtilityRoom > 0 || $publication->Property->HasUtilityRoom == 'TRUE', 'has_bedrooms' => $publication->Property->NumberOfBedrooms < 1 && $publication->Property->HasBedrooms == 'UNDEFINED' ? null : $publication->Property->NumberOfBedrooms > 0 || $publication->Property->HasBedrooms == 'TRUE', 'has_bathroom' => $publication->Property->NumberOfBathrooms < 1 && $publication->Property->HasBathroom == 'UNDEFINED' ? null : $publication->Property->NumberOfBathrooms > 0 || $publication->Property->HasBathroom == 'TRUE', 'has_toilet' => $publication->Property->NumberOfToilets < 1 && $publication->Property->HasToilet == 'UNDEFINED' ? null : $publication->Property->NumberOfToilets > 0 || $publication->Property->HasToilet == 'TRUE', 'has_storage' => (!isset($publication->Property->SurfaceStock) || $publication->Property->SurfaceStock < 1) && $publication->Property->HasStock == 'UNDEFINED' ? null : isset($publication->Property->SurfaceStock) && $publication->Property->SurfaceStock > 0 || $publication->Property->HasStock == 'TRUE', 'has_wash_place' => $publication->Property->HasWashPlace == 'UNDEFINED' ? null : $publication->Property->HasWashPlace == 'TRUE', 'has_dinging_room' => $publication->Property->SurfaceDiningRoom < 1 && $publication->Property->HasDiningRoom == 'UNDEFINED' ? null : $publication->Property->SurfaceDiningRoom > 0 || $publication->Property->HasDiningRoom == 'TRUE', 'surface_kitchen' => isset($publication->Property->SurfaceKitchen) && floatval($publication->Property->SurfaceKitchen) >= 0 ? floatval($publication->Property->SurfaceKitchen) : null, 'surface_living' => isset($publication->Property->SurfaceLiving) && floatval($publication->Property->SurfaceLiving) >= 0 ? floatval($publication->Property->SurfaceLiving) : null, 'surface_storage' => isset($publication->Property->SurfaceStock) && floatval($publication->Property->SurfaceStock) >= 0 ? floatval($publication->Property->SurfaceStock) : null, 'surface_utility_room' => isset($publication->Property->SurfaceUtilityRoom) && floatval($publication->Property->SurfaceUtilityRoom) >= 0 ? floatval($publication->Property->SurfaceUtilityRoom) : null, 'surface_showroom' => isset($publication->Property->SurfaceShowroom) && floatval($publication->Property->SurfaceShowroom) >= 0 ? floatval($publication->Property->SurfaceShowroom) : null, 'surface_profession_room' => isset($publication->Property->SurfaceProfessionRoom) && floatval($publication->Property->SurfaceProfessionRoom) >= 0 ? floatval($publication->Property->SurfaceProfessionRoom) : null, 'surface_attic' => isset($publication->Property->SurfaceAttick) && floatval($publication->Property->SurfaceAttick) >= 0 ? floatval($publication->Property->SurfaceAttick) : null, 'surface_cellar' => isset($publication->Property->SurfaceBasement) && floatval($publication->Property->SurfaceBasement) >= 0 ? floatval($publication->Property->SurfaceBasement) : null, 'surface_dining_room' => isset($publication->Property->SurfaceDiningRoom) && floatval($publication->Property->SurfaceDiningRoom) >= 0 ? floatval($publication->Property->SurfaceDiningRoom) : null, 'surface_cantine' => isset($publication->Property->Dimensions->CantineSurface) && floatval($publication->Property->Dimensions->CantineSurface) >= 0 ? floatval($publication->Property->Dimensions->CantineSurface) : null, 'surface_horeca' => isset($publication->Property->Dimensions->CateringSurface) && floatval($publication->Property->Dimensions->CateringSurface) >= 0 ? floatval($publication->Property->Dimensions->CateringSurface) : null, 'surface_industry' => isset($publication->Property->Dimensions->IndustrySurface) && floatval($publication->Property->Dimensions->IndustrySurface) >= 0 ? floatval($publication->Property->Dimensions->IndustrySurface) : null, 'surface_industry_land' => isset($publication->Property->Dimensions->IndustryLandSurface) && floatval($publication->Property->Dimensions->IndustryLandSurface) >= 0 ? floatval($publication->Property->Dimensions->IndustryLandSurface) : null, 'surface_industry_office' => isset($publication->Property->Dimensions->IndustryOfficeSurface) && floatval($publication->Property->Dimensions->IndustryOfficeSurface) >= 0 ? floatval($publication->Property->Dimensions->IndustryOfficeSurface) : null, 'surface_industry_hall' => isset($publication->Property->Dimensions->IndustryHallSurface) && floatval($publication->Property->Dimensions->IndustryHallSurface) >= 0 ? floatval($publication->Property->Dimensions->IndustryHallSurface) : null, 'surface_office' => isset($publication->Property->Dimensions->OfficeSurface) && floatval($publication->Property->Dimensions->OfficeSurface) >= 0 ? floatval($publication->Property->Dimensions->OfficeSurface) : null, 'surface_production' => isset($publication->Property->Dimensions->ProductionHallSurface) && floatval($publication->Property->Dimensions->ProductionHallSurface) >= 0 ? floatval($publication->Property->Dimensions->ProductionHallSurface) : null, 'surface_rentable' => isset($publication->Property->Dimensions->RentableSurface) && floatval($publication->Property->Dimensions->RentableSurface) >= 0 ? floatval($publication->Property->Dimensions->RentableSurface) : null, 'surface_sales_room' => isset($publication->Property->Dimensions->SalesRoomSurface) && floatval($publication->Property->Dimensions->SalesRoomSurface) >= 0 ? floatval($publication->Property->Dimensions->SalesRoomSurface) : null, 'surface_shop' => isset($publication->Property->Dimensions->ShopSurface) && floatval($publication->Property->Dimensions->ShopSurface) >= 0 ? floatval($publication->Property->Dimensions->ShopSurface) : null, 'living_type' => isset($living_types[$publication->Property->LivingRoomType]) ? $living_types[$publication->Property->LivingRoomType] : null, 'garage_type' => isset($garage_types[$publication->Property->GarageType]) ? $garage_types[$publication->Property->GarageType] : null, 'profession_room_type' => isset($profession_room_types[$publication->Property->ProfessionRoomType]) ? $profession_room_types[$publication->Property->ProfessionRoomType] : null, 'office_type' => isset($office_types[$publication->Property->OfficeType]) ? $office_types[$publication->Property->OfficeType] : null, 'storage_type' => isset($storage_types[$publication->Property->StorageRoom]) ? $storage_types[$publication->Property->StorageRoom] : null, 'kitchen_type' => isset($kitchen_types[$publication->Property->KitchenGenre]) ? $kitchen_types[$publication->Property->KitchenGenre] : null, 'cellar_type' => isset($cellar_types[$publication->Property->BasesType]) ? $cellar_types[$publication->Property->BasesType] : null, 'cellar_evaluation' => isset($evaluations[$publication->Property->BasesEvaluation]) ? $evaluations[$publication->Property->BasesEvaluation] : null, 'cellar_comment' => isset($publication->Property->BasesComment) ? $publication->Property->BasesComment : null, 'has_elevator' => $publication->Property->HasElevator == 'UNDEFINED' ? null : $publication->Property->HasElevator == 'TRUE', 'has_alarm' => $publication->Property->HasAlarm == 'UNDEFINED' ? null : $publication->Property->HasAlarm == 'TRUE', 'furnished' => $publication->Property->HasFurniture == 'UNDEFINED' ? null : $publication->Property->HasFurniture == 'TRUE', 'kitchen_equipped' => $publication->Property->KitchenType == 'UNDEFINED' ? null : $publication->Property->KitchenType == 'BUILD_WITH_APPLIANCES', 'pets_allowed' => $publication->Property->PetsAllowed == 'UNDEFINED' ? null : $publication->Property->PetsAllowed == 'TRUE', 'child_friendly' => $publication->Property->IsChildFriendly == 'UNDEFINED' ? null : $publication->Property->IsChildFriendly == 'TRUE', 'has_roller_blinds' => $publication->Property->HasRollerBlinds == 'UNDEFINED' ? null : $publication->Property->HasRollerBlinds == 'TRUE', 'has_heating' => $publication->Property->HasHeating == 'UNDEFINED' ? null : $publication->Property->HasHeating == 'TRUE', 'has_electricity' => $publication->Property->HasElectricity == 'UNDEFINED' ? null : $publication->Property->HasElectricity == 'TRUE', 'has_sanitary' => $publication->Property->HasSanitary == 'UNDEFINED' ? null : $publication->Property->HasSanitary == 'TRUE', 'has_external_solar_blinds' => $publication->Property->ExternalSolarBlinds == 'UNDEFINED' ? null : $publication->Property->ExternalSolarBlinds == 'TRUE', 'has_ventilation' => $publication->Property->HasVentilation == 'UNDEFINED' ? null : $publication->Property->HasVentilation == 'TRUE', 'garnished' => $publication->Property->Garnished == 'UNDEFINED' ? null : !($publication->Property->Garnished == 'NO'), 'has_cable_tv' => $publication->Property->HasCable_TV == 'UNDEFINED' ? null : $publication->Property->HasCable_TV == 'TRUE', 'has_cai_tv' => $publication->Property->HasCAI_TV == 'UNDEFINED' ? null : $publication->Property->HasCAI_TV == 'TRUE', 'has_pool' => $publication->Property->HasPool == 'UNDEFINED' ? null : $publication->Property->HasPool == 'TRUE', 'has_airco' => $publication->Property->HasAirco == 'UNDEFINED' ? null : $publication->Property->HasAirco == 'TRUE', 'has_jacuzzi' => $publication->Property->HasJacuzzi == 'UNDEFINED' ? null : $publication->Property->HasJacuzzi == 'TRUE', 'has_intercom' => $publication->Property->HasIntercom == 'UNDEFINED' ? null : $publication->Property->HasIntercom == 'TRUE', 'has_electricity_connection' => $publication->Property->HasElectricityConnect == 'UNDEFINED' ? null : $publication->Property->HasElectricityConnect == 'TRUE', 'has_gas_connection' => $publication->Property->HasGasConnect == 'UNDEFINED' ? null : $publication->Property->HasGasConnect == 'TRUE', 'has_water_connection' => $publication->Property->HasWaterConnect == 'UNDEFINED' ? null : $publication->Property->HasWaterConnect == 'TRUE', 'has_sewer_connection' => $publication->Property->HasSewerConnect == 'UNDEFINED' ? null : $publication->Property->HasSewerConnect == 'TRUE', 'has_internet_connection' => $publication->Property->HasInternetConnect == 'UNDEFINED' ? null : $publication->Property->HasInternetConnect == 'TRUE', 'has_fireplace' => $publication->Property->HasFirePlace == 'UNDEFINED' ? null : $publication->Property->HasFirePlace == 'TRUE', 'external_solar_blinds_comment' => $publication->Property->ExternalSolarBlindsComment, 'ventilation_comment' => $publication->Property->VentilationComment, 'cable_tv_comment' => $publication->Property->Cable_TVComment, 'pool_comment' => $publication->Property->PoolComment, 'elevator_evaluation' => isset($evaluations[$publication->Property->ElevatorEvaluation]) ? $evaluations[$publication->Property->ElevatorEvaluation] : null, 'elevator_comment' => $publication->Property->ElevatorComment, 'alarm_evaluation' => isset($evaluations[$publication->Property->AlarmEvaluation]) ? $evaluations[$publication->Property->AlarmEvaluation] : null, 'alarm_comment' => $publication->Property->AlarmComment, 'roller_blinds_evaluation' => isset($evaluations[$publication->Property->RollerBlindsEvaluation]) ? $evaluations[$publication->Property->RollerBlindsEvaluation] : null, 'roller_blinds_comment' => $publication->Property->RollerBlindsComment, 'isolation_evaluation' => isset($evaluations[$publication->Property->IsolationEvaluation]) ? $evaluations[$publication->Property->IsolationEvaluation] : null, 'isolation_comment' => $publication->Property->IsolationComment, 'isolation_type' => null, 'klevel' => !isset($publication->Property->Energy->KLevel) || is_null($publication->Property->Energy->KLevel) ? null : intval($publication->Property->Energy->KLevel), 'elevel' => !isset($publication->Property->Energy->EnergyLevel) || is_null($publication->Property->Energy->EnergyLevel) ? null : intval($publication->Property->Energy->EnergyLevel), 'epc' => !isset($publication->Property->Energy->Index) || is_null($publication->Property->Energy->Index) || $publication->Property->Energy->Index == 0 ? null : intval($publication->Property->Energy->Index), 'epc_certificate' => !isset($publication->Property->Energy->EnergyCertificateNr) || is_null($publication->Property->Energy->EnergyCertificateNr) ? null : $publication->Property->Energy->EnergyCertificateNr, 'heating_type' => null, 'heating_source' => null, 'heating_evaluation' => isset($evaluations[$publication->Property->HeatingEvaluation]) ? $evaluations[$publication->Property->HeatingEvaluation] : null, 'heating_comment' => $publication->Property->HeatingComment, 'water_heating_type' => null, 'water_heating_source' => null, 'water_heating_evaluation' => isset($evaluations[$publication->Property->WarmWaterEvaluation]) ? $evaluations[$publication->Property->WarmWaterEvaluation] : null, 'cadastrall_numbers' => $publication->Property->CadastrallNumbers, 'cadastrall_area' => $publication->Property->CadastrallArea < 0 ? null : $publication->Property->CadastrallArea, 'cadastrall_income' => floatval($publication->Property->CadastrallIncome) >= 0 ? floatval($publication->Property->CadastrallIncome) : null, 'cadastrall_income_indexed' => floatval($publication->Property->CadastrallIncomeIndexed) >= 0 ? floatval($publication->Property->CadastrallIncomeIndexed) : null, 'cadastrall_description' => $publication->Property->CadastrallDescription, 'percent_private_usage' => $publication->Property->UsagePrivatePercent <= 0 && $publication->Property->UsageProfessionalPercent <= 0 ? null : $publication->Property->UsagePrivatePercent, 'percent_professional_usage' => $publication->Property->UsagePrivatePercent <= 0 && $publication->Property->UsageProfessionalPercent <= 0 ? null : $publication->Property->UsageProfessionalPercent, 'easement' => isset($easements[$publication->Property->Easement]) ? $easements[$publication->Property->Easement] : null, 'restriction_comment' => $publication->Property->RestrictionComment, 'environmental_planning_type' => isset($environmental_planning_types[$publication->Property->EnvironmentalPlanning]) ? $environmental_planning_types[$publication->Property->EnvironmentalPlanning] : null, 'clauses' => $publication->Property->Clauses, 'is_monument' => $publication->Property->IsMonumentsAct == 'UNDEFINED' ? null : $publication->Property->IsMonumentsAct == 'TRUE', 'is_protected' => $publication->Property->IsProtected == 'UNDEFINED' ? null : $publication->Property->IsProtected == 'TRUE', 'has_asbestus' => $publication->Property->HasAsbestus == 'UNDEFINED' ? null : $publication->Property->HasAsbestus == 'TRUE', 'has_ground_pollution' => $publication->Property->HasGroundPollution == 'UNDEFINED' ? null : $publication->Property->HasGroundPollution == 'TRUE', 'planning_permission' => $publication->Property->UrbanDevelopment->Permit == 'UNDEFINED' ? null : $publication->Property->UrbanDevelopment->Permit == 'TRUE', 'subdivision_permit' => $publication->Property->UrbanDevelopment->AllotmentPermit == 'UNDEFINED' ? null : $publication->Property->UrbanDevelopment->AllotmentPermit == 'TRUE', 'preemption_right' => $publication->Property->UrbanDevelopment->PreemptiveRights == 'UNDEFINED' ? null : $publication->Property->UrbanDevelopment->PreemptiveRights == 'TRUE', 'urbanism_citation' => $publication->Property->UrbanDevelopment->Summons == 'UNDEFINED' ? null : $publication->Property->UrbanDevelopment->Summons == 'TRUE', 'judicial_decision' => $publication->Property->UrbanDevelopment->JudicialDecision == 'UNDEFINED' ? null : $publication->Property->UrbanDevelopment->JudicialDecision == 'TRUE', 'land_use_designation' => isset($land_use_designations[$publication->Property->UrbanDevelopment->AreaApplication->Code]) ? $land_use_designations[$publication->Property->UrbanDevelopment->AreaApplication->Code] : null, 'as_built_certificate_date' => null, 'diagnostics_certificate_date' => null, 'electricity_certificate_date' => null, 'energy_consumption_certificate_date' => null, 'energy_performance_certificate_date' => null, 'gas_certificate_date' => null, 'polution_certificate_date' => null, 'accessibility_certificate_date' => null, 'lead_certificate_date' => null, 'nature_risk_certificate_date' => null, 'oil_tank_certificate_date' => null, 'planning_certificate_date' => null, 'private_area_certificate_date' => null, 'smoke_detection_certificate_date' => null, 'soil_certificate_date' => null));
                     if (isset($publication->Property->Project->PublicationID) && $publication->Property->Project->PublicationID > 0) {
                         if ($project = where('publication_id = %d', $publication->Property->Project->PublicationID)->get_row('skarabee>project')) {
                             $data['project_id'] = $project->id;
                         }
                     }
                     if ((!isset($data['coord_lat']) || !$data['coord_lat']) && (!isset($data['coord_lon']) || !$data['coord_lat'])) {
                         if ($geocode = self::geocode($data['address'] . ', ' . $data['postal'] . ' ' . $data['city'])) {
                             $data['coord_lat'] = number_format($geocode['lat'], 10, '.', '');
                             $data['coord_lon'] = number_format($geocode['lon'], 10, '.', '');
                         }
                     }
                     $data['sold'] = $data['purpose_status'] == 2;
                     $glazing_types_array = array();
                     if (isset($publication->Property->GlazingTypes->GlazingType)) {
                         if (!is_array($publication->Property->GlazingTypes->GlazingType)) {
                             $publication->Property->GlazingTypes->GlazingType = array($publication->Property->GlazingTypes->GlazingType);
                         }
                         foreach ($publication->Property->GlazingTypes->GlazingType as $glazing_type) {
                             if (isset($glazing_types[$glazing_type])) {
                                 $glazing_types_array[] = $glazing_types[$glazing_type];
                             }
                         }
                     }
                     $data['glazing_type'] = implode(',', $glazing_types_array);
                     $heating_sources_array = array();
                     if (isset($publication->Property->HeatingTypes->HeatingType)) {
                         if (!is_array($publication->Property->HeatingTypes->HeatingType)) {
                             $publication->Property->HeatingTypes->HeatingType = array($publication->Property->HeatingTypes->HeatingType);
                         }
                         foreach ($publication->Property->HeatingTypes->HeatingType as $heating_type) {
                             if (isset($heating_types[$heating_type])) {
                                 $data['heating_type'] = $heating_types[$heating_type];
                             } else {
                                 if (isset($heating_sources[$heating_type])) {
                                     $heating_sources_array[] = $heating_sources[$heating_type];
                                 }
                             }
                         }
                     }
                     $data['heating_source'] = implode(',', $heating_sources_array);
                     if (isset($publication->Property->WarmWaterTypes->WarmWaterType)) {
                         if (!is_array($publication->Property->WarmWaterTypes->WarmWaterType)) {
                             $publication->Property->WarmWaterTypes->WarmWaterType = array($publication->Property->WarmWaterTypes->WarmWaterType);
                         }
                         foreach ($publication->Property->WarmWaterTypes->WarmWaterType as $warm_water_type) {
                             if (isset($heating_types[$warm_water_type])) {
                                 $data['water_heating_type'] = $heating_types[$warm_water_type];
                             } else {
                                 if (isset($water_heating_sources[$warm_water_type])) {
                                     $data['water_heating_source'] = $water_heating_sources[$warm_water_type];
                                 }
                             }
                         }
                     }
                     $plumbing_types_array = array();
                     if (isset($publication->Property->PlumbingTypes->PlumbingType)) {
                         if (!is_array($publication->Property->PlumbingTypes->PlumbingType)) {
                             $publication->Property->PlumbingTypes->PlumbingType = array($publication->Property->PlumbingTypes->PlumbingType);
                         }
                         foreach ($publication->Property->PlumbingTypes->PlumbingType as $plumbing_type) {
                             if (isset($plumbing_types[$plumbing_type])) {
                                 $plumbing_types_array[] = $plumbing_types[$plumbing_type];
                             }
                         }
                     }
                     $data['plumbing_type'] = implode(',', $plumbing_types_array);
                     if (isset($publication->Property->IsolationTypes->IsolationType)) {
                         if (!is_array($publication->Property->IsolationTypes->IsolationType)) {
                             $publication->Property->IsolationTypes->IsolationType = array($publication->Property->IsolationTypes->IsolationType);
                         }
                         foreach ($publication->Property->IsolationTypes->IsolationType as $isolation_type) {
                             if (isset($isolation_types[$isolation_type])) {
                                 $data['isolation_type'] = $isolation_types[$isolation_type];
                                 break;
                             }
                         }
                     }
                     if (isset($publication->Property->Certifications->Certification)) {
                         if (!is_array($publication->Property->Certifications->Certification)) {
                             $publication->Property->Certifications->Certification = array($publication->Property->Certifications->Certification);
                         }
                         foreach ($publication->Property->Certifications->Certification as $certification) {
                             if (isset($certificate_fields[$certification->Type]) && isset($certification->Date) && preg_match('/^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})$/s', $certification->Date, $match)) {
                                 $data[$certificate_fields[$certification->Type]] = mktime(0, 0, 0, $match[2], $match[3], $match[1]);
                             }
                         }
                     }
                     if (isset($subcategory_ids[$publication->Property->Typo->Genre])) {
                         $data['subcategory_id'] = $subcategory_ids[$publication->Property->Typo->Genre];
                     } else {
                         $data['subcategory_id'] = $subcategory_ids[$publication->Property->Typo->Sort];
                     }
                     foreach (array_keys(languages()) as $language) {
                         if (!isset($subcategories[$publication->Property->Typo->Genre][$language]) && !isset($subcategories[$publication->Property->Typo->Sort][$language])) {
                             continue;
                         }
                         if (isset($subcategories[$publication->Property->Typo->Genre][$language])) {
                             $data['subcategory_' . $language] = $subcategories[$publication->Property->Typo->Genre][$language];
                         } else {
                             $data['subcategory_' . $language] = $subcategories[$publication->Property->Typo->Sort][$language];
                         }
                         $data['subcategory_slug_' . $language] = slug_format($data['subcategory_' . $language]);
                         $data['slug_' . $language] = slug_format($data['subcategory_slug_' . $language] . '-' . l(array('nl' => 'in', 'fr' => 'a', 'en' => 'in'), $language) . '-' . $data['city']);
                         if (isset($styles[$publication->Property->Typo->Characterisation][$language])) {
                             $data['style_' . $language] = $styles[$publication->Property->Typo->Characterisation][$language];
                         }
                         $data['features_' . $language] = isset($features[$language]) ? json_encode($features[$language]) : '[]';
                     }
                 }
                 if ($existing = where('software_id = %d', $data['software_id'])->get_row($stack)) {
                     // Update existing photos
                     $existing_photos = array();
                     foreach ($existing->photo as $current_photo) {
                         $found = false;
                         foreach ($photos as $key => $photo) {
                             if ($photo['orig_filename'] == $current_photo->orig_filename) {
                                 if ($key != $current_photo->_sort_order || $photo['type'] != $current_photo->image_type) {
                                     where('id = %d', $current_photo->id)->update($stack . '>photo', array('_sort_order' => $key, 'image_type' => $photo['type']));
                                 }
                                 $existing_photos[] = $key;
                                 $found = true;
                             }
                         }
                         if (!$found) {
                             where('id = %d', $current_photo->id)->delete($stack . '>photo');
                         }
                     }
                     $photos = array_diff_key($photos, array_flip($existing_photos));
                     // Update existing documents
                     $existing_documents = array();
                     foreach ($existing->file as $current_file) {
                         $found = false;
                         foreach ($documents as $key => $document) {
                             if ($document['url'] == $current_file->url) {
                                 if ($document['name'] != $current_file->name || $document['filename'] != $current_file->filename) {
                                     where('id = %d', $current_file->id)->update($stack . '>file', $document);
                                 }
                                 $existing_documents[] = $key;
                                 $found = true;
                             }
                         }
                         if (!$found) {
                             where('id = %d', $current_file->id)->delete($stack . '>file');
                         }
                     }
                     $documents = array_diff_key($documents, array_flip($existing_documents));
                     // Update existing open house
                     $existing_records = array();
                     foreach ($existing->open_house as $current_record) {
                         $found = false;
                         foreach ($openhouse as $key => $record) {
                             if ($record['from'] == $current_record->fromdate && $record['to'] == $current_record->todate) {
                                 if ($record['comment'] != $current_record->comment) {
                                     where('id = %d', $current_record->id)->update($stack . '>open_house', array('comment' => $record['comment']));
                                 }
                                 $existing_records[] = $key;
                                 $found = true;
                             }
                         }
                         if (!$found) {
                             where('id = %d', $current_record->id)->delete($stack . '>open_house');
                         }
                     }
                     $openhouse = array_diff_key($openhouse, array_flip($existing_records));
                     // Update existing floors
                     if (!$is_project) {
                         $existing_floors = array();
                         foreach ($existing->floor as $current_floor) {
                             if (isset($floors[$current_floor->level])) {
                                 if (count(array_diff_assoc($floors[$current_floor->level], $current_floor->to_array()))) {
                                     foreach ($floors[$current_floor->level] as $key => $value) {
                                         if ($value != $current_floor->{$key}) {
                                             where('id = %d', $current_floor->id)->update($stack . '>floor', $floors[$current_floor->level]);
                                             break;
                                         }
                                     }
                                 }
                                 $existing_floors[] = $current_floor->level;
                             } else {
                                 where('id = %d', $current_record->id)->delete($stack . '>floor');
                             }
                         }
                         $floors = array_diff_key($floors, array_flip($existing_floors));
                     }
                     // Update data
                     where('id = %d', $existing->id)->update($stack, $data);
                     $id = $existing->id;
                 } else {
                     $id = insert($stack, $data);
                 }
                 // Create new photos
                 foreach ($photos as $key => $photo) {
                     $newphoto = array($is_project ? 'project_id' : 'property_id' => $id, 'orig_filename' => $photo['orig_filename'], 'filename' => 'properties/' . $id . '/' . md5($photo['orig_filename']) . '.jpg', 'upload_date' => time(), '_sort_order' => $key, 'image_type' => $photo['type']);
                     foreach (array_keys(languages()) as $language) {
                         $newphoto['alt_' . $language] = $is_project ? $data['name'] : $data['subcategory_' . $language] . ' ' . l(array('nl' => 'in', 'fr' => 'a', 'en' => 'in'), $language) . ' ' . $data['city'];
                         $newphoto['slug_' . $language] = slug_format($newphoto['alt_' . $language]);
                     }
                     if (!file_exists(FILESPATH . 'properties')) {
                         mkdir(FILESPATH . 'properties');
                     }
                     if (!file_exists(FILESPATH . 'properties/' . $id)) {
                         mkdir(FILESPATH . 'properties/' . $id);
                     }
                     if (self::download_remote_file($photo['url'], FILESPATH . $newphoto['filename'])) {
                         insert($stack . '>photo', $newphoto);
                     }
                 }
                 // Add new documents
                 foreach ($documents as $key => $document) {
                     $document[$is_project ? 'project_id' : 'property_id'] = $id;
                     insert($stack . '>file', $document);
                 }
                 // Add new open house
                 foreach ($openhouse as $key => $record) {
                     insert($stack . '>open_house', array($is_project ? 'project_id' : 'property_id' => $id, 'comment' => $record['comment'], 'fromdate' => $record['from'], 'todate' => $record['to']));
                 }
                 // Add new floors
                 if (!$is_project) {
                     foreach ($floors as $level => $floor) {
                         $floor[$is_project ? 'project_id' : 'property_id'] = $id;
                         insert($stack . '>floor', $floor);
                     }
                 }
                 $present_properties[] = $data['software_id'];
                 $current = where('id = %d', $id)->get_row($stack);
                 $feedbacks[] = array('PublicationID' => $data['publication_id'], 'Status' => 'AVAILABLE', 'StatusDescription' => $existing ? 'Property was updated' : 'Property was created', 'ExternalID' => strval($id), 'URL' => $current->url);
             }
         }
         if (count($present_properties)) {
             foreach (where('software_id NOT IN %$', $present_properties)->get('skarabee>property') as $todelete) {
                 $feedbacks[] = array('PublicationID' => $todelete->publication_id, 'Status' => 'DELETED', 'StatusDescription' => 'Property was deleted', 'ExternalID' => $todelete->id, 'URL' => $todelete->url);
             }
             where('software_id NOT IN %$', $present_properties)->delete('skarabee>property');
             foreach (where('software_id NOT IN %$', $present_properties)->get('skarabee>project') as $todelete) {
                 $feedbacks[] = array('PublicationID' => $todelete->publication_id, 'Status' => 'DELETED', 'StatusDescription' => 'Property was deleted', 'ExternalID' => $todelete->id, 'URL' => $todelete->url);
             }
             where('software_id NOT IN %$', $present_properties)->delete('skarabee>project');
         }
         $site = current_site();
         if ($site->live) {
             $feedbackresponse = $client->Feedback(array('FeedbackList' => array('FeedbackList' => $feedbacks)));
         }
     }
 }
Example #20
0
function list_languages($message = '')
{
    global $prefs, $locale, $textarray;
    require_once txpath . '/lib/IXRClass.php';
    // Select and save active language
    if (!$message && ps('step') == 'list_languages' && ps('language')) {
        $locale = doSlash(getlocale(ps('language')));
        safe_update("txp_prefs", "val='" . doSlash(ps('language')) . "'", "name='language'");
        safe_update("txp_prefs", "val='" . $locale . "'", "name='locale'");
        $textarray = load_lang(doSlash(ps('language')));
        $locale = setlocale(LC_ALL, $locale);
        $message = gTxt('preferences_saved');
    }
    $active_lang = safe_field('val', 'txp_prefs', "name='language'");
    $lang_form = '<div id="language_control" class="txp-control-panel">' . form(graf(gTxt('active_language') . languages('language', $active_lang) . n . fInput('submit', 'Submit', gTxt('save'), 'publish') . eInput('prefs') . sInput('list_languages'))) . '</div>';
    $client = new IXR_Client(RPC_SERVER);
    //$client->debug = true;
    $available_lang = array();
    $rpc_connect = false;
    $show_files = false;
    // Get items from RPC
    @set_time_limit(90);
    if ($client->query('tups.listLanguages', $prefs['blog_uid'])) {
        $rpc_connect = true;
        $response = $client->getResponse();
        foreach ($response as $language) {
            $available_lang[$language['language']]['rpc_lastmod'] = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year);
        }
    } elseif (gps('force') != 'file') {
        $msg = gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->";
    }
    // Get items from Filesystem
    $files = get_lang_files();
    if (is_array($files) && !empty($files)) {
        foreach ($files as $file) {
            if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) {
                $name = str_replace('.txt', '', $file);
                $firstline = fgets($fp, 4069);
                fclose($fp);
                if (strpos($firstline, '#@version') !== false) {
                    @(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1)))));
                } else {
                    $fversion = $ftime = NULL;
                }
                $available_lang[$name]['file_note'] = isset($fversion) ? $fversion : 0;
                $available_lang[$name]['file_lastmod'] = isset($ftime) ? $ftime : 0;
            }
        }
    }
    // Get installed items from the database
    // We need a value here for the language itself, not for each one of the rows
    $rows = safe_rows('lang, UNIX_TIMESTAMP(MAX(lastmod)) as lastmod', 'txp_lang', "1 GROUP BY lang ORDER BY lastmod DESC");
    $installed_lang = array();
    foreach ($rows as $language) {
        $available_lang[$language['lang']]['db_lastmod'] = $language['lastmod'];
        if ($language['lang'] != $active_lang) {
            $installed_lang[] = $language['lang'];
        }
    }
    $list = '';
    // Show the language table
    foreach ($available_lang as $langname => $langdat) {
        $file_updated = isset($langdat['db_lastmod']) && @$langdat['file_lastmod'] > $langdat['db_lastmod'];
        $rpc_updated = @$langdat['rpc_lastmod'] > @$langdat['db_lastmod'];
        $rpc_install = tda($rpc_updated ? strong(eLink('prefs', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']), '')) . n . '<span class="date modified">' . safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']) . '</span>' : (isset($langdat['rpc_lastmod']) ? gTxt('updated') : '-') . (isset($langdat['db_lastmod']) ? n . '<span class="date modified">' . safe_strftime('%d %b %Y %X', $langdat['db_lastmod']) . '</span>' : ''), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-value"' : ' class="lang-value"');
        $lang_file = tda(isset($langdat['file_lastmod']) ? strong(eLink('prefs', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file', '')) . n . '<span class="date ' . ($file_updated ? 'created' : 'modified') . '">' . safe_strftime($prefs['archive_dateformat'], $langdat['file_lastmod']) . '</span>' : '-', ' class="lang-value languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"');
        $list .= tr(tda(gTxt($langname), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-label"' : ' class="lang-label"') . n . $rpc_install . n . $lang_file . n . tda(in_array($langname, $installed_lang) ? dLink('prefs', 'remove_language', 'lang_code', $langname, 1) : '-', ' class="languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"')) . n . n;
    }
    // Output Table + Content
    // TODO: tab_languages when this panel is moved to its own tab
    pagetop(gTxt('update_languages'), $message);
    //TODO: tab_languages when this panel is moved to its own tab
    echo '<h1 class="txp-heading">' . gTxt('update_languages') . '</h1>';
    echo n . '<div id="language_container" class="txp-container">';
    if (isset($msg) && $msg) {
        echo tag($msg, 'p', ' class="error lang-msg"');
    }
    echo n . '<p class="nav-tertiary">' . sLink('prefs', 'prefs_list', gTxt('site_prefs'), 'navlink') . sLink('prefs', 'advanced_prefs', gTxt('advanced_preferences'), 'navlink') . sLink('prefs', 'list_languages', gTxt('manage_languages'), 'navlink-active') . n . '</p>';
    echo $lang_form;
    echo n, '<div class="txp-listtables">', startTable('', '', 'txp-list'), '<thead>', tr(hCell(gTxt('language')) . hCell(gTxt('from_server') . n . popHelp('install_lang_from_server')) . hCell(gTxt('from_file') . n . popHelp('install_lang_from_file'), '', ' class="languages_detail"') . hCell(gTxt('remove_lang') . n . popHelp('remove_lang'), '', ' class="languages_detail"')), '</thead>';
    echo '<tbody>' . $list . '</tbody>', endTable(), n, '</div>';
    echo graf(toggle_box('languages_detail'), ' class="detail-toggle"');
    echo hed(gTxt('install_from_textpack'), 3) . n . form(graf('<label for="textpack-install">' . gTxt('install_textpack') . '</label>' . n . popHelp('get_textpack') . n . '<textarea id="textpack-install" class="code" name="textpack" cols="' . INPUT_LARGE . '" rows="' . INPUT_XSMALL . '"></textarea>' . n . fInput('submit', 'install_new', gTxt('upload')) . eInput('prefs') . sInput('get_textpack')), '', '', 'post', 'edit-form', '', 'text_uploader');
    echo '</div>';
    // end language_container
}
function get_languages($feature, $spare = '')
{
    // get the languages
    $a_languages = languages();
    $index = '';
    $complete = '';
    $found = false;
    // set to default value
    //prepare user language array
    $user_languages = array();
    //check to see if language is set
    if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
        $languages = strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
        // $languages = ' fr-ch;q=0.3, da, en-us;q=0.8, en;q=0.5, fr;q=0.3';
        // need to remove spaces from strings to avoid error
        $languages = str_replace(' ', '', $languages);
        $languages = explode(",", $languages);
        //$languages = explode( ",", $test);// this is for testing purposes only
        foreach ($languages as $language_list) {
            // pull out the language, place languages into array of full and primary
            // string structure:
            $temp_array = array();
            // slice out the part before ; on first step, the part before - on second, place into array
            $temp_array[0] = substr($language_list, 0, strcspn($language_list, ';'));
            //full language
            $temp_array[1] = substr($language_list, 0, 2);
            // cut out primary language
            //place this array into main $user_languages language array
            $user_languages[] = $temp_array;
        }
        //start going through each one
        for ($i = 0; $i < count($user_languages); $i++) {
            foreach ($a_languages as $index => $complete) {
                if ($index == $user_languages[$i][0]) {
                    // complete language, like english (canada)
                    $user_languages[$i][2] = $complete;
                    // extract working language, like english
                    $user_languages[$i][3] = substr($complete, 0, strcspn($complete, ' ('));
                }
            }
        }
    } else {
        $user_languages[0] = array('', '', '', '');
        //return blank array.
    }
    // print_r($user_languages);
    // return parameters
    if ($feature == 'data') {
        return $user_languages;
    } elseif ($feature == 'header') {
        switch ($user_languages[0][1]) {
            case 'en':
                $location = 'english.php';
                $found = true;
                break;
            case 'sp':
                $location = 'spanish.php';
                $found = true;
                break;
            default:
                break;
        }
        if ($found) {
            header("Location: {$location}");
        } else {
            header("Location: default.php");
        }
    }
}
Example #22
0
 function parseLanguage($file)
 {
     $tab = array();
     $cnt = fgc($file);
     $sentences = explode('@@@', $cnt);
     $key = null;
     if (count($sentences)) {
         foreach ($sentences as $sentence) {
             $sentence = trim($sentence);
             $rows = explode("\n", $sentence);
             if (count($rows)) {
                 foreach ($rows as $row) {
                     $row = trim($row);
                     if (!contain('[:', $row)) {
                         $key = $row;
                     } else {
                         $lng = Utils::cut('[:', ':]', $row);
                         $translation = str_replace("[:{$lng}:]", '', $row);
                         if (!Arrays::exists(Inflector::lower($lng), $tab)) {
                             $tab[Inflector::lower($lng)] = array();
                         }
                         $tab[Inflector::lower($lng)][sha1($key)] = $translation;
                     }
                 }
             }
         }
     }
     foreach ($tab as $lng => $sentences) {
         $setter = setter($lng);
         languages()->{$setter}($sentences);
     }
 }
Example #23
0
function get_languages($feature, $spare = '')
{
    // get the languages
    $a_languages = languages();
    $index = '';
    $complete = '';
    $found = false;
    // set to default value
    //prepare user language array
    $user_languages = array();
    //check to see if language is set
    if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
        //explode languages into array
        $languages = strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
        $languages = explode(",", $languages);
        foreach ($languages as $language_list) {
            // pull out the language, place languages into array of full and primary
            // string structure:
            $temp_array = array();
            // slice out the part before ; on first step, the part before - on second, place into array
            $temp_array[0] = substr($language_list, 0, strcspn($language_list, ';'));
            //full language
            $temp_array[1] = substr($language_list, 0, 2);
            // cut out primary language
            //place this array into main $user_languages language array
            $user_languages[] = $temp_array;
        }
        //start going through each one
        for ($i = 0; $i < count($user_languages); $i++) {
            foreach ($a_languages as $index => $complete) {
                if ($index == $user_languages[$i][0]) {
                    // complete language, like english (canada)
                    $user_languages[$i][2] = $complete;
                    // extract working language, like english
                    $user_languages[$i][3] = substr($complete, 0, strcspn($complete, ' ('));
                }
            }
        }
    } else {
        $user_languages[0] = array('', '', '', '');
        //return blank array.
    }
    // return parameters
    if ($feature == 'data') {
        return $user_languages;
    } elseif ($feature == 'header') {
        switch ($user_languages[0][1]) {
            case 'pt':
                $lang = 'Portugues';
                $found = false;
                break;
            case 'pt-br':
                $lang = 'Portugues';
                $found = false;
                break;
            case 'en':
                $lang = 'English';
                $found = true;
                break;
            case 'nl':
                $lang = 'Dutch';
                $found = true;
                break;
            case 'fr':
                $lang = 'French';
                $found = true;
                break;
            default:
                break;
        }
        if ($found) {
            return $lang;
        } else {
            return "English";
        }
    }
}
Example #24
0

  var max_fields      = 30; //maximum input boxes allowed
  var wrapper         = $(".input_fields_wrap"); //Fields wrapper
  var add_button      = $(".add_field_button"); //Add button ID
  
  var x = 20; //initlal text box count
  $(add_button).click(function(e){ //on add input button click
      e.preventDefault();
      if(x < max_fields){ //max input box allowed
          x++; //text box increment
          var html = '<div id="item"><div class="form-group"><label class="col-sm-3 control-label"><?php 
echo lang('language');
?>
</label><div class="col-sm-2"><select name="description['+x+'][lang]" size="1" class="form-control input-sm"><?php 
foreach (languages() as $key => $value) {
    ?>
<option value="<?php 
    echo $value["code"];
    ?>
"><?php 
    echo $value["name"];
    ?>
</option><?php 
}
?>
</select></div><div class="col-sm-4"><a class="btn btn-xs btn-danger remove_field" href="#"><?php 
echo lang('remove');
?>
</a></div></div><div class="form-group"><label class="col-sm-3 control-label"><?php 
echo lang('description');
Example #25
0
 public function edit($data, $field, $newdata, $olddata, $object)
 {
     if (isset($field['translatable']) && $field['translatable']) {
         foreach (languages() as $key => $lang) {
             $data[strval($field['name']) . '_' . $key] = $this->correctURL($newdata[strval($field['name']) . '_' . $key]);
         }
     } else {
         $data[strval($field['name'])] = $this->correctURL($newdata[strval($field['name'])]);
     }
     return $data;
 }
Example #26
0
<?php

/*
    Filters
*/
Route::action('check', function () {
    /* Check if you have installed credit to Striker */
    if (file_exists(APP . 'install.lock')) {
        return Layout::create('installed', array('installed' => true));
    }
});
/*
    Start (Language Select)
*/
Route::get(array('/', 'start'), array('before' => 'check', 'main' => function () {
    $vars['languages'] = languages();
    $vars['prefered_languages'] = prefered_languages();
    $vars['timezones'] = timezones();
    $vars['current_timezone'] = current_timezone();
    return Layout::create('start', $vars);
}));
Route::post('start', array('before' => 'check', 'main' => function () {
    $i18n = Input::get(array('language', 'timezone'));
    $validator = new Validator($i18n);
    $validator->check('language')->is_max(2, 'Please select a language');
    $validator->check('timezone')->is_max(2, 'Please select a timezone');
    if ($errors = $validator->errors()) {
        Input::flash();
        Notify::error($errors);
        return Response::redirect('start');
    }
Example #27
0
 public static function determine_language()
 {
     // If multilanguage, determine current language. Redirect to appropriate language if unable to determine.
     if (count(languages()) > 1) {
         $language_codes = array_keys(languages());
         if ($countries = Config::countries()) {
             $language_codes = array_keys($countries);
         }
         $language_values = languages();
         if ($countries) {
             $language_values = $countries;
         }
         $site = current_site();
         $url_key = 'url_' . reset($language_codes);
         if ($site->{$url_key} && false === stristr($_SERVER['HTTP_HOST'], '.fw4.be')) {
             foreach ($language_codes as $lang) {
                 $url_key = 'url_' . $lang;
                 if ($_SERVER['HTTP_HOST'] == $site->{$url_key}) {
                     if ($countries) {
                         self::set_language($countries[$lang]);
                         self::set_country($lang);
                     } else {
                         self::set_language($lang);
                     }
                     break;
                 }
             }
         } else {
             foreach ($language_codes as $lang) {
                 if (segment(0) == $lang) {
                     if ($countries) {
                         self::set_country(array_shift(self::$segments));
                         self::set_language($countries[country()]);
                     } else {
                         self::set_language(array_shift(self::$segments));
                     }
                     break;
                 }
             }
         }
         if (!language()) {
             if (isset($_COOKIE['language']) && isset($language_values[$_COOKIE['language']])) {
                 $language = $_COOKIE['language'];
             } else {
                 if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && ($negotiated = self::prefered_language($language_codes))) {
                     $language = $negotiated;
                 } else {
                     $language = array_shift($language_codes);
                 }
             }
             if ($countries) {
                 self::set_country($language);
                 self::set_language($countries[$language]);
             } else {
                 self::set_language($language);
             }
             return false;
         }
         if (!isset($_COOKIE['language']) || $_COOKIE['language'] != language_identifier()) {
             setcookie('language', language_identifier(), time() + 60 * 60 * 24 * 30 * 24, '/');
         }
     } else {
         $languages = array_keys(languages());
         self::set_language(array_shift($languages));
         // If single language, define it.
     }
     return true;
 }
Example #28
0
/**
 * Generates a &lt;table&gt; of every language that Textpattern supports.
 *
 * If requested with HTTP POST parameter 'force' set anything other than 'file',
 * outputs any errors in RPC server connection.
 *
 * @param string|array $message The activity message
 */
function list_languages($message = '')
{
    require_once txpath . '/lib/IXRClass.php';
    $active_lang = safe_field("val", 'txp_prefs', "name = 'language'");
    $lang_form = tag(form(tag(gTxt('active_language'), 'label', array('for' => 'language')) . languages('language', $active_lang) . eInput('lang') . sInput('save_language')), 'div', array('class' => 'txp-control-panel'));
    $client = new IXR_Client(RPC_SERVER);
    //    $client->debug = true;
    $available_lang = array();
    $rpc_connect = false;
    $show_files = false;
    // Get items from RPC.
    @set_time_limit(90);
    // TODO: 90 seconds: seriously?
    if ($client->query('tups.listLanguages', get_pref('blog_uid'))) {
        $rpc_connect = true;
        $response = $client->getResponse();
        foreach ($response as $language) {
            $available_lang[$language['language']]['rpc_lastmod'] = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year);
        }
    } elseif (gps('force') != 'file') {
        $msg = gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->";
    }
    // Get items from Filesystem.
    $files = get_lang_files();
    if (is_array($files) && !empty($files)) {
        foreach ($files as $file) {
            if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) {
                $name = preg_replace('/\\.(txt|textpack)$/i', '', $file);
                $firstline = fgets($fp, 4069);
                fclose($fp);
                if (strpos($firstline, '#@version') !== false) {
                    @(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1)))));
                } else {
                    $fversion = $ftime = null;
                }
                $available_lang[$name]['file_note'] = isset($fversion) ? $fversion : 0;
                $available_lang[$name]['file_lastmod'] = isset($ftime) ? $ftime : 0;
            }
        }
    }
    // Get installed items from the database.
    // We need a value here for the language itself, not for each one of the rows.
    $rows = safe_rows("lang, UNIX_TIMESTAMP(MAX(lastmod)) AS lastmod", 'txp_lang', "1 = 1 GROUP BY lang ORDER BY lastmod DESC");
    $installed_lang = array();
    foreach ($rows as $language) {
        $available_lang[$language['lang']]['db_lastmod'] = $language['lastmod'];
        if ($language['lang'] != $active_lang) {
            $installed_lang[] = $language['lang'];
        }
    }
    $list = '';
    // Create the language table components.
    foreach ($available_lang as $langname => $langdat) {
        $file_updated = isset($langdat['db_lastmod']) && @$langdat['file_lastmod'] > $langdat['db_lastmod'];
        $rpc_updated = @$langdat['rpc_lastmod'] > @$langdat['db_lastmod'];
        $rpc_install = tda($rpc_updated ? strong(eLink('lang', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']), '')) . n . span(safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']), array('class' => 'date modified')) : (isset($langdat['rpc_lastmod']) ? gTxt('up_to_date') : '-') . (isset($langdat['db_lastmod']) ? n . span(safe_strftime('%d %b %Y %X', $langdat['db_lastmod']), array('class' => 'date modified')) : ''), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-value"' : ' class="lang-value"');
        $lang_file = tda(isset($langdat['file_lastmod']) ? strong(eLink('lang', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file', '')) . n . span(safe_strftime(get_pref('archive_dateformat'), $langdat['file_lastmod']), array('class' => 'date ' . ($file_updated ? 'created' : 'modified'))) : '-', ' class="lang-value languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"');
        $list .= tr(hCell(gTxt($langname), '', isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-label" scope="row"' : ' class="lang-label" scope="row"') . n . $rpc_install . n . $lang_file . tda(in_array($langname, $installed_lang) ? dLink('lang', 'remove_language', 'lang_code', $langname, 1) : '-', ' class="languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"')) . n;
    }
    // Output table and content.
    pagetop(gTxt('tab_languages'), $message);
    echo n . tag(hed(gTxt('tab_languages'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => 'language_container'));
    if (isset($msg) && $msg) {
        echo graf('<span class="ui-icon ui-icon-closethick"></span> ' . $msg, array('class' => 'alert-block error'));
    }
    echo $lang_form, n . tag(toggle_box('languages_detail'), 'div', array('class' => 'txp-list-options')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(hCell(gTxt('language'), '', ' scope="col"') . hCell(gTxt('from_server') . popHelp('install_lang_from_server'), '', ' scope="col"') . hCell(gTxt('from_file') . popHelp('install_lang_from_file'), '', ' class="languages_detail" scope="col"') . hCell(gTxt('remove_lang') . popHelp('remove_lang'), '', ' class="languages_detail" scope="col"')) . n . tag_end('thead') . n . tag_start('tbody') . $list . n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . hed(gTxt('install_from_textpack'), 2) . n . tag(form('<label for="textpack-install">' . gTxt('install_textpack') . '</label>' . popHelp('get_textpack') . n . '<textarea class="code" id="textpack-install" name="textpack" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '" dir="ltr"></textarea>' . fInput('submit', 'install_new', gTxt('upload')) . eInput('lang') . sInput('get_textpack'), '', '', 'post', '', '', 'text_uploader'), 'div', array('class' => 'txp-control-panel')) . n . tag_end('div');
}
Example #29
0
/**
 * Validate languages
 *
 * @return string
 */
function validateLangs()
{
    return implode(',', languages());
}