コード例 #1
0
ファイル: admin_users.php プロジェクト: ITw3/redaxscript
/**
 * admin users form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_users_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define fields for existing user */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query user */
        $query = 'SELECT * FROM ' . PREFIX . 'users WHERE id = ' . ID_PARAMETER;
        $result = mysql_query($query);
        $r = mysql_fetch_assoc($result);
        if ($r) {
            foreach ($r as $key => $value) {
                ${$key} = stripslashes($value);
            }
        }
        $wording_headline = $name;
        $wording_submit = l('save');
        $route = 'admin/process/users/' . $id;
    } else {
        if (ADMIN_PARAMETER == 'new') {
            $status = 1;
            $groups = 0;
            $wording_headline = l('user_new');
            $wording_submit = l('create');
            $route = 'admin/process/users';
            $code_required = ' required="required"';
        }
    }
    /* collect output */
    $output .= '<h2 class="title_content">' . $wording_headline . '</h2>';
    $output .= form_element('form', 'form_admin', 'js_validate_form js_tab form_admin hidden_legend', '', '', '', 'action="' . REWRITE_ROUTE . $route . '" method="post"');
    /* collect tab list output */
    $output .= '<ul class="js_list_tab list_tab list_tab_admin">';
    $output .= '<li class="js_item_active item_first item_active">' . anchor_element('internal', '', '', l('user'), FULL_ROUTE . '#tab-1') . '</li>';
    $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li></ul>';
    /* collect tab box output */
    $output .= '<div class="js_box_tab box_tab box_tab_admin">';
    /* collect user set */
    $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l('user')) . '<ul>';
    $output .= '<li>' . form_element('text', 'name', 'field_text_admin field_note', 'name', $name, l('name'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>';
    if ($id == '') {
        $output .= '<li>' . form_element('text', 'user', 'field_text_admin field_note', 'user', $user, l('user'), 'maxlength="50" required="required"') . '</li>';
    }
    $output .= '<li>' . form_element('password', 'password', 'js_unmask_password field_text_admin field_note', 'password', '', l('password'), 'maxlength="50" autocomplete="off"' . $code_required) . '</li>';
    $output .= '<li>' . form_element('password', 'password_confirm', 'js_unmask_password field_text_admin field_note', 'password_confirm', '', l('password_confirm'), 'maxlength="50" autocomplete="off"' . $code_required) . '</li>';
    $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', $email, l('email'), 'maxlength="50" required="required"') . '</li>';
    $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small_admin', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>';
    $output .= '</ul></fieldset>';
    /* collect customize set */
    $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>';
    /* languages directory object */
    $languages_directory = new Redaxscript\Directory('languages');
    $languages_directory_array = $languages_directory->get();
    /* build languages select */
    $language_array[l('select')] = '';
    foreach ($languages_directory_array as $value) {
        $value = substr($value, 0, 2);
        $language_array[l($value, '_index')] = $value;
    }
    $output .= '<li>' . select_element('language', 'field_select_admin', 'language', $language_array, $language, l('language')) . '</li>';
    if ($id == '' || $id > 1) {
        $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('enable') => 1, l('disable') => 0), $status, l('status')) . '</li>';
        /* build groups select */
        if (GROUPS_EDIT == 1 && USERS_EDIT == 1) {
            $groups_query = 'SELECT * FROM ' . PREFIX . 'groups ORDER BY name ASC';
            $groups_result = mysql_query($groups_query);
            if ($groups_result) {
                while ($g = mysql_fetch_assoc($groups_result)) {
                    $groups_array[$g['name']] = $g['id'];
                }
            }
            $output .= '<li>' . select_element('groups', 'field_select_admin', 'groups', $groups_array, $groups, l('groups'), 'multiple="multiple"') . '</li>';
        }
    }
    $output .= '</ul></fieldset></div>';
    /* collect hidden output */
    if ($id) {
        $output .= form_element('hidden', '', '', 'user', $user);
    }
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    /* collect button output */
    if (USERS_EDIT == 1 || USERS_DELETE == 1) {
        $cancel_route = 'admin/view/users';
    } else {
        $cancel_route = 'admin';
    }
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large_admin button_cancel_admin', l('cancel'), $cancel_route);
    /* delete button */
    if ((USERS_DELETE == 1 || USERS_EXCEPTION == 1) && $id > 1) {
        $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large_admin button_delete_admin', l('delete'), 'admin/delete/users/' . $id . '/' . TOKEN);
    }
    /* submit button */
    if (USERS_NEW == 1 || USERS_EDIT == 1 || USERS_EXCEPTION == 1) {
        $output .= form_element('button', '', 'js_submit button_admin button_large_admin button_submit_admin', ADMIN_PARAMETER, $wording_submit);
    }
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #2
0
ファイル: admin_settings.php プロジェクト: ITw3/redaxscript
/**
 * admin settings form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_settings_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    $output .= '<h2 class="title_content">' . l('settings') . '</h2>';
    $output .= form_element('form', 'form_admin', 'js_validate_form js_accordion form_admin', '', '', '', 'action="' . REWRITE_ROUTE . 'admin/update/settings" method="post"');
    /* collect general set */
    $output .= '<fieldset class="js_set_accordion js_set_active set_accordion set_accordion_admin set_active">';
    $output .= '<legend class="js_title_accordion js_title_active title_accordion title_accordion_admin title_active">' . l('general') . '</legend>';
    $output .= '<ul class="js_box_accordion js_box_active box_accordion box_accordion_admin box_active">';
    /* languages directory object */
    $languages_directory = new Redaxscript\Directory('languages');
    $languages_directory_array = $languages_directory->get();
    /* build languages select */
    if (count($languages_directory_array) > 1) {
        $language_array[l('detect')] = 'detect';
    }
    foreach ($languages_directory_array as $value) {
        $value = substr($value, 0, 2);
        $language_array[l($value, '_index')] = $value;
    }
    $output .= '<li>' . select_element('language', 'field_select_admin', 'language', $language_array, s('language'), l('language')) . '</li>';
    /* templates directory object */
    $templates_directory = new Redaxscript\Directory('templates', array('admin', 'install'));
    $templates_directory_array = $templates_directory->get();
    /* build templates select */
    $output .= '<li>' . select_element('template', 'field_select_admin', 'template', $templates_directory_array, s('template'), l('template')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect metadata set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('metadata') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . form_element('text', 'title', 'field_text_admin', 'title', s('title'), l('title'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . form_element('text', 'author', 'field_text_admin', 'author', s('author'), l('author'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . form_element('text', 'copyright', 'field_text_admin', 'copyright', s('copyright'), l('copyright'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small_admin', 'description', s('description'), l('description'), 'rows="1" cols="15"') . '</li>';
    $output .= '<li>' . form_element('textarea', 'keywords', 'js_auto_resize field_textarea_admin field_small_admin', 'keywords', s('keywords'), l('keywords'), 'rows="1" cols="15"') . '</li>';
    $output .= '<li>' . select_element('robots', 'field_select_admin', 'robots', array(l('index') => 'all', l('index_no') => 'none'), s('robots'), l('robots')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect contact set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('contact') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', s('email'), l('email'), 'maxlength="50" required="required"') . '</li>';
    $output .= '<li>' . form_element('text', 'subject', 'field_text_admin', 'subject', s('subject'), l('subject'), 'maxlength="50"') . '</li>';
    $output .= '<li>' . select_element('notification', 'field_select_admin', 'notification', array(l('enable') => 1, l('disable') => 0), s('notification'), l('notification')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect formatting set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('formatting') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . form_element('text', 'charset', 'field_text_admin field_note', 'charset', s('charset'), l('charset'), 'maxlength="10" required="required"') . '</li>';
    $output .= '<li>' . form_element('text', 'divider', 'field_text_admin', 'divider', s('divider'), l('divider'), 'maxlength="10"') . '</li>';
    $output .= '<li>' . select_element('time', 'field_select_admin', 'time', array('H:i', 'h:i'), s('time'), l('time')) . '</li>';
    $output .= '<li>' . select_element('date', 'field_select_admin', 'date', array('d.m.Y', 'm.d.Y', 'Y.d.m'), s('date'), l('date')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect contents set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('contents') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $homepage_array[l('none')] = 0;
    $homepage_query = 'SELECT id, title FROM ' . PREFIX . 'articles ORDER BY rank ASC';
    $homepage_result = mysql_query($homepage_query);
    if ($homepage_result) {
        while ($r = mysql_fetch_assoc($homepage_result)) {
            $homepage_array[$r['title']] = $r['id'];
        }
    }
    $output .= '<li>' . select_element('homepage', 'field_select_admin', 'homepage', $homepage_array, s('homepage'), l('homepage')) . '</li>';
    $output .= '<li>' . form_element('text', 'limit', 'field_text_admin field_note', 'limit', s('limit'), l('limit'), 'min="1" max="1000" required="required"') . '</li>';
    $output .= '<li>' . select_element('order', 'field_select_admin', 'order', array(l('ascending') => 'asc', l('descending') => 'desc'), s('order'), l('order')) . '</li>';
    $output .= '<li>' . select_element('pagination', 'field_select_admin', 'pagination', array(l('enable') => 1, l('disable') => 0), s('pagination'), l('pagination')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect comments set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('comments') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . select_element('moderation', 'field_select_admin', 'moderation', array(l('enable') => 1, l('disable') => 0), s('moderation'), l('moderation')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect users set */
    $output .= '<fieldset class="js_set_accordion set_accordion set_accordion_admin">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('users') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . select_element('registration', 'field_select_admin', 'registration', array(l('enable') => 1, l('disable') => 0), s('registration'), l('registration')) . '</li>';
    $output .= '<li>' . select_element('verification', 'field_select_admin', 'verification', array(l('enable') => 1, l('disable') => 0), s('verification'), l('verification')) . '</li>';
    $output .= '<li>' . select_element('reminder', 'field_select_admin', 'reminder', array(l('enable') => 1, l('disable') => 0), s('reminder'), l('reminder')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect security set */
    $output .= '<fieldset class="js_set_accordion js_set_accordion_last set_accordion set_accordion_admin set_accordion_last">';
    $output .= '<legend class="js_title_accordion title_accordion title_accordion_admin">' . l('security') . '</legend>';
    $output .= '<ul class="js_box_accordion box_accordion box_accordion_admin">';
    $output .= '<li>' . select_element('captcha', 'field_select_admin', 'captcha', array(l('random') => 1, l('addition') => 2, l('subtraction') => 3, l('disable') => 0), s('captcha'), l('captcha')) . '</li>';
    $output .= '<li>' . select_element('blocker', 'field_select_admin', 'blocker', array(l('enable') => 1, l('disable') => 0), s('blocker'), l('blocker')) . '</li>';
    $output .= '</ul></fieldset>';
    /* collect hidden and button output */
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large_admin button_cancel_admin', l('cancel'), 'admin');
    $output .= form_element('button', '', 'js_submit button_admin button_large_admin button_submit_admin', 'update', l('save'));
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #3
0
ファイル: navigation.php プロジェクト: ITw3/redaxscript
/**
 * templates list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Navigation
 * @author Henry Ruhs
 *
 * @param array $options
 */
function templates_list($options = '')
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    }
    /* templates directory object */
    $templates_directory = new Redaxscript\Directory('templates', array('admin', 'install'));
    $templates_directory_array = $templates_directory->get();
    /* collect templates output */
    foreach ($templates_directory_array as $value) {
        $class_string = ' class="template_' . $value;
        if ($value == TEMPLATE) {
            $class_string .= ' item_active';
        }
        $class_string .= '"';
        $output .= '<li' . $class_string . '>' . anchor_element('internal', '', '', $value, FULL_ROUTE . TEMPLATE_ROUTE . $value, '', 'rel="nofollow"') . '</li>';
    }
    /* build id string */
    if ($option_id) {
        $id_string = ' id="' . $option_id . '"';
    }
    /* build class string */
    if ($option_class) {
        $class_string = ' class="' . $option_class . '"';
    } else {
        $class_string = ' class="list_templates"';
    }
    /* collect list output */
    if ($output) {
        $output = '<ul' . $id_string . $class_string . '>' . $output . '</ul>';
    }
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #4
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * file manager
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param string $directory
 */
function file_manager($directory = '')
{
    if (!is_dir($directory)) {
        mkdir($directory, 0777);
    }
    if (!is_dir($directory)) {
        $output = '<div class="box_note note_error">' . l('directory_create', 'file_manager') . l('colon') . ' ' . $directory . l('point') . '</div>';
    } else {
        if (!is_writable($directory)) {
            $output = '<div class="box_note note_error">' . l('directory_permission_grant', 'file_manager') . l('colon') . ' ' . $directory . l('point') . '</div>';
        }
    }
    /* collect listing output */
    $output .= '<h2 class="title_content">' . l('file_manager', 'file_manager') . '</h2>';
    $output .= form_element('form', 'form_file_manager', 'js_form_file_manager form_file_manager', '', '', '', 'action="' . REWRITE_ROUTE . 'admin/file-manager/upload" method="post" enctype="multipart/form-data"');
    $output .= form_element('file', '', 'js_file field_file hide_if_js', 'file', '', l('browse', 'file_manager'));
    $output .= '<button type="submit" class="js_upload field_upload button_admin hide_if_js">' . l('upload', 'file_manager') . '</span></span></button>';
    $output .= '</form>';
    $output .= '<div class="wrapper_table_admin"><table class="table table_admin">';
    /* collect thead and tfoot */
    $output .= '<thead><tr><th class="s4o6 column_first">' . l('name') . '</th><th class="s1o6 column_second">' . l('file_size', 'file_manager') . '</th><th class="s1o6 column_last">' . l('date') . '</th></tr></thead>';
    $output .= '<tfoot><tr><td class="column_first">' . l('name') . '</td><td class="column_second">' . l('file_size', 'file_manager') . '</td><td class="column_last">' . l('date') . '</td></tr></tfoot>';
    /* file manager directory object */
    $file_manager_directory = new Redaxscript\Directory($directory);
    $file_manager_directory_array = $file_manager_directory->get();
    /* collect directory output */
    if (count($file_manager_directory_array)) {
        $output .= '<tbody>';
        foreach ($file_manager_directory_array as $key => $value) {
            $output .= '<tr><td class="column_first">';
            $path = $directory . '/' . $value;
            if (function_exists('exif_imagetype') && exif_imagetype($path)) {
                $output .= anchor_element('external', '', '', $value, ROOT . '/' . $path);
            } else {
                $output .= $value;
            }
            /* collect control output */
            $output .= '<ul class="list_control_admin"><li class="item_delete">' . anchor_element('internal', '', 'js_confirm', l('delete'), 'admin/file-manager/delete/' . $key . '/' . TOKEN) . '</li></ul>';
            /* collect filesize and filetime output */
            $output .= '</td><td class="column_second">' . ceil(filesize($path) / 1024) . ' Kb</td><td class="column_last">' . date(s('date'), filectime($path)) . '</td></tr>';
        }
        $output .= '</tbody>';
    } else {
        $error = l('file_no', 'file_manager') . l('point');
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="2">' . $error . '</td></tr></tbody>';
    }
    $output .= '</table></div>';
    echo $output;
}
コード例 #5
0
ファイル: index.php プロジェクト: ITw3/redaxscript
/**
 * gallery
 *
 * @since 2.0.2
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Modules
 * @author Henry Ruhs
 *
 * @param string $directory
 * @param array $options
 * @param string $command
 */
function gallery($directory = '', $options = '', $command = '')
{
    global $gallery_counter;
    /* define option variables */
    if (is_array($options)) {
        foreach ($options as $key => $value) {
            $key = 'option_' . $key;
            ${$key} = $value;
        }
    } else {
        if ($options === 'build' || $options === 'delete') {
            $command = $options;
        }
    }
    /* gallery directory object */
    $gallery_directory = new Redaxscript\Directory($directory, 'thumbs');
    $gallery_directory_array = $gallery_directory->get();
    /* reverse order */
    if ($option_order == 'desc') {
        $gallery_directory_array = array_reverse($gallery_directory_array);
    }
    /* delete gallery thumbs directory */
    if ($command == 'delete') {
        $gallery_directory->remove('thumbs');
    } else {
        /* collect gallery */
        $gallery_total = count($gallery_directory_array);
        $gallery_id = str_replace('/', '_', $directory) . '_' . ++$gallery_counter;
        if ($gallery_total) {
            foreach ($gallery_directory_array as $value) {
                $path = $directory . '/' . $value;
                $thumb_route = $directory . '/thumbs/' . $value;
                /* build thumb */
                if (file_exists($thumb_route) == '' || $command == 'build') {
                    gallery_build_thumb($value, $directory, $options);
                }
                if (file_exists($thumb_route)) {
                    /* read exif data */
                    $image_data = exif_read_data($path);
                    if ($image_data) {
                        $image_artist = $image_data['Artist'];
                        $image_datetime = $image_data['DateTime'];
                        if ($image_datetime) {
                            $image_date = date(s('date'), strtotime($image_datetime));
                        } else {
                            $image_date = '';
                        }
                        $image_description = $image_data['ImageDescription'];
                    }
                    /* build data string */
                    $data_string = 'data-counter="' . ++$image_counter . '" data-total="' . $gallery_total . '" data-id="' . $gallery_id . '"';
                    if ($image_artist) {
                        $data_string .= ' data-artist="' . $image_artist . '"';
                    }
                    if ($image_date) {
                        $data_string .= ' data-date="' . $image_date . '"';
                    }
                    if ($image_description) {
                        $data_string .= ' data-description="' . $image_description . '"';
                        $alt_string = ' alt="' . $image_description . '"';
                    } else {
                        $alt_string = ' alt="' . str_replace('_', ' ', pathinfo($value, PATHINFO_FILENAME)) . '"';
                    }
                    /* collect image output */
                    $image = '<img src="' . $thumb_route . '" class="image image_gallery"' . $alt_string . ' />';
                    $output .= '<li class="item_gallery">' . anchor_element('', '', 'link_gallery', $image, $path, $image_description, $data_string) . '</li>';
                }
            }
            /* collect list output */
            if ($output) {
                $output = '<ul id="' . $gallery_id . '" class="js_list_gallery list_gallery ' . $gallery_id . ' clearfix">' . $output . '</ul>';
                echo $output;
            }
        } else {
            $gallery_directory->remove('thumbs');
        }
    }
}
コード例 #6
0
ファイル: admin_modules.php プロジェクト: ITw3/redaxscript
/**
 * admin modules list
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_modules_list()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* query modules */
    $query = 'SELECT id, name, alias, version, status FROM ' . PREFIX . 'modules';
    $result = mysql_query($query);
    $num_rows = mysql_num_rows($result);
    /* collect listing output */
    $output .= '<h2 class="title_content">' . l('modules') . '</h2>';
    $output .= '<div class="wrapper_table_admin"><table class="table table_admin">';
    /* collect thead and tfoot */
    $output .= '<thead><tr><th class="s4o6 column_first">' . l('name') . '</th><th class="s1o6 column_second">' . l('alias') . '</th><th class="s1o6 column_last">' . l('version') . '</th></tr></thead>';
    $output .= '<tfoot><tr><td class="column_first">' . l('name') . '</td><td class="column_second">' . l('alias') . '</td><td class="column_last">' . l('version') . '</td></tr></tfoot>';
    if ($result == '' || $num_rows == '') {
        $error = l('module_no') . l('point');
    } else {
        if ($result) {
            $accessValidator = new Redaxscript\Validator\Access();
            $output .= '<tbody>';
            while ($r = mysql_fetch_assoc($result)) {
                $access = $r['access'];
                $check_access = $accessValidator->validate($access, MY_GROUPS);
                /* if access granted */
                if ($check_access == 1) {
                    if ($r) {
                        foreach ($r as $key => $value) {
                            ${$key} = stripslashes($value);
                        }
                    }
                    $modules_installed_array[] = $alias;
                    $file_install = is_dir('modules/' . $alias);
                    /* build class string */
                    if ($status == 1) {
                        $class_status = '';
                    } else {
                        $class_status = 'row_disabled';
                    }
                    /* collect table row */
                    $output .= '<tr';
                    if ($alias) {
                        $output .= ' id="' . $alias . '"';
                    }
                    if ($class_status) {
                        $output .= ' class="' . $class_status . '"';
                    }
                    $output .= '><td class="column_first">' . $name;
                    /* collect control output */
                    if ($file_install) {
                        $output .= admin_control('modules_installed', 'modules', $id, $alias, $status, MODULES_INSTALL, MODULES_EDIT, MODULES_UNINSTALL);
                    }
                    /* collect alias and version output */
                    $output .= '</td><td class="column_second">' . $alias . '</td><td class="column_last">' . $version . '</td></tr>';
                } else {
                    $counter++;
                }
            }
            $output .= '</tbody>';
            /* handle access */
            if ($num_rows == $counter) {
                $error = l('access_no') . l('point');
            }
        }
    }
    /* handle error */
    if ($error) {
        $output .= '<tbody><tr><td colspan="3">' . $error . '</td></tr></tbody>';
    }
    /* modules not installed */
    if (MODULES_INSTALL == 1) {
        /* modules directory object */
        $modules_directory = new Redaxscript\Directory('modules');
        $modules_directory_array = $modules_directory->get();
        if ($modules_directory_array && $modules_installed_array) {
            $modules_not_installed_array = array_diff($modules_directory_array, $modules_installed_array);
        } else {
            if ($modules_directory_array) {
                $modules_not_installed_array = $modules_directory_array;
            }
        }
        if ($modules_not_installed_array) {
            $output .= '<tbody><tr class="row_group"><td colspan="3">' . l('install') . '</td></tr>';
            foreach ($modules_not_installed_array as $alias) {
                $file_install = is_dir('modules/' . $alias);
                if ($file_install) {
                    $class_file_install = '';
                } else {
                    $class_file_install = 'row_disabled';
                }
                /* collect table row */
                $output .= '<tr';
                if ($alias) {
                    $output .= ' id="' . $alias . '"';
                }
                if ($class_file_install) {
                    $output .= ' class="' . $class_file_install . '"';
                }
                $output .= '><td colspan="3">' . $alias;
                /* collect control output */
                if ($file_install) {
                    $output .= admin_control('modules_not_installed', 'modules', $id, $alias, $status, MODULES_INSTALL, MODULES_EDIT, MODULES_UNINSTALL);
                }
                $output .= '</td></tr>';
            }
            $output .= '</tbody>';
        }
    }
    $output .= '</table></div>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}
コード例 #7
0
ファイル: admin_contents.php プロジェクト: ITw3/redaxscript
/**
 * admin contents form
 *
 * @since 1.2.1
 * @deprecated 2.0.0
 *
 * @package Redaxscript
 * @category Admin
 * @author Henry Ruhs
 */
function admin_contents_form()
{
    $output = Redaxscript\Hook::trigger(__FUNCTION__ . '_start');
    /* switch table */
    switch (TABLE_PARAMETER) {
        case 'categories':
            $wording_single = 'category';
            break;
        case 'articles':
            $wording_single = 'article';
            break;
        case 'extras':
            $wording_single = 'extra';
            break;
        case 'comments':
            $wording_single = 'comment';
            break;
    }
    /* define fields for existing user */
    if (ADMIN_PARAMETER == 'edit' && ID_PARAMETER) {
        /* query content */
        $query = 'SELECT * FROM ' . PREFIX . TABLE_PARAMETER . ' WHERE id = ' . ID_PARAMETER;
        $result = mysql_query($query);
        $r = mysql_fetch_assoc($result);
        if ($r) {
            foreach ($r as $key => $value) {
                ${$key} = stripslashes($value);
            }
        }
        if (TABLE_PARAMETER == 'comments') {
            $wording_headline = $author;
        } else {
            $wording_headline = $title;
        }
        if (TABLE_PARAMETER != 'categories') {
            $text = htmlspecialchars($text);
        }
        $wording_submit = l('save');
        $route = 'admin/process/' . TABLE_PARAMETER . '/' . $id;
    } else {
        if (ADMIN_PARAMETER == 'new') {
            if (TABLE_PARAMETER == 'comments') {
                $author = MY_USER;
                $email = MY_EMAIL;
                $code_readonly = ' readonly="readonly"';
            }
            if (TABLE_PARAMETER == 'categories') {
                $parent = 0;
            }
            if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
                $category = 0;
                $headline = 1;
            }
            if (TABLE_PARAMETER == 'articles') {
                $infoline = 0;
                $comments = 0;
            }
            $status = 1;
            $rank = query_plumb('rank', TABLE_PARAMETER, 'max') + 1;
            $access = 0;
            $wording_headline = l($wording_single . '_new');
            $wording_submit = l('create');
            $route = 'admin/process/' . TABLE_PARAMETER;
        }
    }
    /* collect output */
    $output .= '<h2 class="title_content">' . $wording_headline . '</h2>';
    $output .= form_element('form', 'form_admin', 'js_validate_form js_tab form_admin hidden_legend', '', '', '', 'action="' . REWRITE_ROUTE . $route . '" method="post"');
    /* collect tab list output */
    $output .= '<ul class="js_list_tab list_tab list_tab_admin">';
    $output .= '<li class="js_item_active item_first item_active">' . anchor_element('internal', '', '', l($wording_single), FULL_ROUTE . '#tab-1') . '</li>';
    $output .= '<li class="item_second">' . anchor_element('internal', '', '', l('customize'), FULL_ROUTE . '#tab-2') . '</li>';
    if (TABLE_PARAMETER != 'categories' && TABLE_PARAMETER != 'comments') {
        $output .= '<li class="item_last">' . anchor_element('internal', '', '', l('date'), FULL_ROUTE . '#tab-3') . '</li>';
    }
    $output .= '</ul>';
    /* collect tab box output */
    $output .= '<div class="js_box_tab box_tab box_tab_admin">';
    /* collect content set */
    $output .= form_element('fieldset', 'tab-1', 'js_set_tab js_set_active set_tab set_tab_admin set_active', '', '', l($wording_single)) . '<ul>';
    if (TABLE_PARAMETER == 'comments') {
        $output .= '<li>' . form_element('text', 'author', 'field_text_admin field_note', 'author', $author, '* ' . l('author'), 'maxlength="50" required="required" autofocus="autofocus"' . $code_readonly) . '</li>';
        $output .= '<li>' . form_element('email', 'email', 'field_text_admin field_note', 'email', $email, '* ' . l('email'), 'maxlength="50" required="required"' . $code_readonly) . '</li>';
        $output .= '<li>' . form_element('url', 'url', 'field_text_admin', 'url', $url, l('url'), 'maxlength="50"') . '</li>';
    } else {
        $output .= '<li>' . form_element('text', 'title', 'js_generate_alias_input field_text_admin field_note', 'title', $title, l('title'), 'maxlength="50" required="required" autofocus="autofocus"') . '</li>';
        $output .= '<li>' . form_element('text', 'alias', 'js_generate_alias_output field_text_admin field_note', 'alias', $alias, l('alias'), 'maxlength="50" required="required"') . '</li>';
    }
    if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles') {
        $output .= '<li>' . form_element('textarea', 'description', 'js_auto_resize field_textarea_admin field_small_admin', 'description', $description, l('description'), 'rows="1" cols="15"') . '</li>';
        $output .= '<li>' . form_element('textarea', 'keywords', 'js_auto_resize js_generate_keyword_output field_textarea_admin field_small_admin', 'keywords', $keywords, l('keywords'), 'rows="1" cols="15"') . '</li>';
    }
    if (TABLE_PARAMETER != 'categories') {
        $output .= '<li>' . form_element('textarea', 'text', 'js_auto_resize js_generate_keyword_input js_editor_textarea field_textarea_admin field_note', 'text', $text, l('text'), 'rows="5" cols="100" required="required"') . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* collect customize set */
    $output .= form_element('fieldset', 'tab-2', 'js_set_tab set_tab set_tab_admin', '', '', l('customize')) . '<ul>';
    /* languages directory object */
    $languages_directory = new Redaxscript\Directory('languages');
    $languages_directory_array = $languages_directory->get();
    /* build languages select */
    $language_array[l('select')] = '';
    foreach ($languages_directory_array as $value) {
        $value = substr($value, 0, 2);
        $language_array[l($value, '_index')] = $value;
    }
    $output .= '<li>' . select_element('language', 'field_select_admin', 'language', $language_array, $language, l('language')) . '</li>';
    if (TABLE_PARAMETER == 'categories' || TABLE_PARAMETER == 'articles') {
        /* templates directory object */
        $templates_directory = new Redaxscript\Directory('templates', array('admin', 'install'));
        $templates_directory_array = $templates_directory->get();
        /* build templates select */
        $template_array[l('select')] = '';
        foreach ($templates_directory_array as $value) {
            $template_array[$value] = $value;
        }
        $output .= '<li>' . select_element('template', 'field_select_admin', 'template', $template_array, $template, l('template')) . '</li>';
    }
    /* build category select */
    if (TABLE_PARAMETER != 'comments') {
        if (TABLE_PARAMETER == 'extras') {
            $category_array[l('all')] = 0;
        } else {
            $category_array[l('none')] = 0;
        }
        $categories_query = 'SELECT id, title, parent FROM ' . PREFIX . 'categories ORDER BY rank ASC';
        $categories_result = mysql_query($categories_query);
        if ($categories_result) {
            while ($c = mysql_fetch_assoc($categories_result)) {
                if (TABLE_PARAMETER != 'categories') {
                    $category_array[$c['title']] = $c['id'];
                } else {
                    if (ID_PARAMETER != $c['id'] && $c['parent'] == 0) {
                        $category_array[$c['title']] = $c['id'];
                    }
                }
            }
        }
        if (TABLE_PARAMETER == 'categories') {
            $output .= '<li>' . select_element('parent', 'field_select_admin', 'parent', $category_array, $parent, l('category_parent')) . '</li>';
        } else {
            $output .= '<li>' . select_element('category', 'field_select_admin', 'category', $category_array, $category, l('category')) . '</li>';
        }
    }
    /* build article select */
    if (TABLE_PARAMETER == 'extras' || TABLE_PARAMETER == 'comments') {
        if (TABLE_PARAMETER == 'extras') {
            $article_array[l('all')] = 0;
        }
        $articles_query = 'SELECT id, title FROM ' . PREFIX . 'articles';
        if (TABLE_PARAMETER == 'comments') {
            $articles_query .= ' WHERE comments > 0';
        }
        $articles_query .= ' ORDER BY rank ASC';
        $articles_result = mysql_query($articles_query);
        if ($articles_result) {
            while ($a = mysql_fetch_assoc($articles_result)) {
                $article_array[$a['title']] = $a['id'];
            }
        }
        $output .= '<li>' . select_element('article', 'field_select_admin', 'article', $article_array, $article, l('article')) . '</li>';
    }
    if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
        $output .= '<li>' . select_element('headline', 'field_select_admin', 'headline', array(l('enable') => 1, l('disable') => 0), $headline, l('headline')) . '</li>';
    }
    if (TABLE_PARAMETER == 'articles') {
        $output .= '<li>' . select_element('infoline', 'field_select_admin', 'infoline', array(l('enable') => 1, l('disable') => 0), $infoline, l('infoline')) . '</li>';
        $output .= '<li>' . select_element('comments', 'field_select_admin', 'comments', array(l('enable') => 1, l('freeze') => 2, l('restrict') => 3, l('disable') => 0), $comments, l('comments')) . '</li>';
    }
    if ($status != 2) {
        $output .= '<li>' . select_element('status', 'field_select_admin', 'status', array(l('publish') => 1, l('unpublish') => 0), $status, l('status')) . '</li>';
    }
    /* build access select */
    if (GROUPS_EDIT == 1) {
        $access_array[l('all')] = 0;
        $access_query = 'SELECT id, name FROM ' . PREFIX . 'groups ORDER BY name ASC';
        $access_result = mysql_query($access_query);
        if ($access_result) {
            while ($g = mysql_fetch_assoc($access_result)) {
                $access_array[$g['name']] = $g['id'];
            }
        }
        $output .= '<li>' . select_element('access', 'field_select_admin', 'access', $access_array, $access, l('access'), 'multiple="multiple"') . '</li>';
    }
    $output .= '</ul></fieldset>';
    /* collect date set */
    if (TABLE_PARAMETER == 'articles' || TABLE_PARAMETER == 'extras') {
        $output .= form_element('fieldset', 'tab-3', 'js_set_tab set_tab set_tab_admin', '', '', l('date')) . '<ul>';
        $output .= '<li>' . select_date('day', 'field_select_admin', 'day', $date, 'd', 1, 32, l('day')) . '</li>';
        $output .= '<li>' . select_date('month', 'field_select_admin', 'month', $date, 'm', 1, 13, l('month')) . '</li>';
        $output .= '<li>' . select_date('year', 'field_select_admin', 'year', $date, 'Y', 2000, 2020, l('year')) . '</li>';
        $output .= '<li>' . select_date('hour', 'field_select_admin', 'hour', $date, 'H', 0, 24, l('hour')) . '</li>';
        $output .= '<li>' . select_date('minute', 'field_select_admin', 'minute', $date, 'i', 0, 60, l('minute')) . '</li>';
        $output .= '</ul></fieldset>';
    }
    $output .= '</div>';
    /* collect hidden output */
    if (TABLE_PARAMETER != 'comments') {
        $output .= form_element('hidden', '', '', 'author', MY_USER);
    }
    if ($status == 2) {
        $output .= form_element('hidden', '', '', 'publish', 2);
    }
    $output .= form_element('hidden', '', '', 'rank', $rank);
    $output .= form_element('hidden', '', '', 'token', TOKEN);
    /* cancel button */
    if (TABLE_EDIT == 1 || TABLE_DELETE == 1) {
        $cancel_route = 'admin/view/' . TABLE_PARAMETER;
    } else {
        $cancel_route = 'admin';
    }
    $output .= anchor_element('internal', '', 'js_cancel button_admin button_large_admin button_cancel_admin', l('cancel'), $cancel_route);
    /* delete button */
    if (TABLE_DELETE == 1 && $id) {
        $output .= anchor_element('internal', '', 'js_delete js_confirm button_admin button_large_admin button_delete_admin', l('delete'), 'admin/delete/' . TABLE_PARAMETER . '/' . $id . '/' . TOKEN);
    }
    /* submit button */
    if (TABLE_NEW == 1 || TABLE_EDIT == 1) {
        $output .= form_element('button', '', 'js_submit button_admin button_large_admin button_submit_admin', ADMIN_PARAMETER, $wording_submit);
    }
    $output .= '</form>';
    $output .= Redaxscript\Hook::trigger(__FUNCTION__ . '_end');
    echo $output;
}