コード例 #1
0
 public function view()
 {
     $this->appendSubheading(__('Preferences'));
     $bIsWritable = true;
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if (!is_writable(CONFIG)) {
         $this->pageAlert(__('The Symphony configuration file, <code>/manifest/config.php</code>, is not writable. You will not be able to save changes to preferences.'), Alert::ERROR);
         $bIsWritable = false;
     } else {
         if ($formHasErrors) {
             $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR);
         } else {
             if (isset($this->_context[0]) && $this->_context[0] == 'success') {
                 $this->pageAlert(__('Preferences saved.'), Alert::SUCCESS);
             }
         }
     }
     // Get available languages
     $languages = Lang::getAvailableLanguages(new ExtensionManager(Administration::instance()));
     if (count($languages) > 1) {
         // Create language selection
         $group = new XMLElement('fieldset');
         $group->setAttribute('class', 'settings');
         $group->appendChild(new XMLElement('legend', __('System Language')));
         $label = Widget::Label();
         // Get language names
         asort($languages);
         foreach ($languages as $code => $name) {
             $options[] = array($code, $code == Symphony::Configuration()->get('lang', 'symphony'), $name);
         }
         $select = Widget::Select('settings[symphony][lang]', $options);
         $label->appendChild($select);
         $group->appendChild($label);
         $group->appendChild(new XMLElement('p', __('Authors can set up a differing language in their profiles.'), array('class' => 'help')));
         // Append language selection
         $this->Form->appendChild($group);
     }
     ###
     # Delegate: AddCustomPreferenceFieldsets
     # Description: Add Extension custom preferences. Use the $wrapper reference to append objects.
     $this->_Parent->ExtensionManager->notifyMembers('AddCustomPreferenceFieldsets', '/system/preferences/', array('wrapper' => &$this->Form));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $attr = array('accesskey' => 's');
     if (!$bIsWritable) {
         $attr['disabled'] = 'disabled';
     }
     $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', $attr));
     $this->Form->appendChild($div);
 }
コード例 #2
0
 protected function viewLanguages()
 {
     $h2 = new XMLElement('h2', __('Language selection'));
     $p = new XMLElement('p', __('This installation can speak in different languages, which one are you fluent in?'));
     $this->Form->appendChild($h2);
     $this->Form->appendChild($p);
     $languages = array();
     foreach (Lang::getAvailableLanguages(false) as $code => $lang) {
         $languages[] = array($code, $code === 'en', $lang);
     }
     if (count($languages) > 1) {
         $languages[0][1] = false;
         $languages[1][1] = true;
     }
     $this->Form->appendChild(Widget::Select('lang', $languages));
     $Submit = new XMLElement('div', null, array('class' => 'submit'));
     $Submit->appendChild(Widget::Input('action[proceed]', __('Proceed with installation'), 'submit'));
     $this->Form->appendChild($Submit);
 }
コード例 #3
0
ファイル: install.php プロジェクト: knupska/symphony-2
function setLanguage()
{
    require_once 'symphony/lib/toolkit/class.lang.php';
    $lang = NULL;
    if (!empty($_REQUEST['lang'])) {
        $l = preg_replace('/[^a-zA-Z\\-]/', '', $_REQUEST['lang']);
        if (file_exists("./symphony/lib/lang/lang.{$l}.php")) {
            $lang = $l;
        }
    }
    if ($lang === NULL) {
        foreach (Lang::getBrowserLanguages() as $l) {
            if (file_exists("./symphony/lib/lang/lang.{$l}.php")) {
                $lang = $l;
            }
            break;
        }
    }
    ## none of browser accepted languages is available, get first available
    if ($lang === NULL) {
        ## default to English
        if (file_exists('./symphony/lib/lang/lang.en.php')) {
            $lang = 'en';
        } else {
            $l = Lang::getAvailableLanguages();
            if (is_array($l) && count($l) > 0) {
                $lang = $l[0];
            }
        }
    }
    if ($lang === NULL) {
        return NULL;
    }
    try {
        Lang::init('./symphony/lib/lang/lang.%s.php', $lang);
    } catch (Exception $s) {
        return NULL;
    }
    define('__LANG__', $lang);
    return $lang;
}
コード例 #4
0
 public function run()
 {
     // Make sure a log file is available
     if (is_null(Symphony::Log()) || !file_exists(Symphony::Log()->getLogPath())) {
         self::__render(new InstallerPage('missing-log'));
     }
     // Check essential server requirements
     $errors = self::__checkRequirements();
     if (!empty($errors)) {
         Symphony::Log()->pushToLog(sprintf('Installer - Missing requirements.'), E_ERROR, true);
         foreach ($errors as $err) {
             Symphony::Log()->pushToLog(sprintf('Requirement - %s', $err['msg']), E_ERROR, true);
         }
         self::__render(new InstallerPage('requirements', array('errors' => $errors)));
     }
     // If language is not set and there is language packs available, show language selection pages
     if (!isset($_POST['lang']) && count(Lang::getAvailableLanguages(false)) > 1) {
         self::__render(new InstallerPage('languages'));
     }
     // Check for configuration errors and, if there are no errors, install Symphony!
     if (isset($_POST['fields'])) {
         $errors = self::__checkConfiguration();
         if (!empty($errors)) {
             Symphony::Log()->pushToLog(sprintf('Installer - Wrong configuration.'), E_ERROR, true);
             foreach ($errors as $err) {
                 Symphony::Log()->pushToLog(sprintf('Configuration - %s', $err['msg']), E_ERROR, true);
             }
         } else {
             $disabled_extensions = self::__install();
             self::__render(new InstallerPage('success', array('disabled-extensions' => $disabled_extensions)));
         }
     }
     // Display the Installation page
     self::__render(new InstallerPage('configuration', array('errors' => $errors, 'default-config' => Symphony::Configuration()->get())));
 }
コード例 #5
0
$header = '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title><!-- TITLE --></title>
		<link rel="stylesheet" type="text/css" href="' . kINSTALL_ASSET_LOCATION . '/main.css"/>
		<script type="text/javascript" src="' . kINSTALL_ASSET_LOCATION . '/main.js"></script>
	</head>' . CRLF;
