示例#1
0
 public function addSetter($name, $phpDoc = true)
 {
     $setter = new ClassFunction('set' . ucwords($name));
     $setter->addInput(new Input($name));
     $setter->addCode(new Code\RawCode('$this->' . $name . ' = ' . $name . ';'));
     $setter->addCode(new Code\ReturnValue('$this'));
     if ($phpDoc) {
         $phpDocItem = new PhpDoc('Sets "' . $name . '" property');
         $phpDocItem->addTag(new Tag\Base('param', ($this->issetProperty($name) ? $this->getProperty($name)->getType() : 'variant') . ' $' . $name));
         $setter->setComment($phpDocItem);
     }
     $this->addFunction($setter);
     return $this;
 }
示例#2
0
文件: view.php 项目: rair/yacs
    }
    if (isset($context['arguments'][4])) {
        $script .= '/' . $context['arguments'][4];
    }
    if (isset($context['arguments'][5])) {
        $script .= '/' . $context['arguments'][5];
    }
}
// fight against hackers
$script = preg_replace(FORBIDDEN_IN_PATHS, '', strip_tags($script));
// get the actual page
include_once 'scripts.php';
include_once 'phpdoc.php';
$row = PhpDoc::get($script);
if (!$row) {
    $row = PhpDoc::get($script . '/index.php');
}
// load localized strings
i18n::bind('scripts');
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('scripts/' => i18n::s('Server software'));
// page title
if ($script == 'todo') {
    $context['page_title'] = i18n::s('To-do list');
} elseif ($script == 'authors') {
    $context['page_title'] = i18n::s('Authors of all those scripts');
} elseif ($script == 'testers') {
    $context['page_title'] = i18n::s('Testers of all those scripts');
} elseif ($script == 'licenses') {
示例#3
0
文件: index.php 项目: rair/yacs
    // the status message
    Safe::load('footprints.php');
    if (isset($generation['date']) && $generation['date']) {
        $context['text'] .= '<p>' . sprintf(i18n::s('Last update took place on %s'), $generation['date']) . '</p>' . "\n";
    }
    unset($generation);
    // ensure we have a reference server
    if (!isset($context['reference_server']) || !$context['reference_server']) {
        $context['reference_server'] = i18n::s('www.yacs.fr');
    }
    // offer to upgrade
    $context['text'] .= '<p>' . Skin::build_link('scripts/stage.php', i18n::s('Update the software')) . "</p>\n";
}
// get the page from the php documentation, if any
include_once 'phpdoc.php';
$item = PhpDoc::get('index');
if ($item) {
    // the list of things to do
    $context['page_tools'][] = Skin::build_link(Scripts::get_url('todo'), i18n::s('To do'), 'basic');
    // the list of testers
    $context['page_tools'][] = Skin::build_link(Scripts::get_url('testers'), i18n::s('Testers'), 'basic');
    // the list of authors
    $context['page_tools'][] = Skin::build_link(Scripts::get_url('authors'), i18n::s('Authors'), 'basic');
    // the list of licenses
    $context['page_tools'][] = Skin::build_link(Scripts::get_url('licenses'), i18n::s('Licenses'), 'basic');
    // splash message
    $text = '<p>' . i18n::s('Click on any link below to access the documentation extracted from each script (phpDoc).') . "</p>\n";
    // tree of links to documentation pages
    $text .= Codes::beautify($item['content']);
    // link to some other server
} else {
示例#4
0
文件: parse.php 项目: rair/yacs
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('scripts/' => i18n::s('Server software'));
// the title of the page
if ($script) {
    $context['page_title'] = $script;
} else {
    $context['page_title'] = i18n::s('View PHP documentation');
}
// no script has been provided
if (!$script) {
    Logger::error(i18n::s('No script has been provided.'));
    // the script has to be there
} elseif (!file_exists($translated)) {
    Logger::error(i18n::s('Script does not exist.'));
} else {
    include_once 'phpdoc.php';
    $tool = new PhpDoc();
    // parse the file
    $context['text'] .= $tool->parse($script, '');
    // generate the php documentation for this script
    //	$context['page_title'] = $tool->index[$script];
    $context['text'] .= Codes::beautify('[toc] ' . $tool->comments[$script]);
    // menu bar
    $context['page_tools'][] = Skin::build_link('scripts/browse.php?script=' . $script, i18n::s('Browse'));
    $context['page_tools'][] = Skin::build_link('scripts/fetch.php?script=' . $script, i18n::s('Fetch'));
    $context['page_tools'][] = Skin::build_link('scripts/', i18n::s('Server software'));
}
// render the skin
render_skin();
示例#5
0
文件: setup.php 项目: rair/yacs
/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $action;
    // check that the user is an admin, but only if there is at least one user record
    $query = "SELECT count(*) FROM " . SQL::table_name('users');
    if (!Surfer::is_associate() && SQL::query($query) !== FALSE) {
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
        echo '<p>' . i18n::s('You are not allowed to perform this operation.') . "</p>\n";
        return;
    }
    // log the current surfer as an associate if not yet the case
    if (!Surfer::is_associate()) {
        $fields = array();
        $fields['id'] = 1;
        $fields['nick_name'] = 'admin';
        $fields['email'] = '';
        $fields['capability'] = 'A';
        Surfer::set($fields);
        echo '<p>' . i18n::s('You have associate privilege') . '</p>';
    }
    // check every table of the database
    if ($action == 'build') {
        // maybe we will have to switch the server off
        $temporary_off = FALSE;
        // ensure nobody else will access the database during the operation
        if (file_exists('../parameters/switch.on')) {
            if (Safe::rename($context['path_to_root'] . 'parameters/switch.on', $context['path_to_root'] . 'parameters/switch.off')) {
                echo BR . i18n::s('The server has been switched off.');
                $temporary_off = TRUE;
            }
            // let concurrent on-going transactions finish properly
            Safe::sleep(3);
            // first installation
        } elseif (!file_exists('../parameters/switch.off')) {
            echo '<p>' . i18n::s('Review provided information and go to the bottom of the page to move forward.') . "</a></p>\n";
        }
        // ensure utf8 character set for this database
        $query = "ALTER DATABASE `" . $context['database'] . "`  DEFAULT CHARACTER SET utf8";
        SQL::query($query);
        // create tables for users
        echo Users::setup();
        // create tables for activities
        echo Activities::setup();
        // create tables for notifications
        include_once '../users/notifications.php';
        echo Notifications::setup();
        // create tables for messages
        echo Mailer::setup();
        // create tables for visits
        include_once '../users/visits.php';
        echo Visits::setup();
        // create tables for sections
        echo Sections::setup();
        // create tables for articles
        echo Articles::setup();
        // create tables for images
        include_once '../images/images.php';
        echo Images::setup();
        // create tables for tables
        include_once '../tables/tables.php';
        echo Tables::setup();
        // create tables for files
        echo Files::setup();
        // create tables for links
        include_once '../links/links.php';
        echo Links::setup();
        // create tables for locations
        include_once '../locations/locations.php';
        echo Locations::setup();
        // create tables for comments
        include_once '../comments/comments.php';
        echo Comments::setup();
        // create tables for categories
        echo Categories::setup();
        // create tables for members
        include_once '../shared/members.php';
        echo Members::setup();
        // create tables for dates
        include_once '../dates/dates.php';
        echo Dates::setup();
        // create tables for servers
        include_once '../servers/servers.php';
        echo Servers::setup();
        // create tables for versions
        include_once '../versions/versions.php';
        echo Versions::setup();
        // create tables for enrolments
        include_once '../shared/enrolments.php';
        echo Enrolments::setup();
        // create tables for values
        include_once '../shared/values.php';
        echo Values::setup();
        // create tables for the cache
        echo Cache::setup();
        // create tables for the php documentation
        include_once '../scripts/phpdoc.php';
        echo PhpDoc::setup();
        // the setup hook
        if (is_callable(array('Hooks', 'include_scripts'))) {
            echo Hooks::include_scripts('control/setup.php');
        }
        // reopen the server for others
        if ($temporary_off && Safe::rename($context['path_to_root'] . 'parameters/switch.off', $context['path_to_root'] . 'parameters/switch.on')) {
            echo '<p>' . i18n::s('The server has been switched on.') . '</p>';
        }
        // in the middle of an update
        if (file_exists('../parameters/switch.off')) {
            echo Skin::build_block('<form method="get" action="../scripts/run_once.php">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Run one-time scripts and go to the Control Panel')) . '</p>' . "\n" . '</form>', 'bottom');
            // this may take several minutes
            echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
            // populate the database on first installation
        } elseif (!file_exists('../parameters/switch.on')) {
            echo Skin::build_block('<form method="get" action="populate.php">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Initialize the database')) . '</p>' . "\n" . '</form>', 'bottom');
            // or back to the control panel
        } else {
            $menu = array('control/' => i18n::s('Control Panel'));
            echo Skin::build_list($menu, 'menu_bar');
        }
        // clear the cache
        Cache::clear();
        // remember the change
        $label = i18n::c('The database has been optimised');
        Logger::remember('control/setup.php: ' . $label);
        // ask for confirmation
    } else {
        // the splash message
        echo '<p>' . i18n::s('This script will check the structure of the database and optimize data storage:') . '</p>' . "\n" . '<ul>' . "\n" . '<li>' . i18n::s('Missing tables will be created, if necessary.') . '</li>' . "\n" . '<li>' . i18n::s('Some columns may be created or converted if their type has evolved.') . '</li>' . "\n" . '<li>' . i18n::s('All indexes will be (re)built.') . '</li>' . "\n" . '<li>' . i18n::s('Data files will be optimized as well.') . '</li>' . "\n" . '</ul>' . "\n";
        // the submit button
        echo '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . Skin::build_submit_button(i18n::s('Ensure the database structure is accurate'), NULL, NULL, 'confirmed') . '<input type="hidden" name="action" value="build" />' . '</p></form>';
        // the script used for form handling at the browser
        Page::insert_script('$("#confirmed").focus();');
        // this may take several minutes
        echo '<p>' . i18n::s('When you will click on the button the server will be immediately requested to proceed. However, because of the so many things to do on the back-end, you may have to wait for minutes before getting a response displayed. Thank you for your patience.') . '</p>';
    }
}
示例#6
0
文件: build.php 项目: rair/yacs
     }
     // avoid timeouts
     if (!(count($footprints) % 50)) {
         Safe::set_time_limit(30);
         SQL::ping();
     }
 }
 if (count($footprints)) {
     $context['text'] .= sprintf(i18n::s('%d reference scripts have been copied.'), count($footprints)) . "\n";
 }
 $context['text'] .= "</p>\n";
 // purge documentation pages
 $context['text'] .= '<p>' . i18n::s('Purging the documentation pages...') . "</p>\n";
 // get a parser
 include_once 'phpdoc.php';
 $documentation = new PhpDoc();
 // purge the existing documentation, if any
 $documentation->purge();
 // list reference files
 $context['text'] .= '<p>' . i18n::s('Listing files...') . BR . "\n";
 // locate reference files --include special nodes
 $references = Scripts::list_files_at($context['path_to_reference'], TRUE, $context['path_to_reference'], '.htaccess');
 if (is_array($references)) {
     $context['text'] .= BR . sprintf(i18n::s('%d files have been found.'), count($references)) . "\n";
 }
 $context['text'] .= "</p>\n";
 // build documentation pages
 $context['text'] .= '<p>' . i18n::s('Building documentation pages...') . BR . "\n";
 // analyse each script
 $index = 0;
 foreach ($references as $reference) {