示例#1
0
 public static function addExtension($classname)
 {
     $class = get_called_class();
     extension::add($class . '_CLASS', function () use($classname) {
         return $classname;
     });
 }
示例#2
0
 public function init()
 {
     $token = isset($_SESSION['token']) ? $_SESSION['token'] : $_COOKIE['token'];
     $personal_id = isset($_SESSION['person']) ? $_SESSION['person'] : $_COOKIE['person'];
     $user_ip = system::getInstance()->getRealIp();
     // data 1st raw check before sql is used
     if (strlen($token) == 32 && (filter_var($personal_id, FILTER_VALIDATE_EMAIL) || strlen($personal_id) > 0 && system::getInstance()->isLatinOrNumeric($personal_id))) {
         $query = "SELECT * FROM\r\n            " . property::getInstance()->get('db_prefix') . "_user a,\r\n            " . property::getInstance()->get('db_prefix') . "_user_access_level b,\r\n            " . property::getInstance()->get('db_prefix') . "_user_custom c\r\n            WHERE (a.email = ? OR a.login = ?) AND a.token = ? AND a.token_ip = ? AND a.aprove = 0 AND a.access_level = b.group_id AND a.id = c.id";
         $stmt = database::getInstance()->con()->prepare($query);
         $stmt->bindParam(1, $personal_id, \PDO::PARAM_STR);
         $stmt->bindParam(2, $personal_id, \PDO::PARAM_STR);
         $stmt->bindParam(3, $token, \PDO::PARAM_STR, 32);
         $stmt->bindParam(4, $user_ip, \PDO::PARAM_STR);
         $stmt->execute();
         if ($stmt->rowCount() == 1) {
             $result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
             $stmt = null;
             if (time() - $result[0]['token_start'] < property::getInstance()->get('token_time')) {
                 $this->userindex = $result[0]['id'];
                 foreach ($result[0] as $column_index => $column_data) {
                     $this->userdata[$this->userindex][$column_index] = $column_data;
                 }
                 // set template variables
                 template::getInstance()->set(template::TYPE_USER, 'id', $this->userindex);
                 template::getInstance()->set(template::TYPE_USER, 'name', $this->userdata[$this->userindex]['nick']);
                 template::getInstance()->set(template::TYPE_USER, 'admin', permission::getInstance()->have('global/owner'));
                 template::getInstance()->set(template::TYPE_USER, 'admin_panel', permission::getInstance()->have('admin/main'));
                 template::getInstance()->set(template::TYPE_USER, 'news_add', extension::getInstance()->getConfig('enable_useradd', 'news', extension::TYPE_COMPONENT, 'bol'));
                 template::getInstance()->set(template::TYPE_USER, 'balance', $this->userdata[$this->userindex]['balance']);
             }
         }
     }
 }
示例#3
0
 private function cronInit()
 {
     foreach (extension::getInstance()->getAllParams() as $ext_type => $ext_data) {
         foreach ($ext_data as $ext_item) {
             if ($ext_item['enabled'] == 1) {
                 $ext_file = root . '/extensions/' . $ext_type . '/' . $ext_item['dir'] . '/cron.php';
                 if (file_exists($ext_file)) {
                     @(require_once $ext_file);
                     $cname = 'cron_' . $ext_item['dir'];
                     if (class_exists($cname)) {
                         $link = new $cname();
                         if (method_exists($link, 'getInstance') && method_exists($link, 'make')) {
                             $link::getInstance()->make();
                         } else {
                             logger::getInstance()->log(logger::LEVEL_WARN, 'Method getInstance() or make() not founded in cron ' . $ext_file);
                         }
                     } else {
                         logger::getInstance()->log(logger::LEVEL_WARN, 'Class ' . $cname . ' not founded in cron ' . $ext_file);
                     }
                 }
             }
         }
     }
     return null;
 }
 public static function registerUser()
 {
     $sql = sql::factory();
     $sql->setTable('community_user');
     $sql->getPosts(['username' => 'string', 'password' => 'string', 'email' => 'string']);
     $validator = new validator();
     $email = $sql->getPost('email');
     $username = $sql->getPost('username');
     $password = $sql->getPost('password');
     $validUsername = $validator->costum($username, function () {
         preg_match('/\\w{4,}/', $username, $match);
         return $match[0] == $username;
     });
     if (!$validUsername) {
         return 'Username darf nur aus Buchstaben Zahlen und Unterstrich bestehen und muss mindestens 4 Zeichen lang sein.';
     }
     if ($sql->num('SELECT id FROM ' . sql::table('community_user') . ' WHERE `username`= "' . $sql->escape($username) . '"')) {
         return 'Benutzername schon vorhanden';
     }
     if (!$validator->email($email)) {
         return 'Bitte geben Sie eine E-Mail Adresse an';
     }
     $salt = userLogin::generateSalt();
     $sql->addDatePost('registerdate', 'now');
     $sql->addPost('salt', $salt);
     extension::get('COMMUNITY_USER_REGISTER', $sql);
     $password = userLogin::hash($password, $salt);
     $sql->addPost('password', $password);
     $sql->save();
     //Mail send
     return true;
 }