define('kHEADER', $header);
$footer = '
</html>';
define('kFOOTER', $footer);
$warnings = array('no-symphony-dir' => __('No <code>/symphony</code> directory was found at this location. Please upload the contents of Symphony\'s install package here.'), 'no-write-permission-workspace' => __('Symphony does not have write permission to the existing <code>/workspace</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.'), 'no-write-permission-manifest' => __('Symphony does not have write permission to the <code>/manifest</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.'), 'no-write-permission-root' => __('Symphony does not have write permission to the root directory. Please modify permission settings on this directory. This is necessary only if you are not including a workspace, and can be reverted once installation is complete.'), 'no-write-permission-htaccess' => __('Symphony does not have write permission to the temporary <code>htaccess</code> file. Please modify permission settings on this file so it can be written to, and renamed.'), 'no-write-permission-symphony' => __('Symphony does not have write permission to the <code>/symphony</code> directory. Please modify permission settings on this directory. This is necessary only during installation, and can be reverted once installation is complete.'), 'existing-htaccess' => __('There appears to be an existing <code>.htaccess</code> file in the Symphony install location. To avoid name clashes, you will need to delete or rename this file.'), 'existing-htaccess-symphony' => __('There appears to be an existing <code>.htaccess</code> file in the <code>/symphony</code> directory.'), 'no-database-connection' => __('Symphony was unable to connect to the specified database. You may need to modify host or port settings.'), 'database-incorrect-version' => __('Symphony requires <code>MySQL 4.1</code> or greater to work. This requirement must be met before installation can proceed.'), 'database-table-clash' => __('The table prefix <code><!-- TABLE-PREFIX --></code> is already in use. Please choose a different prefix to use with Symphony.'), 'user-password-mismatch' => __('The password and confirmation did not match. Please retype your password.'), 'user-invalid-email' => __('This is not a valid email address. You must provide an email address since you will need it if you forget your password.'), 'user-no-username' => __('You must enter a Username. This will be your Symphony login information.'), 'user-no-password' => __('You must enter a Password. This will be your Symphony login information.'), 'user-no-name' => __('You must enter your name.'));
$notices = array('existing-workspace' => __('An existing <code>/workspace</code> directory was found at this location. Symphony will use this workspace.'));
$languages = array();
foreach (array_keys(Lang::getAvailableLanguages()) as $lang) {
    $languages[] = '<a href="?lang=' . $lang . '">' . $lang . '</a>';
}
$languages = count($languages) > 1 ? implode(', ', $languages) : '';
function installResult(&$Page, &$install_log, $start)
{
    if (!defined('_INSTALL_ERRORS_')) {
        $install_log->writeToLog("============================================", true);
        $install_log->writeToLog("INSTALLATION COMPLETED: Execution Time - " . max(1, time() - $start) . " sec (" . date("d.m.y H:i:s") . ")", true);
        $install_log->writeToLog("============================================" . CRLF . CRLF . CRLF, true);
    } else {
        $install_log->pushToLog(_INSTALL_ERRORS_, E_ERROR, true);
        $install_log->writeToLog("============================================", true);
        $install_log->writeToLog("INSTALLATION ABORTED: Execution Time - " . max(1, time() - $start) . " sec (" . date("d.m.y H:i:s") . ")", true);
        $install_log->writeToLog("============================================" . CRLF . CRLF . CRLF, true);
        $Page->setPage('failure');
コード例 #6
0
 public function __form()
 {
     require_once TOOLKIT . '/class.field.php';
     // Handle unknown context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         Administration::instance()->errorPageNotFound();
     }
     if ($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper()) {
         Administration::instance()->customError(__('Access Denied'), __('You are not authorised to access this page.'));
     }
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Author updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">' . __('View all Authors') . '</a>', Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Author created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/system/authors/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/system/authors/" accesskey="a">' . __('View all Authors') . '</a>', Alert::SUCCESS);
                 break;
         }
     }
     $this->setPageType('form');
     $isOwner = false;
     if (isset($_POST['fields'])) {
         $author = $this->_Author;
     } else {
         if ($this->_context[0] == 'edit') {
             if (!($author_id = $this->_context[1])) {
                 redirect(SYMPHONY_URL . '/system/authors/');
             }
             if (!($author = AuthorManager::fetchByID($author_id))) {
                 Administration::instance()->customError(__('Author not found'), __('The author profile you requested does not exist.'));
             }
         } else {
             $author = new Author();
         }
     }
     if ($this->_context[0] == 'edit' && $author->get('id') == Administration::instance()->Author->get('id')) {
         $isOwner = true;
     }
     if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper()) {
         Administration::instance()->customError(__('Access Denied'), __('You are not authorised to edit other authors.'));
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%2$s &ndash; %3$s' : '%1$s &ndash; %2$s &ndash; %3$s', array($author->getFullName(), __('Authors'), __('Symphony'))));
     $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $author->getFullName());
     $this->insertBreadcrumbs(array(Widget::Anchor(__('Authors'), SYMPHONY_URL . '/system/authors/')));
     // Essentials
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Essentials')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'two columns');
     $label = Widget::Label(__('First Name'), NULL, 'column');
     $label->appendChild(Widget::Input('fields[first_name]', $author->get('first_name')));
     $div->appendChild(isset($this->_errors['first_name']) ? Widget::Error($label, $this->_errors['first_name']) : $label);
     $label = Widget::Label(__('Last Name'), NULL, 'column');
     $label->appendChild(Widget::Input('fields[last_name]', $author->get('last_name')));
     $div->appendChild(isset($this->_errors['last_name']) ? Widget::Error($label, $this->_errors['last_name']) : $label);
     $group->appendChild($div);
     $label = Widget::Label(__('Email Address'));
     $label->appendChild(Widget::Input('fields[email]', $author->get('email')));
     $group->appendChild(isset($this->_errors['email']) ? Widget::Error($label, $this->_errors['email']) : $label);
     $this->Form->appendChild($group);
     // Login Details
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Login Details')));
     $div = new XMLElement('div');
     $label = Widget::Label(__('Username'));
     $label->appendChild(Widget::Input('fields[username]', $author->get('username')));
     $div->appendChild(isset($this->_errors['username']) ? Widget::Error($label, $this->_errors['username']) : $label);
     // Only developers can change the user type. Primary account should NOT be able to change this
     if (Administration::instance()->Author->isDeveloper() && !$author->isPrimaryAccount()) {
         // Create columns
         $div->setAttribute('class', 'two columns');
         $label->setAttribute('class', 'column');
         // User type
         $label = Widget::Label(__('User Type'), NULL, 'column');
         $options = array(array('author', false, __('Author')), array('developer', $author->isDeveloper(), __('Developer')));
         $label->appendChild(Widget::Select('fields[user_type]', $options));
         $div->appendChild($label);
     }
     $group->appendChild($div);
     // Password
     $fieldset = new XMLElement('fieldset', NULL, array('class' => 'two columns', 'id' => 'password'));
     $legend = new XMLElement('legend', __('Password'));
     $help = new XMLElement('i', __('Leave password fields blank to keep the current password'));
     $fieldset->appendChild($legend);
     $fieldset->appendChild($help);
     // Password reset
     if ($this->_context[0] == 'edit' && (!Administration::instance()->Author->isDeveloper() || $isOwner === true)) {
         $fieldset->setAttribute('class', 'three columns');
         $label = Widget::Label(NULL, NULL, 'column');
         $label->appendChild(Widget::Input('fields[old-password]', NULL, 'password', array('placeholder' => __('Old Password'))));
         $fieldset->appendChild(isset($this->_errors['old-password']) ? Widget::Error($label, $this->_errors['password']) : $label);
     }
     // New password
     $callback = Administration::instance()->getPageCallback();
     $placeholder = $callback['context'][0] == 'edit' ? __('New Password') : __('Password');
     $label = Widget::Label(NULL, NULL, 'column');
     $label->appendChild(Widget::Input('fields[password]', NULL, 'password', array('placeholder' => $placeholder)));
     $fieldset->appendChild(isset($this->_errors['password']) ? Widget::Error($label, $this->_errors['password']) : $label);
     // Confirm password
     $label = Widget::Label(NULL, NULL, 'column');
     $label->appendChild(Widget::Input('fields[password-confirmation]', NULL, 'password', array('placeholder' => __('Confirm Password'))));
     $fieldset->appendChild(isset($this->_errors['password-confirmation']) ? Widget::Error($label, $this->_errors['password']) : $label);
     $group->appendChild($fieldset);
     // Auth token
     if (Administration::instance()->Author->isDeveloper()) {
         $label = Widget::Label();
         $input = Widget::Input('fields[auth_token_active]', 'yes', 'checkbox');
         if ($author->isTokenActive()) {
             $input->setAttribute('checked', 'checked');
         }
         $temp = SYMPHONY_URL . '/login/' . $author->createAuthToken() . '/';
         $label->setValue(__('%s Allow remote login via', array($input->generate())) . ' <a href="' . $temp . '">' . $temp . '</a>');
         $group->appendChild($label);
     }
     $label = Widget::Label(__('Default Area'));
     $sections = SectionManager::fetch(NULL, 'ASC', 'sortorder');
     $options = array();
     // If the Author is the Developer, allow them to set the Default Area to
     // be the Sections Index.
     if ($author->isDeveloper()) {
         $options[] = array('/blueprints/sections/', $author->get('default_area') == '/blueprints/sections/', __('Sections Index'));
     }
     if (is_array($sections) && !empty($sections)) {
         foreach ($sections as $s) {
             $options[] = array($s->get('id'), $author->get('default_area') == $s->get('id'), $s->get('name'));
         }
     }
     /**
      * Allows injection or manipulation of the Default Area dropdown for an Author.
      * Take care with adding in options that are only valid for Developers, as if a
      * normal Author is set to that option, they will be redirected to their own
      * Author record.
      *
      *
      * @delegate AddDefaultAuthorAreas
      * @since Symphony 2.2
      * @param string $context
      * '/system/authors/'
      * @param array $options
      * An associative array of options, suitable for use for the Widget::Select
      * function. By default this will be an array of the Sections in the current
      * installation. New options should be the path to the page after the `SYMPHONY_URL`
      * constant.
      * @param string $default_area
      * The current `default_area` for this Author.
      */
     Symphony::ExtensionManager()->notifyMembers('AddDefaultAuthorAreas', '/system/authors/', array('options' => &$options, 'default_area' => $author->get('default_area')));
     $label->appendChild(Widget::Select('fields[default_area]', $options));
     $group->appendChild($label);
     $this->Form->appendChild($group);
     // Custom Language Selection
     $languages = Lang::getAvailableLanguages();
     if (count($languages) > 1) {
         // Get language names
         asort($languages);
         $group = new XMLElement('fieldset');
         $group->setAttribute('class', 'settings');
         $group->appendChild(new XMLElement('legend', __('Custom Preferences')));
         $label = Widget::Label(__('Language'));
         $options = array(array(NULL, is_null($author->get('language')), __('System Default')));
         foreach ($languages as $code => $name) {
             $options[] = array($code, $code == $author->get('language'), $name);
         }
         $select = Widget::Select('fields[language]', $options);
         $label->appendChild($select);
         $group->appendChild($label);
         $this->Form->appendChild($group);
     }
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Author'), 'submit', array('accesskey' => 's')));
     if ($this->_context[0] == 'edit' && !$isOwner && !$author->isPrimaryAccount()) {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this author'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this author?')));
         $div->appendChild($button);
     }
     $this->Form->appendChild($div);
     /**
      * Allows the injection of custom form fields given the current `$this->Form`
      * object. Please note that this custom data should be saved in own extension
      * tables and that modifying `tbl_authors` to house your data is highly discouraged.
      *
      * @delegate AddElementstoAuthorForm
      * @since Symphony 2.2
      * @param string $context
      * '/system/authors/'
      * @param XMLElement $form
      * The contents of `$this->Form` after all the default form elements have been appended.
      * @param Author $author
      * The current Author object that is being edited
      */
     Symphony::ExtensionManager()->notifyMembers('AddElementstoAuthorForm', '/system/authors/', array('form' => &$this->Form, 'author' => $author));
 }
