public function content_stylesheets($format = 'tinymce', $name = 'content', $merge = false, $ws_theme = null)
 {
     global $theme;
     if (empty($ws_theme)) {
         $ws_theme = $theme;
         if ($this->theme != $theme->name) {
             $ws_theme = new theme();
             $ws_theme->load($this->theme);
         }
     }
     // determine stylesheets for content (website > theme + default navigate cms)
     $content_css = array();
     $content_css[] = NAVIGATE_URL . '/css/tools/tinymce.defaults.css';
     // deprecated field (will be removed at some time)
     if (!empty($this->tinymce_css)) {
         $content_css[] = $this->tinymce_css . '?bogus=' . time();
     }
     if (!empty($this->theme) && !empty($ws_theme)) {
         $style = "";
         if (isset($this->theme_options->style)) {
             $style = @$this->theme_options->style;
         }
         if (empty($style)) {
             $theme_styles = get_object_vars($ws_theme->styles);
             $theme_styles = array_values($theme_styles);
             $style = $theme_styles[0]->name;
         }
         if ($name == 'content_selectable' && !isset($ws_theme->styles->{$style}->{$name}) || empty($name)) {
             $name = 'content';
         }
         if (!empty($style) && !empty($ws_theme->styles->{$style}->{$name})) {
             $style_content_css = explode(',', $ws_theme->styles->{$style}->{$name});
             foreach ($style_content_css as $scc) {
                 if (strpos($scc, 'http') === false) {
                     $content_css[] = NAVIGATE_URL . '/themes/' . $this->theme . '/' . $scc . '?bogus=' . time();
                 } else {
                     $content_css[] = $scc;
                 }
             }
         }
     }
     $merge = false;
     // MERGE option is not completely developed
     if ($merge) {
         /*
         $css_merged_rules = '';
         $css_merged_file = 'cache/'.$website->id.'/editor_css.'.md5(json_encode($content_css)).'.css';
         
         foreach($content_css as $csa)
                     {
         	            $css_rules = @file_get_contents($csa);
                         $css_merged_rules .= $css_rules;
                     }
         
         mkdir(NAVIGATE_PATH.'/cache/'.$website->id, 0755, true);
         
         file_put_contents(NAVIGATE_PATH.'/'.$css_merged_file, $css_merged_rules);
         
         if(!empty($css_merged))
         {
         			    if($format=='link_tag')
         				    $content_css = '<link rel="stylesheet" type="text/css" href="'.NAVIGATE_URL.'/'.$css_merged_file.'" />'."\n";
         			    else
         				    $content_css = NAVIGATE_URL.'/'.$css_merged_file;
         }
         else
         			    $content_css = '';
         */
     } else {
         if ($format == 'link_tag') {
             $content_html = '';
             foreach ($content_css as $csa) {
                 if (!empty($csa)) {
                     $content_html .= '<link rel="stylesheet" type="text/css" href="' . trim($csa) . '" />' . "\n";
                 }
             }
             $content_css = $content_html;
         } else {
             if ($format == 'array') {
                 // do nothing, already an array
             } else {
                 $content_css = implode(',', $content_css);
             }
         }
     }
     return $content_css;
 }