示例#5
0
 public function getTemplate()
 {
     ob_start();
     $content = self::generateArticle($this->get('id'));
     $content = extension::get('FRONTEND_OUTPUT', $content);
     dyn::add('content', $content);
     include dir::template(dyn::get('template'), $this->get('template'));
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
示例#6
0
 public static function fe($id = '', $params = [])
 {
     if ($id == '') {
         type::super('page_id', 'int', dyn::get('start_page'));
     }
     $url = extension::get('URL_REWRITE', ['id' => $id, 'params' => $params]);
     if (!extension::has('URL_REWRITE')) {
         $url = 'index.php?page_id=' . $id;
         foreach ($params as $name => $value) {
             $url .= '&amp;' . $name . '=' . $value;
         }
     }
     return $url;
 }
示例#7
0
 public function getTemplate()
 {
     ob_start();
     if (!pageCache::exist($this->get('id'))) {
         pageCache::generateArticle($this->get('id'));
     }
     $content = pageCache::read($this->get('id'));
     $content = pageArea::getEval($content);
     $content = extension::get('FRONTEND_OUTPUT', $content);
     dyn::add('content', $content);
     include dir::template(dyn::get('template'), $this->get('template'));
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
示例#8
0
 public function parseUrl($url)
 {
     $url = str_replace(dyn::get('hp_url'), '', $url);
     $url = trim($url, '/');
     if (isset(self::$pathlist[$url])) {
         $id = self::$pathlist[$url];
         extension::add('SET_PAGE_ID', function () use($id) {
             return $id;
         });
     }
     if ($url == '') {
         $id = dyn::get('start_page');
     }
     return $id;
 }
示例#9
0
 /**
  * Automatically binds extension events to Navigate CMS modules
  * It checks the "bindings" section of every extension definition
  */
 public function extension_backend_bindings($ignore_permissions = true)
 {
     // when running inside Navigate CMS, this binds all extension events
     $extensions = extension::list_installed(null, $ignore_permissions);
     for ($e = 0; $e < count($extensions); $e++) {
         if (!isset($extensions[$e]['enabled']) || $extensions[$e]['enabled'] == '1') {
             if (!empty($extensions[$e]['bindings'])) {
                 foreach ($extensions[$e]['bindings'] as $binding) {
                     extension::include_php($extensions[$e]['code']);
                     $this->bind($binding->module, $binding->event, $extensions[$e]['code'], $binding->function);
                 }
             }
         }
     }
 }
示例#10
0
 public function make()
 {
     if (!property::getInstance()->get('maintenance')) {
         // is not a maintenance mod
         return;
     }
     if (permission::getInstance()->have('admin/main')) {
         // not show for admin
         return;
     }
     $login_form = extension::getInstance()->call(extension::TYPE_COMPONENT, 'user')->viewLogin();
     // call to login view & worker
     $tpl = template::getInstance()->twigRender('maintenance.tpl', array('login_form' => $login_form));
     // render with login form
     template::getInstance()->justPrint($tpl, array());
 }
示例#11
0
 public static function addToPathlist($filter, $addonsUrls)
 {
     $addonnames = [];
     foreach (seo_control::getArticleNames(seo_control::getArticleByFilter($filter)) as $id => $name) {
         $name = rtrim($name, dyn::get('addons')['seo']['ending']);
         if ($name) {
             $name .= '/';
         }
         foreach ($addonsUrls as $addonname) {
             $addonnames[$name . $addonname] = $id;
         }
     }
     extension::add('SEO_GENERATE_PATHLIST', function ($list) use($addonnames) {
         $list = array_merge($addonnames, $list);
         return $list;
     });
 }
示例#12
0
 /**
  * Get admin interface all available permissions
  * @return array
  */
 public function getAdminPermissions()
 {
     $ext = extension::getInstance()->getAllParams();
     $result = array();
     $general_rights = admin::getInstance()->getDefaultAccessRights();
     foreach ($general_rights as $right) {
         $result[] = $right;
     }
     foreach ($ext as $ext_data) {
         foreach ($ext_data as $ext_item) {
             $ext_name = $ext_item['dir'];
             $ext_type = $ext_item['type'];
             $ext_enabled = $ext_item['enabled'] == 1;
             $pathway = root . '/extensions/' . $ext_type . '/' . $ext_name . '/back.php';
             if ($ext_enabled && file_exists($pathway)) {
                 $cname = $ext_type . '_' . $ext_name . '_back';
                 require_once $pathway;
                 if (class_exists($cname)) {
                     $init = new $cname();
                     if (method_exists($init, 'getInstance')) {
                         $object = @$init::getInstance();
                         $data = null;
                         if (method_exists($object, 'accessData')) {
                             $data = @$object->accessData();
                             // @deprecated
                         } elseif (method_exists($init, '_accessData')) {
                             $data = @$object->_accessData();
                         }
                         foreach ($data as $single) {
                             $result[] = $single;
                         }
                         $init = null;
                     }
                 }
             }
         }
     }
     return $result;
 }
示例#13
0
 public static function checkLogin()
 {
     $username = type::post('username', 'string', '');
     $password = type::post('password', 'string', '');
     if ($username == '' || $password == '') {
         echo message::info(lang::get('login_form_notfull'), true);
         return;
     }
     $sql = sql::factory();
     $sql->query('SELECT password, salt, id FROM ' . sql::table('community_user') . ' WHERE `username` = "' . $sql->escape($username) . '"');
     if (!$sql->num()) {
         echo message::danger(sprintf(lang::get('login_no_user'), $email), true);
         return;
     }
     $sql->result();
     if (!userLogin::checkPassword($password, $sql->get('salt'), $sql->get('password'))) {
         echo message::danger(lang::get('login_pwd_false'), true);
         return;
     }
     $_SESSION['community-login'] = $sql->get('id');
     self::checkSession();
     // Für spätere Foren-Bridges
     extension::get('COMMUNITY_USER_LOGIN', $password);
 }
示例#14
0
 public static function generatePathlist()
 {
     $return = [];
     $sql = sql::factory();
     $sql->query('SELECT name, id, seo_costum_url, parent_id FROM ' . sql::table('structure'))->result();
     while ($sql->isNext()) {
         if ($sql->get('seo_costum_url')) {
             $name = $sql->get('seo_costum_url');
         } else {
             $name = self::makeSEOName($sql->get('name'));
         }
         if ($sql->get('parent_id')) {
             $name = self::getParentsName($sql->get('parent_id')) . '/' . $name;
         }
         if ($sql->get('id') == dyn::get('start_page') && dyn::get('addons')['seo']['start_url'] == 0) {
             $name = '';
         }
         $return[$name] = (int) $sql->get('id');
         $sql->next();
     }
     $return = extension::get('SEO_GENERATE_PATHLIST', $return);
     return file_put_contents(dir::addon('seo', 'pathlist.json'), json_encode($return, JSON_PRETTY_PRINT));
 }
示例#15
0
     //update devices having extension assigned to line(s) with new password
     $sql = "update v_device_lines set ";
     $sql .= "password = '" . $password . "' ";
     $sql .= "where domain_uuid = '" . $domain_uuid . "' ";
     $sql .= "and server_address = '" . $_SESSION['domain_name'] . "' ";
     $sql .= "and user_id = '" . $extension . "' ";
     $db->exec(check_sql($sql));
     unset($sql);
 }
 //if ($action == "update")
 //check the permissions
 if (permission_exists('extension_add') || permission_exists('extension_edit')) {
     //synchronize configuration
     if (is_writable($_SESSION['switch']['extensions']['dir'])) {
         require_once "app/extensions/resources/classes/extension.php";
         $ext = new extension();
         $ext->xml();
         unset($ext);
     }
     //write the provision files
     if (is_dir($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . '/app/provision')) {
         require_once "app/provision/provision_write.php";
         $ext = new extension();
     }
     //clear the cache
     $cache = new cache();
     $cache->delete("directory:" . $extension . "@" . $user_context);
 }
 //show the action and redirect the user
 if ($action == "add") {
     //prepare for alternating the row style
示例#16
0
文件: index.php 项目: kyroskoh/rokket
if (!is_null($error)) {
    echo message::danger($error);
} elseif (!is_null($success)) {
    echo message::success($success);
}
layout::addNav(lang::get('dashboard'), 'dashboard', 'home', ['refresh'], true);
layout::addNav(lang::get('settings'), 'settings', 'settings', [], false);
layout::addNav(lang::get('server'), 'server', 'list', ['add'], true);
layout::addNav(lang::get('addons'), 'addons', 'alt', [], true);
layout::addNav(lang::get('user'), 'user', 'users', ['add'], true);
foreach (addonConfig::includeAllConfig() as $file) {
    include $file;
}
if (userLogin::isLogged()) {
    $path = 'pages/' . $page . '.php';
    $path = extension::get('PAGE_PATH', $path);
    if (file_exists($path)) {
        include $path;
    } else {
        echo message::danger(lang::get('page_not_found'), false);
    }
}
$content = ob_get_contents();
ob_end_clean();
rp::add('content', $content);
if (ajax::is()) {
    echo ajax::getReturn();
    die;
}
if (userLogin::isLogged()) {
    include dir::layout('index.php', rp::get('layout'));
示例#17
0
        $field->autofocus();
        $template = template::factory(dyn::get('template'));
        $field = $form->addElement('template', $template->getTemplates('template', $form->get('template')));
        $field->fieldName(lang::get('template'));
        $field = $form->addRadioField('online', $form->get('online'));
        $field->fieldName(lang::get('status'));
        $field->add(1, lang::get('online'));
        $field->add(0, lang::get('offline'));
        if ($action == 'edit') {
            $form->addHiddenField('id', $id);
        }
        extension::add('FORM_AFTER_SAVE', function ($sql) use($action, $id) {
            if ($action == 'add') {
                $id = $sql->insertId();
                pageMisc::updateTime($id, true);
            } else {
                pageMisc::updateTime($id);
            }
            return $sql;
        });
        if ($action == 'edit') {
            $title = $form->get('name');
        } else {
            $title = lang::get('add');
        }
        $buttons = ['<a class="btn btn-sm btn-warning" href="' . url::backend('structure', ['subpage' => 'pages', 'structure_id' => $form->get('id')]) . '">' . lang::get('modules') . '</a>', '<a class="btn btn-sm btn-default" href="' . url::backend('structure') . '">' . lang::get('back') . '</a>'];
        ?>
	<div class="row"><?php 
        echo bootstrap::panel($title, $buttons, $form->show());
        ?>
</div>
/**
* sync_extensions (public)
* 
* 1) Reads directory "extensions/" and adds new record into table 'extension' for each found directory
* 2) searches for file "extension.config.php" and reads the values in that file into the extension record
*   - add new admin-pages automatically, if needed
*   - add new templates automatically, if needed
*	- add new system word group, if needed
*   - import dictionary from language files
*   - run install/update SQL files
*   - check dependencies
* 
* @package CMS
* 
*/
function sync_extensions()
{
    global $site, $class_path;
    include_once $class_path . 'lang_functions.inc.php';
    include_once $class_path . 'install.inc.php';
    $ext_path = $site->absolute_path . 'extensions/';
    $handle = opendir($ext_path);
    while (false !== ($dir = readdir($handle))) {
        if (is_dir($ext_path . $dir) && $dir != '.' && $dir != '..' && $dir != 'CVS') {
            $dirlist[] = $dir . "/";
        }
        # if
    }
    # while
    closedir($handle);
    # if no dirs found => do nothing & return
    if (!count($dirlist)) {
        return;
    }
    sort($dirlist);
    ############ loop over extension directories
    foreach ($dirlist as $dir) {
        $is_install = false;
        # true, if found new extension
        $dir_absolute_path = $ext_path . $dir;
        $dir_relative_path = 'extensions/' . $dir;
        $dir_name = substr($dir, 0, -1);
        #		printr($dir_absolute_path);
        #		printr($dir_relative_path);
        ####### check if extension exists
        $extension = new extension(array(name => $dir_name));
        ###### 1. extension not found in database => INSERT it
        if (!$extension->name) {
            $is_install = true;
            $sql = $site->db->prepare("INSERT INTO extensions (name,path,is_active) VALUES (?,?,?)", $dir_name, $dir_relative_path, '0');
            $sth = new SQL($sql);
            #print($sql);
            $site->debug->msg($sth->debug->get_msgs());
            ####### write log
            new Log(array('action' => 'create', 'component' => 'Extensions', 'message' => "New extension '" . $dir_name . "' inserted. (sync)"));
            # reload extension:
            $extension = new extension(array(name => $dir_name));
            $no_delete_extension[] = $extension->id;
        } else {
            $no_delete_extension[] = $extension->id;
            ####### WRITE LOG
            new Log(array('action' => 'update', 'component' => 'Extensions', 'message' => "New extension '" . $dir_name . "' updated. (sync)"));
        }
        ####### 2. search for CONFIG FILE
        $conf_found = $extension->load_extension_config();
        # now all config variables are in array $extension->CONF
        #printr($conf_found);
        ####### 3. UPDATE extension record
        # 3.A config file found => we have official ext, overwrite all record values with config file values
        if ($conf_found) {
            $sql = $site->db->prepare("UPDATE extensions SET path=?, is_official=?, title=?, description=?, author=?, version=?, version_date=?, icon_path=?, min_saurus_version=?, min_saurus_modules=?, is_downloadable=? WHERE name=?", $dir_relative_path, '1', $extension->CONF['title'], $extension->CONF['description'], $extension->CONF['author'], $extension->CONF['version'], $extension->CONF['version_date'], $extension->CONF['icon_path'], $extension->CONF['min_saurus_version'], $extension->CONF['min_saurus_modules'], $extension->CONF['is_downloadable'] == '1' ? '1' : '0', $extension->name);
        } else {
            $sql = $site->db->prepare("UPDATE extensions SET path=?, is_official=? WHERE name=?", $dir_relative_path, '0', $extension->name);
        }
        # official or custom ext
        $sth = new SQL($sql);
        #print($sql);
        $site->debug->msg($sth->debug->get_msgs());
        ####### 4. CREATE ADMIN-PAGES
        if (count($extension->CONF['adminpages']) > 0) {
            #printr($extension->CONF['adminpages']);
            ## get minimum sorteering from main menu "Extensions"
            $sql = $site->db->prepare("SELECT MIN(sorteering) AS min_sorteering FROM admin_osa WHERE parent_id=?", '86');
            $sth = new SQL($sql);
            #print($sql);
            $site->debug->msg($sth->debug->get_msgs());
            $min_sorteering = $sth->fetchsingle();
            $min_sorteering = intval($min_sorteering) - 1;
            ## find new ID, must be 1000...->
            $sql = $site->db->prepare("SELECT MAX(id) FROM admin_osa WHERE id >= 1000");
            $sth = new SQL($sql);
            $site->debug->msg($sth->debug->get_msgs());
            $max_id = $sth->fetchsingle();
            if ($max_id) {
                $max_id++;
            } else {
                $max_id = 1000;
            }
            foreach ($extension->CONF['adminpages'] as $adminpage) {
                ## parent ID is hardcoded "86": Extensions
                #check if adminpage exists:
                $sql = $site->db->prepare("SELECT id FROM admin_osa WHERE eng_nimetus=? AND parent_id=? AND extension=?", $adminpage["name"], '86', $extension->name);
                $sth = new SQL($sql);
                $adminpage_id = $sth->fetchsingle();
                ## if not found => INSERT
                if (!$adminpage_id) {
                    $sql = $site->db->prepare("INSERT INTO admin_osa (id, parent_id, sorteering, eng_nimetus, fail, moodul_id, extension) VALUES (?, ?, ?, ?, ?, ?, ?)", $max_id, 86, $min_sorteering, $adminpage["name"], $site->CONF['wwwroot'] . '/' . $extension->path . $adminpage["file"], 0, $extension->name);
                    $max_id++;
                    #######write log
                    new Log(array('action' => 'create', 'component' => 'Extensions', 'message' => "Extension '" . $extension->name . "': new admin-page '" . $adminpage["name"] . "' inserted (sync)"));
                } else {
                    $sql = $site->db->prepare("UPDATE admin_osa SET eng_nimetus=?, fail=?, extension=?  WHERE id=?", $adminpage["name"], $site->CONF['wwwroot'] . '/' . $extension->path . $adminpage["file"], $extension->name, $adminpage_id);
                    $no_delete_list[] = $adminpage_id;
                }
                $sth = new SQL($sql);
                if (!$adminpage_id) {
                    $no_delete_list[] = $sth->insert_id;
                }
                #print($sql);
                $site->debug->msg($sth->debug->get_msgs());
                #######################
                # save system word to group "admin":
                include_once $class_path . 'adminpage.inc.php';
                // get admin section key (should always be 12, but in any case)
                $sql = "select sst_id from sys_sona_tyyp where voti = 'admin'";
                $result = new SQL($sql);
                $sst_id = $result->fetchsingle();
                // insert the same translation for every active language
                $sql = 'select distinct glossary_id as keel_id from keel where on_kasutusel = 1';
                $result = new SQL($sql);
                while ($row = $result->fetch('ASSOC')) {
                    save_systemword(array('sysword' => $adminpage['name'], 'translation' => $adminpage['name'], 'lang_id' => $row['keel_id'], 'sst_id' => $sst_id));
                }
            }
            # loop over adminpages
            if (!empty($extension->name)) {
                new sql("delete from admin_osa where extension='" . $extension->name . "' and id not in (" . implode(",", $no_delete_list) . ")");
            }
        }
        # if adminpages found
        ####### 5. CREATE TEMPLATES
        if (count($extension->CONF['templates']) > 0) {
            #printr($extension->CONF['templates']);
            $sql = $site->db->prepare("SELECT max(ttyyp_id) FROM templ_tyyp WHERE ttyyp_id >= 1000 AND ttyyp_id < 2000 OR ttyyp_id >= 2100");
            $sth = new SQL($sql);
            $site->debug->msg($sth->debug->get_msgs());
            $max_id = $sth->fetchsingle();
            if ($max_id) {
                $max_id++;
            } else {
                $max_id = 1000;
            }
            ############## loop over templates
            foreach ($extension->CONF['templates'] as $template) {
                #check if template exists:
                $template['op'] = translate_ee($template['op']);
                /* get op: dont overwrite existing values */
                $sql = $site->db->prepare("SELECT op FROM templ_tyyp WHERE op=? AND nimi<>?;", $template['op'], $template['name']);
                $sth = new SQL($sql);
                $op_found = $sth->fetchsingle();
                if ($op_found) {
                    $template['op'] = '';
                    # dont overwrite
                }
                $sql = $site->db->prepare("SELECT ttyyp_id FROM templ_tyyp WHERE nimi=? AND extension=?", $template["name"], $extension->name);
                $sth = new SQL($sql);
                $template_id = $sth->fetchsingle();
                ## if not found => INSERT
                if (!$template_id) {
                    $sql = $site->db->prepare("INSERT INTO templ_tyyp (ttyyp_id, nimi, templ_fail, on_page_templ, on_nahtav, extension, op, is_readonly, is_default, preview, preview_thumb) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", $max_id, $template['name'], '../../../' . $extension->path . $template['file'], $template['is_page'] ? 1 : 0, $template['is_visible'] ? 1 : 0, $extension->name, $template['op'], $template['is_readonly'] ? 1 : 0, $template['is_default'] ? 1 : 0, $template['preview'], $template['preview_thumb']);
                    $max_id++;
                    #######write log
                    new Log(array('action' => 'create', 'component' => 'Extensions', 'message' => "Extension '" . $extension->name . "': new template '" . $template["name"] . "' inserted (sync)"));
                } else {
                    $sql = $site->db->prepare("UPDATE templ_tyyp SET nimi=?, templ_fail=?, on_page_templ=?, on_nahtav=?, extension=?, op=" . ($template['op'] ? "'" . mysql_real_escape_string($template['op']) . "'" : 'op') . ", is_readonly=?, is_default = ?, preview = ?, preview_thumb = ? WHERE ttyyp_id=?", $template['name'], '../../../' . $extension->path . $template['file'], $template['is_page'] ? 1 : 0, $template['is_visible'] ? 1 : 0, $extension->name, $template['is_readonly'] ? 1 : 0, $template['is_default'] ? 1 : 0, $template['preview'], $template['preview_thumb'], $template_id);
                }
                $sth = new SQL($sql);
                #print($sql.'<br />');
                $site->debug->msg($sth->debug->get_msgs());
            }
            # loop over templates
        }
        # if templates found
        ####### 6. CREATE SYSTEMWORD GROUP in GLOSSARY
        # check if systemword group with that name exists
        $sql = $site->db->prepare("SELECT sst_id FROM sys_sona_tyyp WHERE voti=?", $extension->name);
        $sth = new SQL($sql);
        $sst_id = $sth->fetchsingle();
        # UPDATE glossary group name
        if ($sst_id) {
            $sql = $site->db->prepare("UPDATE sys_sona_tyyp SET voti=?, nimi=?, extension=? WHERE sst_id=?", $extension->name, $extension->CONF['title'] ? $extension->CONF['title'] : $extension->name, $extension->name, $sst_id);
            $sth = new SQL($sql);
        } else {
            # find new sst ID (must be >= 100; 0...100 are reserved for Saurus internal use)
            $sql = $site->db->prepare("SELECT MAX(sst_id) FROM sys_sona_tyyp");
            $sth = new SQL($sql);
            $site->debug->msg($sth->debug->get_msgs());
            $max_id = $sth->fetchsingle();
            if ($max_id >= 100) {
                $max_id++;
            } else {
                $max_id = 100;
            }
            $sql = $site->db->prepare("INSERT INTO sys_sona_tyyp (sst_id, voti, nimi, extension) VALUES (?,?,?,?)", $max_id, $extension->name, $extension->CONF['title'] ? $extension->CONF['title'] : $extension->name, $extension->name);
            $sth = new SQL($sql);
            ####### write log
            new Log(array('action' => 'create', 'component' => 'Extensions', 'message' => "Extension '" . $extension->name . "': new glossary group '" . $extension->CONF['title'] . "' inserted (sync)"));
        }
        ########## 7. import dictionary from language files
        if ($extension->name) {
            /* get site's languages and encodings */
            $languages = array();
            $sql = 'select distinct glossary_id as keel_id, encoding from keel where on_kasutusel = 1;';
            $result = new SQL($sql);
            while ($lang = $result->fetch('ASSOC')) {
                if (file_exists($site->absolute_path . 'extensions/' . $extension->name . '/lang/' . $lang['encoding'] . '/language' . $lang['keel_id'] . '.csv')) {
                    import_dict_from_file($site->absolute_path . 'extensions/' . $extension->name . '/lang/' . $lang['encoding'] . '/language' . $lang['keel_id'] . '.csv');
                }
            }
        }
        ####### 4. RUN INSTALL/UPDATE SQL FILES
        # 8A. if INSTALLING new extension then run all *.sql files in extension folder "install/"
        if ($is_install) {
            $ext_install_path = $dir_absolute_path . 'install/';
            if (is_dir($ext_install_path)) {
                # if install/ exists, Bug #2442
                $handle = opendir($ext_install_path);
                while (false !== ($dir = readdir($handle))) {
                    if (is_file($file = $ext_install_path . $dir) && $dir != '.' && $dir != '..' && $dir != 'CVS') {
                        $tmp_parts = pathinfo($ext_install_path . $dir);
                        ## if file extension is "sql" (case insensitive) => run sql files
                        if (strtoupper($tmp_parts['extension']) == 'SQL') {
                            #
                            if ($fd = fopen($file, "r")) {
                                $sql = fread($fd, filesize($file));
                                fclose($fd);
                                # if there is smth in file
                                if ($sql) {
                                    $pieces = split_sql_file($sql, ';');
                                    // now $pieces is an array of all sql directives to launch
                                    foreach ($pieces as $query) {
                                        $sth = new SQL($query);
                                        if ($sth->error) {
                                            print "<font color=red>Error: " . $sth->error . "</font><br />";
                                        }
                                        $i++;
                                    }
                                }
                                # data found
                            } else {
                                echo "<font color=red>Can't open data file \"<b>" . $filename . "</b>\" - access denied</font><br />";
                            }
                            # cant open sql file
                        }
                        # if sql file
                    }
                    # file
                }
                # while
                closedir($handle);
            }
            # if dir exists
        } else {
        }
        # is update
        ############# 9. CHECK DEPENDENCIES
        $extension->check_dependencies();
    }
    // Delete non-existing extensions
    if (is_array($no_delete_extension)) {
        $sth = new SQL("select name from extensions where extension_id not in (" . implode(",", $no_delete_extension) . ")");
        while ($r = $sth->fetch("ASSOC")) {
            $extension = new extension(array(name => $r['name']));
            $extension->uninstall();
        }
    }
    ############ / loop over extension directories
}
示例#19
0
$subpage = type::super('subpage', 'string');
$successMsg = type::get('success_msg', 'string');
$errorMsg = type::get('error_msg', 'string');
if (!is_null($errorMsg)) {
    echo message::danger($errorMsg);
} elseif (!is_null($successMsg)) {
    echo message::success($successMsg);
}
if (userLogin::isLogged()) {
    if ($file = backend::getNaviInclude()) {
        include $file;
    }
}
$content = ob_get_contents();
ob_end_clean();
$content = extension::get('BACKEND_OUTPUT', $content);
dyn::add('content', $content);
if (ajax::is()) {
    $deleteAction = type::get('deleteAction', 'bool', false);
    if ($deleteAction) {
        $title = type::get('title', 'string');
        $message = type::get('message', 'string');
        getDeleteModal($title, $message);
    }
    echo ajax::getReturn();
    die;
}
if (userLogin::isLogged()) {
    include dir::backend('layout/index.php');
} else {
    include dir::backend('layout/login.php');
示例#20
0
function items_form($item)
{
    global $user;
    global $DB;
    global $website;
    global $layout;
    global $theme;
    global $events;
    global $current_version;
    $navibars = new navibars();
    $naviforms = new naviforms();
    $layout->navigate_media_browser();
    // we can use media browser in this function
    $extra_actions = array();
    if (empty($item->id)) {
        $navibars->title(t(22, 'Items') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(22, 'Items') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    $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>'));
    if (empty($item->id)) {
        $navibars->add_actions(array($user->permission('items.create') == 'true' ? '<a href="#" onclick="navigate_items_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($user->permission('items.edit') == 'true' || $item->author == $user->id ? '<a href="#" onclick="navigate_items_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("items.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>' : ""));
        $extra_actions[] = '<a href="#" onclick="navigate_items_preview();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/monitor.png"> ' . t(274, 'Preview') . '</a>';
        if ($user->permission("items.create") != 'false') {
            $extra_actions[] = '<a href="?fid=items&act=duplicate&id=' . $item->id . '"><img height="16" align="absmiddle" width="16" src="img/icons/silk/page_copy.png"> ' . t(477, 'Duplicate') . '</a>';
        }
        $layout->add_script('
            function navigate_delete_dialog()
            {
                navigate_confirmation_dialog(
                    function() { window.location.href = "?fid=items&act=delete&id=' . $item->id . '"; }, 
                    null, null, "' . t(35, 'Delete') . '"
                );
            }
        ');
    }
    if (!empty($item->id)) {
        $notes = grid_notes::comments('item', $item->id);
        $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_display_notes_dialog();">
					<span class="navigate_grid_notes_span" style=" width: 20px; line-height: 16px; ">' . count($notes) . '</span>
					<img src="img/skins/badge.png" width="20px" height="18px" style="margin-top: -2px;" class="grid_note_edit" align="absmiddle" /> ' . t(168, 'Notes') . '
				</a>'));
    }
    if (!empty($item->id)) {
        // we attach an event to "items" which will be fired by navibars to put an extra button
        $events->add_actions('items', array('item' => &$item, 'navibars' => &$navibars), $extra_actions);
    }
    if (!empty($item->id)) {
        $layout->navigate_notes_dialog('item', $item->id);
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=items&act=edit"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=items&act=list"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>', 'search_form'));
    // languages
    $ws_languages = $website->languages();
    $navibars->form('', 'fid=items&act=edit&id=' . $item->id);
    $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    ");
    $layout->add_script('
		var template_sections = [];	
	');
    $navibars->add_tab(t(43, "Main"));
    // tab #0
    $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>ID</label>', '<span>' . (!empty($item->id) ? $item->id : t(52, '(new)')) . '</span>'));
    if (empty($item->id)) {
        $item->date_to_display = core_time();
    }
    $navibars->add_tab_content_row(array('<label>' . t(551, 'Date to display') . '</label>', $naviforms->datefield('date_to_display', $item->date_to_display, true)));
    $navibars->add_tab_content_row(array('<label>' . t(85, 'Date published') . '</label>', $naviforms->datefield('date_published', $item->date_published, true)));
    $navibars->add_tab_content_row(array('<label>' . t(90, 'Date unpublished') . '</label>', $naviforms->datefield('date_unpublish', $item->date_unpublish, true)));
    $navibars->add_tab_content_row(array('<label>' . t(364, 'Access') . '</label>', $naviforms->selectfield('access', array(0 => 0, 1 => 2, 2 => 1, 3 => 3), array(0 => t(254, 'Everybody'), 1 => t(362, 'Not signed in'), 2 => t(361, 'Web users only'), 3 => t(512, 'Selected web user groups')), $item->access, 'navigate_webuser_groups_visibility($(this).val());', false, array(1 => t(363, 'Users who have not yet signed in')))));
    $webuser_groups = webuser_group::all_in_array();
    $navibars->add_tab_content_row(array('<label>' . t(506, "Groups") . '</label>', $naviforms->multiselect('groups', array_keys($webuser_groups), array_values($webuser_groups), $item->groups)), 'webuser-groups-field');
    $layout->add_script('
        function navigate_webuser_groups_visibility(access_value)
        {
            if(access_value==3)
                $("#webuser-groups-field").show();
            else
                $("#webuser-groups-field").hide();
        }

        navigate_webuser_groups_visibility(' . $item->access . ');
    ');
    $permission_options = array(0 => t(69, 'Published'), 1 => t(70, 'Private'), 2 => t(81, 'Hidden'));
    if ($user->permission("items.publish") == 'false') {
        if (!isset($item->permission)) {
            $item->permission = 1;
        }
        $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', $permission_options[$item->permission], $naviforms->hidden("permission", $item->permission)));
    } else {
        $navibars->add_tab_content_row(array('<label>' . t(68, 'Status') . '</label>', $naviforms->selectfield('permission', array_keys($permission_options), array_values($permission_options), $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'))), '<span id="status_info" class="ui-icon ui-icon-alert"
                       data-message="' . t(618, 'Change the status to Published to see the item on the future publication date currently assigned', false, true) . '"
					   style="display: none; float: none; vertical-align: middle; "></span>'));
    }
    if (empty($item->id)) {
        $item->author = $user->id;
    }
    $author_webuser = $DB->query_single('username', 'nv_users', ' id = ' . $item->author);
    $navibars->add_tab_content($naviforms->hidden('item-author', $item->author));
    $navibars->add_tab_content_row(array('<label>' . t(266, 'Author') . '</label>', $naviforms->textfield('item-author-text', $author_webuser)));
    // script#1
    if ($item->date_modified > 0) {
        $navibars->add_tab_content_row(array('<label>' . t(227, 'Date modified') . '</label>', core_ts2date($item->date_modified, true)));
    }
    if ($item->date_created > 0) {
        $navibars->add_tab_content_row(array('<label>' . t(226, 'Date created') . '</label>', core_ts2date($item->date_created, true)));
    }
    $navibars->add_tab_content_row(array('<label>' . t(280, 'Page views') . '</label>', $item->views), "div_page_views");
    $navibars->add_tab(t(87, "Association"));
    // tab #1
    $navibars->add_tab_content_row(array('<label>' . t(87, "Association") . '</label>', $naviforms->buttonset('association', array('free' => t(100, 'Free'), 'category' => t(78, 'Category')), empty($item->id) ? 'category' : $item->association, "navigate_change_association(this);")));
    $hierarchy = structure::hierarchy(0);
    $categories_list = structure::hierarchyList($hierarchy, $item->category);
    if (empty($categories_list)) {
        $categories_list = '<ul><li value="0">' . t(428, '(no category)') . '</li></ul>';
    }
    $navibars->add_tab_content_row(array('<label>' . t(78, 'Category') . '</label>', $naviforms->dropdown_tree('category', $categories_list, $item->category, 'navigate_item_category_change')), 'div_category_tree');
    $layout->add_script('
        function navigate_item_category_change(id)
        {
            $.ajax(
            {
                url: NAVIGATE_APP + "?fid=" + navigate_query_parameter("fid") + "&act=96&id=" + id,
                dataType: "json",
                data: {},
                success: function(data, textStatus, xhr)
                {
                    item_category_path = data;
                }
            });
        }
    ');
    $navibars->add_tab_content_row(array('<label>' . t(162, 'Embedding') . '</label>', $naviforms->buttonset('embedding', array('1' => t(163, 'Embedded'), '0' => t(164, 'Own path')), empty($item->id) ? '1' : intval($item->embedding), "navigate_change_association();"), '<span id="embedding_info" class="ui-icon ui-icon-info"
			        data-message-title-1="' . t(163, 'Embedded', false, true) . '"
					data-message-content-1="' . t(165, 'Full content is shown on category page. Ex. "Who we are?"', false, true) . '"
					data-message-title-2="' . t(164, 'Own path', false, true) . '"
					data-message-content-2="' . t(166, 'The content is accessed through its own url. Ex. "News"', false, true) . '" 
					style="float: left; margin-left: -4px;">
			</span>'), 'div_category_embedded');
    $navibars->add_tab_content_row(array('<label>' . t(22, 'Elements') . '</label>', '<button style="float: left;">' . t(171, 'Order') . '</button>', '<span id="order_info" class="ui-icon ui-icon-info"
 				   data-message="' . t(425, 'Order elements of a category (unless the template forces other sorting)', false, true) . '"
				   style="float: left; margin-left: 2px;">				   
			</span>', '<div id="items_order_window" style="display: none;"></div>'), 'div_category_order');
    $layout->add_script('
	    $("#div_category_order button").button(
	    {
	        icons:
	        {
                primary: "ui-icon-arrowthick-2-n-s"
            }
	    }).on("click", function(e)
	    {
	        e.stopPropagation();
	        e.preventDefault();
	        navigate_status(navigate_t(6, "Loading") + "...", "loader");

	        $("#items_order_window").load("?fid=items&act=items_order&category=" + $("#category").val() + "&_bogus=" + new Date().getTime(), function()
	        {
	            navigate_status(navigate_t(42, "Ready"), "ready");
                $("#items_order_window").dialog({
                    modal: true,
                    title: "' . t(171, 'Order') . '",
                    width: 600,
                    height: 500,
                    buttons:
                    {
                        "' . t(58, 'Cancel') . '": function()
                        {
                            $(this).dialog("destroy");
                        },
                        "' . t(190, 'Ok') . '": function()
                        {
                            var dialog = this;
                            // save
                            $.post(
                                "?fid=items&act=items_order&category=" + $("#category").val() + "&_bogus=" + new Date().getTime(),
                                {
                                    "items-order": $("#items-order").val()
                                },
                                function(response)
                                {
                                    if(response=="true")
                                    {
                                        $(dialog).dialog("destroy");
                                    }
                                    else
                                    {
                                        $("<div>"+response+"</div>").dialog({
                                            modal: true,
                                            title: "' . t(56, "Unexpected error") . '"
                                        });
                                    }
                                }
                            );
                        }
                    }
                });
            });
	    });
	');
    $templates = template::elements('element');
    $template_select = $naviforms->select_from_object_array('template', $templates, 'id', 'title', $item->template);
    $navibars->add_tab_content_row(array('<label>' . t(79, 'Template') . '</label>', $template_select, '<span id="template_info" class="ui-icon ui-icon-alert"
 				   data-message="' . t(619, "Template changed, please Save now to see the changes in the next tabs", false, true) . '"
				   style="display: none; float: none; vertical-align: middle; "></span>'), 'div_template_select');
    $layout->add_script('
		var last_check = [];
		var active_languages = ["' . implode('", "', array_keys($ws_languages)) . '"];
		$("#div_template_select").hide();
	');
    // script#3
    if (!empty($item->id)) {
        $navibars->add_tab(t(9, "Content"));
        // tab #2
        $navibars->add_tab_content_row(array('<label>' . t(63, 'Languages') . '</label>', $naviforms->buttonset('language_selector', $ws_languages, $website->languages_list[0], "navigate_items_select_language(this);")));
        $template = $item->load_template();
        $translate_extensions = extension::list_installed('translate', false);
        foreach ($website->languages_list as $lang) {
            $navibars->add_tab_content('<div class="language_fields" id="language_fields_' . $lang . '" style=" display: none; ">');
            $navibars->add_tab_content_row(array('<label>' . t(67, 'Title') . '</label>', $naviforms->textfield('title-' . $lang, @$item->dictionary[$lang]['title'])));
            $open_live_site = '';
            if (!empty($item->paths[$lang])) {
                $open_live_site = ' <a target="_blank" href="' . $website->absolute_path(true) . $item->paths[$lang] . '"><img src="img/icons/silk/world_go.png" align="absmiddle" /></a>';
            }
            $navibars->add_tab_content_row(array('<label>' . t(75, 'Path') . $open_live_site . '</label>', $naviforms->textfield('path-' . $lang, @$item->paths[$lang], NULL, 'navigate_items_path_check(this, event);'), '<span>&nbsp;</span>'), 'div_path_' . $lang);
            if (!isset($template->sections)) {
                $template->sections[] = array(0 => array('id' => 'main', 'name' => '#main#', 'editor' => 'tinymce', 'width' => '960px'));
            }
            if (!is_array($template->sections)) {
                $template->sections = array();
            }
            // compatibility fix: auto-correct template sections with missing ID (only "code" provided)
            for ($s = 0; $s < count($template->sections); $s++) {
                if (!isset($template->sections[$s]['id'])) {
                    $template->sections[$s]['id'] = $template->sections[$s]['code'];
                }
            }
            foreach ($template->sections as $section) {
                if (is_object($section)) {
                    $section = (array) $section;
                }
                // ignore empty sections
                if (empty($section)) {
                    continue;
                }
                if ($section['editor'] == 'tinymce') {
                    $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'] . '(\'section-' . $section['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);
                        }
                    }
                    $navibars->add_tab_content_row(array('<label>' . template::section_name($section['name']) . '<span class="editor_selector" for="section-' . $section['id'] . '-' . $lang . '">' . '<i class="fa fa-border fa-fw fa-lg fa-file-text-o active" data-action="tinymce" title="' . t(614, "Edit with TinyMCE") . '"></i> ' . '<i class="fa fa-border fa-fw fa-lg fa-code" data-action="html" title="' . t(615, "Edit as source code") . '"></i> ' . '<i class="fa fa-border fa-fw fa-lg fa-eraser" data-action="clear" title="' . t(208, "Remove all content") . '"></i>' . '</span>' . '</label>', $naviforms->editorfield('section-' . $section['id'] . '-' . $lang, @$item->dictionary[$lang]['section-' . $section['id']], $section['width'] + 48 . 'px', $lang), '<div style="clear:both; margin-top:5px; float:left; margin-bottom: 10px;">', '<label>&nbsp;</label>', $translate_menu, '<button onclick="navigate_items_copy_from_dialog(\'section-' . $section['id'] . '-' . $lang . '\'); return false;"><img src="img/icons/silk/page_white_copy.png" align="absmiddle"> ' . t(189, 'Copy from') . '...</button> ', '<button onclick="navigate_items_copy_from_history_dialog(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/time_green.png" align="absmiddle"> ' . t(40, 'History') . '</button> ', !empty($theme->content_samples) ? '<button onclick="navigate_items_copy_from_theme_samples(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/rainbow.png" align="absmiddle"> ' . t(553, 'Fragments') . ' | ' . $theme->title . '</button> ' : '', '</div>', '<br />'), '', 'lang="' . $lang . '"');
                } else {
                    if ($section['editor'] == 'html') {
                        $navibars->add_tab_content_row(array('<label>' . template::section_name($section['name']) . '</label>', $naviforms->scriptarea('section-' . $section['id'] . '-' . $lang, @$item->dictionary[$lang]['section-' . $section['id']], 'html', ' width: ' . $section['width'] . 'px'), '<div style="clear:both; margin-top:5px; float:left; margin-bottom: 10px;">', '<label>&nbsp;</label>', '<button onclick="navigate_items_copy_from_history_dialog(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/time_green.png" align="absmiddle"> ' . t(40, 'History') . '</button> ', !empty($theme->content_samples) ? '<button onclick="navigate_items_copy_from_theme_samples(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/rainbow.png" align="absmiddle"> ' . t(553, 'Fragments') . ' | ' . $theme->title . '</button> ' : '', '</div>', '<br />'), '', 'lang="' . $lang . '"');
                    } else {
                        $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_textarea_translate_' . $te['code'] . '(\'section-' . $section['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);
                            }
                        }
                        $navibars->add_tab_content_row(array('<label>' . template::section_name($section['name']) . '</label>', $naviforms->textarea('section-' . $section['id'] . '-' . $lang, @$item->dictionary[$lang]['section-' . $section['id']], 8, 48, ' width: ' . $section['width'] . 'px'), '<div style="clear:both; margin-top:5px; margin-bottom: 10px; ">', '<label>&nbsp;</label>', $translate_menu, '<button onclick="navigate_items_copy_from_history_dialog(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/time_green.png" align="absmiddle"> ' . t(40, 'History') . '</button> ', !empty($theme->content_samples) ? '<button onclick="navigate_items_copy_from_theme_samples(\'section-' . $section['id'] . '-' . $lang . '\', \'' . $section['id'] . '\', \'' . $lang . '\', \'' . $section['editor'] . '\'); return false;"><img src="img/icons/silk/rainbow.png" align="absmiddle"> ' . t(553, 'Fragments') . ' | ' . $theme->title . '</button> ' : '', '</div>'), '', 'lang="' . $lang . '"');
                    }
                }
            }
            if ($template->tags == 1 || $template->tags == 'true') {
                $tags_copy_select = '';
                $tags_copy_select_pre = '';
                $tags_copy_select_after = '';
                // allow copying tags between languages?
                if (count($website->languages_list) > 1) {
                    $tags_copy_select = $naviforms->selectfield('', array_keys($ws_languages), array_values($ws_languages), '', '', false, '', ' width: auto; position: absolute; margin-top: 1px; ', false);
                    $tags_copy_select = '
						<div style=" position: relative; margin-left: 600px; margin-top: -57px; width: 200px; height: 68px; ">
							<a href="#" class="uibutton" title="' . t(189, "Copy from") . '…"
							   onclick=" navigate_items_tags_copy_from_language($(this).next().val(), \'' . $lang . '\'); return false; ">
								<img src="img/icons/silk/page_white_copy.png" width="16" height="16" align="absmiddle" style=" cursor: pointer; " />
							</a>&nbsp;' . $tags_copy_select . '
						</div>
					';
                }
                $tags_top_list = '
					<div style=" position: relative; margin-left: 600px; margin-top: -93px; width: 200px; height: 92px; ">
						<a href="#" class="uibutton" onclick=" navigate_items_tags_ranking(\'' . $lang . '\', this); return false; ">
							<img src="img/icons/silk/award_star_gold_3.png" width="16" height="16" align="absmiddle" style=" cursor: pointer; " />
							' . t(613, "Most used") . '
						</a>
					</div>
				';
                $navibars->add_tab_content_row(array('<label>' . t(265, 'Tags') . '</label>', $naviforms->textfield('tags-' . $lang, @$item->dictionary[$lang]['tags']), $tags_top_list, $tags_copy_select));
            }
            $layout->add_script('			                
                $("#tags-' . $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 = "";
                            
                        $("#tags-' . $lang . '")
                            .val(tags)
                            .trigger("change");
                    },
                    afterTagRemoved: function(event, ui)
                    {                    
                        var tags = $(this).tagit("assignedTags");
                        if(tags.length > 0)
                            tags = tags.join(",");
                        else
                            tags = "";
                            
                        $("#tags-' . $lang . '")
                            .val(tags)
                            .trigger("change");
                    }
                });
                
                $("#tags-' . $lang . '").next().sortable({
                    items: ">li:not(.tagit-new)",
                    update: function(ui, event)
                    {
                        var tags = [];
                        
                        $("#tags-' . $lang . '").next().find("span.tagit-label").each(function()
                        {
                            if($(this).text() != "")
                                tags.push($(this).text());
                        });
                        if(tags.length > 0) tags = tags.join(",");
                        else                tags = "";
                                                    
                        $("#tags-' . $lang . '").val(tags);
                        $("#tags-' . $lang . '").trigger("change");                                                
                    }
                });                
			');
            // script#4
            $navibars->add_tab_content('</div>');
        }
        // translate content_samples titles
        if (is_array($theme->content_samples)) {
            for ($i = 0; $i < count($theme->content_samples); $i++) {
                $theme->content_samples[$i]->title = $theme->t($theme->content_samples[$i]->title);
            }
        }
        $layout->add_script('
			var template_sections = ' . json_encode($template->sections) . ';
		    var theme_content_samples = ' . json_encode($theme->content_samples) . ';
		    var website_theme = "' . $website->theme . '";
		');
        $category = new structure();
        $category->paths = array();
        if (!empty($item->category)) {
            $category->load($item->category);
        }
        $layout->add_script('
			var item_category_path = ' . json_encode($category->paths) . ';
			var item_id = "' . $item->id . '";
		');
        // script#5
        // select the first language of the website as the default origin when copying content
        $default_language = array_keys($ws_languages);
        $default_language = $default_language[0];
        $layout->add_content('
			<div id="navigate_items_copy_from" style=" display: none; ">
				<div class="navigate-form-row">
					<label>' . t(191, 'Source') . '</label>
					' . $naviforms->buttonset('navigate_items_copy_from_type', array('language' => t(46, 'Language'), 'item' => t(180, 'Item')), '0', "navigate_items_copy_from_change_origin(this);") . '
				</div>
				<div class="navigate-form-row" style=" display: none; ">
					<label>' . t(46, 'Language') . '</label>
					' . $naviforms->selectfield('navigate_items_copy_from_language_selector', array_keys($ws_languages), array_values($ws_languages), $default_language) . '
				</div>
				<div class="navigate-form-row" style=" display: none; ">
					<label>' . t(79, 'Template') . '</label>
					' . $naviforms->select_from_object_array('navigate_items_copy_from_template', $templates, 'id', 'title', '', '') . '
				</div>			
				<div class="navigate-form-row" style=" display: none; ">		
					<label>' . t(67, 'Title') . '</label>			
					' . $naviforms->textfield('navigate_items_copy_from_title') . '
					' . $naviforms->hidden('navigate_items_copy_from_item_id', '') . '
				</div>
				<div class="navigate-form-row" style=" display: none; ">
					<label>' . t(239, 'Section') . '</label>
					' . $naviforms->select_from_object_array('navigate_items_copy_from_section', array(), 'id', 'name', '') . '
				</div>			
			</div>
			
			<div id="navigate_items_copy_from_history" style=" display: none; ">
				<div class="navigate-form-row">
					<label>' . t(196, 'Date & time') . '</label>
					<select id="navigate_items_copy_from_history_options" 
							name="navigate_items_copy_from_history_options" 
							onchange="navigate_items_copy_from_history_preview(this.value, $(this).attr(\'type\'));">
					</select>
					<a href="#" onclick="navigate_items_copy_from_history_remove();"><img src="img/icons/silk/cancel.png" align="absmiddle"></a>
				</div>			
				<div class="navigate-form-row">
					<!--<div id="navigate_items_copy_from_history_text"
						 name="navigate_items_copy_from_history_text"
						 style="border: 1px solid #CCCCCC; float: left; height: auto; min-height: 20px; overflow: auto; width: 97%; padding: 3px; background: #f7f7f7;">
					</div>
					-->
					<textarea style="display: none;" id="navigate_items_copy_from_history_stylesheets">' . $website->content_stylesheets('link_tag') . '</textarea>
					<iframe id="navigate_items_copy_from_history_text"
						 name="navigate_items_copy_from_history_text"
						 src="about:blank"
						 style="border: 1px solid #CCCCCC; float: left; height: 300px; min-height: 20px; overflow: auto; width: 97%; padding: 3px; ">
					</iframe>
					<div id="navigate_items_copy_from_history_text_raw" style=" display: none; "></div>
				</div>			
			</div>

			<div id="navigate_items_copy_from_theme_samples" style=" display: none; ">
				<div class="navigate-form-row">
					<label>' . t(79, 'Template') . '</label>
					<select id="navigate_items_copy_from_theme_samples_options"
							name="navigate_items_copy_from_theme_samples_options"
							onchange="navigate_items_copy_from_theme_samples_preview(this.value, $(this).attr(\'type\'), $(this).find(\'option:selected\').attr(\'source\'));">
					</select>
				</div>
				<div class="navigate-form-row">
					<div id="navigate_items_copy_from_theme_samples_text"
						 name="navigate_items_copy_from_theme_samples_text"
						 style="border: 1px solid #CCCCCC; float: left; height: auto; min-height: 20px; overflow: auto; width: 97%; padding: 3px; background: #f7f7f7;">
					</div>
					<div id="navigate_items_copy_from_theme_samples_text_raw" style=" display: none; "></div>
				</div>
			</div>
		');
        // script will be bound to onload event at the end of this php function (after getScript is done)
        $onload_language = $_REQUEST['tab_language'];
        if (empty($onload_language)) {
            $onload_language = $website->languages_list[0];
        }
        $layout->add_script('
			function navigate_items_onload()
			{
				navigate_items_select_language("' . $onload_language . '");
				navigate_change_association("' . (empty($item->id) ? 'category' : $item->association) . '");
				setTimeout(function()
				{
					$(navigate_codemirror_instances).each(function() { this.refresh(); } );
				}, 500);
			};
		');
        /* IMAGE GALLERIES */
        if ($template->gallery === 'true' || $template->gallery > 0) {
            $navibars->add_tab(t(210, "Gallery"));
            // tab #3
            $access = array(0 => '', 1 => '<img src="img/icons/silk/lock.png" align="absmiddle" title="' . t(361, 'Web users only') . '" />', 2 => '<img src="img/icons/silk/user_gray.png" align="absmiddle" title="' . t(363, 'Users who have not yet signed up or signed in') . '" />', 3 => '<img src="img/icons/silk/group_key.png" align="absmiddle" title="' . t(512, "Selected web user groups") . '" />');
            $permissions = array(0 => '', 1 => '<img src="img/icons/silk/world_dawn.png" align="absmiddle" title="' . t(70, 'Private') . '" />', 2 => '<img src="img/icons/silk/world_night.png" align="absmiddle" title="' . t(81, 'Hidden') . '" />');
            if (!is_array($item->galleries[0])) {
                $item->galleries[0] = array();
            }
            $gallery_elements_order = implode('#', array_keys($item->galleries[0]));
            $navibars->add_tab_content($naviforms->hidden('items-gallery-elements-order', $gallery_elements_order));
            $gallery = '<ul id="items-gallery-elements" class="items-gallery">';
            $ids = array_keys($item->galleries[0]);
            //$default_img = 'data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='; // transparent pixel
            $default_img = 'img/icons/ricebowl/mimetypes/image.png';
            for ($g = 0; $g < count($ids); $g++) {
                $f = new file();
                $f->load($ids[$g]);
                $gallery .= '
				    <li>
                        <div id="items-gallery-item-' . $ids[$g] . '-droppable" class="navigate-droppable ui-corner-all" data-file-id="' . $f->id . '">
                            <div class="file-access-icons">' . $access[$f->access] . $permissions[$f->permission] . '</div>
                            <img title="' . $ids[$g] . '" src="' . $default_img . '" data-src="' . NAVIGATE_DOWNLOAD . '?wid=' . $website->id . '&id=' . $ids[$g] . '&amp;disposition=inline&amp;width=75&amp;height=75" width="75" height="75" />
                        </div>
                        <div class="navigate-droppable-cancel" style="display: block;"><img src="img/icons/silk/cancel.png" /></div>
                    </li>
                ';
            }
            // empty element
            $gallery .= '
                <li class="gallery-item-empty-droppable">
                    <div id="items-gallery-item-empty-droppable" class="navigate-droppable ui-corner-all">
                        <img src="img/icons/misc/dropbox.png" vspace="18" />
                    </div>
                </li>
            ';
            $gallery .= '</ul>';
            // now the image captions
            foreach ($item->galleries[0] as $image_id => $image_dictionary) {
                if (!is_array($image_dictionary)) {
                    $image_dictionary = array();
                }
                foreach ($website->languages_list as $lang) {
                    $gallery .= $naviforms->hidden('items-gallery-item-' . $image_id . '-dictionary-' . $lang, $image_dictionary[$lang]);
                }
            }
            $navibars->add_tab_content_row(array('<label>' . t(210, 'Gallery') . '</label>', '<div>' . $gallery . '</div>'));
            $layout->add_content('
				<ul id="contextmenu-gallery-items" style="display: none" class="ui-corner-all">
	                <li id="contextmenu-gallery-items-properties"><a href="#"><span class="ui-icon ui-icon-contact"></span>' . t(213, "Image caption") . '</a></li>
	                <li id="contextmenu-gallery-items-permissions"><a href="#"><span class="ui-icon ui-icon-key"></span>' . t(17, "Permissions") . '</a></li>
	                <li id="contextmenu-gallery-items-focalpoint"><a href="#"><span class="ui-icon ui-icon-image"></span>' . t(540, "Focal point") . '</a></li>
	                <li id="contextmenu-gallery-items-description"><a href="#"><span class="ui-icon ui-icon-comment"></span>' . t(334, 'Description') . '</a></li>
	                <li><!--divider--></li>
	                <li id="contextmenu-gallery-items-remove"><a href="#"><span class="ui-icon ui-icon-minus"></span>' . t(627, 'Remove') . '</a></li>
	                <li id="contextmenu-gallery-items-move-beginning"><a href="#"><span class="ui-icon ui-icon-arrowthickstop-1-n"></span>' . t(628, 'Move to the beginning') . '</a></li>
	                <li id="contextmenu-gallery-items-move-end"><a href="#"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span>' . t(629, 'Move to the end') . '</a></li>
	            </ul>
			');
            // script#6
            $layout->add_script('
				$(window).on("load", function()
				{
					new LazyLoad({
					    threshold: 200,
					    container: $("#items-gallery-elements-order").parent()[0],
					    elements_selector: "#items-gallery-elements img",
					    throttle: 40,
					    data_src: "src",
					    show_while_loading: true
					});
				});
			');
            $captions_form = '
				<div id="navigate_items_gallery_captions_form" style=" display: none; ">
					<div class="navigate-form-row">
						<label>' . t(157, 'Image') . '</label>
						' . $naviforms->dropbox('navigate_items_gallery_captions_form_image', '', 'image', true) . '
					</div>
			';
            $caption_langs = array_values($website->languages_list);
            foreach ($caption_langs as $caption_language) {
                $captions_form .= '
					<div class="navigate-form-row">
						<label>' . language::name_by_code($caption_language) . '</label>
						' . $naviforms->textfield('navigate_items_gallery_captions_form_image_' . $caption_language, '') . '
					</div>
				';
            }
            $captions_form .= '
				</div>
			';
            $layout->add_content($captions_form);
        }
        // Properties TAB (only if needed)
        $properties_html = '';
        if ($item->association == 'free' && !empty($item->template) && $item->template != '0') {
            // we already know the properties to show: template is set on item
            $properties_html = navigate_property_layout_form('item', $item->template, 'item', $item->id);
        } else {
            if ($item->association == 'category' && $item->embedding == 0 && !empty($item->template)) {
                // we already know the properties to show: template is set on item
                $properties_html = navigate_property_layout_form('item', $item->template, 'item', $item->id);
            } else {
                if ($item->association == 'category' && $item->category > 0) {
                    // we have to get the template set in the category of the item
                    $template_id = $DB->query_single('template', 'nv_structure', ' id = ' . protect($item->category) . ' AND website = ' . $website->id);
                    $properties_html = navigate_property_layout_form('item', $template_id, 'item', $item->id);
                }
            }
        }
        if (!empty($properties_html)) {
            $navibars->add_tab(t(77, "Properties"));
            // tab #4
            $navibars->add_tab_content($properties_html);
        }
        if ($template->comments > 0 || $template->comments == 'true' || $template->comments === true || is_object($template->comments)) {
            $navibars->add_tab(t(250, "Comments"));
            // tab #5
            $navibars->add_tab_content_row(array('<label>' . t(252, 'Comments enabled to') . '</label>', $naviforms->selectfield('item-comments_enabled_to', array(0 => 0, 1 => 1, 2 => 2), array(0 => t(253, 'Nobody'), 1 => t(24, 'Registered users'), 2 => t(254, 'Everyone')), $item->comments_enabled_to)));
            $moderator_id = '';
            if (!empty($item->comments_moderator)) {
                $moderator_username = $DB->query_single('username', 'nv_users', ' id = ' . $item->comments_moderator);
                if (!empty($moderator_username)) {
                    $moderator_username = array($moderator_username);
                    $moderator_id = array($item->comments_moderator);
                }
            }
            $navibars->add_tab_content_row(array('<label>' . t(255, 'Moderator') . '</label>', $naviforms->selectfield('item-comments_moderator', $moderator_id, $moderator_username, $item->comments_moderator, null, false, null, null, false), '<span style="display: none;" id="item-comments_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>'));
            // script#7
            // comments list
            // removed filter: AND nvwu.website = nvc.website ... reason: the webuser could be from another website if sharing webusers is enabled
            // TODO: retrieve comments by AJAX call to avoid memory issues. right now we just retrieve the first 500 comments
            $DB->query('SELECT nvc.*, nvwu.username, nvwu.avatar
						  FROM nv_comments nvc
						 LEFT OUTER JOIN nv_webusers nvwu 
						 			  ON nvwu.id = nvc.user
						 WHERE nvc.website = ' . protect($website->id) . '
						   AND nvc.item = ' . protect($item->id) . '
						ORDER BY nvc.date_created ASC
						LIMIT 500');
            $comments = $DB->result();
            $comments_total = count($comments);
            for ($c = 0; $c < $comments_total; $c++) {
                if ($comments[$c]->status == 2) {
                    $comment_status = 'hidden';
                } else {
                    if ($comments[$c]->status == 1) {
                        $comment_status = 'private';
                    } else {
                        if ($comments[$c]->status == -1) {
                            $comment_status = 'new';
                        } else {
                            $comment_status = 'public';
                        }
                    }
                }
                $navibars->add_tab_content_row(array('<span class="items-comment-label">' . core_ts2date($comments[$c]->date_created, true) . '<br />' . '<strong>' . (empty($comments[$c]->username) ? $comments[$c]->name : $comments[$c]->username) . '</strong>' . '<br />' . $comments[$c]->ip . '</span>', '<div id="items-comment-' . $comments[$c]->id . '" class="items-comment-message items-comment-status-' . $comment_status . '">' . nl2br($comments[$c]->message) . '</div>', empty($comments[$c]->avatar) ? '' : '<img style=" margin-left: 5px; " src="' . NAVIGATE_DOWNLOAD . '?wid=' . $website->id . '&id=' . $comments[$c]->avatar . '&amp;disposition=inline&amp;width=46&amp;height=46" />'));
            }
            $navibars->add_tab_content('
				<div id="items-comments-toolbar">
					<img id="items-comments-toolbar-publish" src="' . NAVIGATE_URL . '/img/icons/silk/accept.png" title="' . t(258, 'Publish') . '" />
					<img id="items-comments-toolbar-unpublish" src="' . NAVIGATE_URL . '/img/icons/silk/delete.png" title="' . t(259, 'Unpublish') . '" />
					<img id="items-comments-toolbar-delete" src="' . NAVIGATE_URL . '/img/icons/silk/decline.png" title="' . t(35, 'Delete') . '" />				
				</div>
			');
            // script#8
            // comments moderation
        }
        if ($item->votes > 0) {
            $navibars->add_tab(t(352, "Votes"));
            // tab #6
            $score = $item->score / $item->votes;
            $navibars->add_tab_content_panel('<img src="img/icons/silk/chart_pie.png" align="absmiddle" /> ' . t(337, 'Summary'), array('<div class="navigate-panels-summary ui-corner-all"><h2>' . $item->votes . '</h2><br />' . t(352, 'Votes') . '</div>', '<div class="navigate-panels-summary ui-corner-all""><h2>' . $score . '</h2><br />' . t(353, 'Score') . '</div>', '<div style=" float: left; margin-left: 8px; "><a href="#" class="uibutton" id="items_votes_webuser">' . t(15, 'Users') . '</a></div>', '<div style=" float: right; margin-right: 8px; "><a href="#" class="uibutton" id="items_votes_reset">' . t(354, 'Reset') . '</a></div>', '<div id="items_votes_webuser_window" style=" display: none; width: 600px; height: 350px; "></div>'), 'navigate-panel-web-summary', '385px', '200px');
            $layout->add_script('
				$("#items_votes_reset").on("click", function()
				{
				    navigate_confirmation_dialog(
				        function()
                        {                         
                            $.post("?fid=items&act=votes_reset&id=' . $item->id . '", function(data)
                            {
                                $("#navigate-panel-web-summary").addClass("ui-state-disabled");
                                navigate_notification("' . t(355, 'Votes reset') . '");
                            });
                        },
                        "' . t(497, "Do you really want to erase this data?") . '",
                        null,
				        "' . t(354, 'Reset') . '"
                    );					    
				});
				
				$("#items_votes_webuser").on("click", function()
				{
					$( "#items_votes_webuser_window" ).dialog(
					{
						title: "' . t(357, 'User votes') . '",
						width: 700,
						height: 400,
						modal: true,
						open: function()
						{
							$( "#items_votes_webuser_window" ).html("<table id=\\"items_votes_webuser_grid\\"></table>");
							$( "#items_votes_webuser_window" ).append("<div id=\\"items_votes_webuser_grid_pager\\"></div>");
							
							jQuery("#items_votes_webuser_grid").jqGrid(
							{
							  url: "?fid=' . $_REQUEST['fid'] . '&act=votes_by_webuser&id=' . $item->id . '",
							  editurl: "?fid=' . $_REQUEST['fid'] . '&act=votes_by_webuser&id=' . $item->id . '",
							  datatype: "json",
							  mtype: "GET",
							  pager: "#items_votes_webuser_grid_pager",	
							  colNames:["ID", "' . t(86, 'Date') . '", "' . t(1, 'Username') . '"],
							  colModel:[
								{name:"id", index:"id", width: 75, align: "left", sortable:true, editable:false, hidden: true},
								{name:"date",index:"date", width: 180, align: "center", sortable:true, editable:false},
								{name:"username", index:"username", align: "left", width: 380, sortable:true, editable:false}
								
							  ],
							  scroll: 1,
							  loadonce: false,
							  autowidth: true,
							  forceFit: true,
							  rowNum: 12,
							  rowList: [12],	
							  viewrecords: true,
							  multiselect: true,		  
							  sortname: "date",
							  sortorder: "desc"
							});	
							
							$("#items_votes_webuser_grid").jqGrid(	
							    "navGrid", 
								"#items_votes_webuser_grid_pager", 
								{
								    add: false,
									edit: false,
									del: true,
									search: false
                                }
                            );
						}
					});
				});				
			');
            $navibars->add_tab_content_panel('<img src="img/icons/silk/chart_line.png" align="absmiddle" /> ' . t(353, 'Score'), array('<div id="navigate-panel-web-score-graph" style=" margin: 8px; height: 150px; width: 360px; "></div>'), 'navigate-panel-web-score', '385px', '200px');
            $votes_by_score = webuser_vote::object_votes_by_score('item', $item->id);
            $gdata = array();
            $colors = array('#0a2f42', '#62bbe8', '#1d8ec7', '#44aee4', '#bbe1f5');
            foreach ($votes_by_score as $vscore) {
                $gdata[] = (object) array('label' => $vscore->value, 'data' => (int) $vscore->votes, 'color' => $colors[$vscore->value % count($colors)]);
            }
            $navibars->add_tab_content('
                <div class="hidden" id="navigate-panel-web-data-score">' . json_encode($gdata) . '</div>
            ');
            $navibars->add_tab_content_panel('<img src="img/icons/silk/chart_line.png" align="absmiddle" /> ' . t(352, 'Votes') . ' (' . t(356, 'last 90 days') . ')', array('<div id="navigate-panel-web-votes-graph" style=" margin: 8px; height: 150px; width: 360px; "></div>'), 'navigate-panel-web-votes', '385px', '200px');
            $votes_by_date = webuser_vote::object_votes_by_date('item', $item->id, 90);
            $navibars->add_tab_content('
                <div class="hidden" id="navigate-panel-web-data-votes_by_date">' . json_encode($votes_by_date) . '</div>
            ');
            // script#9
        }
        $nvweb_preview = NAVIGATE_PARENT . NAVIGATE_FOLDER . '/web/nvweb.php?preview=true&wid=' . $website->id . '&route=';
        $layout->add_script('
			function navigate_items_preview()
			{
				// navigate_items_disable_spellcheck(); not needed in tinymce 4?
				navigate_periodic_event_delegate(); // force saving current data in history
				var url = "' . $nvweb_preview . '";
				var active_language = $("input[name=\'language_selector[]\']:checked").val();

				if($("#template").parent().css("display")=="block")
					url = url + "node/' . $item->id . '&lang=" + active_language + "&template=" + $("#template").val();
			    else // category URL
			        url = url + item_category_path[active_language].slice(1);

				setTimeout(function() { window.open(url); }, 1000);
			}
		');
        $events->trigger('items', 'edit', array('item' => &$item, 'navibars' => &$navibars, 'naviforms' => &$naviforms));
    }
    $layout->add_script('
		$.getScript("lib/packages/items/items.js?r=' . $current_version->revision . '", function()
		{
			if(typeof navigate_items_onload == "function")
				navigate_items_onload();
		});
	');
    return $navibars->generate();
}
if (!$site->user->allowed_adminpage(array('adminpage_id' => 86,)) ) { # adminpage_id=86 => "System > Extensions"
	############ debug
	if($site->user) { $site->user->debug->print_msg(); } # user debug
	if($site->guest) { 	$site->guest->debug->print_msg(); } 	# guest debug
	$site->debug->print_msg(); 
	exit;
}

$op = $site->fdat['op'];
$op2 = $site->fdat['op2'];


######## create EXTENSION

$extension = new extension(array(
	name => $site->fdat['name']
));
#printr($extension->all);

######################
# leida valitud keele p�hjal �ige lehe encoding,
# admin-osa keel j��b samaks

$keel_id = isset($site->fdat['flt_keel']) ? $site->fdat['flt_keel'] : $site->fdat['keel_id'];
if (!strlen($keel_id)) { $keel_id = $site->keel; }


###############################
# DEPRECATED: extension: Save extension name & close
/*
if($site->fdat['op2'] == 'save_extension' || $site->fdat['op2'] == 'saveclose_extension') {
示例#22
0
                 $sql .= "where dialplan_detail_uuid = '" . $dialplan_detail_uuid . "' ";
                 $sql .= "and domain_uuid = '" . $domain_uuid . "' ";
                 $db->exec(check_sql($sql));
                 unset($sql);
             }
             unset($sql, $prep_statement, $result);
         }
         // update session domain name
         $_SESSION['domains'][$domain_uuid]['domain_name'] = $domain_name;
         // recreate dialplan and extension xml files
         if (is_readable($_SESSION['switch']['dialplan']['dir'])) {
             save_dialplan_xml();
         }
         if (is_readable($_SESSION['switch']['extensions']['dir'])) {
             require_once $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/extensions/resources/classes/extension.php";
             $extension = new extension();
             $extension->xml();
         }
         // if single-tenant and variables exist, update variables > domain value to match new domain
         if (count($_SESSION['domains']) == 1 && file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/vars/")) {
             $sql = "update v_vars set ";
             $sql .= "var_value = '" . $domain_name . "' ";
             $sql .= "where var_name = 'domain' ";
             $db->exec(check_sql($sql));
             unset($sql);
         }
     }
 }
 //upgrade the domains
 if (permission_exists('upgrade_apps') || if_group("superadmin")) {
     require_once "core/upgrade/upgrade_domains.php";
示例#23
0
 function save_switch_xml()
 {
     if (is_readable($_SESSION['switch']['dialplan']['dir'])) {
         save_dialplan_xml();
     }
     if (is_readable($_SESSION['switch']['extensions']['dir'])) {
         if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/extensions/resources/classes/extension.php")) {
             require_once $_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "app/extensions/resources/classes/extension.php";
             $extension = new extension();
             $extension->xml();
         }
     }
     if (is_readable($_SESSION['switch']['conf']['dir'])) {
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/settings/app_config.php")) {
             save_setting_xml();
         }
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/modules/app_config.php")) {
             save_module_xml();
         }
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/vars/app_config.php")) {
             save_var_xml();
         }
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/call_center/app_config.php")) {
             save_call_center_xml();
         }
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/gateways/app_config.php")) {
             save_gateway_xml();
         }
         //if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/ivr_menu/app_config.php")) {
         //	save_ivr_menu_xml();
         //}
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . PROJECT_PATH . "/app/sip_profiles/app_config.php")) {
             save_sip_profile_xml();
         }
     }
 }
示例#24
0
            ' . lang::get('idea_text') . '
            <hr />
        </div>
        <div class="col-md-9">
           <textarea class="form-control"></textarea>
        </div>
        <div class="col-md-3">
           <p><button class="btn btn-default">' . lang::get('send') . '</button></p>
            <div id="ajax-content"></div>
        </div>
    </div>
    ', ['id' => 'idea', 'col' => 'lg-6']);
?>
    </div>
    <div class="expand">
    	<i class="fa fa-chevron-up"></i>
    </div>
</section>
		
<div class="row">
    <?php 
$button = '<a href="http://dynao.de" target="_blank" class="btn btn-sm btn-default">' . lang::get('all_addons') . '</a>';
echo bootstrap::panel(lang::get('addons'), [$button], dyn::getAddons(), ['table' => true, 'col' => 'lg-6']);
$button = '<a href="http://dynao.de" target="_blank" class="btn btn-sm btn-default">' . lang::get('all_modules') . '</a>';
echo bootstrap::panel(lang::get('modules'), [$button], dyn::getModules(), ['table' => true, 'col' => 'lg-6']);
?>
</div>

<?php 
echo extension::get('DASHBOARD_OVERVIEW', '');
示例#25
0
userPerm::add('media[category][delete]', lang::get('media[category][delete]'));
if (dyn::get('user')->hasPerm('media[edit]') || dyn::get('user')->hasPerm('media[delete]') || dyn::get('user')->hasPerm('media[category][edit]') || dyn::get('user')->hasPerm('media[category][delete]')) {
    backend::addNavi(lang::get('media'), url::backend('media'), 'picture-o', 2, function () {
        return dir::addon('mediamanager', 'page' . DIRECTORY_SEPARATOR . 'media.php');
    });
}
form::addClassMethod('addMediaField', function ($name, $value) {
    return $this->addField($name, $value, 'formMedia');
});
form::addClassMethod('addMediaListField', function ($name, $value) {
    return $this->addField($name, $value, 'formMediaList');
});
$page = type::super('page', 'string');
$subpage = type::super('subpage', 'string');
$action = type::super('action', 'string');
pageArea::addType('varsMedia');
pageArea::addType('varsMedialist');
if (addonConfig::isActive('metainfos')) {
    metainfosPage::addType('DYN_MEDIA');
    metainfosPage::addType('DYN_MEDIA_LIST');
    if ($page == 'meta') {
        backend::addSubNavi(lang::get('media'), url::backend('meta', ['subpage' => 'media']), 'circle', -1, function () {
            return dir::addon('mediamanager', 'page' . DIRECTORY_SEPARATOR . 'meta.media.php');
        });
    }
    if ($page == 'media' && $subpage == 'files' && in_array($action, ['add', 'edit'])) {
        extension::add('FORM_BEFORE_ACTION', function ($form) {
            $form = metainfos::getMetaInfos($form, 'media');
        });
    }
}
示例#26
0
function extensions_dialog($extension, $function, $params)
{
    global $layout;
    $layout = null;
    $layout = new layout('navigate');
    // load the extension source code, if not already done
    extension::include_php($extension->code);
    if (function_exists($function)) {
        call_user_func($function, $params);
        $out = $layout->generate();
    } else {
        $out = 'ERROR: "' . $function . '" function does not exist!';
    }
    return $out;
}
示例#27
0
 function ext_saynumber($data, $gender = 'f')
 {
     parent::extension($data);
     $this->gender = $gender;
 }
 public static function blocks()
 {
     $out = array();
     $list = extension::list_installed();
     for ($e = 0; $e < count($list); $e++) {
         if (isset($list[$e]['blocks'])) {
             for ($eb = 0; $eb < count($list[$e]['blocks']); $eb++) {
                 $list[$e]['blocks'][$eb]->_extension = $list[$e]['code'];
                 $out[] = $list[$e]['blocks'][$eb];
             }
         }
     }
     return $out;
 }
示例#29
0
function webdictionary_edit_language_form($code)
{
    global $DB;
    global $website;
    global $theme;
    global $events;
    $navibars = new navibars();
    $naviforms = new naviforms();
    $navibars->title(t(21, 'Dictionary') . ' / ' . t(602, 'Edit language'));
    $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(0);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
    $navibars->add_actions(array('<a href="?fid=webdictionary&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>'));
    $navibars->form();
    $navibars->add_tab(t(188, "Translate"));
    $navibars->add_tab_content($naviforms->hidden('form-sent', 'true'));
    $origin = "";
    foreach ($website->languages_list as $l) {
        if ($l == $code) {
            continue;
        } else {
            $origin = $l;
            break;
        }
    }
    // retrieve original theme translations, if any
    $theme->get_translations();
    $dict_dest = array();
    foreach ($theme->dictionaries as $otext) {
        if ($otext['lang'] == $code) {
            $dict_dest[$otext['node_id']] = $otext['text'];
        }
    }
    // retrieve existing database dictionary translations
    $DB->query('
		SELECT *
		  FROM nv_webdictionary
		 WHERE (	(node_type = "global")
		    		OR (node_type = "theme" AND theme= "' . $theme->name . '")
		       ) AND
		       website = ' . $website->id . '
    ');
    $db_trans = $DB->result();
    foreach ($db_trans as $otext) {
        $text_id = $otext->node_id;
        if ($otext->node_type == "theme") {
            $text_id = $otext->subtype;
        }
        if ($otext->lang == $code) {
            $dict_dest[$text_id] = $otext->text;
        } else {
            if ($otext->lang == $origin && $otext->node_type == "global") {
                array_push($theme->dictionaries, array("source" => $text_id, "node_id" => $text_id, "text" => $otext->text, "lang" => $otext->lang));
            }
        }
    }
    $extensions_translations = array();
    $extensions = extension::list_installed();
    if (!is_array($extensions)) {
        $extensions = array();
    }
    foreach ($extensions as $extension) {
        $ext = new extension();
        $ext->load($extension['code']);
        $extension_translations = $ext->get_translations();
        // load all translations of the extension
        $extensions_translations = array_merge($extensions_translations, $extension_translations);
    }
    $DB->query('
		SELECT *
		  FROM nv_webdictionary
		 WHERE node_type = "extension" AND
		       website = ' . $website->id, 'array');
    $resultset = $DB->result();
    for ($dbrs = 0; $dbrs < count($resultset); $dbrs++) {
        $found = false;
        for ($trs = 0; $trs < count($extensions_translations); $trs++) {
            if ($resultset[$dbrs]['node_type'] == "extension" && $resultset[$dbrs]['extension'] == $extensions_translations[$trs]['extension'] && $resultset[$dbrs]['subtype'] == $extensions_translations[$trs]['node_id'] && $resultset[$dbrs]['lang'] == $extensions_translations[$trs]['lang']) {
                $found = true;
                $extensions_translations[$trs]['text'] = $resultset[$dbrs]['text'];
            }
        }
        // translation was not included in the extension languages, so we need to add it to our array
        if (!$found) {
            $extensions_translations[] = array('extension' => $resultset[$dbrs]['extension'], 'source' => 'extension.' . $resultset[$dbrs]['extension'] . '.' . $resultset[$dbrs]['subtype'], 'node_id' => $resultset[$dbrs]['subtype'], 'lang' => $resultset[$dbrs]['lang'], 'text' => $resultset[$dbrs]['text']);
        }
    }
    // generate table
    $table = '<table class="box-table">';
    $table .= '<tr><th>' . t(237, "Code") . '</th><th>' . language::name_by_code($origin) . '</th><th>' . language::name_by_code($code) . '</th></tr>';
    foreach ($theme->dictionaries as $otext) {
        if ($otext['lang'] == $origin) {
            $translation = $dict_dest[$otext['node_id']];
            if (is_numeric($otext['source'])) {
                $otext['source'] = 'global.' . $otext['source'];
            }
            // note: PHP does not allow using dots in $_POST variable names, unless they are used in an array
            $table .= '
				<tr>
					<td>' . $otext['node_id'] . '</textarea></td>
					<td><textarea rows="2" cols="60" disabled="disabled">' . $otext['text'] . '</textarea></td>
					<td><textarea name="data[' . $code . '.' . $otext['source'] . ']" rows="2" cols="60">' . $translation . '</textarea></td>
				</tr>
			';
        }
    }
    foreach ($extensions_translations as $otext) {
        if ($otext['lang'] == $origin) {
            $translation = "";
            foreach ($extensions_translations as $dtext) {
                if ($otext['source'] == $dtext['source'] && $dtext['lang'] == $code) {
                    $translation = $dtext['text'];
                }
            }
            $table .= '
				<tr>
					<td>' . $otext['source'] . '</textarea></td>
					<td><textarea rows="2" cols="60" disabled="disabled">' . $otext['text'] . '</textarea></td>
					<td><textarea name="data[' . $code . '.' . $otext['source'] . ']" rows="2" cols="60">' . $translation . '</textarea></td>
				</tr>
			';
        }
    }
    $table .= '</table>';
    $navibars->add_tab_content($table);
    return $navibars->generate();
}
示例#30
0
    $subpage = type::super('subpage', 'string');
    $action = type::super('action', 'string');
    $structure_id = type::super('structure_id', 'int', 0);
    $id = type::super('id', 'int', 0);
    // Falls was an der Page geändert worden ist
    if ($page == 'structure' && $subpage == 'pages' && in_array($action, ['add', 'edit', 'seo']) && !$structure_id) {
        extension::add('FORM_AFTER_SAVE', function ($form) {
            seo_rewrite::generatePathlist();
            return $form;
        });
    }
    // Wenn SEO Button geklickt worden ist
    if ($page == 'structure' && $subpage == 'pages' && $action == 'seo') {
        seoPage::generateForm($id);
        layout::addJsCode("\n\t\tvar default_url = \$('#seo-costum-url').text();\n\t\t\n\t\t\$('#seo-costum-url-text').keyup(function() {\n\t\t\tvar val = \$(this).val();\n\t\t\t\n\t\t\tif(val == '')\n\t\t\t\tval = default_url;\n\t\t\t\t\t\t\t\n\t\t\t\$('#seo-costum-url').text(val);\n\t\t});\n\t\t\n\t\tvar default_title = \$('#seo-default-title').text();\n\t\t\$('#seo-title-text').keyup(function() {\n\t\t\tvar val = \$(this).val();\n\t\t\t\n\t\t\tif(val == '')\n\t\t\t\tval = default_title;\n\t\t\t\n\t\t\t\$('#seo-title').text(val);\n\t\t});\n\t\t");
    }
    // Wenn Sortiert worden ist
    if ($page == 'structure' && $subpage == 'pages' && (ajax::is() || $action == 'delete' && !$structure_id)) {
        extension::add('BACKEND_OUTPUT', function ($output) {
            seo_rewrite::generatePathlist();
            return $output;
        });
    }
    // Inhaltsseite der page
    if ($page == 'structure' && $subpage == 'pages' && ($structure_id || $action == 'edit' && $id)) {
        $id = $structure_id ? $structure_id : $id;
        extension::add('BACKEND_OUTPUT', function ($output) use($id) {
            return seoPage::generateButton($output, $id);
        });
    }
}