コード例 #7
0
} else {
    $fields['docroot'] = rtrim(getcwd_safe(), '/');
    $fields['database']['host'] = 'localhost';
    $fields['database']['port'] = '3306';
    $fields['database']['prefix'] = 'sym_';
    $fields['permission']['file'] = '0775';
    $fields['permission']['directory'] = '0775';
    $conf = getDynamicConfiguration();
    $fields['general']['sitename'] = $conf['general']['sitename'];
    $fields['region']['date_format'] = $conf['region']['date_format'];
    $fields['region']['time_format'] = $conf['region']['time_format'];
}
$warnings = array('no-symphony-dir' => __('No <code>/symphony</code> directory was found at this location. Please upload the contents of Symphony\'s install package here.'), 'no-write-permission-workspace' => __('Symphony does not have write permission to the existing <code>/workspace</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.'), 'no-write-permission-manifest' => __('Symphony does not have write permission to the <code>/manifest</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.'), 'no-write-permission-root' => __('Symphony does not have write permission to the root directory. Please modify permission settings on this directory. This is necessary only if you are not including a workspace, and can be reverted once installation is complete.'), 'no-write-permission-htaccess' => __('Symphony does not have write permission to the temporary <code>htaccess</code> file. Please modify permission settings on this file so it can be written to, and renamed.'), 'no-write-permission-symphony' => __('Symphony does not have write permission to the <code>/symphony</code> directory. Please modify permission settings on this directory. This is necessary only during installation, and can be reverted once installation is complete.'), 'existing-htaccess' => __('There appears to be an existing <code>.htaccess</code> file in the Symphony install location. To avoid name clashes, you will need to delete or rename this file.'), 'existing-htaccess-symphony' => __('There appears to be an existing <code>.htaccess</code> file in the <code>/symphony</code> directory.'), 'no-database-connection' => __('Symphony was unable to connect to the specified database. You may need to modify host or port settings.'), 'database-table-clash' => __('The table prefix <code><!-- TABLE-PREFIX --></code> is already in use. Please choose a different prefix to use with Symphony.'), 'user-password-mismatch' => __('The password and confirmation did not match. Please retype your password.'), 'user-invalid-email' => __('This is not a valid email address. You must provide an email address since you will need it if you forget your password.'), 'user-no-username' => __('You must enter a Username. This will be your Symphony login information.'), 'user-no-password' => __('You must enter a Password. This will be your Symphony login information.'), 'user-no-name' => __('You must enter your name.'));
$notices = array('existing-workspace' => __('An existing <code>/workspace</code> directory was found at this location. Symphony will use this workspace.'));
$languages = array();
foreach (Lang::getAvailableLanguages() as $lang) {
    $languages[] = '<a href="?lang=' . $lang . '">' . $lang . '</a>';
}
$languages = count($languages) > 1 ? implode(', ', $languages) : '';
class Display
{
    function index(&$Page, &$Contents, $fields)
    {
        global $warnings;
        global $notices;
        global $languages;
        $Form = new XMLElement('form');
        $Form->setAttribute('action', kINSTALL_FILENAME . ($_GET['lang'] ? '?lang=' . $_GET['lang'] : ''));
        $Form->setAttribute('method', 'post');
        /** 
         *
コード例 #8
0
 /**
  * Display overview page
  */
 function view()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Symphony'), __('Localisation Manager'))));
     $this->appendSubheading(__('Language Manager'));
     $this->addScriptToHead(URL . '/extensions/localisationmanager/assets/sortit.js', 101);
     // Get extensions
     $overview = Symphony::ExtensionManager()->listAll();
     // Add core
     $overview['symphony'] = array('name' => 'Symphony Core', 'handle' => 'symphony');
     // Sort by  name:
     uasort($overview, array('contentExtensionLocalisationManagerLocalisations', 'sortByName'));
     // Create table head
     $thead = array(array(__('Name'), 'col'), array(__('Export dictionary'), 'col'), array(__('Create dictionary'), 'col'));
     // Create table body
     $tbody = array();
     // Create rows
     if (is_array($overview)) {
         foreach ($overview as $name => $details) {
             if (strpos($about['handle'], 'lang_') !== false) {
                 continue;
             }
             $langlinks = '';
             // Extensions
             if ($name != 'symphony') {
                 $path = EXTENSIONS . '/' . $name . '/lang/';
                 if (file_exists($path)) {
                     $directory = new DirectoryIterator($path);
                     foreach ($directory as $file) {
                         if ($file->isDot()) {
                             continue;
                         }
                         include $file->getPathname();
                         // Get language code
                         $code = explode('.', $file);
                         $code = $code[1];
                         // Create link
                         if (!empty($langlinks)) {
                             $langlinks .= ', ';
                         }
                         $langlinks .= '<a href="' . URL . '/symphony/extension/localisationmanager/download/' . $details['handle'] . '/' . $code . '/">' . ($about['name'] ? $about['name'] : $code) . '</a>';
                     }
                 }
             } else {
                 foreach (Lang::getAvailableLanguages() as $code => $language) {
                     if ($code == 'en') {
                         continue;
                     }
                     // Create link
                     if (!empty($langlinks)) {
                         $langlinks .= ', ';
                     }
                     $langlinks .= '<a href="' . URL . '/symphony/extension/localisationmanager/download/symphony/' . $code . '/">' . $language . '</a>';
                 }
             }
             // Status
             $class = NULL;
             if (empty($langlinks)) {
                 $langlinks = __('No language available');
                 $class = 'inactive';
             }
             // Create cells
             $td1 = Widget::TableData($details['name']);
             $td2 = Widget::TableData(str_replace('%ext%', $about['handle'], $langlinks), $class);
             $td3 = Widget::TableData('+ <a href="' . URL . '/symphony/extension/localisationmanager/download/' . $details['handle'] . '">' . __('Add language') . '</a>');
             // Populate table body
             $tbody[] = Widget::TableRow(array($td1, $td2, $td3), NULL);
         }
     }
     // Build table
     $table = Widget::Table(Widget::TableHead($thead), NULL, Widget::TableBody($tbody));
     // Append table
     $this->Form->appendChild($table);
 }
コード例 #9
0
ConfigValidator::addCheck('lang_selector_enabled', function ($value, &$error) {
    if (!$value) {
        return true;
    }
    if (Config::get('lang_url_enabled')) {
        return true;
    }
    $error = 'lang_url_enabled must be set to true if lang_selector_enabled is, otherwise the language selector won\'t work';
    return false;
});
ConfigValidator::addCheck('default_language', function ($lang, &$error) {
    if (!$lang) {
        return true;
    }
    $lang = Lang::realCode($lang);
    $available = Lang::getAvailableLanguages();
    if (array_key_exists($lang, $available)) {
        return true;
    }
    $error = 'default_language must be one of the available languages defined in locale.php (' . implode(', ', array_keys($available)) . ')';
    return false;
});
ConfigValidator::addCheck('allow_transfer_expiry_date_extension', function ($pattern, &$error) {
    if (!$pattern) {
        return true;
    }
    if (!is_array($pattern)) {
        $pattern = array($pattern);
    }
    if (!is_int($pattern[0]) || $pattern[0] <= 0) {
        $error = 'allow_transfer_expiry_date_extension expects at least one positive non-zero integer';
コード例 #10
0
 function __form()
 {
     require_once TOOLKIT . '/class.field.php';
     ## Handle unknow context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         $this->_Parent->errorPageNotFound();
     }
     if ($this->_context[0] == 'new' && !Administration::instance()->Author->isDeveloper()) {
         $this->_Parent->customError(E_USER_ERROR, 'Access Denied', 'You are not authorised to access this page.');
     }
     if (isset($this->_context[2])) {
         switch ($this->_context[2]) {
             case 'saved':
                 $this->pageAlert(__('Author updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Authors</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/system/authors/new/', URL . '/symphony/system/authors/')), Alert::SUCCESS);
                 break;
             case 'created':
                 $this->pageAlert(__('Author created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Authors</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/system/authors/new/', URL . '/symphony/system/authors/')), Alert::SUCCESS);
                 break;
         }
     }
     $this->setPageType('form');
     $isOwner = false;
     if (isset($_POST['fields'])) {
         $author = $this->_Author;
     } elseif ($this->_context[0] == 'edit') {
         if (!($author_id = $this->_context[1])) {
             redirect(URL . '/symphony/system/authors/');
         }
         if (!($author = AuthorManager::fetchByID($author_id))) {
             $this->_Parent->customError(E_USER_ERROR, 'Author not found', 'The author profile you requested does not exist.');
         }
     } else {
         $author = new Author();
     }
     if ($this->_context[0] == 'edit' && $author->get('id') == Administration::instance()->Author->get('id')) {
         $isOwner = true;
     }
     if ($this->_context[0] == 'edit' && !$isOwner && !Administration::instance()->Author->isDeveloper()) {
         $this->_Parent->customError(E_USER_ERROR, 'Access Denied', 'You are not authorised to edit other authors.');
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%1$s &ndash; %2$s &ndash; %3$s' : '%1$s &ndash; %2$s', array(__('Symphony'), __('Authors'), $author->getFullName())));
     $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $author->getFullName());
     ### Essentials ###
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Essentials')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'group');
     $label = Widget::Label(__('First Name'));
     $label->appendChild(Widget::Input('fields[first_name]', $author->get('first_name')));
     $div->appendChild(isset($this->_errors['first_name']) ? $this->wrapFormElementWithError($label, $this->_errors['first_name']) : $label);
     $label = Widget::Label(__('Last Name'));
     $label->appendChild(Widget::Input('fields[last_name]', $author->get('last_name')));
     $div->appendChild(isset($this->_errors['last_name']) ? $this->wrapFormElementWithError($label, $this->_errors['last_name']) : $label);
     $group->appendChild($div);
     $label = Widget::Label(__('Email Address'));
     $label->appendChild(Widget::Input('fields[email]', $author->get('email')));
     $group->appendChild(isset($this->_errors['email']) ? $this->wrapFormElementWithError($label, $this->_errors['email']) : $label);
     $this->Form->appendChild($group);
     ###
     ### Login Details ###
     $group = new XMLElement('fieldset');
     $group->setAttribute('class', 'settings');
     $group->appendChild(new XMLElement('legend', __('Login Details')));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'group');
     $label = Widget::Label(__('Username'));
     $label->appendChild(Widget::Input('fields[username]', $author->get('username'), NULL));
     $div->appendChild(isset($this->_errors['username']) ? $this->wrapFormElementWithError($label, $this->_errors['username']) : $label);
     // Only developers can change the user type. Primary account should NOT be able to change this
     if (Administration::instance()->Author->isDeveloper() && !$author->isPrimaryAccount()) {
         $label = Widget::Label(__('User Type'));
         $options = array(array('author', false, __('Author')), array('developer', $author->isDeveloper(), __('Developer')));
         $label->appendChild(Widget::Select('fields[user_type]', $options));
         $div->appendChild($label);
     }
     $group->appendChild($div);
     $div = new XMLElement('div', NULL, array('class' => 'group'));
     if ($this->_context[0] == 'edit') {
         $div->setAttribute('id', 'change-password');
         if (!Administration::instance()->Author->isDeveloper() || $isOwner === true) {
             $div->setAttribute('class', 'triple group');
             $label = Widget::Label(__('Old Password'));
             if (isset($this->_errors['old-password'])) {
                 $label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->_errors['old-password']));
             }
             $label->appendChild(Widget::Input('fields[old-password]', NULL, 'password'));
             $div->appendChild(isset($this->_errors['old-password']) ? $this->wrapFormElementWithError($label, $this->_errors['old-password']) : $label);
         }
     }
     $label = Widget::Label($this->_context[0] == 'edit' ? __('New Password') : __('Password'));
     $label->appendChild(Widget::Input('fields[password]', NULL, 'password'));
     $div->appendChild(isset($this->_errors['password']) ? $this->wrapFormElementWithError($label, $this->_errors['password']) : $label);
     $label = Widget::Label($this->_context[0] == 'edit' ? __('Confirm New Password') : __('Confirm Password'));
     if (isset($this->_errors['password-confirmation'])) {
         $label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->_errors['password-confirmation']));
     }
     $label->appendChild(Widget::Input('fields[password-confirmation]', NULL, 'password'));
     $div->appendChild($label);
     $group->appendChild($div);
     if ($this->_context[0] == 'edit') {
         $group->appendChild(new XMLElement('p', __('Leave password fields blank to keep the current password'), array('class' => 'help')));
     }
     if (Administration::instance()->Author->isDeveloper()) {
         $label = Widget::Label();
         $input = Widget::Input('fields[auth_token_active]', 'yes', 'checkbox');
         if ($author->get('auth_token_active') == 'yes') {
             $input->setAttribute('checked', 'checked');
         }
         $temp = URL . '/symphony/login/' . $author->createAuthToken() . '/';
         $label->setValue(__('%1$s Allow remote login via <a href="%2$s">%2$s</a>', array($input->generate(), $temp)));
         $group->appendChild($label);
     }
     $label = Widget::Label(__('Default Section'));
     $sectionManager = new SectionManager($this->_Parent);
     $sections = $sectionManager->fetch(NULL, 'ASC', 'sortorder');
     $options = array();
     if (is_array($sections) && !empty($sections)) {
         foreach ($sections as $s) {
             $options[] = array($s->get('id'), $author->get('default_section') == $s->get('id'), $s->get('name'));
         }
     }
     $label->appendChild(Widget::Select('fields[default_section]', $options));
     $group->appendChild($label);
     $this->Form->appendChild($group);
     ###
     ### Custom Language Selection ###
     $languages = Lang::getAvailableLanguages(Administration::instance()->ExtensionManager);
     if (count($languages) > 1) {
         // Get language names
         asort($languages);
         $group = new XMLElement('fieldset');
         $group->setAttribute('class', 'settings');
         $group->appendChild(new XMLElement('legend', __('Custom Preferences')));
         $div = new XMLElement('div');
         $div->setAttribute('class', 'group');
         $label = Widget::Label(__('Language'));
         $options = array(array(NULL, is_null($author->get('language')), __('System Default')));
         foreach ($languages as $code => $name) {
             $options[] = array($code, $code == $author->get('language'), $name);
         }
         $select = Widget::Select('fields[language]', $options);
         $label->appendChild($select);
         $group->appendChild($label);
         $this->Form->appendChild($group);
     }
     ###
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Author'), 'submit', array('accesskey' => 's')));
     if ($this->_context[0] == 'edit' && !$isOwner && !$author->isPrimaryAccount()) {
         $button = new XMLElement('button', __('Delete'));
         $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this author'), 'type' => 'submit'));
         $div->appendChild($button);
     }
     $this->Form->appendChild($div);
 }