示例#2
0
function process()
{
    global $DB;
    global $website;
    global $events;
    global $theme;
    set_time_limit(0);
    setlocale(LC_ALL, $_SESSION['navigate_install_locale']);
    $lang = navigate_install_load_language();
    switch ($_REQUEST['process']) {
        case 'verify_zip':
            sleep(1);
            if (!file_exists('package.zip')) {
                die(json_encode($lang['missing_package']));
            } else {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') !== TRUE) {
                    die(json_encode($lang['invalid_package']));
                } else {
                    $zip->close();
                    die(json_encode(true));
                }
            }
            break;
        case 'extract_zip':
            $npath = getcwd() . NAVIGATE_FOLDER;
            $npath = str_replace('\\', '/', $npath);
            if (!file_exists($npath)) {
                mkdir($npath);
            }
            if (file_exists($npath)) {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') === TRUE) {
                    $zip->extractTo($npath);
                    $zip->close();
                    copy($npath . '/crossdomain.xml', dirname($npath) . '/crossdomain.xml');
                    die(json_encode(true));
                } else {
                    die(json_encode($lang['extraction_failed']));
                }
            }
            die(json_encode($lang['folder_not_exists']));
            break;
        case 'chmod':
            sleep(1);
            // chmod the directories recursively
            $npath = getcwd() . NAVIGATE_FOLDER;
            if (!navigate_install_chmodr($npath, 0755)) {
                die(json_encode($lang['chmod_failed']));
            } else {
                die(json_encode(true));
            }
            break;
        case 'verify_database':
            if ($_REQUEST['PDO_DRIVER'] == 'mysql' || $_REQUEST['PDO_DRIVER'] == 'mysql-socket') {
                try {
                    $dsn = "mysql:host=" . $_REQUEST['PDO_HOSTNAME'] . ";port=" . $_REQUEST['PDO_PORT'] . ';charset=utf8';
                    if ($_REQUEST['PDO_DRIVER'] == "mysql-socket") {
                        $dsn = "mysql:unix_socket=" . $_REQUEST['PDO_SOCKET'] . ";charset=utf8";
                    }
                    $db_test = @new PDO($dsn, $_REQUEST['PDO_USERNAME'], $_REQUEST['PDO_PASSWORD']);
                    if (!$db_test) {
                        echo json_encode(array('error' => $lang['database_connect_error']));
                    } else {
                        $create_database_privilege = false;
                        $drop_database_privilege = false;
                        $stm = $db_test->query('SHOW DATABASES;');
                        $rs = $stm->fetchAll(PDO::FETCH_COLUMN, 'Database');
                        $rs = array_diff($rs, array('mysql', 'information_schema'));
                        $stm = $db_test->query('SHOW PRIVILEGES;');
                        $privileges = $stm->fetchAll(PDO::FETCH_ASSOC);
                        for ($p = 0; $p < count($privileges); $p++) {
                            if ($privileges[$p]['Privilege'] == 'Create') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $create_database_privilege = true;
                                }
                            }
                            if ($privileges[$p]['Privilege'] == 'Drop') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $drop_database_privilege = true;
                                }
                            }
                        }
                        if ($create_database_privilege && $drop_database_privilege) {
                            // check if we are really allowed to create databases
                            $dbname = 'navigate_test_' . time();
                            $create_result = $db_test->exec('CREATE DATABASE ' . $dbname);
                            if ($create_result) {
                                $db_test->exec('DROP DATABASE ' . $dbname);
                            }
                            if (!$create_result) {
                                $create_database_privilege = false;
                            }
                        }
                        $db_test = NULL;
                        echo json_encode(array('databases' => array_values($rs), 'create_database_privilege' => $create_database_privilege));
                    }
                } catch (Exception $e) {
                    echo json_encode(array('error' => $e->getMessage()));
                }
            } else {
                echo json_encode(array('error' => $lang['database_driver_error']));
            }
            exit;
            break;
        case 'database_create':
            $DB = new database();
            if (!$DB->connect()) {
                // try to create the database automatically
                if (PDO_DRIVER == 'mysql') {
                    if (PDO_DATABASE != '') {
                        if (PDO_HOSTNAME != "") {
                            $dsn = "mysql:host=" . PDO_HOSTNAME . ";port=" . PDO_PORT . ";charset=utf8";
                        } else {
                            $dsn = "mysql:unix_socket=" . PDO_SOCKET . ";charset=utf8";
                        }
                        $db_test = new PDO($dsn, PDO_USERNAME, PDO_PASSWORD);
                        $db_test->exec('CREATE DATABASE IF NOT EXISTS `' . PDO_DATABASE . '` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
                        $db_test = NULL;
                    }
                    if (!$DB->connect()) {
                        echo json_encode(array('error' => $DB->get_last_error()));
                    } else {
                        echo json_encode(array('ok' => $lang['database_created']));
                    }
                }
            } else {
                echo json_encode(array('ok' => $lang['database_exists']));
            }
            exit;
            break;
        case 'database_import':
            $DB = new database();
            if (!$DB->connect()) {
                die(json_encode(array('error' => $DB->get_last_error())));
            }
            try {
                $sql = file_get_contents('navigate.sql');
                $sql = str_replace("{#!NAVIGATE_FOLDER!#}", NAVIGATE_PARENT . NAVIGATE_FOLDER, $sql);
                $sql = explode("\n\n", $sql);
                // can't do it in one step => SQLSTATE[HY000]: General error: 2014
                foreach ($sql as $sqlline) {
                    $sqlline = trim($sqlline);
                    if (empty($sqlline)) {
                        continue;
                    }
                    if (!@$DB->execute($sqlline)) {
                        $error = $DB->get_last_error();
                    }
                    if (!empty($error)) {
                        break;
                    }
                }
            } catch (Exception $e) {
                $error = $e->getMessage();
            }
            if (!empty($error) && false) {
                echo json_encode(array('error' => $error));
            } else {
                echo json_encode(array('ok' => $lang['done']));
            }
            exit;
            break;
        case 'create_account':
            // create admin
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                $user = new user();
                $user->id = 0;
                $user->username = $_SESSION['NAVIGATE-SETUP']['ADMIN_USERNAME'];
                $user->set_password($_SESSION['NAVIGATE-SETUP']['ADMIN_PASSWORD']);
                $user->email = $_SESSION['NAVIGATE-SETUP']['ADMIN_EMAIL'];
                $user->profile = 1;
                $user->skin = 'cupertino';
                $user->language = $_SESSION['navigate_install_lang'];
                $user->blocked = 0;
                $user->timezone = 'UTC';
                $user->date_format = 'Y-m-d H:i';
                $user->decimal_separator = ',';
                $user->thousands_separator = '';
                $user->attempts = 0;
                $user->cookie_hash = '';
                $user->activation_key = '';
                $ok = $user->insert();
                if (!$ok) {
                    throw new Exception($lang['error']);
                }
                // create default website details
                $website = new website();
                $website->create_default();
                $_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT'] = $website->id;
                echo json_encode(array('ok' => $lang['done']));
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'install_default_theme':
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                if (@$_SESSION['NAVIGATE-SETUP']['DEFAULT_THEME'] == 'theme_kit') {
                    $website = new website();
                    $website->load($_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT']);
                    $website->theme = 'theme_kit';
                    $website->languages = array('en' => array('language' => 'en', 'variant' => '', 'code' => 'en', 'system_locale' => 'en_US.utf8'), 'es' => array('language' => 'es', 'variant' => '', 'code' => 'es', 'system_locale' => 'es_ES.utf8'));
                    $website->languages_published = array('en', 'es');
                    $website->save();
                    // default objects (first user, no events bound...)
                    $user = new user();
                    $user->load(1);
                    $events = new events();
                    $zip = new ZipArchive();
                    $zip_open_status = $zip->open(NAVIGATE_PATH . '/themes/theme_kit.zip');
                    if ($zip_open_status === TRUE) {
                        $zip->extractTo(NAVIGATE_PATH . '/themes/theme_kit');
                        $zip->close();
                        $theme = new theme();
                        $theme->load('theme_kit');
                        $theme->import_sample($website);
                    }
                    echo json_encode(array('ok' => $lang['done']));
                } else {
                    // user does not want to install the default theme
                    echo json_encode(array('ok' => $lang['not_selected']));
                }
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'apache_htaccess':
            try {
                $nvweb = dirname($_SERVER['REQUEST_URI']) . NAVIGATE_FOLDER . '/web/nvweb.php';
                $nvweb = str_replace('//', '/', $nvweb);
                $data = array();
                $data[] = 'Options +FollowSymLinks';
                $data[] = 'Options -Indexes';
                $data[] = 'RewriteEngine On';
                $data[] = 'RewriteBase /';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
                $data[] = 'RewriteRule ^(.+) ' . $nvweb . '?route=$1 [QSA]';
                $data[] = 'RewriteRule ^$ ' . $nvweb . '?route=nv.empty [L,QSA]';
                $ok = @file_put_contents(dirname(NAVIGATE_PATH) . '/.htaccess', implode("\n", $data));
                if (!$ok) {
                    throw new Exception($lang['unexpected_error']);
                }
                echo json_encode('true');
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
    }
}
 public function load_from_webuser($property_id, $webuser_id = null)
 {
     global $website;
     global $theme;
     global $webuser;
     $wu = $webuser;
     if (!empty($webuser_id)) {
         $wu = new webuser();
         $wu->load($webuser_id);
     }
     $ws = $website;
     $ws_theme = $theme;
     if ($wu->website != $website->id) {
         $ws = new website();
         $ws->load($wu->website);
         $ws_theme = new theme();
         $ws_theme->load($ws->theme);
     }
     if (empty($ws_theme->webusers['properties'])) {
         $ws_theme->webusers['properties'] = array();
     }
     foreach ($ws_theme->webusers['properties'] as $to) {
         if ($to->id == $property_id || $to->name == $property_id) {
             $webuser_option = $to;
             $webuser_option->element = 'webuser';
             break;
         }
     }
     $this->id = $webuser_option->id;
     $this->website = $ws->id;
     $this->element = $webuser_option->element;
     $this->template = '';
     $this->name = $webuser_option->name;
     $this->type = $webuser_option->type;
     $this->options = (array) $webuser_option->options;
     $this->dvalue = $webuser_option->dvalue;
     // default value
     $this->width = $webuser_option->width;
     $this->multilanguage = $webuser_option->multilanguage;
     $this->helper = $webuser_option->helper;
     $this->function = $webuser_option->function;
     $this->conditional = $webuser_option->conditional;
     $this->position = 0;
     $this->enabled = 1;
     // decimal format extra fields
     $this->precision = $webuser_option->precision;
     $this->prefix = $webuser_option->prefix;
     $this->suffix = $webuser_option->suffix;
     if (substr($this->name, 0, 1) == '@') {
         // get translation from theme dictionary
         $this->name = $ws_theme->t(substr($this->name, 1));
     }
     if (substr($this->helper, 0, 1) == '@') {
         $this->helper = $ws_theme->t(substr($this->helper, 1));
     }
     $values = property::load_properties_associative('webuser', '', 'webuser', $wu->id);
     $this->value = $values[$this->id];
     if (is_null($this->value) && !empty($this->dvalue)) {
         $this->value = $this->dvalue;
     }
     if (is_object($this->value)) {
         $this->value = (array) $this->value;
     }
 }
function navigate_property_layout_field($property, $object = "", $website_id = "")
{
    global $website;
    global $layout;
    global $theme;
    global $user;
    global $DB;
    $ws = $website;
    $ws_theme = $theme;
    if (!empty($website_id) && $website_id != $website->id) {
        $ws = new website();
        $ws->load($website_id);
        $ws_theme = new theme();
        $ws_theme->load($ws->theme);
    }
    // object used for translations (theme or extension)
    if (empty($object)) {
        $object = $ws_theme;
    }
    $naviforms = new naviforms();
    $langs = $ws->languages_list;
    $field = array();
    if (!isset($property->value)) {
        $property->value = $property->dvalue;
    }
    if (!isset($property->multilanguage)) {
        $property->multilanguage = 'false';
    }
    $property_name = $property->name;
    if (!empty($object)) {
        $property_name = $object->t($property_name);
    }
    if (in_array($property->type, array("text", "textarea", "rich_textarea", "link")) || $property->multilanguage == 'true') {
        if (!isset($property->multilanguage) || $property->multilanguage !== false || $property->multilanguage == "false") {
            $property->multilanguage = 'true';
        } else {
            $property->multilanguage = 'false';
        }
        if (is_object($property->value)) {
            $property->value = (array) $property->value;
        }
        if (!is_array($property->value)) {
            $property->value = array();
        }
        foreach ($langs as $lang) {
            if (!isset($property->value[$lang]) && isset($property->dvalue)) {
                $property->value[$lang] = $property->dvalue;
            }
        }
    }
    // auto show/hide properties by other properties values --> "conditional": [ { "source_property_id" : [value1,"value2"] } ]
    if (!empty($property->conditional)) {
        foreach ($property->conditional as $conditional) {
            foreach ($conditional as $conditional_property => $conditional_values) {
                if (!is_array($conditional_values)) {
                    $conditional_values = array($conditional_values);
                }
                $conditional_values = '["' . implode('", "', $conditional_values) . '"]';
                $layout->add_script('
                    navigate_tabform_conditional_property("' . $property->id . '", "' . $conditional_property . '", ' . $conditional_values . ');
                ');
            }
        }
    }
    switch ($property->type) {
        case 'value':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->textfield("property-" . $property->id, $property->value);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'decimal':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->decimalfield("property-" . $property->id, $property->value, $property->precision, $user->decimal_separator, $user->thousands_separator, @$property->prefix, @$property->suffix);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'rating':
            $default = explode('#', $property->dvalue);
            $stars = $default[1];
            if (empty($stars)) {
                $stars = 5;
            }
            $inputs = $stars * 2;
            // half stars ALWAYS enabled
            if ($property->value == $property->dvalue) {
                $property->value = intval($default[0]) * 2;
            }
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '" style=" height: 18px; ">';
            $field[] = '<label>' . $property_name . '</label>';
            for ($i = 1; $i <= $inputs; $i++) {
                $checked = '';
                if ($property->value == $i) {
                    $checked = ' checked="checked" ';
                }
                $field[] = '<input type="radio" name="property-' . $property->id . '" class="star {split:2}" value="' . $i . '" ' . $checked . ' />';
            }
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'boolean':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->checkbox("property-" . $property->id, $property->value == '1');
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'option':
            $options = $property->options;
            if (is_string($options)) {
                $options = mb_unserialize($options);
            } else {
                if (is_object($options)) {
                    $options = (array) $options;
                }
            }
            // translate each option text
            if (!empty($object) && !empty($options)) {
                foreach ($options as $value => $text) {
                    $options[$value] = $object->t($text);
                }
            }
            if (!isset($property->option_html)) {
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
                $field[] = '<label>' . $property_name . '</label>';
                $field[] = $naviforms->selectfield("property-" . $property->id, array_keys($options), array_values($options), $property->value);
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
            } else {
                // each option formatted in a specific html fragment
                if (isset($property->stylesheet)) {
                    $custom_stylesheet = $property->stylesheet;
                    if (strpos($custom_stylesheet, 'http') === false) {
                        $custom_stylesheet = NAVIGATE_URL . '/themes/' . $ws->theme . '/' . $custom_stylesheet . '?bogus=' . time();
                    }
                    $layout->add_style_tag($custom_stylesheet, false);
                    if (empty($options)) {
                        $custom_stylesheet_contents = file_get_contents(NAVIGATE_PATH . '/themes/' . $ws->theme . '/' . $property->stylesheet);
                        $custom_stylesheet_contents = stylesheet_parse($custom_stylesheet_contents);
                        $options = array();
                        if (is_array($custom_stylesheet_contents)) {
                            foreach ($custom_stylesheet_contents as $rule => $rule_content) {
                                if (in_array(substr($rule, 0, 1), array('.', '#'))) {
                                    $rule = str_replace(array('.', '#', ':before', ':after', ':focus', ':visited'), '', $rule);
                                    $options[$rule] = $rule;
                                    if (!empty($object)) {
                                        $options[$rule] = $object->t($rule);
                                    }
                                }
                            }
                        }
                    }
                }
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
                $field[] = '<label>' . $property_name . '</label>';
                $field[] = $naviforms->selectfield("property-" . $property->id, array_keys($options), array_values($options), $property->value, NULL, false, NULL, NULL, false, false);
                $layout->add_script('
					$("#property-' . $property->id . '").select2(
				        {
				            selectOnBlur: true,
				            minimumResultsForSearch: 6,
							escapeMarkup: function (markup)
					        {
					            return markup; // let our custom formatter work
					        },
					        templateSelection: function(row)
					        {					        
					            var option_html = "' . str_replace('"', '\\"', $property->option_html) . '";
					            option_html = option_html.replace(/{{VALUE}}/g, row.id);
					            option_html = option_html.replace(/{{TEXT}}/g, row.text);
					        
					            if(row.id)
					                return option_html;
					            else
					                return "("  + navigate_t(581, "None") + ")";
					        },
					        templateResult: function(data)
					        {
					            var option_html = "' . str_replace('"', '\\"', $property->option_html) . '";
					            option_html = option_html.replace(/{{VALUE}}/g, data.id);
					            option_html = option_html.replace(/{{TEXT}}/g, data.text);
					        
					            if(data.id)
					                return option_html;
					            else
					                return "("  + navigate_t(581, "None") + ")";
					        }
				        }
				    );
			    ');
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
            }
            break;
        case 'moption':
            $options = $property->options;
            if (is_string($options)) {
                $options = mb_unserialize($options);
            } else {
                if (is_object($options)) {
                    $options = (array) $options;
                }
            }
            // translate each option text
            if (!empty($object)) {
                foreach ($options as $value => $text) {
                    $options[$value] = $object->t($text);
                }
            }
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->selectfield("property-" . $property->id, array_keys($options), array_values($options), explode(',', $property->value), "", true);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'country':
            $options = property::countries();
            $country_codes = array_keys($options);
            $country_names = array_values($options);
            // include "country not defined" item
            array_unshift($country_codes, '');
            array_unshift($country_names, '(' . t(307, "Unspecified") . ')');
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->selectfield("property-" . $property->id, $country_codes, $country_names, strtoupper($property->value));
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'coordinates':
            $coordinates = explode('#', $property->value);
            $latitude = @$coordinates[0];
            $longitude = @$coordinates[1];
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->textfield("property-" . $property->id . '-latitude', $latitude, '182px');
            $field[] = $naviforms->textfield("property-" . $property->id . '-longitude', $longitude, '182px');
            $field[] = '<img src="img/icons/silk/map_magnify.png" align="absmiddle" hspace="3px" id="property-' . $property->id . '-show" />';
            $field[] = '<div id="property-' . $property->id . '-map-container" style=" display: none; ">';
            $field[] = '	<div class="navigate-form-row" id="property-' . $property->id . '-search" style=" width: 278px; height: 24px; margin-top: 9px; margin-left: 40px; position: absolute; z-index: 1000; opacity: 0.95; ">';
            $field[] = '		<input type="text" name="property-' . $property->id . '-search-text" style=" width: 240px; " /> ';
            $field[] = '		<img class="ui-widget ui-button ui-state-default ui-corner-all" sprite="false" style=" cursor: pointer; padding: 3px; " src="' . NAVIGATE_URL . '/img/icons/silk/zoom.png" align="right" />';
            $field[] = '	</div>';
            $field[] = '	<div id="property-' . $property->id . '-map" style=" width: 400px; height: 200px; "></div>';
            $field[] = '</div>';
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            $layout->add_script('
                // auto parse standard Google Maps URLs when pasting them in the latitude field
                $("#property-' . $property->id . '-latitude").on("keyup", function()
                {
                    var value = $(this).val();                                        
                    if(value.indexOf("https://www.google")==0)
                    {                    
                        // locate the @ symbol
                        value = value.substr(value.indexOf("@")+1);
                        value = value.substr(0, value.indexOf("z"));
                        value = value.split(",");
                                                                        
                        if(value.length == 3) // parsed values seem fine
                        {
                            $("#property-' . $property->id . '-latitude").val(value[0]);                            
                            $("#property-' . $property->id . '-longitude").val(value[1]);                            
                        }
                    }
                });
            ');
            $layout->add_script('
				var property_' . $property->id . '_lmap = null;
			    var marker = null;
			    
			    L.Icon.Default.imagePath = "' . NAVIGATE_URL . '/lib/external/leaflet/images";
			    
			    // initialize leaflet map
                property_' . $property->id . '_lmap = L.map(
                    "property-' . $property->id . '-map",
                    {
                        doubleClickZoom: false
                    }
                );					    
                
                // create the tile layer with correct attribution
                var osmUrl = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
                var osmAttrib = "Map data © <a href=\\"http://openstreetmap.org\\">OpenStreetMap</a> contributors";
                var osm = new L.TileLayer(osmUrl, {minZoom: 0, maxZoom: 19, attribution: osmAttrib });
                
                property_' . $property->id . '_lmap.addLayer(osm);
							
				$("#property-' . $property->id . '-search input").on("keyup", function(e)
				{	if(e.keyCode == 13)	property' . $property->id . 'search();	});
				
				$("#property-' . $property->id . '-search img").on("click", property' . $property->id . 'search);
				
				$("#property-' . $property->id . '-show").on("click", function()
				{
					var myLatlng = new L.LatLng(
					    $("#property-' . $property->id . '-latitude").val(),
					    $("#property-' . $property->id . '-longitude").val()
					);																
												
                    property_' . $property->id . '_lmap.setView(myLatlng, 17);
	                
	                marker = L.marker(myLatlng).addTo(property_' . $property->id . '_lmap);
	                
	                property_' . $property->id . '_lmap.on("dblclick", function(e)
	                {	                    
                        $("#property-' . $property->id . '-latitude").val(e.latlng.lat);
						$("#property-' . $property->id . '-longitude").val(e.latlng.lng)
	                    
	                    marker.remove();
	                    marker = L.marker(e.latlng).addTo(property_' . $property->id . '_lmap);                        
	                });
					                    
					$("#property-' . $property->id . '-map-container").dialog(
					{
						width: 600,
						height: 400,
						title: "' . t(300, 'Map') . ': ' . t(301, 'Double click a place to set the coordinates') . '",
						resize: property' . $property->id . 'resize,
						open: function()
						{
						    $(this).css("padding", 0);
						    property_' . $property->id . '_lmap.invalidateSize();
                        }
                    }).dialogExtend(
					{
						maximizable: true,
						"maximize" : property' . $property->id . 'resize,
						"restore" : property' . $property->id . 'resize
					});
					
					property' . $property->id . 'resize();

				}).css("cursor", "pointer");	
				
				function property' . $property->id . 'resize()
				{
					$("#property-' . $property->id . '-map").width($("#property-' . $property->id . '-map-container").width()); 
					$("#property-' . $property->id . '-map").height($("#property-' . $property->id . '-map-container").height());	
					property_' . $property->id . '_lmap.invalidateSize();
				}
				
				function property' . $property->id . 'search()
				{				
					var address = $("#property-' . $property->id . '-search input").val();

                    $.getJSON("http://services.gisgraphy.com/geocoding/geocode?format=json&callback=?&address="+address, function(data)
                    {                                    
                        if(!data.result || data.result.length < 1)
                            alert("Geocode was not successful for the following reason: " + status);
                        else
                        {
                            property_' . $property->id . '_lmap.setView([data.result[0].lat, data.result[0].lng], 19);
                        }
                    });						        

					return false;
				}		
                
			');
            break;
        case 'text':
            foreach ($langs as $lang) {
                if (!is_array($property->value)) {
                    $ovalue = $property->value;
                    $property->value = array();
                    foreach ($langs as $lang_value) {
                        $property->value[$lang_value] = $ovalue;
                    }
                }
                $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '" lang="' . $lang . '">';
                $field[] = '<label>' . $property_name . ' ' . $language_info . '</label>';
                $field[] = $naviforms->textfield("property-" . $property->id . "-" . $lang, $property->value[$lang]);
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
            }
            break;
        case 'textarea':
            foreach ($langs as $lang) {
                if (!is_array($property->value)) {
                    $ovalue = $property->value;
                    $property->value = array();
                    foreach ($langs as $lang_value) {
                        $property->value[$lang_value] = $ovalue;
                    }
                }
                $style = "";
                if (!empty($property->width)) {
                    $style = ' width: ' . $property->width . 'px; ';
                }
                $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
                if ($property->multilanguage == 'false') {
                    $language_info = '';
                }
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '" lang="' . $lang . '">';
                $field[] = '<label>' . $property_name . ' ' . $language_info . '</label>';
                $field[] = $naviforms->textarea("property-" . $property->id . "-" . $lang, $property->value[$lang], 4, 48, $style);
                $field[] = '<button class="navigate-form-row-property-action" data-field="property-' . $property->id . '-' . $lang . '" data-action="copy-from" title="' . t(189, 'Copy from') . '…"><img src="img/icons/silk/page_white_copy.png" align="absmiddle"></button>';
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
                if ($property->multilanguage == 'false') {
                    break;
                }
            }
            break;
        case 'rich_textarea':
            foreach ($langs as $lang) {
                if (!is_array($property->value)) {
                    $ovalue = $property->value;
                    $property->value = array();
                    foreach ($langs as $lang_value) {
                        $property->value[$lang_value] = $ovalue;
                    }
                }
                $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
                if ($property->multilanguage == 'false') {
                    $language_info = '';
                }
                $width = NULL;
                if (!empty($property->width)) {
                    $width = $property->width . 'px';
                }
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '" lang="' . $lang . '">';
                $field[] = '<label>' . $property_name . ' ' . $language_info . '</label>';
                $field[] = $naviforms->editorfield("property-" . $property->id . "-" . $lang, $property->value[$lang], $width, NULL, $website_id);
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                // additional control buttons
                $translate_menu = '';
                if (!empty($translate_extensions)) {
                    $translate_extensions_titles = array();
                    $translate_extensions_actions = array();
                    foreach ($translate_extensions as $te) {
                        if ($te['enabled'] == '0') {
                            continue;
                        }
                        $translate_extensions_titles[] = $te['title'];
                        $translate_extensions_actions[] = 'javascript: navigate_tinymce_translate_' . $te['code'] . '(\'property-' . $property->id . '-' . $lang . '\', \'' . $lang . '\');';
                    }
                    if (!empty($translate_extensions_actions)) {
                        $translate_menu = $naviforms->splitbutton('translate_' . $lang, '<img src="img/icons/silk/comment.png" align="absmiddle"> ' . t(188, 'Translate'), $translate_extensions_actions, $translate_extensions_titles);
                    }
                }
                $field[] = '<div style="clear:both; margin-top:5px; float:left; margin-bottom: 10px;">';
                $field[] = '<label>&nbsp;</label>';
                $field[] = $translate_menu;
                $field[] = '<button class="navigate-form-row-property-action" data-field="property-' . $property->id . '-' . $lang . '" data-action="copy-from"><img src="img/icons/silk/page_white_copy.png" align="absmiddle">' . t(189, 'Copy from') . '...</button> ';
                $field[] = !empty($theme->content_samples) ? '<button onclick="navigate_items_copy_from_theme_samples(\'property-' . $property->id . '-' . $lang . '\', \'' . $property->id . '\', \'' . $lang . '\', \'tinymce\'); return false;"><img src="img/icons/silk/rainbow.png" align="absmiddle"> ' . t(553, 'Fragments') . ' | ' . $theme->title . '</button> ' : '';
                $field[] = '</div>';
                $field[] = '</div>';
                // divformrow
                if ($property->multilanguage == 'false') {
                    break;
                }
            }
            break;
        case 'color':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->colorfield("property-" . $property->id, $property->value, @$property->options);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'date':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->datefield("property-" . $property->id, $property->value, false);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'datetime':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->datefield("property-" . $property->id, $property->value, true);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'source_code':
            if ($property->multilanguage != 'true' && $property->multilanguage != '1') {
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
                $field[] = '<label>' . $property_name . '</label>';
                $field[] = $naviforms->scriptarea("property-" . $property->id, $property->value);
                $field[] = '&nbsp;<button class="navigate-form-row-property-action" data-field="property-' . $property->id . '-' . $lang . '" data-action="copy-from" title="' . t(189, 'Copy from') . '…"><img src="img/icons/silk/page_white_copy.png" align="absmiddle"></button>';
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
            } else {
                foreach ($langs as $lang) {
                    if (!is_array($property->value)) {
                        $ovalue = $property->value;
                        $property->value = array();
                        foreach ($langs as $lang_value) {
                            $property->value[$lang_value] = $ovalue;
                        }
                    }
                    $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
                    $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '" lang="' . $lang . '">';
                    $field[] = '<label>' . $property_name . ' ' . $language_info . '</label>';
                    $field[] = $naviforms->scriptarea("property-" . $property->id . "-" . $lang, $property->value[$lang]);
                    $field[] = '&nbsp;<button class="navigate-form-row-property-action" data-field="property-' . $property->id . '-' . $lang . '" data-action="copy-from" title="' . t(189, 'Copy from') . '…"><img src="img/icons/silk/page_white_copy.png" align="absmiddle"></button>';
                    if (!empty($property->helper)) {
                        $helper_text = $property->helper;
                        if (!empty($object)) {
                            $helper_text = $object->t($helper_text);
                        }
                        $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                    }
                    $field[] = '</div>';
                }
            }
            break;
        case 'link':
            foreach ($langs as $lang) {
                if (!is_array($property->value)) {
                    $ovalue = $property->value;
                    $property->value = array();
                    foreach ($langs as $lang_value) {
                        $property->value[$lang_value] = $ovalue;
                    }
                }
                $link = explode('##', $property->value[$lang]);
                if (is_array($link)) {
                    $target = @$link[2];
                    $title = @$link[1];
                    $link = $link[0];
                    if (empty($title)) {
                        $title = $link;
                    }
                } else {
                    $title = $property->value[$lang];
                    $link = $property->value[$lang];
                    $target = '_self';
                }
                $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
                if ($property->multilanguage == 'false') {
                    $language_info = '';
                }
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '" lang="' . $lang . '" style="margin-bottom: 0px;">';
                $field[] = '<label>' . $property_name . ' ' . $language_info . '</label>';
                $field[] = $naviforms->textfield("property-" . $property->id . "-" . $lang . "-title", $title);
                $field[] = '<span class="navigate-form-row-info">' . t(67, 'Title') . '</span>';
                $field[] = '</div>';
                $field[] = '<div class="navigate-form-row" lang="' . $lang . '" style="margin-bottom: 0px;" nv_property="' . $property->id . '" >';
                $field[] = '<label>&nbsp;</label>';
                $field[] = $naviforms->textfield("property-" . $property->id . "-" . $lang . "-link", $link);
                $field[] = '<span class="navigate-form-row-info">' . t(197, 'Link') . '</span>';
                $field[] = '</div>';
                $field[] = '<div class="navigate-form-row" lang="' . $lang . '" nv_property="' . $property->id . '" >';
                $field[] = '<label>&nbsp;</label>';
                $field[] = $naviforms->selectfield("property-" . $property->id . "-" . $lang . "-target", array('_self', '_blank'), array(t(173, "Follow URL"), t(174, "Open URL (new window)")), $target);
                $field[] = '<span class="navigate-form-row-info">' . t(172, 'Action') . '</span>';
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
                if ($property->multilanguage == 'false') {
                    break;
                }
            }
            break;
        case 'image':
            if ($property->multilanguage != 'true' && $property->multilanguage != '1') {
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
                $field[] = '<label>' . $property_name . '</label>';
                $field[] = $naviforms->dropbox("property-" . $property->id, $property->value, "image", false, @$property->dvalue, @$property->options, $website_id);
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
            } else {
                foreach ($langs as $lang) {
                    if (!is_array($property->value)) {
                        $ovalue = $property->value;
                        $property->value = array();
                        foreach ($langs as $lang_value) {
                            $property->value[$lang_value] = $ovalue;
                        }
                    }
                    $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
                    $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '" lang="' . $lang . '">';
                    $field[] = '<label>' . $property_name . ' ' . $language_info . '</label>';
                    $field[] = $naviforms->dropbox("property-" . $property->id . "-" . $lang, $property->value[$lang], "image", false, @$property->dvalue, $website_id);
                    if (!empty($property->helper)) {
                        $helper_text = $property->helper;
                        if (!empty($object)) {
                            $helper_text = $object->t($helper_text);
                        }
                        $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                    }
                    $field[] = '</div>';
                }
            }
            break;
        case 'video':
            if ($property->multilanguage != 'true' && $property->multilanguage != '1') {
                $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
                $field[] = '<label>' . $property_name . '</label>';
                $field[] = $naviforms->dropbox("property-" . $property->id, $property->value, "video", false, $property->dvalue, $website_id);
                if (!empty($property->helper)) {
                    $helper_text = $property->helper;
                    if (!empty($object)) {
                        $helper_text = $object->t($helper_text);
                    }
                    $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                }
                $field[] = '</div>';
            } else {
                foreach ($langs as $lang) {
                    if (!is_array($property->value)) {
                        $ovalue = $property->value;
                        $property->value = array();
                        foreach ($langs as $lang_value) {
                            $property->value[$lang_value] = $ovalue;
                        }
                    }
                    $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
                    $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
                    $field[] = '<label>' . $property_name . ' ' . $language_info . '</label>';
                    $field[] = $naviforms->dropbox("property-" . $property->id . "-" . $lang, $property->value[$lang], "video", false, $property->dvalue, $website_id);
                    if (!empty($property->helper)) {
                        $helper_text = $property->helper;
                        if (!empty($object)) {
                            $helper_text = $object->t($helper_text);
                        }
                        $field[] = '<div class="subcomment">' . $helper_text . '</div>';
                    }
                    $field[] = '</div>';
                }
            }
            break;
        case 'file':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->dropbox("property-" . $property->id, $property->value, NULL, NULL, NULL, NULL, $website_id);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'comment':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $comment_text = $property->value;
            if (!empty($object)) {
                $comment_text = $object->t($property->value);
            }
            $field[] = '<div class="subcomment" style="clear: none;">' . $comment_text . '</div>';
            $field[] = '</div>';
            break;
        case 'category':
            $hierarchy = structure::hierarchy(0, $website_id);
            $categories_list = structure::hierarchyList($hierarchy, $property->value);
            if (empty($categories_list)) {
                $categories_list = '<ul><li value="0">' . t(428, '(no category)') . '</li></ul>';
            }
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->dropdown_tree("property-" . $property->id, $categories_list, $property->value);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'categories':
            $hierarchy = structure::hierarchy(0, $website_id);
            $selected = explode(',', $property->value);
            if (!is_array($selected)) {
                $selected = array($property->value);
            }
            $categories_list = structure::hierarchyList($hierarchy, $selected);
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = '<div class="category_tree" id="categories-tree-property-' . $property->id . '">
                            <img src="img/icons/silk/world.png" align="absmiddle" /> ' . $ws->name . '<div class="tree_ul">' . $categories_list . '</div>' . '</div>';
            $field[] = $naviforms->hidden('property-' . $property->id, $property->value);
            $field[] = '<label>&nbsp;</label>';
            $field[] = '<button id="categories_tree_select_all_categories-property-' . $property->id . '">' . t(481, 'Select all') . '</button>';
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            $layout->add_script('              
                $("#categories-tree-property-' . $property->id . ' .tree_ul").jstree({
                    plugins: ["changed", "types", "checkbox"],
                    "types" :
                    {
                        "default":  {   "icon": "img/icons/silk/folder.png"    },
                        "leaf":     {   "icon": "img/icons/silk/page_white.png"      }
                    },
                    "checkbox":
                    {
                        three_state: false,
                        cascade: "undetermined"
                    },
                    "core":
                    {
                        dblclick_toggle: false
                    }
                })
                .on("dblclick.jstree", function(e)
                {
                    e.preventDefault();
                    e.stopPropagation();
                
                    var li = $(e.target).closest("li");
                    $("#categories-tree-property-' . $property->id . ' .tree_ul").jstree("open_node", "#" + li[0].id);
                
                    var children_nodes = new Array();
                    children_nodes.push(li);
                    $(li).find("li").each(function() {
                        children_nodes.push("#" + $(this)[0].id);
                    });
                
                    $("#categories-tree-property-' . $property->id . ' .tree_ul").jstree("select_node", children_nodes);
                
                    return false;
                })
                .on("changed.jstree", function(e, data)
                {
                    var i, j, r = [];
                    var categories = new Array();
                    $("#property-' . $property->id . '").val("");       
                
                    for(i = 0, j = data.selected.length; i < j; i++)
                    {
                        var id = data.instance.get_node(data.selected[i]).data.nodeId;
                        categories.push(id);
                    }
                    
                    if(categories.length > 0)
                        $("#property-' . $property->id . '").val(categories);                                                                
                });

                $("#categories_tree_select_all_categories-property-' . $property->id . '").on("click", function(e)
                {
                    e.stopPropagation();
                    e.preventDefault();
                    $("#categories-tree-property-' . $property->id . ' .tree_ul").jstree("select_all");
                    return false;
                });                                
            ');
            break;
        case 'element':
        case 'item':
            $property_item_title = '';
            $property_item_id = '';
            if (!empty($property->value)) {
                $property_item_title = $DB->query_single('text', 'nv_webdictionary', '   node_type = "item" AND
                        website = "' . $ws->id . '" AND
                        node_id = "' . $property->value . '" AND
                        subtype = "title" AND
                        lang = "' . $ws->languages_published[0] . '"');
                $property_item_title = array($property_item_title);
                $property_item_id = array($property->value);
            }
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->selectfield("property-" . $property->id, $property_item_id, $property_item_title, $property->value, null, false, null, null, false);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            $template_filter = @$property->element_template;
            if (empty($template_filter)) {
                $template_filter = $property->item_template;
            }
            $layout->add_script('
                $("#property-' . $property->id . '").select2(
                {
                    placeholder: "' . t(533, "Find element by title") . '",
                    minimumInputLength: 1,
                    ajax: {
                        url: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=items&act=json_find_item",
                        dataType: "json",
                        delay: 100,
                        data: function(params)
                        {
	                        return {
				                title: params.term,
				                template: "' . $template_filter . '",
				                nd: new Date().getTime(),
				                page_limit: 30, // page size
				                page: params.page // page number
				            };
                        },
                        processResults: function (data, params)
				        {
				            params.page = params.page || 1;
				            return {
								results: data.items,
								pagination: { more: (params.page * 30) < data.total_count }
							};
				        }
                    },
                    templateSelection: function(row)
					{
						if(row.id)
							return row.text + " <helper style=\'opacity: .5;\'>#" + row.id + "</helper>";
						else
							return row.text;
					},
					escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
                    triggerChange: true,
                    allowClear: true
                });
            ');
            break;
        case 'elements':
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->textfield("property-" . $property->id);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            $template_filter = @$property->element_template;
            if (empty($template_filter)) {
                $template_filter = $property->item_template;
            }
            $layout->add_script('			                
                $("#property-' . $property->id . '").tagit({
                    removeConfirmation: true,
                    allowSpaces: true,
                    singleField: true,
                    singleFieldDelimiter: ",",
                    placeholderText: "+",
                    autocompleteOnly: true,
                    autocomplete: {
                        delay: 0, 
                        minLength: 1,
                        source: "' . NAVIGATE_URL . '/' . NAVIGATE_MAIN . '?fid=items&act=json_find_item&format=tagit&page_limit=10&template=' . $template_filter . '"
                    },
                    afterTagAdded: function(event, ui)
                    {                           
                        var tags = $(this).tagit("assignedValues");
                        if(tags.length > 0) tags = tags.join(",");
                        else                tags = "";
                            
                        $("#property-' . $property->id . '").val(tags).trigger("change");
                    },
                    afterTagRemoved: function(event, ui)
                    {
                        var tags = $(this).tagit("assignedValues");
                        if(tags.length > 0) tags = tags.join(",");
                        else                tags = "";

                        $("#property-' . $property->id . '").val(tags).trigger("change");
                    }
                });
                                
                $("#property-' . $property->id . '").next().sortable(
                {
                    items: ">li:not(.tagit-new)",
                    update: function(ui, event)
                    {
                        var tags = $("#property-' . $property->id . '").tagit("assignedValues");
                        if(tags.length > 0) tags = tags.join(",");
                        else                tags = "";

                        $("#property-' . $property->id . '").val(tags).trigger("change");
                    }
                });    
			');
            if (!empty($property->value)) {
                $values = explode(",", $property->value);
                $values = array_filter($values);
                foreach ($values as $cid) {
                    $content_title = $DB->query_single('text', 'nv_webdictionary', '   node_type = "item" AND
                        website = "' . $ws->id . '" AND
                        node_id = ' . protect($cid) . ' AND
                        subtype = "title" AND
                        lang = "' . $ws->languages_published[0] . '"');
                    $layout->add_script('
                        $("#property-' . $property->id . '").tagit("createTag", "' . $content_title . '", "", "", "' . $cid . '");                
                    ');
                }
                $layout->add_script('
                    $("#property-' . $property->id . '").trigger("change");
                ');
            }
            break;
        case 'webuser_groups':
            $webuser_groups = webuser_group::all_in_array();
            // to get the array of groups first we remove the "g" character
            $property->value = str_replace('g', '', $property->value);
            $property->value = explode(',', $property->value);
            $field[] = '<div class="navigate-form-row" nv_property="' . $property->id . '">';
            $field[] = '<label>' . $property_name . '</label>';
            $field[] = $naviforms->multiselect('property-' . $property->id, array_keys($webuser_groups), array_values($webuser_groups), $property->value);
            if (!empty($property->helper)) {
                $helper_text = $property->helper;
                if (!empty($object)) {
                    $helper_text = $object->t($helper_text);
                }
                $field[] = '<div class="subcomment">' . $helper_text . '</div>';
            }
            $field[] = '</div>';
            break;
        case 'product':
            // TO DO (when navigate has products!)
            break;
        default:
    }
    return implode("\n", $field);
}
示例#5
0
function themes_grid($list)
{
    global $layout;
    global $website;
    global $user;
    global $current_version;
    $navibars = new navibars();
    $navibars->title(t(367, 'Themes'));
    $marketplace = isset($_REQUEST['marketplace']);
    if ($user->permission("themes.install") == "true") {
        $navibars->add_actions(array('<a href="#" id="theme-upload-button"><img height="16" align="absmiddle" width="16" src="img/icons/silk/package_add.png"> ' . t(461, 'Install from file') . '</a>'));
    }
    $navibars->add_actions(array('<a href="?fid=themes&act=theme_sample_content_export" id="theme-sample-content-export-button"><img height="16" align="absmiddle" width="16" src="img/icons/silk/server_compressed.png"> ' . t(480, 'Export sample content') . '</a>'));
    $grid = new navigrid('themes');
    $grid->set_header('
        <div class="navibrowse-path ui-corner-all">
            <input type="checkbox" id="theme-available-button" /><label for="theme-available-button"><img src="img/icons/silk/rainbow.png" width="16px" height="16px" align="absbottom" /> ' . t(528, 'Available') . '</label>
            ' . ($user->permission("themes.marketplace") == "true" ? '<input type="checkbox" id="theme-marketplace-button" /><label for="theme-marketplace-button"><img src="img/icons/silk/basket.png" width="16px" height="16px" align="absbottom" /> ' . t(527, 'Marketplace') . '</label>' : '') . '
        </div>
	');
    $layout->add_script('
        $("#theme-available-button").button().on("click", function()
        {
            window.location.replace("?fid=themes");
        });
        $("#theme-marketplace-button").button();
        $("#theme-marketplace-button").button().on("click", function()
        {
            window.location.replace("?fid=themes&marketplace");
        });

        $(".navibrowse-path input").removeAttr("checked");
        $("#theme-' . ($marketplace ? 'marketplace' : 'available') . '-button").attr("checked", "checked");
        $("#theme-marketplace-button,#theme-available-button").button("refresh");
    ');
    if (!$marketplace) {
        $grid->item_size(220, 220);
        //$grid->thumbnail_size(138, 150); NV 1.x thumbnail size
        $grid->thumbnail_size(205, 145);
        $grid->highlight_on_click = false;
        $themes = array();
        // current website theme
        if (!empty($website->theme)) {
            $theme = new theme();
            $theme->load($website->theme, true);
            $update_ver = $_SESSION['themes_updates'][$theme->name];
            if (version_compare($update_ver, $theme->version, '<=')) {
                $update_ver = '';
            } else {
                $update_ver = $theme->version . ' &raquo; ' . $update_ver;
            }
            $themes[] = array('id' => $website->theme, 'name' => '<div class="navigrid-themes-title navigrid-themes-installed">' . $theme->title . '</div>', 'thumbnail' => NAVIGATE_URL . '/themes/' . $website->theme . '/thumbnail.png', 'header' => '
                ' . (file_exists(NAVIGATE_PATH . '/themes/' . $website->theme . '/' . $website->theme . '.info.html') ? '<a href="#" class="navigrid-themes-info" theme="' . $website->theme . '" theme-title="' . $theme->title . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/information.png"></a>' : '') . '
                ' . (empty($update_ver) ? '' : '
                    <a href="#" class="navigrid-themes-update" theme="' . $website->theme . '" title="' . t(285, "Update") . ' ' . $update_ver . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/asterisk_orange.png"></a>
                '), 'footer' => '
                    <a href="?fid=websites&act=edit&id=' . $website->id . '&tab=7" class="uibutton navigrid-themes-button navigrid-theme-configure"><img height="16" align="absmiddle" width="16" src="img/icons/silk/wrench_orange.png"> ' . t(200, 'Options') . '</a>
                ' . (!file_exists(NAVIGATE_PATH . '/themes/' . $website->theme . '/' . $website->theme . '_sample.zip') ? '' : '<a href="#" class="uibutton navigrid-themes-button navigrid-theme-install-demo"><img height="16" align="absmiddle" width="16" src="img/icons/silk/wand.png"> ' . t(484, 'Install demo') . '</a>'));
        }
        for ($t = 0; $t < count($list); $t++) {
            if ($website->theme == $list[$t]['code']) {
                continue;
            }
            $update_ver = $_SESSION['themes_updates'][$list[$t]['code']];
            if (version_compare($update_ver, $list[$t]['version'], '<=')) {
                $update_ver = '';
            } else {
                $update_ver = $list[$t]['version'] . ' &raquo; ' . $update_ver;
            }
            $themes[] = array('id' => $list[$t]['code'], 'name' => '<div class="navigrid-themes-title">' . $list[$t]['title'] . '</div>', 'thumbnail' => NAVIGATE_URL . '/themes/' . $list[$t]['code'] . '/thumbnail.png', 'header' => '
                    ' . ($user->permission("themes.delete") == "true" ? '<a href="#" class="navigrid-themes-remove" theme="' . $list[$t]['code'] . '" theme-title="' . $list[$t]['title'] . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"></a>' : '') . '
                    ' . (file_exists(NAVIGATE_PATH . '/themes/' . $list[$t]['code'] . '/' . $list[$t]['code'] . '.info.html') ? '<a href="#" class="navigrid-themes-info" theme="' . $list[$t]['code'] . '" theme-title="' . $list[$t]['title'] . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/information.png"></a>' : '') . '
                    ' . (empty($update_ver) ? '' : '
                    ' . ($user->permission("themes.update") == "true" ? '<a href="#" class="navigrid-themes-update" theme="' . $list[$t]['code'] . '" title="' . t(285, "Update") . ' ' . $update_ver . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/asterisk_orange.png"></a>' : '') . '
                '), 'footer' => '
                    ' . (file_exists(NAVIGATE_PATH . '/themes/' . $list[$t]['code'] . '/demo.html') ? '<a href="' . NAVIGATE_URL . '/themes/' . $list[$t]['code'] . '/demo.html' . '" class="uibutton navigrid-themes-button" target="_blank"><img height="16" align="absmiddle" width="16" src="img/icons/silk/monitor.png"> ' . t(274, 'Preview') . '</a>' : '') . '
                    <a href="#" class="uibutton navigrid-themes-button navigrid-themes-install" theme="' . $list[$t]['code'] . '" target="_blank" style=" margin-left: 5px; "><img height="16" align="absmiddle" width="16" src="img/icons/silk/world_go.png"> ' . t(365, 'Install') . '</a>
                ');
        }
        $grid->items($themes);
        $navibars->add_content($grid->generate());
        $navibars->add_content('
            <div id="navigrid-themes-install-confirmation" title="' . t(59, 'Confirmation') . '" style=" display: none; ">
                ' . t(371, 'Installing a new theme removes the settings of the old one.') . '<br />
                ' . t(372, 'The list of available block types may also change.') . '<br /><br />
                ' . t(373, 'Are you sure you want to continue?') . '
            </div>

            <div id="navigrid-themes-information" title="" style=" display: none; "></div>
        ');
        $navibars->add_content('
            <div id="navigrid-themes-install-demo-confirmation" title="' . t(59, 'Confirmation') . '" style=" display: none; ">
                ' . t(483, 'Do you really want to import the default website for the theme selected?') . '
            </div>');
        $navibars->add_content('
            <div id="navigrid-themes-remove-confirmation" title="' . t(59, 'Confirmation') . '" style=" display: none; ">
                ' . t(57, 'Do you really want to delete the item?') . '
            </div>');
        $navibars->add_content('
            <div id="navigrid-themes-update" title="' . t(285, 'Update') . '" style=" display: none; ">
                <iframe src="about:blank"
                    class="ui-corner-all"
                    border="0" frameborder="0" allowtransparency="true">
                </iframe>
            </div>');
    } else {
        $html = '
            <div class="navibrowse-path ui-corner-all">
                <input type="checkbox" id="theme-available-button" /><label for="theme-available-button"><img src="img/icons/silk/rainbow.png" width="16px" height="16px" align="absbottom" /> ' . t(528, 'Available') . '</label>
                <input type="checkbox" id="theme-marketplace-button" /><label for="theme-marketplace-button"><img src="img/icons/silk/basket.png" width="16px" height="16px" align="absbottom" /> ' . t(527, 'Marketplace') . '</label>
            </div>
        ';
        $html .= '
            <iframe src="http://www.navigatecms.com/en/marketplace/themes"
                    style="visibility: hidden; width: 1px; height: 1px;"
                    class="ui-corner-all"
                    border="0" frameborder="0" allowtransparency="true">
            </iframe>
        ';
        $navibars->add_content('<div id="navigate-content-safe" class="ui-corner-all">' . $html . '</div>');
        $layout->add_script('
            $(window).on("resize focus blur", function()
            {
                $("#navigate-content-safe iframe").css({"width": 1, "height": 1});

                $("#navigate-content-safe iframe").css({
                    padding: "0px 4px",
                    width: $(".navibrowse-path").width() + parseInt($(".navibrowse-path").css("padding-right")) * 2,
                    height: $("#navigate-content-safe").height() - $("#navigate-content-safe div:first").height() - 24,
                    visibility: "visible"
                });
            });

            $("#navigate-content-safe iframe").on("focus blur load", function(){ $(window).trigger("resize");});
        ');
    }
    $layout->add_script('
        function navigatecms_marketplace_install_from_hash(hash)
        {
            window.location.replace("?fid=themes&act=install_from_hash&hash="+hash);
        }

        if(typeof(window.postMessage) != "undefined")
        {
           if(typeof(window.addEventListener) != "undefined")
            {
                window.addEventListener("message", function(event) {
                    navigatecms_marketplace_install_from_hash(event.data);
                }, false);
            }
            else
            {
                window.attachEvent("onmessage", function(e) {
                    navigatecms_marketplace_install_from_hash(e.data);
                });
            }
        }
    ');
    $out = $navibars->generate();
    $layout->add_script('
		$.getScript("lib/packages/themes/themes.js?r=' . $current_version->revision . '", function()
		{
			navigate_themes_init();
		});
	');
    return $out;
}
示例#6
0
function websites_form($item)
{
    global $user;
    global $DB;
    global $layout;
    global $events;
    $navibars = new navibars();
    $naviforms = new naviforms();
    $layout->navigate_media_browser();
    // we want to use media browser in this function
    $layout->navigate_editorfield_link_dialog();
    $theme = new theme();
    if (!empty($item->theme)) {
        $theme->load($item->theme);
    }
    if (empty($item->id)) {
        $navibars->title(t(241, 'Websites') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(241, 'Websites') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    if ($user->permission('websites.edit') == 'true') {
        $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_media_browser();" title="Ctrl+m">
					<img height="16" align="absmiddle" width="16" src="img/icons/silk/images.png"> ' . t(36, 'Media') . '</a>'));
        $extra_actions = array();
        $extra_actions[] = '<a href="#" action="navigate_reset_statistics" onclick="javascript: navigate_reset_statistics();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/chart_line.png"> ' . t(429, 'Reset statistics') . '</a>';
        $layout->add_script('
            function navigate_reset_statistics()
            {
                navigate_confirmation_dialog(
                    function()
                    {
                        $.post(
                            "?fid=websites&act=reset_statistics&website=' . $item->id . '",
                            {},
                            function(data)
                            {
                                $("a[action=\'navigate_reset_statistics\']").parent().fadeOut();
                            }
                        );
                    }, 
                    "<div>' . t(430, 'Do you really want to remove all statistics of this website?') . '</div>" 
                );
            }
        ');
        if (!empty($item->id)) {
            $extra_actions[] = '<a href="#" action="navigate_replace_urls" onclick="javascript: navigate_replace_urls();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/database_refresh.png"> ' . t(603, 'Replace URLs') . '</a>';
            // try to find the OLD url for NAVIGATE_DOWNLOAD
            $old_url_guessed = "";
            $DB->query('
				SELECT text
				  FROM nv_webdictionary
				  WHERE node_type = "item"
				    AND website = ' . $item->id . '
				    AND text LIKE ' . protect("%navigate_download.php%") . '
			    LIMIT 1
		    ');
            $rs = $DB->result('text');
            preg_match("/<img .*?(?=src)src=\"([^\"]+)\"/si", $rs[0], $old_url_guessed);
            $old_url_guessed = @$old_url_guessed[1];
            $old_url_guessed = substr($old_url_guessed, 0, strpos($old_url_guessed, NAVIGATE_FOLDER));
            $layout->add_content('
		        <div id="navigate_replace_urls_dialog" style="display: none;">
		            <div id="" class="navigate-form-row">
						<label>' . t(604, "Old") . '</label>
						<input type="text" style=" width: 300px;" id="replace_urls_old" name="replace_urls_old" value="' . $old_url_guessed . '/" />
					</div>
					<div id="" class="navigate-form-row">
						<label>' . t(605, "New") . '</label>
						<input type="text" style=" width: 300px;" id="replace_urls_new" name="replace_urls_new" value="' . NAVIGATE_PARENT . '/" />
					</div>
					<div class="navigate-form-row">
						<div class="subcomment">' . t(523, "This action can NOT be undone.") . '</div>
					</div>
		        </div>
		    ');
            $layout->add_script('
	            function navigate_replace_urls()
	            {
	                $("#navigate_replace_urls_dialog").dialog({
	                        resizable: true,
	                        height: 180,
	                        width: 520,
	                        modal: true,
	                        title: "' . t(603, 'Replace URLs') . '",
	                        buttons: {
	                            "' . t(190, 'Ok') . '": function()
	                            {
	                                $.post(
	                                    "?fid=websites&act=replace_urls",
	                                    {
	                                        old: $("#replace_urls_old").val(),
	                                        new: $("#replace_urls_new").val(),
	                                        website: ' . $item->id . '
	                                    },
	                                    function(data)
	                                    {
	                                        if(data!="true")
					                            navigate_notification("' . t(56, "Unexpected error.") . '");
					                        else
					                        {
					                            navigate_notification("' . t(53, "Data saved successfully") . '", false, "fa fa-check");
	                                            $("#navigate_replace_urls_dialog").dialog("close");
	                                        }
	                                    }
	                                );
	                            },
	                            "' . t(58, 'Cancel') . '": function()
	                            {
	                                $("#navigate_replace_urls_dialog").dialog("close");
	                            }
	                        }
	                });
	            }
	        ');
            $extra_actions[] = '<a href="#" action="navigate_remove_website_data" onclick="javascript: navigate_remove_website_data();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cross.png"> ' . t(208, 'Remove all content') . '</a>';
            $layout->add_script('
            function navigate_remove_website_data()
            {
                var confirmation = "<div>";
                confirmation += "<br /><div><strong>' . t(497, 'Do you really want to erase this data?') . '</strong> (' . t(16, "Structure") . ', ' . t(22, "Elements") . ', ' . t(23, "Blocks") . ', ' . t(250, "Comments") . '...)</div><br />";
                confirmation += "<form action=\\"?\\" onSubmit=\\"return false;\\"><div class=\\"navigate-form-row\\"><label>' . t(2, "Password") . '</label></div><input type=\\"password\\" id=\\"navigate_remove_website_data_password\\" style=\\"width: 90%;\\" /></form></div>";
                confirmation += "</div>";

                $(confirmation).dialog({
                        resizable: true,
                        height: 250,
                        width: 400,
                        modal: true,
                        title: "' . t(59, 'Confirmation') . '",
                        buttons: {
                            "' . t(190, 'Ok') . '": function()
                            {
                                $(this).dialog("close");

                                $.post(
                                    "?fid=websites&act=remove_content",
                                    {
                                        website: $("#id").val(),
                                        password: $("#navigate_remove_website_data_password").val()
                                    },
                                    function(data)
                                    {
                                        if(data=="true")
                                        {
                                            navigate_notification("' . t(419, "Process complete") . '");
                                            $("a[action=\'navigate_remove_website_data\']").parent().fadeOut();
                                        }
                                        else
                                            navigate_notification("' . t(56, "Unexpected error.") . ' " + data, true);
                                    }
                                );
                            },
                            "' . t(58, 'Cancel') . '": function()
                            {
                                $(this).dialog("close");
                            }
                        }
                });
            }
        ');
        }
        // we attach an event to "websites" which will be fired by navibars to put an extra button
        $events->add_actions('websites', array('website' => &$item, 'navibars' => &$navibars), $extra_actions);
        if (empty($item->id)) {
            $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);" title="Ctrl+s">
						<img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
        } else {
            $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(1);" title="Ctrl+s">
						<img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', $user->permission('websites.delete') == 'true' ? '<a href="#" onclick="navigate_delete_dialog();">
							<img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>' : ''));
            $delete_html = array();
            $delete_html[] = '<div id="navigate-delete-dialog" class="hidden">' . t(57, 'Do you really want to delete this item?') . '</div>';
            $delete_html[] = '<script language="javascript" type="text/javascript">';
            $delete_html[] = 'function navigate_delete_dialog()';
            $delete_html[] = '{';
            $delete_html[] = '$("#navigate-delete-dialog").removeClass("hidden");';
            $delete_html[] = '$("#navigate-delete-dialog").dialog({
                                resizable: true,
                                height: 150,
                                width: 300,
                                modal: true,
                                title: "' . t(59, 'Confirmation') . '",
                                buttons: {
                                    "' . t(35, 'Delete') . '": function() {
                                        $(this).dialog("close");
                                        window.location.href = "?fid=' . $_REQUEST['fid'] . '&act=4&id=' . $item->id . '";
                                    },
                                    "' . t(58, 'Cancel') . '": function() {
                                        $(this).dialog("close");
                                    }
                                }
                            });';
            $delete_html[] = '}';
            $delete_html[] = '</script>';
            $navibars->add_content(implode("\n", $delete_html));
        }
        $layout->add_script("\r\n            \$(document).on('keydown.ctrl_s', function (evt) { navigate_items_tabform_submit(1); return false; } );\r\n            \$(document).on('keydown.ctrl_m', function (evt) { navigate_media_browser(); return false; } );\r\n        ");
    }
    $navibars->add_actions(array($user->permission('websites.edit') == 'true' && !empty($item->id) ? '<a href="?fid=websites&act=2"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=websites&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
    $navibars->form();
    $navibars->add_tab(t(7, "Settings"));
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $navibars->add_tab_content($naviforms->hidden('id', $item->id));
    $navibars->add_tab_content_row(array('<label>' . t(67, 'Title') . '</label>', $naviforms->textfield('title', $item->name)));
    $navibars->add_tab_content_row(array('<label>' . t(287, 'Protocol') . '</label>', $naviforms->selectfield('protocol', array(0 => 'http://', 1 => 'https://'), array(0 => 'HTTP', 1 => 'HTTPS [' . t(288, 'Secured site (requires certificate)') . ']'), $item->protocol)));
    $navibars->add_tab_content_row(array('<label>' . t(228, 'Subdomain') . '</label>', $naviforms->textfield('subdomain', $item->subdomain), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' www</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(229, 'Domain') . '</label>', $naviforms->textfield('domain', $item->domain), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' naviwebs.net</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(141, 'Folder') . '</label>', $naviforms->textfield('folder', $item->folder), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' /new-website</span>'));
    $homepage_url = "";
    if (!empty($item->homepage)) {
        $homepage_url = $item->homepage_from_structure();
    }
    $navibars->add_tab_content_row(array('<label>' . t(187, 'Homepage') . '</label>', $naviforms->hidden('homepage_from_structure', is_numeric($item->homepage) ? $item->homepage : ""), $naviforms->autocomplete('homepage', $homepage_url, '?fid=' . $_REQUEST['fid'] . '&wid=' . $item->id . '&act=5'), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' /en/home</span>'));
    $navibars->add_tab_content_row(array('<div class="subcomment"><img src="img/icons/silk/house.png" align="absmiddle" /> <span id="navigate-website-home-url"></span></div>'));
    $layout->add_content('
		<div id="homepage_change_dialog" style="display: none;">
			' . t(595, "Right now the homepage is set from a structure element which allows multilanguage redirecting.") . '
			<br /><br />
			' . t(596, "Do you want to enter a fixed path for the homepage?") . '
		</div>
	');
    $layout->add_script('
		$("#homepage").on("click keydown", function(ev)
		{
			if($("#homepage_from_structure").val()!="")
			{
				$("#homepage_change_dialog").dialog({
					title: "' . t(59, "Confirmation") . '",
					modal: true,
					width: 400,
					height: 150,
					buttons: [
					    {
					      text: "' . t(190, "Ok") . '",
					      icons: {  primary: "ui-icon-check"    },
					      click: function()
					      {
					            $("#homepage_from_structure").val("");
					            $("#homepage").focus();
					            $("#homepage_change_dialog").dialog("close");
					      }
					    },
					    {
					      text: "' . t(58, "Cancel") . '",
					      icons: { primary: "ui-icon-close" },
					      click: function()
					      {
			                 setTimeout(
			                    function()
			                    {
	                                $("div.ui-widget-overlay").hide();
			                        $("#homepage").blur();
		                        }, 100
	                         );
					         $("#homepage_change_dialog").dialog("close");
					      }
					    }
					]
				});
			}
		});

		$("#subdomain,#domain,#folder,#homepage").on("keyup", navigate_website_update_home_url);
		$("#protocol").on("change", navigate_website_update_home_url);

		function navigate_website_update_home_url()
		{
			var url = $("#protocol").val();
			if($("#subdomain").val().length > 0)
				url += $("#subdomain").val() + ".";
			url += $("#domain").val();
			url += $("#folder").val();
			url += $("#homepage").val();

			$("#navigate-website-home-url").html(url);
		}

		navigate_website_update_home_url();
	');
    if (!empty($item->theme)) {
        $navibars->add_tab_content_row(array('<label>' . t(368, 'Theme') . '</label>', '<strong>
				<a href="?fid=8&act=themes">
					<img height="16" width="16" align="absmiddle" src="img/icons/silk/rainbow.png" />
				</a> ' . $theme->title . '
			</strong>'));
    }
    $navibars->add_tab_content_row(array('<label>' . t(515, 'Not found paths') . '...</label>', $naviforms->selectfield('wrong_path_action', array(0 => 'blank', 1 => 'homepage', 2 => 'theme_404', 3 => 'http_404', 4 => 'website_path'), array(0 => t(516, 'Show a blank page'), 1 => t(517, 'Redirect to home page'), 2 => t(518, 'Use the custom 404 template of a theme (if exists)'), 3 => t(519, 'Send a 404 HTTP error header'), 4 => t(642, 'Redirect to a website page')), $item->wrong_path_action, 'navigate_websites_wrong_path_action_change(this)', false), '<a class="uibutton nv_website_wrong_path_trigger hidden"><i class="fa fa-sitemap"></i></a>', '<span id="navigate-website-wrong-path-redirect" class="nv_website_wrong_path_info navigate-form-row-info">' . $item->wrong_path_redirect . '</span>', $naviforms->hidden('wrong_path_redirect', $item->wrong_path_redirect)));
    $layout->add_script('
        function navigate_websites_wrong_path_action_change(el)
        {
            $(el).parent().find(".nv_website_wrong_path_trigger").addClass("hidden");
            $(el).parent().find(".nv_website_wrong_path_info").addClass("hidden");
            
            if($(el).val()=="website_path")
            {
                $(el).parent().find(".nv_website_wrong_path_trigger").removeClass("hidden");
                $(el).parent().find(".nv_website_wrong_path_info").removeClass("hidden");                
            }
        }
                
        navigate_websites_wrong_path_action_change($("#wrong_path_action"));
    
        $(".nv_website_wrong_path_trigger").on("click", function()
        {
            var trigger = this;
        
            // hide "replace title" when calling the dialog from the block action
            // leave it enabled when calling the dialog from the Links table
            if($(this).parents("table.box-table").length == 0)
                $("#nv_link_dialog_replace_text").parent().css("visibility", "hidden");
        
            $("#nv_link_dialog").removeClass("hidden");
            $("#nv_link_dialog").dialog({
                title: $("#nv_link_dialog").attr("title"),
                modal: true,
                width: 620,
                height: 400,
                buttons: [
                    {
                        text: "Ok",
                        click: function(event, ui)
                        {
                            // check if there is any path selected
                            if(!$("#nv_link_dialog_dynamic_path").hasClass("hidden"))
                            {
                                var input_path = $("#wrong_path_redirect");
                                input_path.val($("#nv_link_dialog_dynamic_path").text());
                                $(".nv_website_wrong_path_info").html($("#nv_link_dialog_dynamic_path").text());
        
                                $("#nv_link_dialog").dialog("close");
                            }
                        }
                    },
                    {
                        text: "Cancel",
                        click: function(event, ui)
                        {
                            $("#nv_link_dialog").dialog("close");
                        }
                    }
                ],
                close: function()
                {
                    $("#nv_link_dialog_replace_text").parent().css("visibility", "visible");
                }
            });
        });    
    ');
    // when no path is given
    $navibars->add_tab_content_row(array('<label>' . t(625, 'Empty paths') . '...</label>', $naviforms->selectfield('empty_path_action', array(0 => 'homepage_redirect', 1 => 'homepage_noredirect', 2 => 'blank', 3 => 'theme_404', 4 => 'http_404'), array(0 => t(517, 'Redirect to home page'), 1 => t(626, 'Display the home page, without changing the route'), 2 => t(516, 'Show a blank page'), 3 => t(518, 'Use the custom 404 template of a theme (if exists)'), 4 => t(519, 'Send a 404 HTTP error header')), $item->empty_path_action, '', false)));
    $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', $naviforms->selectfield('permission', array(0 => 0, 1 => 1, 2 => 2), array(0 => t(69, 'Published'), 1 => t(70, 'Private'), 2 => t(71, 'Closed')), $item->permission, '', false, array(0 => t(360, 'Visible to everybody'), 1 => t(359, 'Visible only to Navigate CMS users'), 2 => t(358, 'Hidden to everybody')))));
    $layout->add_script('
        $("#permission").on("change", function()
        {
            if($(this).val() > 0)
                $("#redirect_to").parent().show();
            else
                $("#redirect_to").parent().hide();
        });

        $("#permission").trigger("change");
    ');
    $navibars->add_tab_content_row(array('<label>' . t(505, 'Redirect to') . '</label>', $naviforms->textfield('redirect_to', $item->redirect_to), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' /landing_page.html</span>'));
    $navibars->add_tab(t(63, "Languages"));
    // system locales
    $locales = $item->unix_locales();
    $system = PHP_OS;
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && empty($locales)) {
        $locales = $item->windows_locales();
        $system = 'MS Windows';
    }
    /* Languages selector */
    if (!is_array($item->languages_list)) {
        $item->languages_list = array();
    }
    $table = new naviorderedtable("website_languages_table");
    //$table->setWidth("600px");
    $table->setHiddenInput("languages-order");
    $navibars->add_tab_content($naviforms->hidden('languages-order', implode('#', $item->languages_list)));
    $table->addHeaderColumn(t(159, 'Name'), 160);
    $table->addHeaderColumn(t(237, 'Code'), 60);
    $table->addHeaderColumn(t(471, 'Variant') . '/' . t(473, 'Region'), 120);
    $table->addHeaderColumn(t(474, 'System locale') . ' (' . $system . ')', 150);
    $table->addHeaderColumn(t(64, 'Published'), 60);
    $table->addHeaderColumn(t(35, 'Remove'), 60);
    $DB->query('SELECT code, name FROM nv_languages');
    $languages_rs = $DB->result();
    $languages = array();
    foreach ($languages_rs as $lang) {
        $languages[$lang->name] = $lang->code;
    }
    if (empty($item->languages)) {
        // load default language settings
        $item->languages_list = array('en');
        $item->languages_published = array('en');
        $item->languages = array('en' => array('language' => 'en', 'variant' => '', 'code' => 'en', 'system_locale' => strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? 'ENU_USA' : 'en_US.utf8'));
    }
    if (empty($item->languages)) {
        $item->languages = array();
    }
    // add previously assigned locales if they are missing
    foreach ($item->languages as $lcode => $ldef) {
        if (!in_array($ldef['system_locale'], $locales)) {
            $locales[$ldef['system_locale']] = '? [' . $ldef['system_locale'] . ']';
        }
    }
    $p = 0;
    foreach ($item->languages as $lcode => $ldef) {
        $p++;
        $published = array_search($lcode, $item->languages_published) !== false;
        $variant = !empty($ldef['variant']);
        $select_language = $naviforms->select_from_object_array('language-id[]', $languages_rs, 'code', 'name', $ldef['language'], ' width: 150px; ');
        if (empty($locales)) {
            $select_locale = $naviforms->textfield('language-locale[]', $ldef['system_locale'], '300px');
        } else {
            $select_locale = $naviforms->selectfield('language-locale[]', array_keys($locales), array_values($locales), $ldef['system_locale'], '', false, array(), 'width: 300px;');
        }
        $uid = uniqid();
        $table->addRow($p, array(array('content' => $select_language, 'align' => 'left'), array('content' => '<div style=" white-space: nowrap; "><input type="text" name="language-code[]" value="' . $ldef['language'] . '" style="width: 30px;" /></div>', 'align' => 'left'), array('content' => '<input type="checkbox" name="language-variant[]" id="language-variant[' . $uid . ']" value="1" ' . ($variant ? 'checked="checked"' : '') . ' style="float:left;" class="raw-checkbox" /> <input type="text" name="language-variant-code[]" value="' . $ldef['variant'] . '" style="width: 75px;" />', 'align' => 'left'), array('content' => $select_locale, 'align' => 'left'), array('content' => '<input type="hidden" name="language-published[]" value="' . ($published ? '1' : '0') . '" /><input type="checkbox" id="language-published[' . $uid . ']" value="' . $lcode . '" ' . ($published ? 'checked="checked"' : '') . ' onclick=" if($(this).is(\':checked\')) { $(this).prev().val(1); } else { $(this).prev().val(0); }; " /><label for="language-published[' . $uid . ']"></label>', 'align' => 'center'), array('content' => '<img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" onclick="navigate_websites_language_remove(this);" />', 'align' => 'center')));
    }
    $navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', '<div>' . $table->generate() . '</div>', '<div class="subcomment">
                <img src="img/icons/silk/information.png" align="absmiddle" /> ' . t(72, 'Drag any row to assign priorities') . '
            </div>'));
    $navibars->add_tab_content_row(array('<label>&nbsp;</label>', '<button id="websites-languages-add"><img src="img/icons/silk/add.png" align="absmiddle" style="cursor:pointer;" /> ' . t(472, 'Add') . '</button>'));
    $layout->add_script('
        $("#website_languages_table tr").eq(1).find("td:last").children().hide();
        $(\'input[name="language-variant[]"]\').each(function(i, el)
        {
            if($(el).is(":checked"))
                $(el).next().removeClass("ui-state-disabled");
            else
                $(el).next().val("").addClass("ui-state-disabled");
        });

        $(\'input[name="language-variant-code[]"]\').on("click", function()
        {
            if(!$(this).prev().is(":checked"))
                $(this).prev().trigger("click");
        });

        $("#website_languages_table").on("change", \'select[name="language-id[]"]\', function()
        {
            var input = $(this).parent().next().find("input");
            $(input).val($(this).val());
            $(input).effect("highlight", {}, 2000);
        });

        $("#website_languages_table").on("change", \'input[name="language-variant[]"]\', function()
        {
            if($(this).is(":checked"))
                $(this).next().removeClass("ui-state-disabled");
            else
                $(this).next().val("").addClass("ui-state-disabled");
        });

        $("#websites-languages-add").on("click", function()
        {
            var tr = $("#website_languages_table").find("tr").eq(1).clone();            
            var tsid = new Date().getTime();
            $(tr).attr("id", tsid);
            
            $(tr).find("input,label,select").each(function()
		    {
		        if($(this).attr("id"))
		        {
		            var new_name = ($(this).attr("id").split("["))[0];
		            $(this).attr("id", new_name + "[" + tsid + "]");
		        }
		
		        if($(this).attr("for"))
		        {
		            var new_name = ($(this).attr("for").split("["))[0];
		            $(this).attr("for", new_name + "[" + tsid + "]");
		        }
		    });

            $("#website_languages_table").find("tbody:last").append(tr);
            $("#website_languages_table").tableDnD({
                onDrop: function(table, row)
                {
                    navigate_naviorderedtable_website_languages_table_reorder();
                }
            });

            navigate_naviorderedtable_website_languages_table_reorder();

            $(tr).find("td:first").find("a,div,span").remove();
            $(tr).find("td").eq(3).find("a,div,span").remove();

            navigate_selector_upgrade($(tr).find("td:first").find("select"));

            if($(tr).find("td").eq(3).find("select").length > 0)
                navigate_selector_upgrade($(tr).find("td").eq(3).find("select"));

            return false;
        });

        function navigate_websites_language_remove(el)
        {
            $(el).parent().parent().remove();
        }

        function navigate_naviorderedtable_website_languages_table_reorder()
        {
            $("#website_languages_table tr").find("td:last").not(":first").children().show();
            $("#website_languages_table tr").eq(1).find("td:last").children().hide();
        }
    ');
    $navibars->add_tab(t(485, "Aliases"));
    $table = new naviorderedtable("website_aliases_table");
    $table->addHeaderColumn(t(486, 'Alias'), 160);
    $table->addHeaderColumn('', 24);
    $table->addHeaderColumn(t(487, 'Real URL'), 60);
    $table->addHeaderColumn(t(35, 'Remove'), 60);
    $table->addRow($lang->code, array(array('content' => '<div style="width: 308px;">http://example.domain.com/demo</div>', 'align' => 'left'), array('content' => '&rarr;', 'align' => 'center'), array('content' => '<div style="width: 308px;">http://www.domain.com/example/demo</div>', 'align' => 'left'), array('content' => '', 'align' => 'left')));
    if (!is_array($item->aliases)) {
        $item->aliases = array();
    }
    foreach ($item->aliases as $alias => $realurl) {
        $table->addRow($lang->code, array(array('content' => '<input type="text" name="website-aliases-alias[]" value="' . $alias . '" style="width: 300px;" />', 'align' => 'left'), array('content' => '&rarr;', 'align' => 'center'), array('content' => '<input type="text" name="website-aliases-real[]" value="' . $realurl . '" style="width: 300px;" />', 'align' => 'left'), array('content' => '<img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" onclick="navigate_websites_aliases_remove(this);" />', 'align' => 'center')));
    }
    $navibars->add_tab_content_row(array('<label>' . t(485, 'Aliases') . '</label>', '<div>' . $table->generate() . '</div>', '<div class="subcomment">
                <img src="img/icons/silk/information.png" align="absmiddle" /> ' . t(72, 'Drag any row to assign priorities') . '
            </div>'));
    $navibars->add_tab_content_row(array('<label>&nbsp;</label>', '<button id="websites-aliases-add"><img src="img/icons/silk/add.png" align="absmiddle" style="cursor:pointer;" /> ' . t(472, 'Add') . '</button>'));
    $layout->add_script('
        $("#websites-aliases-add").on("click", function()
        {
            var tr = $("<tr><td></td><td></td><td></td><td></td></tr>");
            $(tr).attr("id", new Date().getTime());
            $(tr).find("td").eq(0).html("<input type=\\"text\\" name=\\"website-aliases-alias[]\\" style=\\"width: 300px;\\" />");
            $(tr).find("td").attr("align", "center").eq(1).html("&rarr;");
            $(tr).find("td").eq(2).html("<input type=\\"text\\" name=\\"website-aliases-real[]\\" style=\\"width: 300px;\\" />");
            $(tr).find("td").attr("align", "center").eq(3).html("<img src=\\"' . NAVIGATE_URL . '/img/icons/silk/cancel.png\\" onclick=\\"navigate_websites_aliases_remove(this);\\" />");

            $("#website_aliases_table").find("tbody:last").append(tr);
            $("#website_aliases_table").tableDnD();
            return false;
        });

        function navigate_websites_aliases_remove(el)
        {
            $(el).parent().parent().remove();
        }
    ');
    $navibars->add_tab(t(9, "Content"));
    // keep the default value for Navigate CMS < 2.0
    if (empty($item->word_separator)) {
        $item->word_separator = "_";
    }
    $navibars->add_tab_content_row(array('<label>' . t(633, 'Word separator in paths') . '</label>', $naviforms->selectfield('word_separator', array(0 => '-', 1 => '_'), array(0 => t(634, "Hyphen") . " /navigate-cms", 1 => t(635, "Underscore") . " /navigate_cms"), $item->word_separator), '<span class="navigate-form-row-info">' . t(636, 'Existing paths will not be modified') . '</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(50, 'Date format') . '</label>', $naviforms->selectfield('date_format', array(0 => 'd/m/Y', 1 => 'd-m-Y', 2 => 'm/d/Y', 3 => 'm-d-Y', 4 => 'Y-m-d', 5 => 'Y/m/d'), array(0 => date('d/m/Y'), 1 => date('d-m-Y'), 2 => date('m/d/Y'), 3 => date('m-d-Y'), 4 => date('Y-m-d'), 5 => date('Y/m/d')), $item->date_format)));
    $timezones = property::timezones();
    if (empty($item->default_timezone)) {
        $item->default_timezone = date_default_timezone_get();
    }
    $navibars->add_tab_content_row(array('<label>' . t(207, 'Default timezone') . '</label>', $naviforms->selectfield("default_timezone", array_keys($timezones), array_values($timezones), $item->default_timezone)));
    $navibars->add_tab_content_row(array('<label>' . t(433, 'Resize uploaded images') . '</label>', $naviforms->selectfield('resize_uploaded_images', array(0 => 0, 1 => 600, 2 => 800, 3 => 960, 4 => 1200, 5 => 1600, 6 => 2000), array(0 => t(434, 'Keep original file'), 1 => '600 px', 2 => '800 px', 3 => '960 px', 4 => '1200 px', 5 => '1600 px', 6 => '2000 px'), $item->resize_uploaded_images), '<span class="navigate-form-row-info">' . t(435, 'Maximum width or height') . '</span>'));
    // navigate cms 2.0.2: website->tinymce_css field is DEPRECATED (will be removed in a future revision)
    if (!empty($item->tinymce_css)) {
        $navibars->add_tab_content_row(array('<label>tinyMCE CSS</label>', $naviforms->textfield('tinymce_css', $item->tinymce_css), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' /css/style.content.css</span>'));
    }
    $navibars->add_tab_content_row(array('<label>' . t(328, 'Favicon') . '</label>', $naviforms->dropbox('website-favicon', $item->favicon, "image")));
    $navibars->add_tab_content_row(array('<label>' . t(597, 'Share files in media browser') . '</label>', $naviforms->checkbox('share_files_media_browser', $item->share_files_media_browser == '1'), '<span class="navigate-form-row-info">(' . t(598, 'Only between websites of the current Navigate CMS installation') . ')</span>'));
    // default comment options for elements
    $navibars->add_tab_content_row(array('<label>' . t(252, 'Comments enabled for') . '</label>', $naviforms->selectfield('comments_enabled_for', array(0 => 0, 1 => 1, 2 => 2), array(0 => t(253, 'Nobody'), 1 => t(24, 'Registered users'), 2 => t(254, 'Everyone')), $item->comments_enabled_for)));
    $webuser_name = '';
    if ($item->comments_default_moderator == "c_author") {
        $webuser_name = t(545, 'Content author');
    } else {
        if (!empty($item->comments_default_moderator)) {
            $webuser_name = $DB->query_single('username', 'nv_users', ' id = ' . intval($item->comments_default_moderator));
        }
    }
    $moderator_id = array('c_author');
    $moderator_username = array('{' . t(545, 'Content author') . '}');
    if (!empty($item->comments_default_moderator)) {
        if ($item->comments_default_moderator != 'c_author') {
            $moderator_username[] = $DB->query_single('username', 'nv_users', ' id = ' . intval($item->comments_default_moderator));
            $moderator_id[] = $item->comments_default_moderator;
        }
    }
    $navibars->add_tab_content_row(array('<label>' . t(255, 'Moderator') . '</label>', $naviforms->selectfield('comments_default_moderator', $moderator_id, $moderator_username, $item->comments_default_moderator, null, false, null, null, false), '<span style="display: none;" id="comments_default_moderator-helper">' . t(535, "Find user by name") . '</span>', '<div class="subcomment"><img align="absmiddle" src="' . NAVIGATE_URL . '/img/icons/silk/information.png" /> ' . t(256, 'Leave blank to accept all comments') . '</div>'));
    $layout->add_script('
        // comments moderator autocomplete
        $("#comments_default_moderator").select2(
        {
            placeholder: $("#comments_default_moderator-helper").text(),
            minimumInputLength: 0,
            ajax: {
                url: "?fid=items&act=json_find_user",
                dataType: "json",
                delay: 100,
                data: function (params)
		        {
		            return {
		                username: params.term,
		                nd: new Date().getTime(),
		                page_limit: 30, // page size
		                page: params.page // page number
		            };
		        },
		        processResults: function (data, params)
		        {
		            params.page = params.page || 1;
		            data.items.unshift({id: "c_author", text: "{' . t(545, 'Content author') . '}" });
		            data.total_count++;
		            return {
						results: data.items,
						pagination: { more: (params.page * 30) < data.total_count }
					};
		        }
            },
            templateSelection: function(row)
			{
				if(row.id && row.id != "c_author")
					return row.text + " <helper style=\'opacity: .5;\'>#" + row.id + "</helper>";
				else
					return row.text;
			},
			escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
            triggerChange: true,
            allowClear: true
        });

        $("#comments_default_moderator-text").on("change", function(e)
        {
            $("#comments_default_moderator").val(e.val);
        });
    ');
    /* TAB EMAIL */
    $navibars->add_tab(t(44, "E-Mail"));
    $navibars->add_tab_content_row(array('<label>' . t(548, "Method") . '</label>', $naviforms->buttonset('mail_mailer', array('smtp' => 'SMTP', 'sendmail' => 'Sendmail', 'mail' => 'PHP mail'), empty($item->mail_mailer) ? 'smtp' : $item->mail_mailer, "navigate_change_mail_transport(this);")));
    $layout->add_script('
        function navigate_change_mail_transport(el)
        {
            var mail_mailer = "";
            if(el=="smtp" || el=="sendmail" || el=="mail")
                mail_mailer = el;
            else
                mail_mailer = $("input#" + $(el).attr("for")).val();

            $("#mail_server").parent().show();
            $("#mail_port").parent().show();
            $("#mail_security").parent().show();
            $("#mail_user").parent().show();
            $("#mail_password").parent().show();
            if(mail_mailer=="sendmail" || mail_mailer=="mail")
            {
                $("#mail_server").parent().hide();
                $("#mail_port").parent().hide();
                $("#mail_security").parent().hide();
                $("#mail_user").parent().hide();
                $("#mail_password").parent().hide();
            }
        }

        navigate_change_mail_transport("' . (empty($item->mail_mailer) ? 'smtp' : $item->mail_mailer) . '");
    ');
    $navibars->add_tab_content_row(array('<label>' . t(231, 'Server') . '</label>', $naviforms->textfield('mail_server', $item->mail_server), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' localhost, mail.yourdomain.com</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(232, 'Port') . '</label>', $naviforms->textfield('mail_port', $item->mail_port), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' 25</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(427, 'Security protocol') . '</label>', $naviforms->selectfield('mail_security', array(0, 1, 2), array(t(581, "None"), "SSL / TLS", "STARTTLS"), $item->mail_security)));
    $navibars->add_tab_content_row(array('<label>' . t(1, 'User') . '</label>', $naviforms->textfield('mail_user', $item->mail_user), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' web@yourdomain.com</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(233, 'Address') . '</label>', $naviforms->textfield('mail_address', $item->mail_address), '<span class="navigate-form-row-info">' . t(230, 'Ex.') . ' web@yourdomain.com</span>'));
    $navibars->add_tab_content_row(array('<label>' . t(2, 'Password') . '</label>', '<input type="password" name="mail_password" id="mail_password" autocomplete="off"  value="" size="32" />', '<span class="navigate-form-row-info">' . t(48, "Leave blank to keep the current value") . '</span>'));
    // force removing the browser saved password
    $layout->add_script('
		setTimeout(function() {
			$("input[name=mail_password]").val("");
		}, 10);
	');
    if (empty($item->contact_emails)) {
        $item->contact_emails = array();
    }
    $navibars->add_tab_content_row(array('<label>' . t(263, 'Support E-Mails') . '</label>', $naviforms->textarea('contact_emails', implode("\n", $item->contact_emails)), '<span class="navigate-form-row-info">' . t(264, "One entry per line") . '</span>'));
    $navibars->add_tab_content_row(array('<label>&nbsp;</label>', '<button id="mail_test"><img src="' . NAVIGATE_URL . '/img/icons/silk/email_go.png" align="absmiddle" /> ' . t(390, "Test") . '</button>'));
    $layout->add_script('
		$("#mail_test").on("click", function()
		{
			navigate_status("' . t(391, "Trying to send a test e-mail…") . '", "loader", true);
			$.ajax({
			  type: "POST",
			  url: "?fid=' . $_GET['fid'] . '&act=email_test",
			  data: {
				 mail_mailer: $("input[name=\\"mail_mailer[]\\"]:checked").val(),
				 mail_server: $("#mail_server").val(),
				 mail_port: $("#mail_port").val(),
				 mail_security: $("#mail_security").is(":checked"),
				 mail_user: $("#mail_user").val(),
				 mail_address: $("#mail_address").val(),
				 mail_password: $("#mail_password").val(),
				 send_to: $("#contact_emails").val()
			  },
			  success: function(data)
			  {
				  navigate_status(navigate_lang_dictionary[42], "ready"); 
				  
				  if(!data)
				  	navigate_notification("' . t(56, "Unexpected error.") . '");
				  else
				  	navigate_notification("' . t(392, "E-Mail sent") . '");
			  },
			  error: function(data)
			  {
			        navigate_status(navigate_lang_dictionary[42], "ready");
			        var error_message = (data.responseText).split("<br />")[0];
			        if(error_message!="")
			            error_message = ": " + error_message;

			        navigate_notification("' . t(56, "Unexpected error.") . '" + error_message, true);
			  },
			  dataType: "json"
			});
			return false;
		});
	');
    /* METATAGS TAB */
    if (!empty($item->id) && !empty($item->languages)) {
        $navibars->add_tab(t(513, "Metatags"));
        $website_languages_selector = $item->languages();
        $website_languages_selector = array_merge(array('' => '(' . t(443, 'All') . ')'), $website_languages_selector);
        $navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', $naviforms->buttonset('metatags_language_selector', $website_languages_selector, '', "navigate_tabform_language_selector(this);")));
        foreach ($item->languages_list as $lang) {
            $language_info = '<span class="navigate-form-row-language-info" title="' . language::name_by_code($lang) . '"><img src="img/icons/silk/comment.png" align="absmiddle" />' . $lang . '</span>';
            $navibars->add_tab_content_row(array('<label>' . t(334, 'Description') . ' ' . $language_info . '</label>', $naviforms->textfield('metatag_description-' . $lang, $item->metatag_description[$lang]), '<span class="navigate-form-row-info">150-160</span>'), '', 'lang="' . $lang . '"');
            $navibars->add_tab_content_row(array('<label>' . t(536, 'Keywords') . ' ' . $language_info . '</label>', $naviforms->textfield('metatag_keywords-' . $lang, $item->metatag_keywords[$lang])), '', 'lang="' . $lang . '"');
            $layout->add_script('               
                $("#metatag_keywords-' . $lang . '").tagit({
                    removeConfirmation: true,
                    allowSpaces: true,
                    singleField: true,
                    singleFieldDelimiter: ",",
                    placeholderText: "+",
                    autocomplete: 
                    {
                        delay: 0, 
                        minLength: 1,
                        source: "?fid=items&act=json_tags_search&lang=' . $lang . '"
                    },
                    afterTagAdded: function(event, ui)
                    {
                        var tags = $(this).tagit("assignedTags");
                        if(tags.length > 0)
                            tags = tags.join(",");
                        else
                            tags = "";
                            
                        $("#metatag_keywords-' . $lang . '").val(tags);
                    }
                });
			');
            $navibars->add_tab_content_row(array('<label>' . t(514, "Additional metatags") . ' ' . $language_info . '</label>', $naviforms->scriptarea('metatags-' . $lang, $item->metatags[$lang], 'html', ' width: 75%; height: 100px; ')), '', 'lang="' . $lang . '"');
        }
    }
    /* SERVICES TAB */
    $navibars->add_tab(t(178, "Services"));
    $navibars->add_tab_content_row(array('<label>' . t(498, 'Additional scripts') . '</label>', $naviforms->scriptarea('additional_scripts', $item->additional_scripts, 'js', ' width: 600px; height: 250px; '), '<div style="clear: both;"><label>&nbsp;</label>&lt;script type="text/javascript"&gt;...&lt;/script&gt;</div>'));
    if (!empty($item->theme)) {
        $navibars->add_tab(t(368, 'Theme') . ': ' . $theme->title);
        if (!is_array($theme->options)) {
            $theme->options = array();
        }
        // show a language selector (only if it's a multilanguage website and has properties)
        if (!empty($theme->options) && count($item->languages) > 1) {
            $website_languages_selector = $item->languages();
            $website_languages_selector = array_merge(array('' => '(' . t(443, 'All') . ')'), $website_languages_selector);
            $navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', $naviforms->buttonset('language_selector', $website_languages_selector, '', "navigate_tabform_language_selector(this);")), "navigate-form-tab-theme-language_selector");
            // hide languages selector if there isn't a multilanguage property
            $layout->add_script('
				$(document).ready(function()
			    {
					if($("#navigate-form-tab-theme-language_selector").parent().find(".navigate-form-row[lang]").length < 1)
					{
						$("#navigate-form-tab-theme-language_selector").css("display", "none");
					}
			    });
		    ');
        }
        // common property: style
        // 1: get available style IDs
        $styles_values = array_keys((array) $theme->styles);
        if (!is_array($styles_values)) {
            $styles_values = array();
        }
        // 2: prepare array of style ID => style name
        $styles = array();
        foreach ($styles_values as $sv) {
            $styles[$sv] = $theme->styles->{$sv}->name;
            if (empty($styles[$sv])) {
                $styles[$sv] = $sv;
            }
            $styles[$sv] = $theme->t($styles[$sv]);
        }
        $property = new property();
        $property->id = 'style';
        $property->name = t(431, 'Style');
        $property->type = 'option';
        $property->options = serialize($styles);
        $property->value = $item->theme_options->style;
        $navibars->add_tab_content(navigate_property_layout_field($property));
        foreach ($theme->options as $theme_option) {
            $property = new property();
            $property->load_from_theme($theme_option, $item->theme_options->{$theme_option->id});
            $navibars->add_tab_content(navigate_property_layout_field($property, "", $item->id));
        }
        navigate_property_layout_scripts($item->id);
    }
    $events->trigger('websites', 'edit', array('item' => &$item, 'navibars' => &$navibars, 'naviforms' => &$naviforms));
    return $navibars->generate();
}
示例#7
0
     if (!empty($website->redirect_to)) {
         header('location: ' . $website->redirect_to);
     }
     nvweb_clean_exit();
 }
 // global helper variables
 $session = array();
 // webuser session
 $structure = array();
 // web menu structure
 $webgets = array();
 // webgets static data
 $webuser = new webuser();
 $theme = new theme();
 if (!empty($website->theme)) {
     $theme->load($website->theme);
 }
 $route = $_REQUEST['route'];
 // remove last '/' in route if exists
 if (substr($route, -1) == '/') {
     $route = substr($route, 0, -1);
 }
 // remove the "folder" part of the route (only if this url is really under a folder)
 if (!empty($website->folder) && strpos('/' . $route, $website->folder) === 0) {
     $route = substr('/' . $route, strlen($website->folder) + 1);
 }
 $nvweb_absolute = $idn->encode($website->absolute_path());
 define('NVWEB_ABSOLUTE', $nvweb_absolute);
 define('NVWEB_OBJECT', $nvweb_absolute . '/object');
 define('NVWEB_AJAX', $nvweb_absolute . '/nvajax');
 define('NVWEB_THEME', NAVIGATE_PARENT . NAVIGATE_FOLDER . '/themes/' . $theme->name);
 public static function section_name($default)
 {
     global $website;
     global $theme;
     $out = $default;
     if (!empty($website->theme)) {
         if (empty($theme)) {
             $theme = new theme();
             $theme->load($website->theme);
         }
         $out = $theme->template_title($default, false);
     }
     switch ($default) {
         case '#main#':
             $out = t(238, 'Main content');
             break;
         default:
     }
     return $out;
 }