コード例 #11
0
 private function __form()
 {
     $layout = new Layout();
     $left = $layout->createColumn(Layout::SMALL);
     $center = $layout->createColumn(Layout::LARGE);
     $right = $layout->createColumn(Layout::SMALL);
     require_once LIB . '/class.field.php';
     ## Handle unknow context
     if (!in_array($this->_context[0], array('new', 'edit'))) {
         throw new AdministrationPageNotFoundException();
     }
     $callback = Administration::instance()->getPageCallback();
     if (isset($callback['flag'])) {
         switch ($callback['flag']) {
             case 'saved':
                 $this->alerts()->append(__('User updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/system/users/new/', ADMIN_URL . '/system/users/')), AlertStack::SUCCESS);
                 break;
             case 'created':
                 $this->alerts()->append(__('User created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/system/users/new/', ADMIN_URL . '/system/users/')), AlertStack::SUCCESS);
                 break;
         }
     }
     $isOwner = false;
     /*if(isset($_POST['fields']))
     				$user = $this->user;
     
     			elseif($this->_context[0] == 'edit'){
     
     				if(!$user_id = $this->_context[1]) redirect(ADMIN_URL . '/system/users/');
     
     				if(!$user = UserManager::fetchByID($user_id)){
     					throw new SymphonyErrorPage('The user profile you requested does not exist.', 'User not found');
     				}
     			}
     
     			else */
     if ($this->_context[0] == 'edit' && $this->user->id == Administration::instance()->User->id) {
         $isOwner = true;
     }
     $this->setTitle(__($this->_context[0] == 'new' ? '%1$s &ndash; %2$s &ndash; Untitled' : '%1$s &ndash; %2$s &ndash; %3$s', array(__('Symphony'), __('Users'), $this->user->getFullName())));
     $this->appendSubheading($this->_context[0] == 'new' ? __('New User') : $this->user->getFullName());
     ### Essentials ###
     $fieldset = Widget::Fieldset(__('Essentials'));
     $label = Widget::Label(__('First Name'));
     $label->appendChild(Widget::Input('fields[first_name]', $this->user->{'first_name'}));
     $fieldset->appendChild(isset($this->errors->{'first-name'}) ? Widget::wrapFormElementWithError($label, $this->errors->{'first-name'}) : $label);
     $label = Widget::Label(__('Last Name'));
     $label->appendChild(Widget::Input('fields[last_name]', $this->user->{'last_name'}));
     $fieldset->appendChild(isset($this->errors->{'last-name'}) ? Widget::wrapFormElementWithError($label, $this->errors->{'last-name'}) : $label);
     $label = Widget::Label(__('Email Address'));
     $label->appendChild(Widget::Input('fields[email]', $this->user->email));
     $fieldset->appendChild(isset($this->errors->email) ? Widget::wrapFormElementWithError($label, $this->errors->email) : $label);
     $left->appendChild($fieldset);
     ###
     ### Login Details ###
     $fieldset = Widget::Fieldset(__('Login Details'));
     $label = Widget::Label(__('Username'));
     $label->appendChild(Widget::Input('fields[username]', $this->user->username, NULL));
     $fieldset->appendChild(isset($this->errors->username) ? Widget::wrapFormElementWithError($label, $this->errors->username) : $label);
     if ($this->_context[0] == 'edit') {
         $fieldset->setAttribute('id', 'change-password');
     }
     $label = Widget::Label($this->_context[0] == 'edit' ? __('New Password') : __('Password'));
     $label->appendChild(Widget::Input('fields[password]', NULL, 'password'));
     $fieldset->appendChild(isset($this->errors->password) ? Widget::wrapFormElementWithError($label, $this->errors->password) : $label);
     $label = Widget::Label($this->_context[0] == 'edit' ? __('Confirm New Password') : __('Confirm Password'));
     if (isset($this->errors->{'password-confirmation'})) {
         $label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->errors->{'password-confirmation'}));
     }
     $label->appendChild(Widget::Input('fields[password-confirmation]', NULL, 'password'));
     $fieldset->appendChild($label);
     if ($this->_context[0] == 'edit') {
         $fieldset->appendChild($this->createElement('p', __('Leave password fields blank to keep the current password'), array('class' => 'help')));
     }
     $label = Widget::Label();
     $input = Widget::Input('fields[auth_token_active]', 'yes', 'checkbox');
     if ($this->user->auth_token_active == 'yes') {
         $input->setAttribute('checked', 'checked');
     }
     $temp = ADMIN_URL . '/login/' . $this->user->createAuthToken() . '/';
     $label->appendChild($input);
     $label->appendChild(new DOMText(__('Allow remote login via ')));
     $label->appendChild(Widget::Anchor($temp, $temp));
     $fieldset->appendChild($label);
     $center->appendChild($fieldset);
     ### Default Section ###
     $fieldset = Widget::Fieldset(__('Custom Preferences'));
     $label = Widget::Label(__('Default Section'));
     //$sections = SectionManager::instance()->fetch(NULL, 'ASC', 'sortorder');
     $options = array();
     //if(is_array($sections) && !empty($sections))
     foreach (new SectionIterator() as $s) {
         $options[] = array($s->handle, $this->user->default_section == $s->handle, $s->name);
     }
     $label->appendChild(Widget::Select('fields[default_section]', $options));
     $fieldset->appendChild($label);
     ### Custom Language Selection ###
     $languages = Lang::getAvailableLanguages(true);
     if (count($languages > 1)) {
         // Get language names
         asort($languages);
         $label = Widget::Label(__('Language'));
         $options = array(array(NULL, is_null($this->user->language), __('System Default')));
         foreach ($languages as $code => $name) {
             $options[] = array($code, $code == $this->user->language, $name);
         }
         $select = Widget::Select('fields[language]', $options);
         $label->appendChild($select);
         $fieldset->appendChild($label);
         $right->appendChild($fieldset);
         $layout->appendTo($this->Form);
     }
     ###
     $div = $this->createElement('div');
     $div->setAttribute('class', 'actions');
     $div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create User'), array('accesskey' => 's')));
     if ($this->_context[0] == 'edit' && !$isOwner) {
         $div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this user'))));
     }
     $this->Form->appendChild($div);
 }
コード例 #12
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title><!-- TITLE --></title>
		<link rel="stylesheet" type="text/css" href="' . kINSTALL_ASSET_LOCATION . '/main.css"/>
		<script type="text/javascript" src="' . kINSTALL_ASSET_LOCATION . '/main.js"></script>
	</head>' . CRLF;
define('kHEADER', $header);
$footer = '
</html>';
define('kFOOTER', $footer);
$warnings = array('no-symphony-dir' => __('No <code>/symphony</code> directory was found at this location. Please upload the contents of Symphony\'s install package here.'), 'no-write-permission-workspace' => __('Symphony does not have write permission to the existing <code>/workspace</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.'), 'no-write-permission-manifest' => __('Symphony does not have write permission to the <code>/manifest</code> directory. Please modify permission settings on this directory and its contents to allow this, such as with a recursive <code>chmod -R</code> command.'), 'no-write-permission-root' => __('Symphony does not have write permission to the root directory. Please modify permission settings on this directory. This is necessary only if you are not including a workspace, and can be reverted once installation is complete.'), 'no-write-permission-htaccess' => __('Symphony does not have write permission to the temporary <code>htaccess</code> file. Please modify permission settings on this file so it can be written to, and renamed.'), 'no-write-permission-symphony' => __('Symphony does not have write permission to the <code>/symphony</code> directory. Please modify permission settings on this directory. This is necessary only during installation, and can be reverted once installation is complete.'), 'no-database-connection' => __('Symphony was unable to connect to the specified database. You may need to modify host or port settings.'), 'database-incorrect-version' => __('Symphony requires <code>MySQL 4.1</code> or greater to work. This requirement must be met before installation can proceed.'), 'database-table-clash' => __('The table prefix <code><!-- TABLE-PREFIX --></code> is already in use. Please choose a different prefix to use with Symphony.'), 'user-password-mismatch' => __('The password and confirmation did not match. Please retype your password.'), 'user-invalid-email' => __('This is not a valid email address. You must provide an email address since you will need it if you forget your password.'), 'user-no-username' => __('You must enter a Username. This will be your Symphony login information.'), 'user-no-password' => __('You must enter a Password. This will be your Symphony login information.'), 'user-no-name' => __('You must enter your name.'));
$notices = array('existing-workspace' => __('An existing <code>/workspace</code> directory was found at this location. Symphony will use this workspace.'));
$languages = array();
$current = $_REQUEST['lang'];
foreach (Lang::getAvailableLanguages(false) as $code => $lang) {
    $class = '';
    if ($current == $code || $current == NULL && $code == 'en') {
        $class = ' class="selected"';
    }
    $languages[] = '<li' . $class . '><a href="?lang=' . $code . '">' . $lang . '</a></li>';
}
$languages = implode('', $languages);
function installResult(&$Page, &$install_log, $start)
{
    if (!defined('_INSTALL_ERRORS_')) {
        $install_log->writeToLog("============================================", true);
        $install_log->writeToLog("INSTALLATION COMPLETED: Execution Time - " . max(1, time() - $start) . " sec (" . date("d.m.y H:i:s") . ")", true);
        $install_log->writeToLog("============================================" . CRLF . CRLF . CRLF, true);
    } else {
        $install_log->pushToLog(_INSTALL_ERRORS_, E_ERROR, true);
コード例 #13
0
ファイル: menu.php プロジェクト: eheb/renater-decide
<li>
    <a href="{cfg:application_url}" title="{tr:home_page}">
        <span class="fi-home"></span> <label>{tr:home_page}</label>
    </a>
</li>

<?php 
if (Config::get('lang_url_enabled') && Config::get('lang_selector_enabled')) {
    ?>
<li class="has-dropdown" data-action="select_language">
    <a href="#" title="{tr:select_language}">
        <span class="fa fa-language"></span> <label>{tr:language}</label>
    </a>
    <ul class="dropdown">
        <?php 
    foreach (Lang::getAvailableLanguages() as $lang => $content) {
        ?>
        <li>
            <a class="<?php 
        if ($lang == Lang::getCode()) {
            echo 'nocursor';
        }
        ?>
" data-lang="<?php 
        echo $lang;
        ?>
" title="<?php 
        echo $content['name'];
        ?>
">
                <img src="{img:core/<?php 
コード例 #14
0
 /**
  * Setter
  * 
  * @param string $property property to get
  * @param mixed $value value to set property to
  * 
  * @throws BadVoucherException
  * @throws BadStatusException
  * @throws BadExpireException
  * @throws PropertyAccessException
  */
 public function __set($property, $value)
 {
     if ($property == 'additional_attributes') {
         $this->additional_attributes = (object) (array) $value;
     } else {
         if ($property == 'lang') {
             if (!array_key_exists($value, Lang::getAvailableLanguages())) {
                 throw new BadLangCodeException($value);
             }
             $this->lang = (string) $value;
         } else {
             if ($property == 'email_addresses') {
                 if (!is_array($value)) {
                     $value = array($value);
                 }
                 foreach ($value as $email) {
                     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                         throw new BadEmailException($value);
                     }
                 }
                 $this->email_addresses = $value;
             } else {
                 if ($property == 'name') {
                     $this->name = (string) $value;
                 } else {
                     throw new PropertyAccessException($this, $property);
                 }
             }
         }
     }
 }
コード例 #15
0
 /**
  * Allows to show the lang selector button
  */
 private function showLangSelector()
 {
     echo "<li class='has-dropdown' id='li_lang'>";
     echo "    <a href='#' title='Choisissez votre langue'><i class='fa fa-language'></i><label>" . lang::tr('Language') . "</label></a>";
     echo "    <ul class='dropdown'>";
     $langs = Lang::getAvailableLanguages();
     $currentLang = Lang::getCode();
     foreach ($langs as $lang => $content) {
         echo "<li>";
         echo "<a class='lang" . ($lang == $currentLang ? ' nocursor' : '') . "' data-lang='" . $lang . "' title='" . $content['name'] . "'>";
         echo "<img src='" . Config::get('site_url') . ('/lib/images/' . $lang . '.png') . "'/> <label>" . $content['name'] . "</label>";
         if ($lang == $currentLang) {
             echo " <i class='fa fa-check'></i>";
         }
         echo "</a>";
         echo "</li>";
     }
     echo "</ul>";
     echo "</li>";
 }
コード例 #16
0
 function appendNavigation()
 {
     $nav = $this->getNavigationArray();
     ####
     # Delegate: NavigationPreRender
     # Description: Immediately before displaying the admin navigation. Provided with the navigation array
     #              Manipulating it will alter the navigation for all pages.
     # Global: Yes
     $this->_Parent->ExtensionManager->notifyMembers('NavigationPreRender', '/backend/', array('navigation' => &$nav));
     $xNav = new XMLElement('ul');
     $xNav->setAttribute('id', 'nav');
     foreach ($nav as $n) {
         $n_bits = explode('/', $n['link'], 3);
         $can_access = false;
         if ($n['visible'] != 'no') {
             if (!isset($n['limit']) || $n['limit'] == 'author') {
                 $can_access = true;
             } elseif ($n['limit'] == 'developer' && $this->_Parent->Author->isDeveloper()) {
                 $can_access = true;
             } elseif ($n['limit'] == 'primary' && $this->_Parent->Author->isPrimaryAccount()) {
                 $can_access = true;
             }
             if ($can_access) {
                 $xGroup = new XMLElement('li', $n['name']);
                 if (isset($n['class']) && trim($n['name']) != '') {
                     $xGroup->setAttribute('class', $n['class']);
                 }
                 $xChildren = new XMLElement('ul');
                 $hasChildren = false;
                 if (is_array($n['children']) && !empty($n['children'])) {
                     foreach ($n['children'] as $c) {
                         $can_access_child = false;
                         ## Check if this is a Section or Extension, and die if the user is not allowed to access it
                         if (!$this->_Parent->Author->isDeveloper() && $c['visible'] == 'no') {
                             if ($c['type'] == 'extension') {
                                 $bits = preg_split('/\\//i', $c['link'], 2, PREG_SPLIT_NO_EMPTY);
                                 if (!$this->_Parent->Author->isDeveloper() && preg_match('#^/extension/#i' . $bits[2] . '/i', $_REQUEST['page'])) {
                                     $this->_Parent->customError(E_USER_ERROR, __('Access Denied'), __('You are not authorised to access this page.'));
                                 }
                             } elseif ($c['type'] == 'section') {
                                 if ($_REQUEST['section'] == $c['section_id'] && preg_match('#^/publish/section/#', $_REQUEST['page'])) {
                                     $this->_Parent->customError(E_USER_ERROR, __('Access Denied'), __('You are not authorised to access this section.'));
                                 }
                             }
                         }
                         if ($c['visible'] != 'no') {
                             if (!isset($c['limit']) || $c['limit'] == 'author') {
                                 $can_access_child = true;
                             } elseif ($c['limit'] == 'developer' && $this->_Parent->Author->isDeveloper()) {
                                 $can_access_child = true;
                             } elseif ($c['limit'] == 'primary' && $this->_Parent->Author->isPrimaryAccount()) {
                                 $can_access_child = true;
                             }
                             if ($can_access_child) {
                                 ## Make sure preferences menu only shows if multiple languages or extension preferences are available
                                 if ($c['name'] == __('Preferences') && $n['name'] == __('System')) {
                                     $extensions = Symphony::Database()->fetch("\n\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT * \n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `tbl_extensions_delegates` \n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `delegate` = 'AddCustomPreferenceFieldsets'");
                                     $l = Lang::getAvailableLanguages(new ExtensionManager($this->_Parent));
                                     if (count($l) == 1 && (!is_array($extensions) || empty($extensions))) {
                                         continue;
                                     }
                                 }
                                 ##
                                 $xChild = new XMLElement('li');
                                 $xLink = new XMLElement('a', $c['name']);
                                 $xLink->setAttribute('href', URL . '/symphony' . $c['link']);
                                 $xChild->appendChild($xLink);
                                 $xChildren->appendChild($xChild);
                                 $hasChildren = true;
                             }
                         }
                     }
                     if ($hasChildren) {
                         $xGroup->appendChild($xChildren);
                         $xNav->appendChild($xGroup);
                     }
                 }
             }
         }
     }
     $this->Form->appendChild($xNav);
     $this->_Parent->Profiler->sample('Navigation Built', PROFILE_LAP);
 }
コード例 #17
0
 public function view()
 {
     $this->setPageType('form');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Preferences'), __('Symphony'))));
     $this->appendSubheading(__('Preferences'));
     $bIsWritable = true;
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if (!is_writable(CONFIG)) {
         $this->pageAlert(__('The Symphony configuration file, %s, is not writable. You will not be able to save changes to preferences.', array('<code>/manifest/config.php</code>')), Alert::ERROR);
         $bIsWritable = false;
     } elseif ($formHasErrors) {
         $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR);
     } elseif (isset($this->_context[0]) && $this->_context[0] == 'success') {
         $this->pageAlert(__('Preferences saved.'), Alert::SUCCESS);
     }
     // Get available languages
     $languages = Lang::getAvailableLanguages();
     if (count($languages) > 1) {
         // Create language selection
         $group = new XMLElement('fieldset');
         $group->setAttribute('class', 'settings');
         $group->appendChild(new XMLElement('legend', __('System Language')));
         $label = Widget::Label();
         // Get language names
         asort($languages);
         foreach ($languages as $code => $name) {
             $options[] = array($code, $code == Symphony::Configuration()->get('lang', 'symphony'), $name);
         }
         $select = Widget::Select('settings[symphony][lang]', $options);
         $label->appendChild($select);
         $group->appendChild($label);
         $group->appendChild(new XMLElement('p', __('Authors can set up a differing language in their profiles.'), array('class' => 'help')));
         // Append language selection
         $this->Form->appendChild($group);
     }
     // Get available EmailGateways
     $email_gateway_manager = new EmailGatewayManager();
     $email_gateways = $email_gateway_manager->listAll();
     if (count($email_gateways) >= 1) {
         $group = new XMLElement('fieldset', NULL, array('class' => 'settings condensed'));
         $group->appendChild(new XMLElement('legend', __('Default Email Settings')));
         $label = Widget::Label(__('Gateway'));
         // Get gateway names
         ksort($email_gateways);
         $default_gateway = $email_gateway_manager->getDefaultGateway();
         $selected_is_installed = $email_gateway_manager->__getClassPath($default_gateway);
         $options = array();
         foreach ($email_gateways as $handle => $details) {
             $options[] = array($handle, $handle == $default_gateway || $selected_is_installed == false && $handle == 'sendmail', $details['name']);
         }
         $select = Widget::Select('settings[Email][default_gateway]', $options, array('class' => 'picker', 'data-interactive' => 'data-interactive'));
         $label->appendChild($select);
         $group->appendChild($label);
         // Append email gateway selection
         $this->Form->appendChild($group);
     }
     foreach ($email_gateways as $gateway) {
         $gateway_settings = $email_gateway_manager->create($gateway['handle'])->getPreferencesPane();
         if (is_a($gateway_settings, 'XMLElement')) {
             $this->Form->appendChild($gateway_settings);
         }
     }
     // Get available cache drivers
     $caches = Symphony::ExtensionManager()->getProvidersOf('cache');
     // Add default Symphony cache driver..
     $caches['database'] = 'Database';
     if (count($caches) > 1) {
         $group = new XMLElement('fieldset', NULL, array('class' => 'settings condensed'));
         $group->appendChild(new XMLElement('legend', __('Default Cache Settings')));
         /**
          * Add custom Caching groups. For example a Datasource extension might want to add in the ability
          * for set a cache driver for it's functionality. This should usually be a dropdown, which allows
          * a developer to select what driver they want to use for caching. This choice is stored in the
          * Configuration in a Caching node.
          * eg.
          *  'caching' => array (
          *        'remote_datasource' => 'database',
          *        'dynamic_ds' => 'YourCachingExtensionClassName'
          *  )
          *
          * @since Symphony 2.4
          * @delegate AddCachingOpportunity
          * @param string $context
          * '/system/preferences/'
          * @param XMLElement $wrapper
          *  An XMLElement of the current Caching fieldset
          * @param string $config_path
          *  The node in the Configuration where this information will be stored. Read only.
          * @param array $available_caches
          *  An array of the available cache providers
          * @param array $errors
          *  An array of errors
          */
         Symphony::ExtensionManager()->notifyMembers('AddCachingOpportunity', '/system/preferences/', array('wrapper' => &$group, 'config_path' => 'caching', 'available_caches' => $caches, 'errors' => $this->_errors));
         $this->Form->appendChild($group);
     }
     /**
      * Add Extension custom preferences. Use the $wrapper reference to append objects.
      *
      * @delegate AddCustomPreferenceFieldsets
      * @param string $context
      * '/system/preferences/'
      * @param XMLElement $wrapper
      *  An XMLElement of the current page
      * @param array $errors
      *  An array of errors
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomPreferenceFieldsets', '/system/preferences/', array('wrapper' => &$this->Form, 'errors' => $this->_errors));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
     $div->appendChild($version);
     $attr = array('accesskey' => 's');
     if (!$bIsWritable) {
         $attr['disabled'] = 'disabled';
     }
     $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', $attr));
     $this->Form->appendChild($div);
 }
コード例 #18
0
 public function __viewIndex()
 {
     $this->appendSubheading(__('Settings'));
     $this->appendTabs();
     if (!is_writable(CONF . '/core.xml')) {
         $this->alerts()->append(__('The core Symphony configuration file, /manifest/conf/core.xml, is not writable. You will not be able to save any changes.'), AlertStack::ERROR);
     }
     // Status message:
     $callback = Administration::instance()->getPageCallback();
     if (isset($callback['flag']) && !is_null($callback['flag'])) {
         switch ($callback['flag']) {
             case 'saved':
                 $this->alerts()->append(__('System settings saved at %1$s.', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__))), AlertStack::SUCCESS);
                 break;
         }
     }
     // SETUP PAGE
     $layout = new Layout();
     $left = $layout->createColumn(Layout::LARGE);
     $center = $layout->createColumn(Layout::LARGE);
     $right = $layout->createColumn(Layout::LARGE);
     // SITE SETUP
     $helptext = 'Symphony version: ' . Symphony::Configuration()->core()->symphony->version;
     $fieldset = Widget::Fieldset(__('Site Setup'), $helptext);
     $label = Widget::Label(__('Site Name'));
     $input = Widget::Input('settings[symphony][sitename]', Symphony::Configuration()->core()->symphony->sitename);
     $label->appendChild($input);
     if (isset($this->errors->{'symphony::sitename'})) {
         $label = Widget::wrapFormElementWithError($label, $this->errors->{'symphony::sitename'});
     }
     $fieldset->appendChild($label);
     // Get available languages
     $languages = Lang::getAvailableLanguages(true);
     if (count($languages) > 1) {
         // Create language selection
         $label = Widget::Label(__('Default Language'));
         // Get language names
         asort($languages);
         foreach ($languages as $code => $name) {
             $options[] = array($code, $code == Symphony::Configuration()->core()->symphony->lang, $name);
         }
         $select = Widget::Select('settings[symphony][lang]', $options);
         unset($options);
         $label->appendChild($select);
         //$group->appendChild(new XMLElement('p', __('Users can set individual language preferences in their profiles.'), array('class' => 'help')));
         // Append language selection
         $fieldset->appendChild($label);
     }
     $left->appendChild($fieldset);
     // REGIONAL SETTINGS
     $fieldset = Widget::Fieldset(__('Date & Time Settings'));
     // Date and Time Settings
     $label = Widget::Label(__('Date Format'));
     $input = Widget::Input('settings[region][date-format]', Symphony::Configuration()->core()->region->{'date-format'});
     $label->appendChild($input);
     if (isset($this->errors->{'region::date-format'})) {
         $label = Widget::wrapFormElementWithError($label, $this->errors->{'region::date-format'});
     }
     $fieldset->appendChild($label);
     $label = Widget::Label(__('Time Format'));
     $input = Widget::Input('settings[region][time-format]', Symphony::Configuration()->core()->region->{'time-format'});
     $label->appendChild($input);
     if (isset($this->errors->{'region::time-format'})) {
         $label = Widget::wrapFormElementWithError($label, $this->errors->{'region::time-format'});
     }
     $fieldset->appendChild($label);
     $label = Widget::Label(__('Timezone'));
     $timezones = timezone_identifiers_list();
     foreach ($timezones as $timezone) {
         $options[] = array($timezone, $timezone == Symphony::Configuration()->core()->region->timezone, $timezone);
     }
     $select = Widget::Select('settings[region][timezone]', $options);
     unset($options);
     $label->appendChild($select);
     $fieldset->appendChild($label);
     $center->appendChild($fieldset);
     // PERMISSIONS
     $fieldset = Widget::Fieldset(__('Permissions'));
     $permissions = array('0777', '0775', '0755', '0666', '0644');
     $fileperms = Symphony::Configuration()->core()->symphony->{'file-write-mode'};
     $dirperms = Symphony::Configuration()->core()->symphony->{'directory-write-mode'};
     $label = Widget::Label(__('File Permissions'));
     foreach ($permissions as $p) {
         $options[] = array($p, $p == $fileperms, $p);
     }
     if (!in_array($fileperms, $permissions)) {
         $options[] = array($fileperms, true, $fileperms);
     }
     $select = Widget::Select('settings[symphony][file-write-mode]', $options);
     unset($options);
     $label->appendChild($select);
     $fieldset->appendChild($label);
     $label = Widget::Label(__('Directory Permissions'));
     foreach ($permissions as $p) {
         $options[] = array($p, $p == $dirperms, $p);
     }
     if (!in_array($dirperms, $permissions)) {
         $options[] = array($dirperms, true, $dirperms);
     }
     $select = Widget::Select('settings[symphony][directory-write-mode]', $options);
     unset($options);
     $label->appendChild($select);
     $fieldset->appendChild($label);
     $right->appendChild($fieldset);
     $layout->appendTo($this->Form);
     $div = $this->createElement('div');
     $div->setAttribute('class', 'actions');
     $attr = array('accesskey' => 's');
     if (!is_writable(CONF)) {
         $attr['disabled'] = 'disabled';
     }
     $div->appendChild(Widget::Submit('action[save]', __('Save Changes'), $attr));
     $this->Form->appendChild($div);
 }
コード例 #19
0
 public function view()
 {
     $this->setPageType('form');
     $this->setTitle(__('%1$s &ndash; %2$s', array(__('Preferences'), __('Symphony'))));
     $this->appendSubheading(__('Preferences'));
     $bIsWritable = true;
     $formHasErrors = is_array($this->_errors) && !empty($this->_errors);
     if (!is_writable(CONFIG)) {
         $this->pageAlert(__('The Symphony configuration file, %s, is not writable. You will not be able to save changes to preferences.', array('<code>/manifest/config.php</code>')), Alert::ERROR);
         $bIsWritable = false;
     } else {
         if ($formHasErrors) {
             $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR);
         } else {
             if (isset($this->_context[0]) && $this->_context[0] == 'success') {
                 $this->pageAlert(__('Preferences saved.'), Alert::SUCCESS);
             }
         }
     }
     // Get available languages
     $languages = Lang::getAvailableLanguages();
     if (count($languages) > 1) {
         // Create language selection
         $group = new XMLElement('fieldset');
         $group->setAttribute('class', 'settings');
         $group->appendChild(new XMLElement('legend', __('System Language')));
         $label = Widget::Label();
         // Get language names
         asort($languages);
         foreach ($languages as $code => $name) {
             $options[] = array($code, $code == Symphony::Configuration()->get('lang', 'symphony'), $name);
         }
         $select = Widget::Select('settings[symphony][lang]', $options);
         $label->appendChild($select);
         $group->appendChild($label);
         $group->appendChild(new XMLElement('p', __('Authors can set up a differing language in their profiles.'), array('class' => 'help')));
         // Append language selection
         $this->Form->appendChild($group);
     }
     // Get available EmailGateways
     $email_gateway_manager = new EmailGatewayManager($this);
     $email_gateways = $email_gateway_manager->listAll();
     if (count($email_gateways) >= 1) {
         $group = new XMLElement('fieldset', NULL, array('class' => 'settings picker'));
         $group->appendChild(new XMLElement('legend', __('Default Email Settings')));
         $label = Widget::Label(__('Gateway'));
         // Get gateway names
         ksort($email_gateways);
         $default_gateway = $email_gateway_manager->getDefaultGateway();
         $selected_is_installed = $email_gateway_manager->__getClassPath($default_gateway);
         $options = array();
         foreach ($email_gateways as $handle => $details) {
             $options[] = array($handle, $handle == $default_gateway || $selected_is_installed == false && $handle == 'sendmail', $details['name']);
         }
         $select = Widget::Select('settings[Email][default_gateway]', $options);
         $label->appendChild($select);
         $group->appendChild($label);
         // Append email gateway selection
         $this->Form->appendChild($group);
     }
     foreach ($email_gateways as $gateway) {
         $gateway_settings = $email_gateway_manager->create($gateway['handle'])->getPreferencesPane();
         if (is_a($gateway_settings, 'XMLElement')) {
             $this->Form->appendChild($gateway_settings);
         }
     }
     /**
      * Add Extension custom preferences. Use the $wrapper reference to append objects.
      *
      * @delegate AddCustomPreferenceFieldsets
      * @param string $context
      * '/system/preferences/'
      * @param XMLElement $wrapper
      *  An XMLElement of the current page
      * @param array $errors
      *  An array of errors
      */
     Symphony::ExtensionManager()->notifyMembers('AddCustomPreferenceFieldsets', '/system/preferences/', array('wrapper' => &$this->Form, 'errors' => $this->_errors));
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $attr = array('accesskey' => 's');
     if (!$bIsWritable) {
         $attr['disabled'] = 'disabled';
     }
     $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', $attr));
     $this->Form->appendChild($div);
 }
コード例 #20
0
 /**
  * Prepare mail to be sent to recipient
  * 
  * @param string $translation_id
  * @param mixed $to recipient
  * @param mixed * translation args
  * 
  * @return ApplicationMail
  */
 public static function prepare($translation_id, $to)
 {
     $vars = array_slice(func_get_args(), 2);
     if (!is_scalar($to)) {
         array_unshift($vars, $to);
     }
     // compute lang from arguments
     $lang = null;
     if (is_object($to) && $to instanceof User) {
         $lang = $to->lang;
         $to = $to->email;
     }
     // Translate mail parts
     $email_translation = call_user_func_array(array(Lang::translateEmail($translation_id, $lang), 'replace'), $vars);
     // Build mail with body and footer
     $plain = $email_translation->plain->out();
     $html = $email_translation->html->out();
     // No need for translatable emails if only one language available ...
     if (count(Lang::getAvailableLanguages()) > 1) {
         // Create object
         $translatable = self::create($translation_id, $vars);
         // Translate specific footer
         $footer_translation = Lang::translateEmail('translate_email_footer', $lang)->r($translatable);
         $plain .= "\n\n" . $footer_translation->plain->out();
         $html .= "\n\n" . $footer_translation->html->out();
     }
     $mail = new ApplicationMail(new Translation(array('subject' => $email_translation->subject->out(), 'plain' => $plain, 'html' => $html)));
     // Add recipient
     $mail->to($to);
     return $mail;
 }